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", + )