diff --git a/.stats.yml b/.stats.yml index f68c2db0980..295cf853b21 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1417 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-4c49562d088783434a838d9fb04f3a71514aaf0ee9096dabf65e3ae0825b8756.yml +configured_endpoints: 1411 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d8a11058191753bacee9c070940904a1318942d364a2420ad1e253bd450b2bcf.yml diff --git a/api.md b/api.md index 58c4a312a69..42ac1905090 100644 --- a/api.md +++ b/api.md @@ -1193,42 +1193,8 @@ Methods: - client.email_security.investigate.raw(postfix_id, \*, account_id) -> InvestigateRawResponse - client.email_security.investigate.trace(postfix_id, \*, account_id) -> InvestigateTraceResponse -## Phishguard - -Types: - -```python -from cloudflare.types.email_security import PhishguardListResponse -``` - -Methods: - -- client.email_security.phishguard.list(\*, account_id, \*\*params) -> SyncSinglePage[PhishguardListResponse] - ## Settings -### AllowPatterns - -Types: - -```python -from cloudflare.types.email_security.settings import ( - AllowPatternCreateResponse, - AllowPatternListResponse, - AllowPatternDeleteResponse, - AllowPatternEditResponse, - AllowPatternGetResponse, -) -``` - -Methods: - -- client.email_security.settings.allow_patterns.create(\*, account_id, \*\*params) -> AllowPatternCreateResponse -- client.email_security.settings.allow_patterns.list(\*, account_id, \*\*params) -> SyncV4PagePaginationArray[AllowPatternListResponse] -- client.email_security.settings.allow_patterns.delete(pattern_id, \*, account_id) -> AllowPatternDeleteResponse -- client.email_security.settings.allow_patterns.edit(pattern_id, \*, account_id, \*\*params) -> AllowPatternEditResponse -- client.email_security.settings.allow_patterns.get(pattern_id, \*, account_id) -> AllowPatternGetResponse - ### BlockSenders Types: diff --git a/src/cloudflare/resources/email_security/__init__.py b/src/cloudflare/resources/email_security/__init__.py index c531ca2570a..dd7d0e7a767 100644 --- a/src/cloudflare/resources/email_security/__init__.py +++ b/src/cloudflare/resources/email_security/__init__.py @@ -8,14 +8,6 @@ SettingsResourceWithStreamingResponse, AsyncSettingsResourceWithStreamingResponse, ) -from .phishguard import ( - PhishguardResource, - AsyncPhishguardResource, - PhishguardResourceWithRawResponse, - AsyncPhishguardResourceWithRawResponse, - PhishguardResourceWithStreamingResponse, - AsyncPhishguardResourceWithStreamingResponse, -) from .investigate import ( InvestigateResource, AsyncInvestigateResource, @@ -40,12 +32,6 @@ "AsyncInvestigateResourceWithRawResponse", "InvestigateResourceWithStreamingResponse", "AsyncInvestigateResourceWithStreamingResponse", - "PhishguardResource", - "AsyncPhishguardResource", - "PhishguardResourceWithRawResponse", - "AsyncPhishguardResourceWithRawResponse", - "PhishguardResourceWithStreamingResponse", - "AsyncPhishguardResourceWithStreamingResponse", "SettingsResource", "AsyncSettingsResource", "SettingsResourceWithRawResponse", diff --git a/src/cloudflare/resources/email_security/email_security.py b/src/cloudflare/resources/email_security/email_security.py index 22ca82da91f..a7d8846ac4f 100644 --- a/src/cloudflare/resources/email_security/email_security.py +++ b/src/cloudflare/resources/email_security/email_security.py @@ -11,14 +11,6 @@ AsyncSettingsResourceWithStreamingResponse, ) from ..._compat import cached_property -from .phishguard import ( - PhishguardResource, - AsyncPhishguardResource, - PhishguardResourceWithRawResponse, - AsyncPhishguardResourceWithRawResponse, - PhishguardResourceWithStreamingResponse, - AsyncPhishguardResourceWithStreamingResponse, -) from ..._resource import SyncAPIResource, AsyncAPIResource from .investigate import ( InvestigateResource, @@ -38,10 +30,6 @@ class EmailSecurityResource(SyncAPIResource): def investigate(self) -> InvestigateResource: return InvestigateResource(self._client) - @cached_property - def phishguard(self) -> PhishguardResource: - return PhishguardResource(self._client) - @cached_property def settings(self) -> SettingsResource: return SettingsResource(self._client) @@ -71,10 +59,6 @@ class AsyncEmailSecurityResource(AsyncAPIResource): def investigate(self) -> AsyncInvestigateResource: return AsyncInvestigateResource(self._client) - @cached_property - def phishguard(self) -> AsyncPhishguardResource: - return AsyncPhishguardResource(self._client) - @cached_property def settings(self) -> AsyncSettingsResource: return AsyncSettingsResource(self._client) @@ -107,10 +91,6 @@ def __init__(self, email_security: EmailSecurityResource) -> None: def investigate(self) -> InvestigateResourceWithRawResponse: return InvestigateResourceWithRawResponse(self._email_security.investigate) - @cached_property - def phishguard(self) -> PhishguardResourceWithRawResponse: - return PhishguardResourceWithRawResponse(self._email_security.phishguard) - @cached_property def settings(self) -> SettingsResourceWithRawResponse: return SettingsResourceWithRawResponse(self._email_security.settings) @@ -124,10 +104,6 @@ def __init__(self, email_security: AsyncEmailSecurityResource) -> None: def investigate(self) -> AsyncInvestigateResourceWithRawResponse: return AsyncInvestigateResourceWithRawResponse(self._email_security.investigate) - @cached_property - def phishguard(self) -> AsyncPhishguardResourceWithRawResponse: - return AsyncPhishguardResourceWithRawResponse(self._email_security.phishguard) - @cached_property def settings(self) -> AsyncSettingsResourceWithRawResponse: return AsyncSettingsResourceWithRawResponse(self._email_security.settings) @@ -141,10 +117,6 @@ def __init__(self, email_security: EmailSecurityResource) -> None: def investigate(self) -> InvestigateResourceWithStreamingResponse: return InvestigateResourceWithStreamingResponse(self._email_security.investigate) - @cached_property - def phishguard(self) -> PhishguardResourceWithStreamingResponse: - return PhishguardResourceWithStreamingResponse(self._email_security.phishguard) - @cached_property def settings(self) -> SettingsResourceWithStreamingResponse: return SettingsResourceWithStreamingResponse(self._email_security.settings) @@ -158,10 +130,6 @@ def __init__(self, email_security: AsyncEmailSecurityResource) -> None: def investigate(self) -> AsyncInvestigateResourceWithStreamingResponse: return AsyncInvestigateResourceWithStreamingResponse(self._email_security.investigate) - @cached_property - def phishguard(self) -> AsyncPhishguardResourceWithStreamingResponse: - return AsyncPhishguardResourceWithStreamingResponse(self._email_security.phishguard) - @cached_property def settings(self) -> AsyncSettingsResourceWithStreamingResponse: return AsyncSettingsResourceWithStreamingResponse(self._email_security.settings) diff --git a/src/cloudflare/resources/email_security/phishguard.py b/src/cloudflare/resources/email_security/phishguard.py deleted file mode 100644 index 1520026d2b8..00000000000 --- a/src/cloudflare/resources/email_security/phishguard.py +++ /dev/null @@ -1,199 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Union -from datetime import date - -import httpx - -from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ..._utils import maybe_transform -from ..._compat import cached_property -from ..._resource import SyncAPIResource, AsyncAPIResource -from ..._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ...pagination import SyncSinglePage, AsyncSinglePage -from ..._base_client import AsyncPaginator, make_request_options -from ...types.email_security import phishguard_list_params -from ...types.email_security.phishguard_list_response import PhishguardListResponse - -__all__ = ["PhishguardResource", "AsyncPhishguardResource"] - - -class PhishguardResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> PhishguardResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers - """ - return PhishguardResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> PhishguardResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response - """ - return PhishguardResourceWithStreamingResponse(self) - - def list( - self, - *, - account_id: str, - from_date: Union[str, date], - to_date: Union[str, date], - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncSinglePage[PhishguardListResponse]: - """ - Get PhishGuard reports - - 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 - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return self._get_api_list( - f"/accounts/{account_id}/email-security/phishguard/reports", - page=SyncSinglePage[PhishguardListResponse], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "from_date": from_date, - "to_date": to_date, - }, - phishguard_list_params.PhishguardListParams, - ), - ), - model=PhishguardListResponse, - ) - - -class AsyncPhishguardResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncPhishguardResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers - """ - return AsyncPhishguardResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncPhishguardResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response - """ - return AsyncPhishguardResourceWithStreamingResponse(self) - - def list( - self, - *, - account_id: str, - from_date: Union[str, date], - to_date: Union[str, date], - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[PhishguardListResponse, AsyncSinglePage[PhishguardListResponse]]: - """ - Get PhishGuard reports - - 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 - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return self._get_api_list( - f"/accounts/{account_id}/email-security/phishguard/reports", - page=AsyncSinglePage[PhishguardListResponse], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "from_date": from_date, - "to_date": to_date, - }, - phishguard_list_params.PhishguardListParams, - ), - ), - model=PhishguardListResponse, - ) - - -class PhishguardResourceWithRawResponse: - def __init__(self, phishguard: PhishguardResource) -> None: - self._phishguard = phishguard - - self.list = to_raw_response_wrapper( - phishguard.list, - ) - - -class AsyncPhishguardResourceWithRawResponse: - def __init__(self, phishguard: AsyncPhishguardResource) -> None: - self._phishguard = phishguard - - self.list = async_to_raw_response_wrapper( - phishguard.list, - ) - - -class PhishguardResourceWithStreamingResponse: - def __init__(self, phishguard: PhishguardResource) -> None: - self._phishguard = phishguard - - self.list = to_streamed_response_wrapper( - phishguard.list, - ) - - -class AsyncPhishguardResourceWithStreamingResponse: - def __init__(self, phishguard: AsyncPhishguardResource) -> None: - self._phishguard = phishguard - - self.list = async_to_streamed_response_wrapper( - phishguard.list, - ) diff --git a/src/cloudflare/resources/email_security/settings/__init__.py b/src/cloudflare/resources/email_security/settings/__init__.py index 2ed151a18fb..f961d525457 100644 --- a/src/cloudflare/resources/email_security/settings/__init__.py +++ b/src/cloudflare/resources/email_security/settings/__init__.py @@ -24,14 +24,6 @@ BlockSendersResourceWithStreamingResponse, AsyncBlockSendersResourceWithStreamingResponse, ) -from .allow_patterns import ( - AllowPatternsResource, - AsyncAllowPatternsResource, - AllowPatternsResourceWithRawResponse, - AsyncAllowPatternsResourceWithRawResponse, - AllowPatternsResourceWithStreamingResponse, - AsyncAllowPatternsResourceWithStreamingResponse, -) from .trusted_domains import ( TrustedDomainsResource, AsyncTrustedDomainsResource, @@ -50,12 +42,6 @@ ) __all__ = [ - "AllowPatternsResource", - "AsyncAllowPatternsResource", - "AllowPatternsResourceWithRawResponse", - "AsyncAllowPatternsResourceWithRawResponse", - "AllowPatternsResourceWithStreamingResponse", - "AsyncAllowPatternsResourceWithStreamingResponse", "BlockSendersResource", "AsyncBlockSendersResource", "BlockSendersResourceWithRawResponse", diff --git a/src/cloudflare/resources/email_security/settings/allow_patterns.py b/src/cloudflare/resources/email_security/settings/allow_patterns.py deleted file mode 100644 index 4c7ef5913f9..00000000000 --- a/src/cloudflare/resources/email_security/settings/allow_patterns.py +++ /dev/null @@ -1,842 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Any, Type, Iterable, Optional, cast -from typing_extensions import Literal, overload - -import httpx - -from ...._types import NOT_GIVEN, Body, Query, Headers, NotGiven -from ...._utils import ( - required_args, - maybe_transform, - async_maybe_transform, -) -from ...._compat import cached_property -from ...._resource import SyncAPIResource, AsyncAPIResource -from ...._response import ( - to_raw_response_wrapper, - to_streamed_response_wrapper, - async_to_raw_response_wrapper, - async_to_streamed_response_wrapper, -) -from ...._wrappers import ResultWrapper -from ....pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from ...._base_client import AsyncPaginator, make_request_options -from ....types.email_security.settings import ( - allow_pattern_edit_params, - allow_pattern_list_params, - allow_pattern_create_params, -) -from ....types.email_security.settings.allow_pattern_get_response import AllowPatternGetResponse -from ....types.email_security.settings.allow_pattern_edit_response import AllowPatternEditResponse -from ....types.email_security.settings.allow_pattern_list_response import AllowPatternListResponse -from ....types.email_security.settings.allow_pattern_create_response import AllowPatternCreateResponse -from ....types.email_security.settings.allow_pattern_delete_response import AllowPatternDeleteResponse - -__all__ = ["AllowPatternsResource", "AsyncAllowPatternsResource"] - - -class AllowPatternsResource(SyncAPIResource): - @cached_property - def with_raw_response(self) -> AllowPatternsResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers - """ - return AllowPatternsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AllowPatternsResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response - """ - return AllowPatternsResourceWithStreamingResponse(self) - - @overload - def create( - self, - *, - account_id: str, - is_recipient: bool, - is_regex: bool, - is_sender: bool, - is_spoof: bool, - pattern: str, - pattern_type: Literal["EMAIL", "DOMAIN", "IP", "UNKNOWN"], - verify_sender: bool, - comments: Optional[str] | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AllowPatternCreateResponse: - """ - Create an email allow pattern - - 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 - """ - ... - - @overload - def create( - self, - *, - account_id: str, - body: Iterable[allow_pattern_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, - ) -> AllowPatternCreateResponse: - """ - Create an email allow pattern - - 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", "is_recipient", "is_regex", "is_sender", "is_spoof", "pattern", "pattern_type", "verify_sender"], - ["account_id", "body"], - ) - def create( - self, - *, - account_id: str, - is_recipient: bool | NotGiven = NOT_GIVEN, - is_regex: bool | NotGiven = NOT_GIVEN, - is_sender: bool | NotGiven = NOT_GIVEN, - is_spoof: bool | NotGiven = NOT_GIVEN, - pattern: str | NotGiven = NOT_GIVEN, - pattern_type: Literal["EMAIL", "DOMAIN", "IP", "UNKNOWN"] | NotGiven = NOT_GIVEN, - verify_sender: bool | NotGiven = NOT_GIVEN, - comments: Optional[str] | NotGiven = NOT_GIVEN, - body: Iterable[allow_pattern_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, - ) -> AllowPatternCreateResponse: - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return cast( - AllowPatternCreateResponse, - self._post( - f"/accounts/{account_id}/email-security/settings/allow_patterns", - body=maybe_transform( - { - "is_recipient": is_recipient, - "is_regex": is_regex, - "is_sender": is_sender, - "is_spoof": is_spoof, - "pattern": pattern, - "pattern_type": pattern_type, - "verify_sender": verify_sender, - "comments": comments, - "body": body, - }, - allow_pattern_create_params.AllowPatternCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[AllowPatternCreateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[AllowPatternCreateResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - def list( - self, - *, - account_id: str, - direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, - is_recipient: bool | NotGiven = NOT_GIVEN, - is_sender: bool | NotGiven = NOT_GIVEN, - is_spoof: bool | NotGiven = NOT_GIVEN, - order: Literal["pattern", "created_at"] | NotGiven = NOT_GIVEN, - page: int | NotGiven = NOT_GIVEN, - pattern_type: Literal["EMAIL", "DOMAIN", "IP", "UNKNOWN"] | NotGiven = NOT_GIVEN, - per_page: int | NotGiven = NOT_GIVEN, - search: str | NotGiven = NOT_GIVEN, - verify_sender: bool | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> SyncV4PagePaginationArray[AllowPatternListResponse]: - """ - Lists, searches, and sorts an account’s email allow patterns. - - Args: - account_id: Account Identifier - - direction: The sorting direction. - - order: The field to sort by. - - page: The page number of paginated results. - - per_page: The number of results per page. - - search: Allows searching in multiple properties of a record simultaneously. This - parameter is intended for human users, not automation. Its exact behavior is - intentionally left unspecified and is subject to change in the future. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return self._get_api_list( - f"/accounts/{account_id}/email-security/settings/allow_patterns", - page=SyncV4PagePaginationArray[AllowPatternListResponse], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "direction": direction, - "is_recipient": is_recipient, - "is_sender": is_sender, - "is_spoof": is_spoof, - "order": order, - "page": page, - "pattern_type": pattern_type, - "per_page": per_page, - "search": search, - "verify_sender": verify_sender, - }, - allow_pattern_list_params.AllowPatternListParams, - ), - ), - model=AllowPatternListResponse, - ) - - def delete( - self, - pattern_id: int, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AllowPatternDeleteResponse: - """ - Delete an email allow pattern - - 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 - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return self._delete( - f"/accounts/{account_id}/email-security/settings/allow_patterns/{pattern_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[AllowPatternDeleteResponse]._unwrapper, - ), - cast_to=cast(Type[AllowPatternDeleteResponse], ResultWrapper[AllowPatternDeleteResponse]), - ) - - def edit( - self, - pattern_id: int, - *, - account_id: str, - comments: Optional[str] | NotGiven = NOT_GIVEN, - is_recipient: Optional[bool] | NotGiven = NOT_GIVEN, - is_regex: Optional[bool] | NotGiven = NOT_GIVEN, - is_sender: Optional[bool] | NotGiven = NOT_GIVEN, - is_spoof: Optional[bool] | NotGiven = NOT_GIVEN, - pattern: Optional[str] | NotGiven = NOT_GIVEN, - pattern_type: Optional[Literal["EMAIL", "DOMAIN", "IP", "UNKNOWN"]] | NotGiven = NOT_GIVEN, - verify_sender: Optional[bool] | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AllowPatternEditResponse: - """ - Update an email allow pattern - - 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 - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return self._patch( - f"/accounts/{account_id}/email-security/settings/allow_patterns/{pattern_id}", - body=maybe_transform( - { - "comments": comments, - "is_recipient": is_recipient, - "is_regex": is_regex, - "is_sender": is_sender, - "is_spoof": is_spoof, - "pattern": pattern, - "pattern_type": pattern_type, - "verify_sender": verify_sender, - }, - allow_pattern_edit_params.AllowPatternEditParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[AllowPatternEditResponse]._unwrapper, - ), - cast_to=cast(Type[AllowPatternEditResponse], ResultWrapper[AllowPatternEditResponse]), - ) - - def get( - self, - pattern_id: int, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AllowPatternGetResponse: - """ - Get an email allow pattern - - 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 - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return self._get( - f"/accounts/{account_id}/email-security/settings/allow_patterns/{pattern_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[AllowPatternGetResponse]._unwrapper, - ), - cast_to=cast(Type[AllowPatternGetResponse], ResultWrapper[AllowPatternGetResponse]), - ) - - -class AsyncAllowPatternsResource(AsyncAPIResource): - @cached_property - def with_raw_response(self) -> AsyncAllowPatternsResourceWithRawResponse: - """ - This property can be used as a prefix for any HTTP method call to return the - the raw response object instead of the parsed content. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#accessing-raw-response-data-eg-headers - """ - return AsyncAllowPatternsResourceWithRawResponse(self) - - @cached_property - def with_streaming_response(self) -> AsyncAllowPatternsResourceWithStreamingResponse: - """ - An alternative to `.with_raw_response` that doesn't eagerly read the response body. - - For more information, see https://www.github.com/cloudflare/cloudflare-python#with_streaming_response - """ - return AsyncAllowPatternsResourceWithStreamingResponse(self) - - @overload - async def create( - self, - *, - account_id: str, - is_recipient: bool, - is_regex: bool, - is_sender: bool, - is_spoof: bool, - pattern: str, - pattern_type: Literal["EMAIL", "DOMAIN", "IP", "UNKNOWN"], - verify_sender: bool, - comments: Optional[str] | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AllowPatternCreateResponse: - """ - Create an email allow pattern - - 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 - """ - ... - - @overload - async def create( - self, - *, - account_id: str, - body: Iterable[allow_pattern_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, - ) -> AllowPatternCreateResponse: - """ - Create an email allow pattern - - 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", "is_recipient", "is_regex", "is_sender", "is_spoof", "pattern", "pattern_type", "verify_sender"], - ["account_id", "body"], - ) - async def create( - self, - *, - account_id: str, - is_recipient: bool | NotGiven = NOT_GIVEN, - is_regex: bool | NotGiven = NOT_GIVEN, - is_sender: bool | NotGiven = NOT_GIVEN, - is_spoof: bool | NotGiven = NOT_GIVEN, - pattern: str | NotGiven = NOT_GIVEN, - pattern_type: Literal["EMAIL", "DOMAIN", "IP", "UNKNOWN"] | NotGiven = NOT_GIVEN, - verify_sender: bool | NotGiven = NOT_GIVEN, - comments: Optional[str] | NotGiven = NOT_GIVEN, - body: Iterable[allow_pattern_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, - ) -> AllowPatternCreateResponse: - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return cast( - AllowPatternCreateResponse, - await self._post( - f"/accounts/{account_id}/email-security/settings/allow_patterns", - body=await async_maybe_transform( - { - "is_recipient": is_recipient, - "is_regex": is_regex, - "is_sender": is_sender, - "is_spoof": is_spoof, - "pattern": pattern, - "pattern_type": pattern_type, - "verify_sender": verify_sender, - "comments": comments, - "body": body, - }, - allow_pattern_create_params.AllowPatternCreateParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[AllowPatternCreateResponse]._unwrapper, - ), - cast_to=cast( - Any, ResultWrapper[AllowPatternCreateResponse] - ), # Union types cannot be passed in as arguments in the type system - ), - ) - - def list( - self, - *, - account_id: str, - direction: Literal["asc", "desc"] | NotGiven = NOT_GIVEN, - is_recipient: bool | NotGiven = NOT_GIVEN, - is_sender: bool | NotGiven = NOT_GIVEN, - is_spoof: bool | NotGiven = NOT_GIVEN, - order: Literal["pattern", "created_at"] | NotGiven = NOT_GIVEN, - page: int | NotGiven = NOT_GIVEN, - pattern_type: Literal["EMAIL", "DOMAIN", "IP", "UNKNOWN"] | NotGiven = NOT_GIVEN, - per_page: int | NotGiven = NOT_GIVEN, - search: str | NotGiven = NOT_GIVEN, - verify_sender: bool | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AsyncPaginator[AllowPatternListResponse, AsyncV4PagePaginationArray[AllowPatternListResponse]]: - """ - Lists, searches, and sorts an account’s email allow patterns. - - Args: - account_id: Account Identifier - - direction: The sorting direction. - - order: The field to sort by. - - page: The page number of paginated results. - - per_page: The number of results per page. - - search: Allows searching in multiple properties of a record simultaneously. This - parameter is intended for human users, not automation. Its exact behavior is - intentionally left unspecified and is subject to change in the future. - - extra_headers: Send extra headers - - extra_query: Add additional query parameters to the request - - extra_body: Add additional JSON properties to the request - - timeout: Override the client-level default timeout for this request, in seconds - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return self._get_api_list( - f"/accounts/{account_id}/email-security/settings/allow_patterns", - page=AsyncV4PagePaginationArray[AllowPatternListResponse], - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - query=maybe_transform( - { - "direction": direction, - "is_recipient": is_recipient, - "is_sender": is_sender, - "is_spoof": is_spoof, - "order": order, - "page": page, - "pattern_type": pattern_type, - "per_page": per_page, - "search": search, - "verify_sender": verify_sender, - }, - allow_pattern_list_params.AllowPatternListParams, - ), - ), - model=AllowPatternListResponse, - ) - - async def delete( - self, - pattern_id: int, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AllowPatternDeleteResponse: - """ - Delete an email allow pattern - - 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 - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return await self._delete( - f"/accounts/{account_id}/email-security/settings/allow_patterns/{pattern_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[AllowPatternDeleteResponse]._unwrapper, - ), - cast_to=cast(Type[AllowPatternDeleteResponse], ResultWrapper[AllowPatternDeleteResponse]), - ) - - async def edit( - self, - pattern_id: int, - *, - account_id: str, - comments: Optional[str] | NotGiven = NOT_GIVEN, - is_recipient: Optional[bool] | NotGiven = NOT_GIVEN, - is_regex: Optional[bool] | NotGiven = NOT_GIVEN, - is_sender: Optional[bool] | NotGiven = NOT_GIVEN, - is_spoof: Optional[bool] | NotGiven = NOT_GIVEN, - pattern: Optional[str] | NotGiven = NOT_GIVEN, - pattern_type: Optional[Literal["EMAIL", "DOMAIN", "IP", "UNKNOWN"]] | NotGiven = NOT_GIVEN, - verify_sender: Optional[bool] | NotGiven = NOT_GIVEN, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AllowPatternEditResponse: - """ - Update an email allow pattern - - 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 - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return await self._patch( - f"/accounts/{account_id}/email-security/settings/allow_patterns/{pattern_id}", - body=await async_maybe_transform( - { - "comments": comments, - "is_recipient": is_recipient, - "is_regex": is_regex, - "is_sender": is_sender, - "is_spoof": is_spoof, - "pattern": pattern, - "pattern_type": pattern_type, - "verify_sender": verify_sender, - }, - allow_pattern_edit_params.AllowPatternEditParams, - ), - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[AllowPatternEditResponse]._unwrapper, - ), - cast_to=cast(Type[AllowPatternEditResponse], ResultWrapper[AllowPatternEditResponse]), - ) - - async def get( - self, - pattern_id: int, - *, - account_id: str, - # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. - # The extra values given here take precedence over values defined on the client or passed to this method. - extra_headers: Headers | None = None, - extra_query: Query | None = None, - extra_body: Body | None = None, - timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN, - ) -> AllowPatternGetResponse: - """ - Get an email allow pattern - - 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 - """ - if not account_id: - raise ValueError(f"Expected a non-empty value for `account_id` but received {account_id!r}") - return await self._get( - f"/accounts/{account_id}/email-security/settings/allow_patterns/{pattern_id}", - options=make_request_options( - extra_headers=extra_headers, - extra_query=extra_query, - extra_body=extra_body, - timeout=timeout, - post_parser=ResultWrapper[AllowPatternGetResponse]._unwrapper, - ), - cast_to=cast(Type[AllowPatternGetResponse], ResultWrapper[AllowPatternGetResponse]), - ) - - -class AllowPatternsResourceWithRawResponse: - def __init__(self, allow_patterns: AllowPatternsResource) -> None: - self._allow_patterns = allow_patterns - - self.create = to_raw_response_wrapper( - allow_patterns.create, - ) - self.list = to_raw_response_wrapper( - allow_patterns.list, - ) - self.delete = to_raw_response_wrapper( - allow_patterns.delete, - ) - self.edit = to_raw_response_wrapper( - allow_patterns.edit, - ) - self.get = to_raw_response_wrapper( - allow_patterns.get, - ) - - -class AsyncAllowPatternsResourceWithRawResponse: - def __init__(self, allow_patterns: AsyncAllowPatternsResource) -> None: - self._allow_patterns = allow_patterns - - self.create = async_to_raw_response_wrapper( - allow_patterns.create, - ) - self.list = async_to_raw_response_wrapper( - allow_patterns.list, - ) - self.delete = async_to_raw_response_wrapper( - allow_patterns.delete, - ) - self.edit = async_to_raw_response_wrapper( - allow_patterns.edit, - ) - self.get = async_to_raw_response_wrapper( - allow_patterns.get, - ) - - -class AllowPatternsResourceWithStreamingResponse: - def __init__(self, allow_patterns: AllowPatternsResource) -> None: - self._allow_patterns = allow_patterns - - self.create = to_streamed_response_wrapper( - allow_patterns.create, - ) - self.list = to_streamed_response_wrapper( - allow_patterns.list, - ) - self.delete = to_streamed_response_wrapper( - allow_patterns.delete, - ) - self.edit = to_streamed_response_wrapper( - allow_patterns.edit, - ) - self.get = to_streamed_response_wrapper( - allow_patterns.get, - ) - - -class AsyncAllowPatternsResourceWithStreamingResponse: - def __init__(self, allow_patterns: AsyncAllowPatternsResource) -> None: - self._allow_patterns = allow_patterns - - self.create = async_to_streamed_response_wrapper( - allow_patterns.create, - ) - self.list = async_to_streamed_response_wrapper( - allow_patterns.list, - ) - self.delete = async_to_streamed_response_wrapper( - allow_patterns.delete, - ) - self.edit = async_to_streamed_response_wrapper( - allow_patterns.edit, - ) - self.get = async_to_streamed_response_wrapper( - allow_patterns.get, - ) diff --git a/src/cloudflare/resources/email_security/settings/domains.py b/src/cloudflare/resources/email_security/settings/domains.py index 79101bdfe36..00f33a1231d 100644 --- a/src/cloudflare/resources/email_security/settings/domains.py +++ b/src/cloudflare/resources/email_security/settings/domains.py @@ -173,6 +173,7 @@ def edit( *, account_id: str, domain: Optional[str] | NotGiven = NOT_GIVEN, + folder: Literal["AllItems", "Inbox"] | NotGiven = NOT_GIVEN, integration_id: Optional[str] | NotGiven = NOT_GIVEN, lookback_hops: Optional[int] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -205,6 +206,7 @@ def edit( body=maybe_transform( { "domain": domain, + "folder": folder, "integration_id": integration_id, "lookback_hops": lookback_hops, }, @@ -363,6 +365,7 @@ async def edit( *, account_id: str, domain: Optional[str] | NotGiven = NOT_GIVEN, + folder: Literal["AllItems", "Inbox"] | NotGiven = NOT_GIVEN, integration_id: Optional[str] | NotGiven = NOT_GIVEN, lookback_hops: Optional[int] | NotGiven = NOT_GIVEN, # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs. @@ -395,6 +398,7 @@ async def edit( body=await async_maybe_transform( { "domain": domain, + "folder": folder, "integration_id": integration_id, "lookback_hops": lookback_hops, }, diff --git a/src/cloudflare/resources/email_security/settings/settings.py b/src/cloudflare/resources/email_security/settings/settings.py index f3e477bcfc0..f8f2ab6dd7d 100644 --- a/src/cloudflare/resources/email_security/settings/settings.py +++ b/src/cloudflare/resources/email_security/settings/settings.py @@ -20,14 +20,6 @@ BlockSendersResourceWithStreamingResponse, AsyncBlockSendersResourceWithStreamingResponse, ) -from .allow_patterns import ( - AllowPatternsResource, - AsyncAllowPatternsResource, - AllowPatternsResourceWithRawResponse, - AsyncAllowPatternsResourceWithRawResponse, - AllowPatternsResourceWithStreamingResponse, - AsyncAllowPatternsResourceWithStreamingResponse, -) from .trusted_domains import ( TrustedDomainsResource, AsyncTrustedDomainsResource, @@ -49,10 +41,6 @@ class SettingsResource(SyncAPIResource): - @cached_property - def allow_patterns(self) -> AllowPatternsResource: - return AllowPatternsResource(self._client) - @cached_property def block_senders(self) -> BlockSendersResource: return BlockSendersResource(self._client) @@ -90,10 +78,6 @@ def with_streaming_response(self) -> SettingsResourceWithStreamingResponse: class AsyncSettingsResource(AsyncAPIResource): - @cached_property - def allow_patterns(self) -> AsyncAllowPatternsResource: - return AsyncAllowPatternsResource(self._client) - @cached_property def block_senders(self) -> AsyncBlockSendersResource: return AsyncBlockSendersResource(self._client) @@ -134,10 +118,6 @@ class SettingsResourceWithRawResponse: def __init__(self, settings: SettingsResource) -> None: self._settings = settings - @cached_property - def allow_patterns(self) -> AllowPatternsResourceWithRawResponse: - return AllowPatternsResourceWithRawResponse(self._settings.allow_patterns) - @cached_property def block_senders(self) -> BlockSendersResourceWithRawResponse: return BlockSendersResourceWithRawResponse(self._settings.block_senders) @@ -159,10 +139,6 @@ class AsyncSettingsResourceWithRawResponse: def __init__(self, settings: AsyncSettingsResource) -> None: self._settings = settings - @cached_property - def allow_patterns(self) -> AsyncAllowPatternsResourceWithRawResponse: - return AsyncAllowPatternsResourceWithRawResponse(self._settings.allow_patterns) - @cached_property def block_senders(self) -> AsyncBlockSendersResourceWithRawResponse: return AsyncBlockSendersResourceWithRawResponse(self._settings.block_senders) @@ -184,10 +160,6 @@ class SettingsResourceWithStreamingResponse: def __init__(self, settings: SettingsResource) -> None: self._settings = settings - @cached_property - def allow_patterns(self) -> AllowPatternsResourceWithStreamingResponse: - return AllowPatternsResourceWithStreamingResponse(self._settings.allow_patterns) - @cached_property def block_senders(self) -> BlockSendersResourceWithStreamingResponse: return BlockSendersResourceWithStreamingResponse(self._settings.block_senders) @@ -209,10 +181,6 @@ class AsyncSettingsResourceWithStreamingResponse: def __init__(self, settings: AsyncSettingsResource) -> None: self._settings = settings - @cached_property - def allow_patterns(self) -> AsyncAllowPatternsResourceWithStreamingResponse: - return AsyncAllowPatternsResourceWithStreamingResponse(self._settings.allow_patterns) - @cached_property def block_senders(self) -> AsyncBlockSendersResourceWithStreamingResponse: return AsyncBlockSendersResourceWithStreamingResponse(self._settings.block_senders) diff --git a/src/cloudflare/types/email_security/__init__.py b/src/cloudflare/types/email_security/__init__.py index 0c4d8f906e9..baad343a973 100644 --- a/src/cloudflare/types/email_security/__init__.py +++ b/src/cloudflare/types/email_security/__init__.py @@ -2,11 +2,9 @@ from __future__ import annotations -from .phishguard_list_params import PhishguardListParams as PhishguardListParams from .investigate_list_params import InvestigateListParams as InvestigateListParams from .investigate_get_response import InvestigateGetResponse as InvestigateGetResponse from .investigate_raw_response import InvestigateRawResponse as InvestigateRawResponse -from .phishguard_list_response import PhishguardListResponse as PhishguardListResponse from .investigate_list_response import InvestigateListResponse as InvestigateListResponse from .investigate_trace_response import InvestigateTraceResponse as InvestigateTraceResponse from .investigate_preview_response import InvestigatePreviewResponse as InvestigatePreviewResponse diff --git a/src/cloudflare/types/email_security/phishguard_list_params.py b/src/cloudflare/types/email_security/phishguard_list_params.py deleted file mode 100644 index 62e22dab48a..00000000000 --- a/src/cloudflare/types/email_security/phishguard_list_params.py +++ /dev/null @@ -1,20 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Union -from datetime import date -from typing_extensions import Required, Annotated, TypedDict - -from ..._utils import PropertyInfo - -__all__ = ["PhishguardListParams"] - - -class PhishguardListParams(TypedDict, total=False): - account_id: Required[str] - """Account Identifier""" - - from_date: Required[Annotated[Union[str, date], PropertyInfo(format="iso8601")]] - - to_date: Required[Annotated[Union[str, date], PropertyInfo(format="iso8601")]] diff --git a/src/cloudflare/types/email_security/phishguard_list_response.py b/src/cloudflare/types/email_security/phishguard_list_response.py deleted file mode 100644 index 7aa653f96de..00000000000 --- a/src/cloudflare/types/email_security/phishguard_list_response.py +++ /dev/null @@ -1,47 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Optional -from datetime import datetime -from typing_extensions import Literal - -from pydantic import Field as FieldInfo - -from ..._models import BaseModel - -__all__ = ["PhishguardListResponse", "Fields", "Tag"] - - -class Fields(BaseModel): - postfix_id: str - - to: List[str] - - ts: datetime - - from_: Optional[str] = FieldInfo(alias="from", default=None) - - -class Tag(BaseModel): - category: str - - value: str - - -class PhishguardListResponse(BaseModel): - id: int - - content: str - - disposition: Literal[ - "MALICIOUS", "MALICIOUS-BEC", "SUSPICIOUS", "SPOOF", "SPAM", "BULK", "ENCRYPTED", "EXTERNAL", "UNKNOWN", "NONE" - ] - - fields: Fields - - priority: str - - title: str - - ts: datetime - - tags: Optional[List[Tag]] = None diff --git a/src/cloudflare/types/email_security/settings/__init__.py b/src/cloudflare/types/email_security/settings/__init__.py index c4967ee7ef3..d773495cf8f 100644 --- a/src/cloudflare/types/email_security/settings/__init__.py +++ b/src/cloudflare/types/email_security/settings/__init__.py @@ -9,26 +9,18 @@ from .domain_delete_response import DomainDeleteResponse as DomainDeleteResponse from .block_sender_edit_params import BlockSenderEditParams as BlockSenderEditParams from .block_sender_list_params import BlockSenderListParams as BlockSenderListParams -from .allow_pattern_edit_params import AllowPatternEditParams as AllowPatternEditParams -from .allow_pattern_list_params import AllowPatternListParams as AllowPatternListParams from .block_sender_get_response import BlockSenderGetResponse as BlockSenderGetResponse -from .allow_pattern_get_response import AllowPatternGetResponse as AllowPatternGetResponse from .block_sender_create_params import BlockSenderCreateParams as BlockSenderCreateParams from .block_sender_edit_response import BlockSenderEditResponse as BlockSenderEditResponse from .block_sender_list_response import BlockSenderListResponse as BlockSenderListResponse from .trusted_domain_edit_params import TrustedDomainEditParams as TrustedDomainEditParams from .trusted_domain_list_params import TrustedDomainListParams as TrustedDomainListParams -from .allow_pattern_create_params import AllowPatternCreateParams as AllowPatternCreateParams -from .allow_pattern_edit_response import AllowPatternEditResponse as AllowPatternEditResponse -from .allow_pattern_list_response import AllowPatternListResponse as AllowPatternListResponse from .trusted_domain_get_response import TrustedDomainGetResponse as TrustedDomainGetResponse from .block_sender_create_response import BlockSenderCreateResponse as BlockSenderCreateResponse from .block_sender_delete_response import BlockSenderDeleteResponse as BlockSenderDeleteResponse from .trusted_domain_create_params import TrustedDomainCreateParams as TrustedDomainCreateParams from .trusted_domain_edit_response import TrustedDomainEditResponse as TrustedDomainEditResponse from .trusted_domain_list_response import TrustedDomainListResponse as TrustedDomainListResponse -from .allow_pattern_create_response import AllowPatternCreateResponse as AllowPatternCreateResponse -from .allow_pattern_delete_response import AllowPatternDeleteResponse as AllowPatternDeleteResponse from .trusted_domain_create_response import TrustedDomainCreateResponse as TrustedDomainCreateResponse from .trusted_domain_delete_response import TrustedDomainDeleteResponse as TrustedDomainDeleteResponse from .impersonation_registry_edit_params import ImpersonationRegistryEditParams as ImpersonationRegistryEditParams diff --git a/src/cloudflare/types/email_security/settings/allow_pattern_create_params.py b/src/cloudflare/types/email_security/settings/allow_pattern_create_params.py deleted file mode 100644 index 1bbe4b4a7d2..00000000000 --- a/src/cloudflare/types/email_security/settings/allow_pattern_create_params.py +++ /dev/null @@ -1,57 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Union, Iterable, Optional -from typing_extensions import Literal, Required, TypeAlias, TypedDict - -__all__ = ["AllowPatternCreateParams", "EmailSecurityCreateAllowPattern", "Variant1", "Variant1Body"] - - -class EmailSecurityCreateAllowPattern(TypedDict, total=False): - account_id: Required[str] - """Account Identifier""" - - is_recipient: Required[bool] - - is_regex: Required[bool] - - is_sender: Required[bool] - - is_spoof: Required[bool] - - pattern: Required[str] - - pattern_type: Required[Literal["EMAIL", "DOMAIN", "IP", "UNKNOWN"]] - - verify_sender: Required[bool] - - comments: Optional[str] - - -class Variant1(TypedDict, total=False): - account_id: Required[str] - """Account Identifier""" - - body: Required[Iterable[Variant1Body]] - - -class Variant1Body(TypedDict, total=False): - is_recipient: Required[bool] - - is_regex: Required[bool] - - is_sender: Required[bool] - - is_spoof: Required[bool] - - pattern: Required[str] - - pattern_type: Required[Literal["EMAIL", "DOMAIN", "IP", "UNKNOWN"]] - - verify_sender: Required[bool] - - comments: Optional[str] - - -AllowPatternCreateParams: TypeAlias = Union[EmailSecurityCreateAllowPattern, Variant1] diff --git a/src/cloudflare/types/email_security/settings/allow_pattern_create_response.py b/src/cloudflare/types/email_security/settings/allow_pattern_create_response.py deleted file mode 100644 index 620953243d0..00000000000 --- a/src/cloudflare/types/email_security/settings/allow_pattern_create_response.py +++ /dev/null @@ -1,60 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import List, Union, Optional -from datetime import datetime -from typing_extensions import Literal, TypeAlias - -from ...._models import BaseModel - -__all__ = ["AllowPatternCreateResponse", "EmailSecurityAllowPattern", "UnionMember1"] - - -class EmailSecurityAllowPattern(BaseModel): - id: int - - created_at: datetime - - is_recipient: bool - - is_regex: bool - - is_sender: bool - - is_spoof: bool - - last_modified: datetime - - pattern: str - - pattern_type: Literal["EMAIL", "DOMAIN", "IP", "UNKNOWN"] - - verify_sender: bool - - comments: Optional[str] = None - - -class UnionMember1(BaseModel): - id: int - - created_at: datetime - - is_recipient: bool - - is_regex: bool - - is_sender: bool - - is_spoof: bool - - last_modified: datetime - - pattern: str - - pattern_type: Literal["EMAIL", "DOMAIN", "IP", "UNKNOWN"] - - verify_sender: bool - - comments: Optional[str] = None - - -AllowPatternCreateResponse: TypeAlias = Union[EmailSecurityAllowPattern, List[UnionMember1]] diff --git a/src/cloudflare/types/email_security/settings/allow_pattern_delete_response.py b/src/cloudflare/types/email_security/settings/allow_pattern_delete_response.py deleted file mode 100644 index d06eb7d2e6d..00000000000 --- a/src/cloudflare/types/email_security/settings/allow_pattern_delete_response.py +++ /dev/null @@ -1,10 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - - -from ...._models import BaseModel - -__all__ = ["AllowPatternDeleteResponse"] - - -class AllowPatternDeleteResponse(BaseModel): - id: int diff --git a/src/cloudflare/types/email_security/settings/allow_pattern_edit_params.py b/src/cloudflare/types/email_security/settings/allow_pattern_edit_params.py deleted file mode 100644 index c5072ec16be..00000000000 --- a/src/cloudflare/types/email_security/settings/allow_pattern_edit_params.py +++ /dev/null @@ -1,29 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing import Optional -from typing_extensions import Literal, Required, TypedDict - -__all__ = ["AllowPatternEditParams"] - - -class AllowPatternEditParams(TypedDict, total=False): - account_id: Required[str] - """Account Identifier""" - - comments: Optional[str] - - is_recipient: Optional[bool] - - is_regex: Optional[bool] - - is_sender: Optional[bool] - - is_spoof: Optional[bool] - - pattern: Optional[str] - - pattern_type: Optional[Literal["EMAIL", "DOMAIN", "IP", "UNKNOWN"]] - - verify_sender: Optional[bool] diff --git a/src/cloudflare/types/email_security/settings/allow_pattern_edit_response.py b/src/cloudflare/types/email_security/settings/allow_pattern_edit_response.py deleted file mode 100644 index a276e21d801..00000000000 --- a/src/cloudflare/types/email_security/settings/allow_pattern_edit_response.py +++ /dev/null @@ -1,33 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from datetime import datetime -from typing_extensions import Literal - -from ...._models import BaseModel - -__all__ = ["AllowPatternEditResponse"] - - -class AllowPatternEditResponse(BaseModel): - id: int - - created_at: datetime - - is_recipient: bool - - is_regex: bool - - is_sender: bool - - is_spoof: bool - - last_modified: datetime - - pattern: str - - pattern_type: Literal["EMAIL", "DOMAIN", "IP", "UNKNOWN"] - - verify_sender: bool - - comments: Optional[str] = None diff --git a/src/cloudflare/types/email_security/settings/allow_pattern_get_response.py b/src/cloudflare/types/email_security/settings/allow_pattern_get_response.py deleted file mode 100644 index e76af1be492..00000000000 --- a/src/cloudflare/types/email_security/settings/allow_pattern_get_response.py +++ /dev/null @@ -1,33 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from datetime import datetime -from typing_extensions import Literal - -from ...._models import BaseModel - -__all__ = ["AllowPatternGetResponse"] - - -class AllowPatternGetResponse(BaseModel): - id: int - - created_at: datetime - - is_recipient: bool - - is_regex: bool - - is_sender: bool - - is_spoof: bool - - last_modified: datetime - - pattern: str - - pattern_type: Literal["EMAIL", "DOMAIN", "IP", "UNKNOWN"] - - verify_sender: bool - - comments: Optional[str] = None diff --git a/src/cloudflare/types/email_security/settings/allow_pattern_list_params.py b/src/cloudflare/types/email_security/settings/allow_pattern_list_params.py deleted file mode 100644 index bd24e235c1d..00000000000 --- a/src/cloudflare/types/email_security/settings/allow_pattern_list_params.py +++ /dev/null @@ -1,41 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -from typing_extensions import Literal, Required, TypedDict - -__all__ = ["AllowPatternListParams"] - - -class AllowPatternListParams(TypedDict, total=False): - account_id: Required[str] - """Account Identifier""" - - direction: Literal["asc", "desc"] - """The sorting direction.""" - - is_recipient: bool - - is_sender: bool - - is_spoof: bool - - order: Literal["pattern", "created_at"] - """The field to sort by.""" - - page: int - """The page number of paginated results.""" - - pattern_type: Literal["EMAIL", "DOMAIN", "IP", "UNKNOWN"] - - per_page: int - """The number of results per page.""" - - search: str - """ - Allows searching in multiple properties of a record simultaneously. This - parameter is intended for human users, not automation. Its exact behavior is - intentionally left unspecified and is subject to change in the future. - """ - - verify_sender: bool diff --git a/src/cloudflare/types/email_security/settings/allow_pattern_list_response.py b/src/cloudflare/types/email_security/settings/allow_pattern_list_response.py deleted file mode 100644 index 209780f9216..00000000000 --- a/src/cloudflare/types/email_security/settings/allow_pattern_list_response.py +++ /dev/null @@ -1,33 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from typing import Optional -from datetime import datetime -from typing_extensions import Literal - -from ...._models import BaseModel - -__all__ = ["AllowPatternListResponse"] - - -class AllowPatternListResponse(BaseModel): - id: int - - created_at: datetime - - is_recipient: bool - - is_regex: bool - - is_sender: bool - - is_spoof: bool - - last_modified: datetime - - pattern: str - - pattern_type: Literal["EMAIL", "DOMAIN", "IP", "UNKNOWN"] - - verify_sender: bool - - comments: Optional[str] = None diff --git a/src/cloudflare/types/email_security/settings/domain_edit_params.py b/src/cloudflare/types/email_security/settings/domain_edit_params.py index 59a34d8d626..e963127bd95 100644 --- a/src/cloudflare/types/email_security/settings/domain_edit_params.py +++ b/src/cloudflare/types/email_security/settings/domain_edit_params.py @@ -3,7 +3,7 @@ from __future__ import annotations from typing import Optional -from typing_extensions import Required, TypedDict +from typing_extensions import Literal, Required, TypedDict __all__ = ["DomainEditParams"] @@ -14,6 +14,8 @@ class DomainEditParams(TypedDict, total=False): domain: Optional[str] + folder: Literal["AllItems", "Inbox"] + integration_id: Optional[str] lookback_hops: Optional[int] diff --git a/src/cloudflare/types/email_security/settings/domain_edit_response.py b/src/cloudflare/types/email_security/settings/domain_edit_response.py index 4983a5f6d2a..a8e5108d5c0 100644 --- a/src/cloudflare/types/email_security/settings/domain_edit_response.py +++ b/src/cloudflare/types/email_security/settings/domain_edit_response.py @@ -25,6 +25,8 @@ class DomainEditResponse(BaseModel): folder: Optional[Literal["AllItems", "Inbox"]] = None + inbox_provider: Optional[Literal["Microsoft", "Google"]] = None + integration_id: Optional[str] = None o365_tenant_id: Optional[str] = None diff --git a/src/cloudflare/types/email_security/settings/domain_list_response.py b/src/cloudflare/types/email_security/settings/domain_list_response.py index 22ecc8e3439..ebd660aecb4 100644 --- a/src/cloudflare/types/email_security/settings/domain_list_response.py +++ b/src/cloudflare/types/email_security/settings/domain_list_response.py @@ -25,6 +25,8 @@ class DomainListResponse(BaseModel): folder: Optional[Literal["AllItems", "Inbox"]] = None + inbox_provider: Optional[Literal["Microsoft", "Google"]] = None + integration_id: Optional[str] = None o365_tenant_id: Optional[str] = None diff --git a/tests/api_resources/email_security/settings/test_allow_patterns.py b/tests/api_resources/email_security/settings/test_allow_patterns.py deleted file mode 100644 index f22f0687dc2..00000000000 --- a/tests/api_resources/email_security/settings/test_allow_patterns.py +++ /dev/null @@ -1,749 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare.pagination import SyncV4PagePaginationArray, AsyncV4PagePaginationArray -from cloudflare.types.email_security.settings import ( - AllowPatternGetResponse, - AllowPatternEditResponse, - AllowPatternListResponse, - AllowPatternCreateResponse, - AllowPatternDeleteResponse, -) - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestAllowPatterns: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_create_overload_1(self, client: Cloudflare) -> None: - allow_pattern = client.email_security.settings.allow_patterns.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - is_recipient=False, - is_regex=False, - is_sender=True, - is_spoof=False, - pattern="test@example.com", - pattern_type="EMAIL", - verify_sender=True, - ) - assert_matches_type(AllowPatternCreateResponse, allow_pattern, path=["response"]) - - @parametrize - def test_method_create_with_all_params_overload_1(self, client: Cloudflare) -> None: - allow_pattern = client.email_security.settings.allow_patterns.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - is_recipient=False, - is_regex=False, - is_sender=True, - is_spoof=False, - pattern="test@example.com", - pattern_type="EMAIL", - verify_sender=True, - comments="Trust all messages send from test@example.com", - ) - assert_matches_type(AllowPatternCreateResponse, allow_pattern, path=["response"]) - - @parametrize - def test_raw_response_create_overload_1(self, client: Cloudflare) -> None: - response = client.email_security.settings.allow_patterns.with_raw_response.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - is_recipient=False, - is_regex=False, - is_sender=True, - is_spoof=False, - pattern="test@example.com", - pattern_type="EMAIL", - verify_sender=True, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - allow_pattern = response.parse() - assert_matches_type(AllowPatternCreateResponse, allow_pattern, path=["response"]) - - @parametrize - def test_streaming_response_create_overload_1(self, client: Cloudflare) -> None: - with client.email_security.settings.allow_patterns.with_streaming_response.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - is_recipient=False, - is_regex=False, - is_sender=True, - is_spoof=False, - pattern="test@example.com", - pattern_type="EMAIL", - verify_sender=True, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - allow_pattern = response.parse() - assert_matches_type(AllowPatternCreateResponse, allow_pattern, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_create_overload_1(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.email_security.settings.allow_patterns.with_raw_response.create( - account_id="", - is_recipient=False, - is_regex=False, - is_sender=True, - is_spoof=False, - pattern="test@example.com", - pattern_type="EMAIL", - verify_sender=True, - ) - - @parametrize - def test_method_create_overload_2(self, client: Cloudflare) -> None: - allow_pattern = client.email_security.settings.allow_patterns.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=[ - { - "is_recipient": False, - "is_regex": False, - "is_sender": True, - "is_spoof": False, - "pattern": "test@example.com", - "pattern_type": "EMAIL", - "verify_sender": True, - } - ], - ) - assert_matches_type(AllowPatternCreateResponse, allow_pattern, path=["response"]) - - @parametrize - def test_raw_response_create_overload_2(self, client: Cloudflare) -> None: - response = client.email_security.settings.allow_patterns.with_raw_response.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=[ - { - "is_recipient": False, - "is_regex": False, - "is_sender": True, - "is_spoof": False, - "pattern": "test@example.com", - "pattern_type": "EMAIL", - "verify_sender": True, - } - ], - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - allow_pattern = response.parse() - assert_matches_type(AllowPatternCreateResponse, allow_pattern, path=["response"]) - - @parametrize - def test_streaming_response_create_overload_2(self, client: Cloudflare) -> None: - with client.email_security.settings.allow_patterns.with_streaming_response.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=[ - { - "is_recipient": False, - "is_regex": False, - "is_sender": True, - "is_spoof": False, - "pattern": "test@example.com", - "pattern_type": "EMAIL", - "verify_sender": True, - } - ], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - allow_pattern = response.parse() - assert_matches_type(AllowPatternCreateResponse, allow_pattern, 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.allow_patterns.with_raw_response.create( - account_id="", - body=[ - { - "is_recipient": False, - "is_regex": False, - "is_sender": True, - "is_spoof": False, - "pattern": "test@example.com", - "pattern_type": "EMAIL", - "verify_sender": True, - } - ], - ) - - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - allow_pattern = client.email_security.settings.allow_patterns.list( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(SyncV4PagePaginationArray[AllowPatternListResponse], allow_pattern, path=["response"]) - - @parametrize - def test_method_list_with_all_params(self, client: Cloudflare) -> None: - allow_pattern = client.email_security.settings.allow_patterns.list( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - direction="asc", - is_recipient=True, - is_sender=True, - is_spoof=True, - order="pattern", - page=1, - pattern_type="EMAIL", - per_page=1, - search="search", - verify_sender=True, - ) - assert_matches_type(SyncV4PagePaginationArray[AllowPatternListResponse], allow_pattern, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.email_security.settings.allow_patterns.with_raw_response.list( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - allow_pattern = response.parse() - assert_matches_type(SyncV4PagePaginationArray[AllowPatternListResponse], allow_pattern, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.email_security.settings.allow_patterns.with_streaming_response.list( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - allow_pattern = response.parse() - assert_matches_type(SyncV4PagePaginationArray[AllowPatternListResponse], allow_pattern, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_list(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.email_security.settings.allow_patterns.with_raw_response.list( - account_id="", - ) - - @parametrize - def test_method_delete(self, client: Cloudflare) -> None: - allow_pattern = client.email_security.settings.allow_patterns.delete( - pattern_id=2401, - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AllowPatternDeleteResponse, allow_pattern, path=["response"]) - - @parametrize - def test_raw_response_delete(self, client: Cloudflare) -> None: - response = client.email_security.settings.allow_patterns.with_raw_response.delete( - pattern_id=2401, - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - allow_pattern = response.parse() - assert_matches_type(AllowPatternDeleteResponse, allow_pattern, path=["response"]) - - @parametrize - def test_streaming_response_delete(self, client: Cloudflare) -> None: - with client.email_security.settings.allow_patterns.with_streaming_response.delete( - pattern_id=2401, - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - allow_pattern = response.parse() - assert_matches_type(AllowPatternDeleteResponse, allow_pattern, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_delete(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.email_security.settings.allow_patterns.with_raw_response.delete( - pattern_id=2401, - account_id="", - ) - - @parametrize - def test_method_edit(self, client: Cloudflare) -> None: - allow_pattern = client.email_security.settings.allow_patterns.edit( - pattern_id=2401, - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AllowPatternEditResponse, allow_pattern, path=["response"]) - - @parametrize - def test_method_edit_with_all_params(self, client: Cloudflare) -> None: - allow_pattern = client.email_security.settings.allow_patterns.edit( - pattern_id=2401, - account_id="023e105f4ecef8ad9ca31a8372d0c353", - comments="comments", - is_recipient=True, - is_regex=True, - is_sender=True, - is_spoof=True, - pattern="x", - pattern_type="EMAIL", - verify_sender=True, - ) - assert_matches_type(AllowPatternEditResponse, allow_pattern, path=["response"]) - - @parametrize - def test_raw_response_edit(self, client: Cloudflare) -> None: - response = client.email_security.settings.allow_patterns.with_raw_response.edit( - pattern_id=2401, - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - allow_pattern = response.parse() - assert_matches_type(AllowPatternEditResponse, allow_pattern, path=["response"]) - - @parametrize - def test_streaming_response_edit(self, client: Cloudflare) -> None: - with client.email_security.settings.allow_patterns.with_streaming_response.edit( - pattern_id=2401, - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - allow_pattern = response.parse() - assert_matches_type(AllowPatternEditResponse, allow_pattern, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_edit(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.email_security.settings.allow_patterns.with_raw_response.edit( - pattern_id=2401, - account_id="", - ) - - @parametrize - def test_method_get(self, client: Cloudflare) -> None: - allow_pattern = client.email_security.settings.allow_patterns.get( - pattern_id=2401, - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AllowPatternGetResponse, allow_pattern, path=["response"]) - - @parametrize - def test_raw_response_get(self, client: Cloudflare) -> None: - response = client.email_security.settings.allow_patterns.with_raw_response.get( - pattern_id=2401, - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - allow_pattern = response.parse() - assert_matches_type(AllowPatternGetResponse, allow_pattern, path=["response"]) - - @parametrize - def test_streaming_response_get(self, client: Cloudflare) -> None: - with client.email_security.settings.allow_patterns.with_streaming_response.get( - pattern_id=2401, - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - allow_pattern = response.parse() - assert_matches_type(AllowPatternGetResponse, allow_pattern, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_get(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.email_security.settings.allow_patterns.with_raw_response.get( - pattern_id=2401, - account_id="", - ) - - -class TestAsyncAllowPatterns: - 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: - allow_pattern = await async_client.email_security.settings.allow_patterns.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - is_recipient=False, - is_regex=False, - is_sender=True, - is_spoof=False, - pattern="test@example.com", - pattern_type="EMAIL", - verify_sender=True, - ) - assert_matches_type(AllowPatternCreateResponse, allow_pattern, path=["response"]) - - @parametrize - async def test_method_create_with_all_params_overload_1(self, async_client: AsyncCloudflare) -> None: - allow_pattern = await async_client.email_security.settings.allow_patterns.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - is_recipient=False, - is_regex=False, - is_sender=True, - is_spoof=False, - pattern="test@example.com", - pattern_type="EMAIL", - verify_sender=True, - comments="Trust all messages send from test@example.com", - ) - assert_matches_type(AllowPatternCreateResponse, allow_pattern, path=["response"]) - - @parametrize - async def test_raw_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: - response = await async_client.email_security.settings.allow_patterns.with_raw_response.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - is_recipient=False, - is_regex=False, - is_sender=True, - is_spoof=False, - pattern="test@example.com", - pattern_type="EMAIL", - verify_sender=True, - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - allow_pattern = await response.parse() - assert_matches_type(AllowPatternCreateResponse, allow_pattern, path=["response"]) - - @parametrize - async def test_streaming_response_create_overload_1(self, async_client: AsyncCloudflare) -> None: - async with async_client.email_security.settings.allow_patterns.with_streaming_response.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - is_recipient=False, - is_regex=False, - is_sender=True, - is_spoof=False, - pattern="test@example.com", - pattern_type="EMAIL", - verify_sender=True, - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - allow_pattern = await response.parse() - assert_matches_type(AllowPatternCreateResponse, allow_pattern, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_create_overload_1(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.email_security.settings.allow_patterns.with_raw_response.create( - account_id="", - is_recipient=False, - is_regex=False, - is_sender=True, - is_spoof=False, - pattern="test@example.com", - pattern_type="EMAIL", - verify_sender=True, - ) - - @parametrize - async def test_method_create_overload_2(self, async_client: AsyncCloudflare) -> None: - allow_pattern = await async_client.email_security.settings.allow_patterns.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=[ - { - "is_recipient": False, - "is_regex": False, - "is_sender": True, - "is_spoof": False, - "pattern": "test@example.com", - "pattern_type": "EMAIL", - "verify_sender": True, - } - ], - ) - assert_matches_type(AllowPatternCreateResponse, allow_pattern, path=["response"]) - - @parametrize - async def test_raw_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: - response = await async_client.email_security.settings.allow_patterns.with_raw_response.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=[ - { - "is_recipient": False, - "is_regex": False, - "is_sender": True, - "is_spoof": False, - "pattern": "test@example.com", - "pattern_type": "EMAIL", - "verify_sender": True, - } - ], - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - allow_pattern = await response.parse() - assert_matches_type(AllowPatternCreateResponse, allow_pattern, path=["response"]) - - @parametrize - async def test_streaming_response_create_overload_2(self, async_client: AsyncCloudflare) -> None: - async with async_client.email_security.settings.allow_patterns.with_streaming_response.create( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - body=[ - { - "is_recipient": False, - "is_regex": False, - "is_sender": True, - "is_spoof": False, - "pattern": "test@example.com", - "pattern_type": "EMAIL", - "verify_sender": True, - } - ], - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - allow_pattern = await response.parse() - assert_matches_type(AllowPatternCreateResponse, allow_pattern, 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.allow_patterns.with_raw_response.create( - account_id="", - body=[ - { - "is_recipient": False, - "is_regex": False, - "is_sender": True, - "is_spoof": False, - "pattern": "test@example.com", - "pattern_type": "EMAIL", - "verify_sender": True, - } - ], - ) - - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - allow_pattern = await async_client.email_security.settings.allow_patterns.list( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AsyncV4PagePaginationArray[AllowPatternListResponse], allow_pattern, path=["response"]) - - @parametrize - async def test_method_list_with_all_params(self, async_client: AsyncCloudflare) -> None: - allow_pattern = await async_client.email_security.settings.allow_patterns.list( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - direction="asc", - is_recipient=True, - is_sender=True, - is_spoof=True, - order="pattern", - page=1, - pattern_type="EMAIL", - per_page=1, - search="search", - verify_sender=True, - ) - assert_matches_type(AsyncV4PagePaginationArray[AllowPatternListResponse], allow_pattern, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.email_security.settings.allow_patterns.with_raw_response.list( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - allow_pattern = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[AllowPatternListResponse], allow_pattern, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.email_security.settings.allow_patterns.with_streaming_response.list( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - allow_pattern = await response.parse() - assert_matches_type(AsyncV4PagePaginationArray[AllowPatternListResponse], allow_pattern, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.email_security.settings.allow_patterns.with_raw_response.list( - account_id="", - ) - - @parametrize - async def test_method_delete(self, async_client: AsyncCloudflare) -> None: - allow_pattern = await async_client.email_security.settings.allow_patterns.delete( - pattern_id=2401, - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AllowPatternDeleteResponse, allow_pattern, path=["response"]) - - @parametrize - async def test_raw_response_delete(self, async_client: AsyncCloudflare) -> None: - response = await async_client.email_security.settings.allow_patterns.with_raw_response.delete( - pattern_id=2401, - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - allow_pattern = await response.parse() - assert_matches_type(AllowPatternDeleteResponse, allow_pattern, path=["response"]) - - @parametrize - async def test_streaming_response_delete(self, async_client: AsyncCloudflare) -> None: - async with async_client.email_security.settings.allow_patterns.with_streaming_response.delete( - pattern_id=2401, - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - allow_pattern = await response.parse() - assert_matches_type(AllowPatternDeleteResponse, allow_pattern, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_delete(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.email_security.settings.allow_patterns.with_raw_response.delete( - pattern_id=2401, - account_id="", - ) - - @parametrize - async def test_method_edit(self, async_client: AsyncCloudflare) -> None: - allow_pattern = await async_client.email_security.settings.allow_patterns.edit( - pattern_id=2401, - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AllowPatternEditResponse, allow_pattern, path=["response"]) - - @parametrize - async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) -> None: - allow_pattern = await async_client.email_security.settings.allow_patterns.edit( - pattern_id=2401, - account_id="023e105f4ecef8ad9ca31a8372d0c353", - comments="comments", - is_recipient=True, - is_regex=True, - is_sender=True, - is_spoof=True, - pattern="x", - pattern_type="EMAIL", - verify_sender=True, - ) - assert_matches_type(AllowPatternEditResponse, allow_pattern, path=["response"]) - - @parametrize - async def test_raw_response_edit(self, async_client: AsyncCloudflare) -> None: - response = await async_client.email_security.settings.allow_patterns.with_raw_response.edit( - pattern_id=2401, - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - allow_pattern = await response.parse() - assert_matches_type(AllowPatternEditResponse, allow_pattern, path=["response"]) - - @parametrize - async def test_streaming_response_edit(self, async_client: AsyncCloudflare) -> None: - async with async_client.email_security.settings.allow_patterns.with_streaming_response.edit( - pattern_id=2401, - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - allow_pattern = await response.parse() - assert_matches_type(AllowPatternEditResponse, allow_pattern, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_edit(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.email_security.settings.allow_patterns.with_raw_response.edit( - pattern_id=2401, - account_id="", - ) - - @parametrize - async def test_method_get(self, async_client: AsyncCloudflare) -> None: - allow_pattern = await async_client.email_security.settings.allow_patterns.get( - pattern_id=2401, - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - assert_matches_type(AllowPatternGetResponse, allow_pattern, path=["response"]) - - @parametrize - async def test_raw_response_get(self, async_client: AsyncCloudflare) -> None: - response = await async_client.email_security.settings.allow_patterns.with_raw_response.get( - pattern_id=2401, - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - allow_pattern = await response.parse() - assert_matches_type(AllowPatternGetResponse, allow_pattern, path=["response"]) - - @parametrize - async def test_streaming_response_get(self, async_client: AsyncCloudflare) -> None: - async with async_client.email_security.settings.allow_patterns.with_streaming_response.get( - pattern_id=2401, - account_id="023e105f4ecef8ad9ca31a8372d0c353", - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - allow_pattern = await response.parse() - assert_matches_type(AllowPatternGetResponse, allow_pattern, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_get(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.email_security.settings.allow_patterns.with_raw_response.get( - pattern_id=2401, - account_id="", - ) diff --git a/tests/api_resources/email_security/settings/test_domains.py b/tests/api_resources/email_security/settings/test_domains.py index ae501f021ba..120e9cd87b5 100644 --- a/tests/api_resources/email_security/settings/test_domains.py +++ b/tests/api_resources/email_security/settings/test_domains.py @@ -130,6 +130,7 @@ def test_method_edit_with_all_params(self, client: Cloudflare) -> None: domain_id=2400, account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="domain", + folder="AllItems", integration_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", lookback_hops=1, ) @@ -281,6 +282,7 @@ async def test_method_edit_with_all_params(self, async_client: AsyncCloudflare) domain_id=2400, account_id="023e105f4ecef8ad9ca31a8372d0c353", domain="domain", + folder="AllItems", integration_id="182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e", lookback_hops=1, ) diff --git a/tests/api_resources/email_security/test_phishguard.py b/tests/api_resources/email_security/test_phishguard.py deleted file mode 100644 index ccbdb6474f5..00000000000 --- a/tests/api_resources/email_security/test_phishguard.py +++ /dev/null @@ -1,116 +0,0 @@ -# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -from __future__ import annotations - -import os -from typing import Any, cast - -import pytest - -from cloudflare import Cloudflare, AsyncCloudflare -from tests.utils import assert_matches_type -from cloudflare._utils import parse_date -from cloudflare.pagination import SyncSinglePage, AsyncSinglePage -from cloudflare.types.email_security import PhishguardListResponse - -base_url = os.environ.get("TEST_API_BASE_URL", "http://127.0.0.1:4010") - - -class TestPhishguard: - parametrize = pytest.mark.parametrize("client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - def test_method_list(self, client: Cloudflare) -> None: - phishguard = client.email_security.phishguard.list( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - from_date=parse_date("2019-12-27"), - to_date=parse_date("2019-12-27"), - ) - assert_matches_type(SyncSinglePage[PhishguardListResponse], phishguard, path=["response"]) - - @parametrize - def test_raw_response_list(self, client: Cloudflare) -> None: - response = client.email_security.phishguard.with_raw_response.list( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - from_date=parse_date("2019-12-27"), - to_date=parse_date("2019-12-27"), - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - phishguard = response.parse() - assert_matches_type(SyncSinglePage[PhishguardListResponse], phishguard, path=["response"]) - - @parametrize - def test_streaming_response_list(self, client: Cloudflare) -> None: - with client.email_security.phishguard.with_streaming_response.list( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - from_date=parse_date("2019-12-27"), - to_date=parse_date("2019-12-27"), - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - phishguard = response.parse() - assert_matches_type(SyncSinglePage[PhishguardListResponse], phishguard, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - def test_path_params_list(self, client: Cloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - client.email_security.phishguard.with_raw_response.list( - account_id="", - from_date=parse_date("2019-12-27"), - to_date=parse_date("2019-12-27"), - ) - - -class TestAsyncPhishguard: - parametrize = pytest.mark.parametrize("async_client", [False, True], indirect=True, ids=["loose", "strict"]) - - @parametrize - async def test_method_list(self, async_client: AsyncCloudflare) -> None: - phishguard = await async_client.email_security.phishguard.list( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - from_date=parse_date("2019-12-27"), - to_date=parse_date("2019-12-27"), - ) - assert_matches_type(AsyncSinglePage[PhishguardListResponse], phishguard, path=["response"]) - - @parametrize - async def test_raw_response_list(self, async_client: AsyncCloudflare) -> None: - response = await async_client.email_security.phishguard.with_raw_response.list( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - from_date=parse_date("2019-12-27"), - to_date=parse_date("2019-12-27"), - ) - - assert response.is_closed is True - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - phishguard = await response.parse() - assert_matches_type(AsyncSinglePage[PhishguardListResponse], phishguard, path=["response"]) - - @parametrize - async def test_streaming_response_list(self, async_client: AsyncCloudflare) -> None: - async with async_client.email_security.phishguard.with_streaming_response.list( - account_id="023e105f4ecef8ad9ca31a8372d0c353", - from_date=parse_date("2019-12-27"), - to_date=parse_date("2019-12-27"), - ) as response: - assert not response.is_closed - assert response.http_request.headers.get("X-Stainless-Lang") == "python" - - phishguard = await response.parse() - assert_matches_type(AsyncSinglePage[PhishguardListResponse], phishguard, path=["response"]) - - assert cast(Any, response.is_closed) is True - - @parametrize - async def test_path_params_list(self, async_client: AsyncCloudflare) -> None: - with pytest.raises(ValueError, match=r"Expected a non-empty value for `account_id` but received ''"): - await async_client.email_security.phishguard.with_raw_response.list( - account_id="", - from_date=parse_date("2019-12-27"), - to_date=parse_date("2019-12-27"), - )