{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.SES.Types.IdentityMailFromDomainAttributes
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SES.Types.IdentityMailFromDomainAttributes where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.SES.Types.BehaviorOnMXFailure
import Amazonka.SES.Types.CustomMailFromStatus

-- | Represents the custom MAIL FROM domain attributes of a verified identity
-- (email address or domain).
--
-- /See:/ 'newIdentityMailFromDomainAttributes' smart constructor.
data IdentityMailFromDomainAttributes = IdentityMailFromDomainAttributes'
  { -- | The custom MAIL FROM domain that the identity is configured to use.
    IdentityMailFromDomainAttributes -> Text
mailFromDomain :: Prelude.Text,
    -- | The state that indicates whether Amazon SES has successfully read the MX
    -- record required for custom MAIL FROM domain setup. If the state is
    -- @Success@, Amazon SES uses the specified custom MAIL FROM domain when
    -- the verified identity sends an email. All other states indicate that
    -- Amazon SES takes the action described by @BehaviorOnMXFailure@.
    IdentityMailFromDomainAttributes -> CustomMailFromStatus
mailFromDomainStatus :: CustomMailFromStatus,
    -- | The action that Amazon SES takes if it cannot successfully read the
    -- required MX record when you send an email. A value of @UseDefaultValue@
    -- indicates that if Amazon SES cannot read the required MX record, it uses
    -- amazonses.com (or a subdomain of that) as the MAIL FROM domain. A value
    -- of @RejectMessage@ indicates that if Amazon SES cannot read the required
    -- MX record, Amazon SES returns a @MailFromDomainNotVerified@ error and
    -- does not send the email.
    --
    -- The custom MAIL FROM setup states that result in this behavior are
    -- @Pending@, @Failed@, and @TemporaryFailure@.
    IdentityMailFromDomainAttributes -> BehaviorOnMXFailure
behaviorOnMXFailure :: BehaviorOnMXFailure
  }
  deriving (IdentityMailFromDomainAttributes
-> IdentityMailFromDomainAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IdentityMailFromDomainAttributes
-> IdentityMailFromDomainAttributes -> Bool
$c/= :: IdentityMailFromDomainAttributes
-> IdentityMailFromDomainAttributes -> Bool
== :: IdentityMailFromDomainAttributes
-> IdentityMailFromDomainAttributes -> Bool
$c== :: IdentityMailFromDomainAttributes
-> IdentityMailFromDomainAttributes -> Bool
Prelude.Eq, ReadPrec [IdentityMailFromDomainAttributes]
ReadPrec IdentityMailFromDomainAttributes
Int -> ReadS IdentityMailFromDomainAttributes
ReadS [IdentityMailFromDomainAttributes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [IdentityMailFromDomainAttributes]
$creadListPrec :: ReadPrec [IdentityMailFromDomainAttributes]
readPrec :: ReadPrec IdentityMailFromDomainAttributes
$creadPrec :: ReadPrec IdentityMailFromDomainAttributes
readList :: ReadS [IdentityMailFromDomainAttributes]
$creadList :: ReadS [IdentityMailFromDomainAttributes]
readsPrec :: Int -> ReadS IdentityMailFromDomainAttributes
$creadsPrec :: Int -> ReadS IdentityMailFromDomainAttributes
Prelude.Read, Int -> IdentityMailFromDomainAttributes -> ShowS
[IdentityMailFromDomainAttributes] -> ShowS
IdentityMailFromDomainAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IdentityMailFromDomainAttributes] -> ShowS
$cshowList :: [IdentityMailFromDomainAttributes] -> ShowS
show :: IdentityMailFromDomainAttributes -> String
$cshow :: IdentityMailFromDomainAttributes -> String
showsPrec :: Int -> IdentityMailFromDomainAttributes -> ShowS
$cshowsPrec :: Int -> IdentityMailFromDomainAttributes -> ShowS
Prelude.Show, forall x.
Rep IdentityMailFromDomainAttributes x
-> IdentityMailFromDomainAttributes
forall x.
IdentityMailFromDomainAttributes
-> Rep IdentityMailFromDomainAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep IdentityMailFromDomainAttributes x
-> IdentityMailFromDomainAttributes
$cfrom :: forall x.
IdentityMailFromDomainAttributes
-> Rep IdentityMailFromDomainAttributes x
Prelude.Generic)

-- |
-- Create a value of 'IdentityMailFromDomainAttributes' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'mailFromDomain', 'identityMailFromDomainAttributes_mailFromDomain' - The custom MAIL FROM domain that the identity is configured to use.
--
-- 'mailFromDomainStatus', 'identityMailFromDomainAttributes_mailFromDomainStatus' - The state that indicates whether Amazon SES has successfully read the MX
-- record required for custom MAIL FROM domain setup. If the state is
-- @Success@, Amazon SES uses the specified custom MAIL FROM domain when
-- the verified identity sends an email. All other states indicate that
-- Amazon SES takes the action described by @BehaviorOnMXFailure@.
--
-- 'behaviorOnMXFailure', 'identityMailFromDomainAttributes_behaviorOnMXFailure' - The action that Amazon SES takes if it cannot successfully read the
-- required MX record when you send an email. A value of @UseDefaultValue@
-- indicates that if Amazon SES cannot read the required MX record, it uses
-- amazonses.com (or a subdomain of that) as the MAIL FROM domain. A value
-- of @RejectMessage@ indicates that if Amazon SES cannot read the required
-- MX record, Amazon SES returns a @MailFromDomainNotVerified@ error and
-- does not send the email.
--
-- The custom MAIL FROM setup states that result in this behavior are
-- @Pending@, @Failed@, and @TemporaryFailure@.
newIdentityMailFromDomainAttributes ::
  -- | 'mailFromDomain'
  Prelude.Text ->
  -- | 'mailFromDomainStatus'
  CustomMailFromStatus ->
  -- | 'behaviorOnMXFailure'
  BehaviorOnMXFailure ->
  IdentityMailFromDomainAttributes
newIdentityMailFromDomainAttributes :: Text
-> CustomMailFromStatus
-> BehaviorOnMXFailure
-> IdentityMailFromDomainAttributes
newIdentityMailFromDomainAttributes
  Text
pMailFromDomain_
  CustomMailFromStatus
pMailFromDomainStatus_
  BehaviorOnMXFailure
pBehaviorOnMXFailure_ =
    IdentityMailFromDomainAttributes'
      { $sel:mailFromDomain:IdentityMailFromDomainAttributes' :: Text
mailFromDomain =
          Text
pMailFromDomain_,
        $sel:mailFromDomainStatus:IdentityMailFromDomainAttributes' :: CustomMailFromStatus
mailFromDomainStatus =
          CustomMailFromStatus
pMailFromDomainStatus_,
        $sel:behaviorOnMXFailure:IdentityMailFromDomainAttributes' :: BehaviorOnMXFailure
behaviorOnMXFailure =
          BehaviorOnMXFailure
pBehaviorOnMXFailure_
      }

-- | The custom MAIL FROM domain that the identity is configured to use.
identityMailFromDomainAttributes_mailFromDomain :: Lens.Lens' IdentityMailFromDomainAttributes Prelude.Text
identityMailFromDomainAttributes_mailFromDomain :: Lens' IdentityMailFromDomainAttributes Text
identityMailFromDomainAttributes_mailFromDomain = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IdentityMailFromDomainAttributes' {Text
mailFromDomain :: Text
$sel:mailFromDomain:IdentityMailFromDomainAttributes' :: IdentityMailFromDomainAttributes -> Text
mailFromDomain} -> Text
mailFromDomain) (\s :: IdentityMailFromDomainAttributes
s@IdentityMailFromDomainAttributes' {} Text
a -> IdentityMailFromDomainAttributes
s {$sel:mailFromDomain:IdentityMailFromDomainAttributes' :: Text
mailFromDomain = Text
a} :: IdentityMailFromDomainAttributes)

-- | The state that indicates whether Amazon SES has successfully read the MX
-- record required for custom MAIL FROM domain setup. If the state is
-- @Success@, Amazon SES uses the specified custom MAIL FROM domain when
-- the verified identity sends an email. All other states indicate that
-- Amazon SES takes the action described by @BehaviorOnMXFailure@.
identityMailFromDomainAttributes_mailFromDomainStatus :: Lens.Lens' IdentityMailFromDomainAttributes CustomMailFromStatus
identityMailFromDomainAttributes_mailFromDomainStatus :: Lens' IdentityMailFromDomainAttributes CustomMailFromStatus
identityMailFromDomainAttributes_mailFromDomainStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IdentityMailFromDomainAttributes' {CustomMailFromStatus
mailFromDomainStatus :: CustomMailFromStatus
$sel:mailFromDomainStatus:IdentityMailFromDomainAttributes' :: IdentityMailFromDomainAttributes -> CustomMailFromStatus
mailFromDomainStatus} -> CustomMailFromStatus
mailFromDomainStatus) (\s :: IdentityMailFromDomainAttributes
s@IdentityMailFromDomainAttributes' {} CustomMailFromStatus
a -> IdentityMailFromDomainAttributes
s {$sel:mailFromDomainStatus:IdentityMailFromDomainAttributes' :: CustomMailFromStatus
mailFromDomainStatus = CustomMailFromStatus
a} :: IdentityMailFromDomainAttributes)

-- | The action that Amazon SES takes if it cannot successfully read the
-- required MX record when you send an email. A value of @UseDefaultValue@
-- indicates that if Amazon SES cannot read the required MX record, it uses
-- amazonses.com (or a subdomain of that) as the MAIL FROM domain. A value
-- of @RejectMessage@ indicates that if Amazon SES cannot read the required
-- MX record, Amazon SES returns a @MailFromDomainNotVerified@ error and
-- does not send the email.
--
-- The custom MAIL FROM setup states that result in this behavior are
-- @Pending@, @Failed@, and @TemporaryFailure@.
identityMailFromDomainAttributes_behaviorOnMXFailure :: Lens.Lens' IdentityMailFromDomainAttributes BehaviorOnMXFailure
identityMailFromDomainAttributes_behaviorOnMXFailure :: Lens' IdentityMailFromDomainAttributes BehaviorOnMXFailure
identityMailFromDomainAttributes_behaviorOnMXFailure = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\IdentityMailFromDomainAttributes' {BehaviorOnMXFailure
behaviorOnMXFailure :: BehaviorOnMXFailure
$sel:behaviorOnMXFailure:IdentityMailFromDomainAttributes' :: IdentityMailFromDomainAttributes -> BehaviorOnMXFailure
behaviorOnMXFailure} -> BehaviorOnMXFailure
behaviorOnMXFailure) (\s :: IdentityMailFromDomainAttributes
s@IdentityMailFromDomainAttributes' {} BehaviorOnMXFailure
a -> IdentityMailFromDomainAttributes
s {$sel:behaviorOnMXFailure:IdentityMailFromDomainAttributes' :: BehaviorOnMXFailure
behaviorOnMXFailure = BehaviorOnMXFailure
a} :: IdentityMailFromDomainAttributes)

instance
  Data.FromXML
    IdentityMailFromDomainAttributes
  where
  parseXML :: [Node] -> Either String IdentityMailFromDomainAttributes
parseXML [Node]
x =
    Text
-> CustomMailFromStatus
-> BehaviorOnMXFailure
-> IdentityMailFromDomainAttributes
IdentityMailFromDomainAttributes'
      forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"MailFromDomain")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"MailFromDomainStatus")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String a
Data..@ Text
"BehaviorOnMXFailure")

instance
  Prelude.Hashable
    IdentityMailFromDomainAttributes
  where
  hashWithSalt :: Int -> IdentityMailFromDomainAttributes -> Int
hashWithSalt
    Int
_salt
    IdentityMailFromDomainAttributes' {Text
BehaviorOnMXFailure
CustomMailFromStatus
behaviorOnMXFailure :: BehaviorOnMXFailure
mailFromDomainStatus :: CustomMailFromStatus
mailFromDomain :: Text
$sel:behaviorOnMXFailure:IdentityMailFromDomainAttributes' :: IdentityMailFromDomainAttributes -> BehaviorOnMXFailure
$sel:mailFromDomainStatus:IdentityMailFromDomainAttributes' :: IdentityMailFromDomainAttributes -> CustomMailFromStatus
$sel:mailFromDomain:IdentityMailFromDomainAttributes' :: IdentityMailFromDomainAttributes -> Text
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
mailFromDomain
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` CustomMailFromStatus
mailFromDomainStatus
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` BehaviorOnMXFailure
behaviorOnMXFailure

instance
  Prelude.NFData
    IdentityMailFromDomainAttributes
  where
  rnf :: IdentityMailFromDomainAttributes -> ()
rnf IdentityMailFromDomainAttributes' {Text
BehaviorOnMXFailure
CustomMailFromStatus
behaviorOnMXFailure :: BehaviorOnMXFailure
mailFromDomainStatus :: CustomMailFromStatus
mailFromDomain :: Text
$sel:behaviorOnMXFailure:IdentityMailFromDomainAttributes' :: IdentityMailFromDomainAttributes -> BehaviorOnMXFailure
$sel:mailFromDomainStatus:IdentityMailFromDomainAttributes' :: IdentityMailFromDomainAttributes -> CustomMailFromStatus
$sel:mailFromDomain:IdentityMailFromDomainAttributes' :: IdentityMailFromDomainAttributes -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
mailFromDomain
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf CustomMailFromStatus
mailFromDomainStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf BehaviorOnMXFailure
behaviorOnMXFailure