diff --git a/.stats.yml b/.stats.yml index c1ea0316647..59104035bdf 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ configured_endpoints: 1489 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-de7ae109130349e5b0b35b4d0944270435dfddb3ce7079da9b85f5dffaf86639.yml +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-6dadcd4e513c89328f85b769caf9ab478a927d302533e01ebf511a2965ec8cd5.yml diff --git a/src/cloudflare/resources/email_security/settings/impersonation_registry.py b/src/cloudflare/resources/email_security/settings/impersonation_registry.py index bb67428ecff..29b5532a411 100644 --- a/src/cloudflare/resources/email_security/settings/impersonation_registry.py +++ b/src/cloudflare/resources/email_security/settings/impersonation_registry.py @@ -2,14 +2,13 @@ from __future__ import annotations -from typing import Any, Type, Iterable, Optional, cast -from typing_extensions import Literal, overload +from typing import Type, Optional, cast +from typing_extensions import Literal import httpx from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven from ...._utils import ( - required_args, maybe_transform, async_maybe_transform, ) @@ -58,7 +57,6 @@ def with_streaming_response(self) -> ImpersonationRegistryResourceWithStreamingR """ return ImpersonationRegistryResourceWithStreamingResponse(self) - @overload def create( self, *, @@ -87,79 +85,26 @@ def create( timeout: Override the client-level default timeout for this request, in seconds """ - ... - - @overload - def create( - self, - *, - account_id: str, - body: Iterable[impersonation_registry_create_params.Variant1Body], - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ImpersonationRegistryCreateResponse: - """ - Create an entry in impersonation registry - - Args: - account_id: Account Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - ... - - @required_args(["account_id", "email", "is_email_regex", "name"], ["account_id", "body"]) - def create( - self, - *, - account_id: str, - email: str | NotGiven = NOT_GIVEN, - is_email_regex: bool | NotGiven = NOT_GIVEN, - name: str | NotGiven = NOT_GIVEN, - body: Iterable[impersonation_registry_create_params.Variant1Body] | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ImpersonationRegistryCreateResponse: if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return cast( - ImpersonationRegistryCreateResponse, - self._post( - f"/accounts/{account_id}/email-security/settings/impersonation_registry", - body=maybe_transform( - { - "email": email, - "is_email_regex": is_email_regex, - "name": name, - "body": body, - }, - impersonation_registry_create_params.ImpersonationRegistryCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[ImpersonationRegistryCreateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[ImpersonationRegistryCreateResponse] - ), # Union types cannot be passed in as arguments in the type system + return self._post( + f"/accounts/{account_id}/email-security/settings/impersonation_registry", + body=maybe_transform( + { + "email": email, + "is_email_regex": is_email_regex, + "name": name, + }, + impersonation_registry_create_params.ImpersonationRegistryCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ImpersonationRegistryCreateResponse]._unwrapper, ), + cast_to=cast(Type[ImpersonationRegistryCreateResponse], ResultWrapper[ImpersonationRegistryCreateResponse]), ) def list( @@ -383,7 +328,6 @@ def with_streaming_response(self) -> AsyncImpersonationRegistryResourceWithStrea """ return AsyncImpersonationRegistryResourceWithStreamingResponse(self) - @overload async def create( self, *, @@ -412,79 +356,26 @@ async def create( timeout: Override the client-level default timeout for this request, in seconds """ - ... - - @overload - async def create( - self, - *, - account_id: str, - body: Iterable[impersonation_registry_create_params.Variant1Body], - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ImpersonationRegistryCreateResponse: - """ - Create an entry in impersonation registry - - Args: - account_id: Account Identifier - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - ... - - @required_args(["account_id", "email", "is_email_regex", "name"], ["account_id", "body"]) - async def create( - self, - *, - account_id: str, - email: str | NotGiven = NOT_GIVEN, - is_email_regex: bool | NotGiven = NOT_GIVEN, - name: str | NotGiven = NOT_GIVEN, - body: Iterable[impersonation_registry_create_params.Variant1Body] | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> ImpersonationRegistryCreateResponse: if not account_id: raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return cast( - ImpersonationRegistryCreateResponse, - await self._post( - f"/accounts/{account_id}/email-security/settings/impersonation_registry", - body=await async_maybe_transform( - { - "email": email, - "is_email_regex": is_email_regex, - "name": name, - "body": body, - }, - impersonation_registry_create_params.ImpersonationRegistryCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[ImpersonationRegistryCreateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[ImpersonationRegistryCreateResponse] - ), # Union types cannot be passed in as arguments in the type system + return await self._post( + f"/accounts/{account_id}/email-security/settings/impersonation_registry", + body=await async_maybe_transform( + { + "email": email, + "is_email_regex": is_email_regex, + "name": name, + }, + impersonation_registry_create_params.ImpersonationRegistryCreateParams, + ), + options=make_request_options( + extra_headers=extra_headers, + extra_query=extra_query, + extra_body=extra_body, + timeout=timeout, + post_parser=ResultWrapper[ImpersonationRegistryCreateResponse]._unwrapper, ), + cast_to=cast(Type[ImpersonationRegistryCreateResponse], ResultWrapper[ImpersonationRegistryCreateResponse]), ) def list( diff --git a/src/cloudflare/types/email_security/settings/impersonation_registry_create_params.py b/src/cloudflare/types/email_security/settings/impersonation_registry_create_params.py index 6afe1e4ecc2..db25db7e746 100644 --- a/src/cloudflare/types/email_security/settings/impersonation_registry_create_params.py +++ b/src/cloudflare/types/email_security/settings/impersonation_registry_create_params.py @@ -2,13 +2,12 @@ from __future__ import annotations -from typing import Union, Iterable -from typing_extensions import Required, TypeAlias, TypedDict +from typing_extensions import Required, TypedDict -__all__ = ["ImpersonationRegistryCreateParams", "EmailSecurityCreateDisplayName", "Variant1", "Variant1Body"] +__all__ = ["ImpersonationRegistryCreateParams"] -class EmailSecurityCreateDisplayName(TypedDict, total=False): +class ImpersonationRegistryCreateParams(TypedDict, total=False): account_id: Required[str] """Account Identifier""" @@ -17,21 +16,3 @@ class EmailSecurityCreateDisplayName(TypedDict, total=False): is_email_regex: Required[bool] name: Required[str] - - -class Variant1(TypedDict, total=False): - account_id: Required[str] - """Account Identifier""" - - body: Required[Iterable[Variant1Body]] - - -class Variant1Body(TypedDict, total=False): - email: Required[str] - - is_email_regex: Required[bool] - - name: Required[str] - - -ImpersonationRegistryCreateParams: TypeAlias = Union[EmailSecurityCreateDisplayName, Variant1] diff --git a/src/cloudflare/types/email_security/settings/impersonation_registry_create_response.py b/src/cloudflare/types/email_security/settings/impersonation_registry_create_response.py index 9a6c685fde3..c0dd1f55354 100644 --- a/src/cloudflare/types/email_security/settings/impersonation_registry_create_response.py +++ b/src/cloudflare/types/email_security/settings/impersonation_registry_create_response.py @@ -1,42 +1,19 @@ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -from typing import List, Union, Optional +from typing import Optional from datetime import datetime -from typing_extensions import TypeAlias from ...._models import BaseModel -__all__ = ["ImpersonationRegistryCreateResponse", "EmailSecurityDisplayName", "UnionMember1"] +__all__ = ["ImpersonationRegistryCreateResponse"] -class EmailSecurityDisplayName(BaseModel): +class ImpersonationRegistryCreateResponse(BaseModel): id: int created_at: datetime - is_email_regex: bool - - last_modified: datetime - - name: str - - comments: Optional[str] = None - - directory_id: Optional[int] = None - - directory_node_id: Optional[int] = None - - email: Optional[str] = None - - external_directory_node_id: Optional[str] = None - - provenance: Optional[str] = None - - -class UnionMember1(BaseModel): - id: int - - created_at: datetime + email: str is_email_regex: bool @@ -50,11 +27,6 @@ class UnionMember1(BaseModel): directory_node_id: Optional[int] = None - email: Optional[str] = None - external_directory_node_id: Optional[str] = None provenance: Optional[str] = None - - -ImpersonationRegistryCreateResponse: TypeAlias = Union[EmailSecurityDisplayName, List[UnionMember1]] diff --git a/src/cloudflare/types/email_security/settings/impersonation_registry_edit_response.py b/src/cloudflare/types/email_security/settings/impersonation_registry_edit_response.py index 8555fe6e757..824a0946f7c 100644 --- a/src/cloudflare/types/email_security/settings/impersonation_registry_edit_response.py +++ b/src/cloudflare/types/email_security/settings/impersonation_registry_edit_response.py @@ -13,6 +13,8 @@ class ImpersonationRegistryEditResponse(BaseModel): created_at: datetime + email: str + is_email_regex: bool last_modified: datetime @@ -25,8 +27,6 @@ class ImpersonationRegistryEditResponse(BaseModel): directory_node_id: Optional[int] = None - email: Optional[str] = None - external_directory_node_id: Optional[str] = None provenance: Optional[str] = None diff --git a/src/cloudflare/types/email_security/settings/impersonation_registry_get_response.py b/src/cloudflare/types/email_security/settings/impersonation_registry_get_response.py index 2ffea2569d4..85a8ab50d71 100644 --- a/src/cloudflare/types/email_security/settings/impersonation_registry_get_response.py +++ b/src/cloudflare/types/email_security/settings/impersonation_registry_get_response.py @@ -13,6 +13,8 @@ class ImpersonationRegistryGetResponse(BaseModel): created_at: datetime + email: str + is_email_regex: bool last_modified: datetime @@ -25,8 +27,6 @@ class ImpersonationRegistryGetResponse(BaseModel): directory_node_id: Optional[int] = None - email: Optional[str] = None - external_directory_node_id: Optional[str] = None provenance: Optional[str] = None diff --git a/src/cloudflare/types/email_security/settings/impersonation_registry_list_response.py b/src/cloudflare/types/email_security/settings/impersonation_registry_list_response.py index d75829c8a05..800c8d4bfd7 100644 --- a/src/cloudflare/types/email_security/settings/impersonation_registry_list_response.py +++ b/src/cloudflare/types/email_security/settings/impersonation_registry_list_response.py @@ -13,6 +13,8 @@ class ImpersonationRegistryListResponse(BaseModel): created_at: datetime + email: str + is_email_regex: bool last_modified: datetime @@ -25,8 +27,6 @@ class ImpersonationRegistryListResponse(BaseModel): directory_node_id: Optional[int] = None - email: Optional[str] = None - external_directory_node_id: Optional[str] = None provenance: Optional[str] = None diff --git a/tests/api_resources/email_security/settings/test_impersonation_registry.py b/tests/api_resources/email_security/settings/test_impersonation_registry.py index 8a4ad4fbe92..166def7dd1e 100644 --- a/tests/api_resources/email_security/settings/test_impersonation_registry.py +++ b/tests/api_resources/email_security/settings/test_impersonation_registry.py @@ -25,7 +25,7 @@ class TestImpersonationRegistry: parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize - def test_method_create_overload_1(self, client: Cloudflare) -> None: + def test_method_create(self, client: Cloudflare) -> None: impersonation_registry = client.email_security.settings.impersonation_registry.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", email="email", @@ -35,7 +35,7 @@ def test_method_create_overload_1(self, client: Cloudflare) -> None: assert_matches_type(ImpersonationRegistryCreateResponse, impersonation_registry, path=["response"]) @parametrize - def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: + def test_raw_response_create(self, client: Cloudflare) -> None: response = client.email_security.settings.impersonation_registry.with_raw_response.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", email="email", @@ -49,7 +49,7 @@ def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: assert_matches_type(ImpersonationRegistryCreateResponse, impersonation_registry, path=["response"]) @parametrize - def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: + def test_streaming_response_create(self, client: Cloudflare) -> None: with client.email_security.settings.impersonation_registry.with_streaming_response.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", email="email", @@ -65,7 +65,7 @@ def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: assert cast(Any, response.is_closed) is True @parametrize - def test_path_params_create_overload_1(self, client: Cloudflare) -> None: + def test_path_params_create(self, client: Cloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): client.email_security.settings.impersonation_registry.with_raw_response.create( account_id="", @@ -74,72 +74,6 @@ def test_path_params_create_overload_1(self, client: Cloudflare) -> None: name="name", ) - @parametrize - def test_method_create_overload_2(self, client: Cloudflare) -> None: - impersonation_registry = client.email_security.settings.impersonation_registry.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=[ - { - "email": "email", - "is_email_regex": True, - "name": "name", - } - ], - ) - assert_matches_type(ImpersonationRegistryCreateResponse, impersonation_registry, path=["response"]) - - @parametrize - def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: - response = client.email_security.settings.impersonation_registry.with_raw_response.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=[ - { - "email": "email", - "is_email_regex": True, - "name": "name", - } - ], - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - impersonation_registry = response.parse() - assert_matches_type(ImpersonationRegistryCreateResponse, impersonation_registry, path=["response"]) - - @parametrize - def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: - with client.email_security.settings.impersonation_registry.with_streaming_response.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=[ - { - "email": "email", - "is_email_regex": True, - "name": "name", - } - ], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - impersonation_registry = response.parse() - assert_matches_type(ImpersonationRegistryCreateResponse, impersonation_registry, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_create_overload_2(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.email_security.settings.impersonation_registry.with_raw_response.create( - account_id="", - body=[ - { - "email": "email", - "is_email_regex": True, - "name": "name", - } - ], - ) - @parametrize def test_method_list(self, client: Cloudflare) -> None: impersonation_registry = client.email_security.settings.impersonation_registry.list( @@ -341,7 +275,7 @@ class TestAsyncImpersonationRegistry: parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) @parametrize - async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> None: + async def test_method_create(self, async_client: AsyncCloudflare) -> None: impersonation_registry = await async_client.email_security.settings.impersonation_registry.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", email="email", @@ -351,7 +285,7 @@ async def test_method_create_overload_1(self, async_client: AsyncCloudflare) -> assert_matches_type(ImpersonationRegistryCreateResponse, impersonation_registry, path=["response"]) @parametrize - async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: + async def test_raw_response_create(self, async_client: AsyncCloudflare) -> None: response = await async_client.email_security.settings.impersonation_registry.with_raw_response.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", email="email", @@ -365,7 +299,7 @@ async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflar assert_matches_type(ImpersonationRegistryCreateResponse, impersonation_registry, path=["response"]) @parametrize - async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: + async def test_streaming_response_create(self, async_client: AsyncCloudflare) -> None: async with async_client.email_security.settings.impersonation_registry.with_streaming_response.create( account_id="023e105f4ecef8ad9ca31a8372d0c353", email="email", @@ -381,7 +315,7 @@ async def test_streaming_response_create_overload_1(self, async_client: AsyncClo assert cast(Any, response.is_closed) is True @parametrize - async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare) -> None: + async def test_path_params_create(self, async_client: AsyncCloudflare) -> None: with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): await async_client.email_security.settings.impersonation_registry.with_raw_response.create( account_id="", @@ -390,72 +324,6 @@ async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare name="name", ) - @parametrize - async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: - impersonation_registry = await async_client.email_security.settings.impersonation_registry.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=[ - { - "email": "email", - "is_email_regex": True, - "name": "name", - } - ], - ) - assert_matches_type(ImpersonationRegistryCreateResponse, impersonation_registry, path=["response"]) - - @parametrize - async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: - response = await async_client.email_security.settings.impersonation_registry.with_raw_response.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=[ - { - "email": "email", - "is_email_regex": True, - "name": "name", - } - ], - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - impersonation_registry = await response.parse() - assert_matches_type(ImpersonationRegistryCreateResponse, impersonation_registry, path=["response"]) - - @parametrize - async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: - async with async_client.email_security.settings.impersonation_registry.with_streaming_response.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=[ - { - "email": "email", - "is_email_regex": True, - "name": "name", - } - ], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - impersonation_registry = await response.parse() - assert_matches_type(ImpersonationRegistryCreateResponse, impersonation_registry, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_create_overload_2(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.email_security.settings.impersonation_registry.with_raw_response.create( - account_id="", - body=[ - { - "email": "email", - "is_email_regex": True, - "name": "name", - } - ], - ) - @parametrize async def test_method_list(self, async_client: AsyncCloudflare) -> None: impersonation_registry = await async_client.email_security.settings.impersonation_registry.list(