# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

from __future__ import annotations

import typing_extensions
from typing import Type, Optional, cast
from typing_extensions import Literal

import httpx

from .dns import (
    DNSResource,
    AsyncDNSResource,
    DNSResourceWithRawResponse,
    AsyncDNSResourceWithRawResponse,
    DNSResourceWithStreamingResponse,
    AsyncDNSResourceWithStreamingResponse,
)
from ..._types import Body, Omit, Query, Headers, NotGiven, omit, not_given
from ..._utils import path_template, maybe_transform, async_maybe_transform
from ..._compat import cached_property
from .addresses import (
    AddressesResource,
    AsyncAddressesResource,
    AddressesResourceWithRawResponse,
    AsyncAddressesResourceWithRawResponse,
    AddressesResourceWithStreamingResponse,
    AsyncAddressesResourceWithStreamingResponse,
)
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 .rules.rules import (
    RulesResource,
    AsyncRulesResource,
    RulesResourceWithRawResponse,
    AsyncRulesResourceWithRawResponse,
    RulesResourceWithStreamingResponse,
    AsyncRulesResourceWithStreamingResponse,
)
from .account_rules import (
    AccountRulesResource,
    AsyncAccountRulesResource,
    AccountRulesResourceWithRawResponse,
    AsyncAccountRulesResourceWithRawResponse,
    AccountRulesResourceWithStreamingResponse,
    AsyncAccountRulesResourceWithStreamingResponse,
)
from ..._base_client import make_request_options
from ...types.email_routing import (
    email_routing_edit_params,
    email_routing_enable_params,
    email_routing_unlock_params,
    email_routing_update_params,
    email_routing_disable_params,
)
from ...types.email_routing.settings import Settings

__all__ = ["EmailRoutingResource", "AsyncEmailRoutingResource"]


class EmailRoutingResource(SyncAPIResource):
    @cached_property
    def dns(self) -> DNSResource:
        return DNSResource(self._client)

    @cached_property
    def rules(self) -> RulesResource:
        return RulesResource(self._client)

    @cached_property
    def account_rules(self) -> AccountRulesResource:
        return AccountRulesResource(self._client)

    @cached_property
    def addresses(self) -> AddressesResource:
        return AddressesResource(self._client)

    @cached_property
    def with_raw_response(self) -> EmailRoutingResourceWithRawResponse:
        """
        This property can be used as a prefix for any HTTP method call to return
        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 EmailRoutingResourceWithRawResponse(self)

    @cached_property
    def with_streaming_response(self) -> EmailRoutingResourceWithStreamingResponse:
        """
        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 EmailRoutingResourceWithStreamingResponse(self)

    def update(
        self,
        *,
        zone_id: str,
        enabled: Literal[True, False] | Omit = omit,
        skip_wizard: Literal[True, False] | Omit = omit,
        support_subaddress: Literal[True, False] | Omit = omit,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> Optional[Settings]:
        """
        Update the settings for your Email Routing zone.

        Args:
          zone_id: Identifier.

          enabled: State of your zone Email Routing settings. No-op on this endpoint - use
              `POST`/`DELETE /zones/{zone_id}/email/routing/dns`.

          skip_wizard: Flag to check if the user skipped the configuration wizard.

          support_subaddress: Whether subaddressing (plus-addressing) is honored when matching incoming mail
              against routing rules.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not zone_id:
            raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
        return self._put(
            path_template("/zones/{zone_id}/email/routing", zone_id=zone_id),
            body=maybe_transform(
                {
                    "enabled": enabled,
                    "skip_wizard": skip_wizard,
                    "support_subaddress": support_subaddress,
                },
                email_routing_update_params.EmailRoutingUpdateParams,
            ),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[Optional[Settings]]._unwrapper,
            ),
            cast_to=cast(Type[Optional[Settings]], ResultWrapper[Settings]),
        )

    @typing_extensions.deprecated("deprecated")
    def disable(
        self,
        *,
        zone_id: str,
        body: object,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> Optional[Settings]:
        """Disable your Email Routing zone.

        Also removes additional MX records previously
        required for Email Routing to work.

        Args:
          zone_id: Identifier.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not zone_id:
            raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
        return self._post(
            path_template("/zones/{zone_id}/email/routing/disable", zone_id=zone_id),
            body=maybe_transform(body, email_routing_disable_params.EmailRoutingDisableParams),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[Optional[Settings]]._unwrapper,
            ),
            cast_to=cast(Type[Optional[Settings]], ResultWrapper[Settings]),
        )

    def edit(
        self,
        *,
        zone_id: str,
        enabled: Literal[True, False] | Omit = omit,
        skip_wizard: Literal[True, False] | Omit = omit,
        support_subaddress: Literal[True, False] | Omit = omit,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> Optional[Settings]:
        """
        Update the settings for your Email Routing zone.

        Args:
          zone_id: Identifier.

          enabled: State of your zone Email Routing settings. No-op on this endpoint - use
              `POST`/`DELETE /zones/{zone_id}/email/routing/dns`.

          skip_wizard: Flag to check if the user skipped the configuration wizard.

          support_subaddress: Whether subaddressing (plus-addressing) is honored when matching incoming mail
              against routing rules.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not zone_id:
            raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
        return self._patch(
            path_template("/zones/{zone_id}/email/routing", zone_id=zone_id),
            body=maybe_transform(
                {
                    "enabled": enabled,
                    "skip_wizard": skip_wizard,
                    "support_subaddress": support_subaddress,
                },
                email_routing_edit_params.EmailRoutingEditParams,
            ),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[Optional[Settings]]._unwrapper,
            ),
            cast_to=cast(Type[Optional[Settings]], ResultWrapper[Settings]),
        )

    @typing_extensions.deprecated("deprecated")
    def enable(
        self,
        *,
        zone_id: str,
        body: object,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> Optional[Settings]:
        """Enable you Email Routing zone.

        Add and lock the necessary MX and SPF records.

        Args:
          zone_id: Identifier.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not zone_id:
            raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
        return self._post(
            path_template("/zones/{zone_id}/email/routing/enable", zone_id=zone_id),
            body=maybe_transform(body, email_routing_enable_params.EmailRoutingEnableParams),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[Optional[Settings]]._unwrapper,
            ),
            cast_to=cast(Type[Optional[Settings]], ResultWrapper[Settings]),
        )

    def get(
        self,
        *,
        zone_id: str,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> Optional[Settings]:
        """
        Get information about the settings for your Email Routing zone.

        Args:
          zone_id: Identifier.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not zone_id:
            raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
        return self._get(
            path_template("/zones/{zone_id}/email/routing", zone_id=zone_id),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[Optional[Settings]]._unwrapper,
            ),
            cast_to=cast(Type[Optional[Settings]], ResultWrapper[Settings]),
        )

    @typing_extensions.deprecated("This endpoint is deprecated. Use PATCH /zones/{zone_id}/email/routing/dns instead.")
    def unlock(
        self,
        *,
        zone_id: str,
        name: str | Omit = omit,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> Optional[Settings]:
        """Unlock MX records previously locked by Email Routing.

        Deprecated - use PATCH
        /zones/{zone_id}/email/routing/dns instead.

        Args:
          zone_id: Identifier.

          name: Domain of your zone.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not zone_id:
            raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
        return self._post(
            path_template("/zones/{zone_id}/email/routing/unlock", zone_id=zone_id),
            body=maybe_transform({"name": name}, email_routing_unlock_params.EmailRoutingUnlockParams),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[Optional[Settings]]._unwrapper,
            ),
            cast_to=cast(Type[Optional[Settings]], ResultWrapper[Settings]),
        )


class AsyncEmailRoutingResource(AsyncAPIResource):
    @cached_property
    def dns(self) -> AsyncDNSResource:
        return AsyncDNSResource(self._client)

    @cached_property
    def rules(self) -> AsyncRulesResource:
        return AsyncRulesResource(self._client)

    @cached_property
    def account_rules(self) -> AsyncAccountRulesResource:
        return AsyncAccountRulesResource(self._client)

    @cached_property
    def addresses(self) -> AsyncAddressesResource:
        return AsyncAddressesResource(self._client)

    @cached_property
    def with_raw_response(self) -> AsyncEmailRoutingResourceWithRawResponse:
        """
        This property can be used as a prefix for any HTTP method call to return
        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 AsyncEmailRoutingResourceWithRawResponse(self)

    @cached_property
    def with_streaming_response(self) -> AsyncEmailRoutingResourceWithStreamingResponse:
        """
        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 AsyncEmailRoutingResourceWithStreamingResponse(self)

    async def update(
        self,
        *,
        zone_id: str,
        enabled: Literal[True, False] | Omit = omit,
        skip_wizard: Literal[True, False] | Omit = omit,
        support_subaddress: Literal[True, False] | Omit = omit,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> Optional[Settings]:
        """
        Update the settings for your Email Routing zone.

        Args:
          zone_id: Identifier.

          enabled: State of your zone Email Routing settings. No-op on this endpoint - use
              `POST`/`DELETE /zones/{zone_id}/email/routing/dns`.

          skip_wizard: Flag to check if the user skipped the configuration wizard.

          support_subaddress: Whether subaddressing (plus-addressing) is honored when matching incoming mail
              against routing rules.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not zone_id:
            raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
        return await self._put(
            path_template("/zones/{zone_id}/email/routing", zone_id=zone_id),
            body=await async_maybe_transform(
                {
                    "enabled": enabled,
                    "skip_wizard": skip_wizard,
                    "support_subaddress": support_subaddress,
                },
                email_routing_update_params.EmailRoutingUpdateParams,
            ),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[Optional[Settings]]._unwrapper,
            ),
            cast_to=cast(Type[Optional[Settings]], ResultWrapper[Settings]),
        )

    @typing_extensions.deprecated("deprecated")
    async def disable(
        self,
        *,
        zone_id: str,
        body: object,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> Optional[Settings]:
        """Disable your Email Routing zone.

        Also removes additional MX records previously
        required for Email Routing to work.

        Args:
          zone_id: Identifier.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not zone_id:
            raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
        return await self._post(
            path_template("/zones/{zone_id}/email/routing/disable", zone_id=zone_id),
            body=await async_maybe_transform(body, email_routing_disable_params.EmailRoutingDisableParams),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[Optional[Settings]]._unwrapper,
            ),
            cast_to=cast(Type[Optional[Settings]], ResultWrapper[Settings]),
        )

    async def edit(
        self,
        *,
        zone_id: str,
        enabled: Literal[True, False] | Omit = omit,
        skip_wizard: Literal[True, False] | Omit = omit,
        support_subaddress: Literal[True, False] | Omit = omit,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> Optional[Settings]:
        """
        Update the settings for your Email Routing zone.

        Args:
          zone_id: Identifier.

          enabled: State of your zone Email Routing settings. No-op on this endpoint - use
              `POST`/`DELETE /zones/{zone_id}/email/routing/dns`.

          skip_wizard: Flag to check if the user skipped the configuration wizard.

          support_subaddress: Whether subaddressing (plus-addressing) is honored when matching incoming mail
              against routing rules.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not zone_id:
            raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
        return await self._patch(
            path_template("/zones/{zone_id}/email/routing", zone_id=zone_id),
            body=await async_maybe_transform(
                {
                    "enabled": enabled,
                    "skip_wizard": skip_wizard,
                    "support_subaddress": support_subaddress,
                },
                email_routing_edit_params.EmailRoutingEditParams,
            ),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[Optional[Settings]]._unwrapper,
            ),
            cast_to=cast(Type[Optional[Settings]], ResultWrapper[Settings]),
        )

    @typing_extensions.deprecated("deprecated")
    async def enable(
        self,
        *,
        zone_id: str,
        body: object,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> Optional[Settings]:
        """Enable you Email Routing zone.

        Add and lock the necessary MX and SPF records.

        Args:
          zone_id: Identifier.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not zone_id:
            raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
        return await self._post(
            path_template("/zones/{zone_id}/email/routing/enable", zone_id=zone_id),
            body=await async_maybe_transform(body, email_routing_enable_params.EmailRoutingEnableParams),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[Optional[Settings]]._unwrapper,
            ),
            cast_to=cast(Type[Optional[Settings]], ResultWrapper[Settings]),
        )

    async def get(
        self,
        *,
        zone_id: str,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> Optional[Settings]:
        """
        Get information about the settings for your Email Routing zone.

        Args:
          zone_id: Identifier.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not zone_id:
            raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
        return await self._get(
            path_template("/zones/{zone_id}/email/routing", zone_id=zone_id),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[Optional[Settings]]._unwrapper,
            ),
            cast_to=cast(Type[Optional[Settings]], ResultWrapper[Settings]),
        )

    @typing_extensions.deprecated("This endpoint is deprecated. Use PATCH /zones/{zone_id}/email/routing/dns instead.")
    async def unlock(
        self,
        *,
        zone_id: str,
        name: str | Omit = omit,
        # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
        # The extra values given here take precedence over values defined on the client or passed to this method.
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> Optional[Settings]:
        """Unlock MX records previously locked by Email Routing.

        Deprecated - use PATCH
        /zones/{zone_id}/email/routing/dns instead.

        Args:
          zone_id: Identifier.

          name: Domain of your zone.

          extra_headers: Send extra headers

          extra_query: Add additional query parameters to the request

          extra_body: Add additional JSON properties to the request

          timeout: Override the client-level default timeout for this request, in seconds
        """
        if not zone_id:
            raise ValueError(f"Expected a non-empty value for `zone_id` but received {zone_id!r}")
        return await self._post(
            path_template("/zones/{zone_id}/email/routing/unlock", zone_id=zone_id),
            body=await async_maybe_transform({"name": name}, email_routing_unlock_params.EmailRoutingUnlockParams),
            options=make_request_options(
                extra_headers=extra_headers,
                extra_query=extra_query,
                extra_body=extra_body,
                timeout=timeout,
                post_parser=ResultWrapper[Optional[Settings]]._unwrapper,
            ),
            cast_to=cast(Type[Optional[Settings]], ResultWrapper[Settings]),
        )


class EmailRoutingResourceWithRawResponse:
    def __init__(self, email_routing: EmailRoutingResource) -> None:
        self._email_routing = email_routing

        self.update = to_raw_response_wrapper(
            email_routing.update,
        )
        self.disable = (  # pyright: ignore[reportDeprecated]
            to_raw_response_wrapper(
                email_routing.disable,  # pyright: ignore[reportDeprecated],
            )
        )
        self.edit = to_raw_response_wrapper(
            email_routing.edit,
        )
        self.enable = (  # pyright: ignore[reportDeprecated]
            to_raw_response_wrapper(
                email_routing.enable,  # pyright: ignore[reportDeprecated],
            )
        )
        self.get = to_raw_response_wrapper(
            email_routing.get,
        )
        self.unlock = (  # pyright: ignore[reportDeprecated]
            to_raw_response_wrapper(
                email_routing.unlock,  # pyright: ignore[reportDeprecated],
            )
        )

    @cached_property
    def dns(self) -> DNSResourceWithRawResponse:
        return DNSResourceWithRawResponse(self._email_routing.dns)

    @cached_property
    def rules(self) -> RulesResourceWithRawResponse:
        return RulesResourceWithRawResponse(self._email_routing.rules)

    @cached_property
    def account_rules(self) -> AccountRulesResourceWithRawResponse:
        return AccountRulesResourceWithRawResponse(self._email_routing.account_rules)

    @cached_property
    def addresses(self) -> AddressesResourceWithRawResponse:
        return AddressesResourceWithRawResponse(self._email_routing.addresses)


class AsyncEmailRoutingResourceWithRawResponse:
    def __init__(self, email_routing: AsyncEmailRoutingResource) -> None:
        self._email_routing = email_routing

        self.update = async_to_raw_response_wrapper(
            email_routing.update,
        )
        self.disable = (  # pyright: ignore[reportDeprecated]
            async_to_raw_response_wrapper(
                email_routing.disable,  # pyright: ignore[reportDeprecated],
            )
        )
        self.edit = async_to_raw_response_wrapper(
            email_routing.edit,
        )
        self.enable = (  # pyright: ignore[reportDeprecated]
            async_to_raw_response_wrapper(
                email_routing.enable,  # pyright: ignore[reportDeprecated],
            )
        )
        self.get = async_to_raw_response_wrapper(
            email_routing.get,
        )
        self.unlock = (  # pyright: ignore[reportDeprecated]
            async_to_raw_response_wrapper(
                email_routing.unlock,  # pyright: ignore[reportDeprecated],
            )
        )

    @cached_property
    def dns(self) -> AsyncDNSResourceWithRawResponse:
        return AsyncDNSResourceWithRawResponse(self._email_routing.dns)

    @cached_property
    def rules(self) -> AsyncRulesResourceWithRawResponse:
        return AsyncRulesResourceWithRawResponse(self._email_routing.rules)

    @cached_property
    def account_rules(self) -> AsyncAccountRulesResourceWithRawResponse:
        return AsyncAccountRulesResourceWithRawResponse(self._email_routing.account_rules)

    @cached_property
    def addresses(self) -> AsyncAddressesResourceWithRawResponse:
        return AsyncAddressesResourceWithRawResponse(self._email_routing.addresses)


class EmailRoutingResourceWithStreamingResponse:
    def __init__(self, email_routing: EmailRoutingResource) -> None:
        self._email_routing = email_routing

        self.update = to_streamed_response_wrapper(
            email_routing.update,
        )
        self.disable = (  # pyright: ignore[reportDeprecated]
            to_streamed_response_wrapper(
                email_routing.disable,  # pyright: ignore[reportDeprecated],
            )
        )
        self.edit = to_streamed_response_wrapper(
            email_routing.edit,
        )
        self.enable = (  # pyright: ignore[reportDeprecated]
            to_streamed_response_wrapper(
                email_routing.enable,  # pyright: ignore[reportDeprecated],
            )
        )
        self.get = to_streamed_response_wrapper(
            email_routing.get,
        )
        self.unlock = (  # pyright: ignore[reportDeprecated]
            to_streamed_response_wrapper(
                email_routing.unlock,  # pyright: ignore[reportDeprecated],
            )
        )

    @cached_property
    def dns(self) -> DNSResourceWithStreamingResponse:
        return DNSResourceWithStreamingResponse(self._email_routing.dns)

    @cached_property
    def rules(self) -> RulesResourceWithStreamingResponse:
        return RulesResourceWithStreamingResponse(self._email_routing.rules)

    @cached_property
    def account_rules(self) -> AccountRulesResourceWithStreamingResponse:
        return AccountRulesResourceWithStreamingResponse(self._email_routing.account_rules)

    @cached_property
    def addresses(self) -> AddressesResourceWithStreamingResponse:
        return AddressesResourceWithStreamingResponse(self._email_routing.addresses)


class AsyncEmailRoutingResourceWithStreamingResponse:
    def __init__(self, email_routing: AsyncEmailRoutingResource) -> None:
        self._email_routing = email_routing

        self.update = async_to_streamed_response_wrapper(
            email_routing.update,
        )
        self.disable = (  # pyright: ignore[reportDeprecated]
            async_to_streamed_response_wrapper(
                email_routing.disable,  # pyright: ignore[reportDeprecated],
            )
        )
        self.edit = async_to_streamed_response_wrapper(
            email_routing.edit,
        )
        self.enable = (  # pyright: ignore[reportDeprecated]
            async_to_streamed_response_wrapper(
                email_routing.enable,  # pyright: ignore[reportDeprecated],
            )
        )
        self.get = async_to_streamed_response_wrapper(
            email_routing.get,
        )
        self.unlock = (  # pyright: ignore[reportDeprecated]
            async_to_streamed_response_wrapper(
                email_routing.unlock,  # pyright: ignore[reportDeprecated],
            )
        )

    @cached_property
    def dns(self) -> AsyncDNSResourceWithStreamingResponse:
        return AsyncDNSResourceWithStreamingResponse(self._email_routing.dns)

    @cached_property
    def rules(self) -> AsyncRulesResourceWithStreamingResponse:
        return AsyncRulesResourceWithStreamingResponse(self._email_routing.rules)

    @cached_property
    def account_rules(self) -> AsyncAccountRulesResourceWithStreamingResponse:
        return AsyncAccountRulesResourceWithStreamingResponse(self._email_routing.account_rules)

    @cached_property
    def addresses(self) -> AsyncAddressesResourceWithStreamingResponse:
        return AsyncAddressesResourceWithStreamingResponse(self._email_routing.addresses)
