{-# 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-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SES.Types.IdentityMailFromDomainAttributes where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(IdentityMailFromDomainAttributes
 -> IdentityMailFromDomainAttributes -> Bool)
-> (IdentityMailFromDomainAttributes
    -> IdentityMailFromDomainAttributes -> Bool)
-> Eq IdentityMailFromDomainAttributes
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]
(Int -> ReadS IdentityMailFromDomainAttributes)
-> ReadS [IdentityMailFromDomainAttributes]
-> ReadPrec IdentityMailFromDomainAttributes
-> ReadPrec [IdentityMailFromDomainAttributes]
-> Read 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
(Int -> IdentityMailFromDomainAttributes -> ShowS)
-> (IdentityMailFromDomainAttributes -> String)
-> ([IdentityMailFromDomainAttributes] -> ShowS)
-> Show IdentityMailFromDomainAttributes
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.
 IdentityMailFromDomainAttributes
 -> Rep IdentityMailFromDomainAttributes x)
-> (forall x.
    Rep IdentityMailFromDomainAttributes x
    -> IdentityMailFromDomainAttributes)
-> Generic IdentityMailFromDomainAttributes
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' :: Text
-> CustomMailFromStatus
-> BehaviorOnMXFailure
-> IdentityMailFromDomainAttributes
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 :: (Text -> f Text)
-> IdentityMailFromDomainAttributes
-> f IdentityMailFromDomainAttributes
identityMailFromDomainAttributes_mailFromDomain = (IdentityMailFromDomainAttributes -> Text)
-> (IdentityMailFromDomainAttributes
    -> Text -> IdentityMailFromDomainAttributes)
-> Lens
     IdentityMailFromDomainAttributes
     IdentityMailFromDomainAttributes
     Text
     Text
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 :: (CustomMailFromStatus -> f CustomMailFromStatus)
-> IdentityMailFromDomainAttributes
-> f IdentityMailFromDomainAttributes
identityMailFromDomainAttributes_mailFromDomainStatus = (IdentityMailFromDomainAttributes -> CustomMailFromStatus)
-> (IdentityMailFromDomainAttributes
    -> CustomMailFromStatus -> IdentityMailFromDomainAttributes)
-> Lens
     IdentityMailFromDomainAttributes
     IdentityMailFromDomainAttributes
     CustomMailFromStatus
     CustomMailFromStatus
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 :: (BehaviorOnMXFailure -> f BehaviorOnMXFailure)
-> IdentityMailFromDomainAttributes
-> f IdentityMailFromDomainAttributes
identityMailFromDomainAttributes_behaviorOnMXFailure = (IdentityMailFromDomainAttributes -> BehaviorOnMXFailure)
-> (IdentityMailFromDomainAttributes
    -> BehaviorOnMXFailure -> IdentityMailFromDomainAttributes)
-> Lens
     IdentityMailFromDomainAttributes
     IdentityMailFromDomainAttributes
     BehaviorOnMXFailure
     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
  Core.FromXML
    IdentityMailFromDomainAttributes
  where
  parseXML :: [Node] -> Either String IdentityMailFromDomainAttributes
parseXML [Node]
x =
    Text
-> CustomMailFromStatus
-> BehaviorOnMXFailure
-> IdentityMailFromDomainAttributes
IdentityMailFromDomainAttributes'
      (Text
 -> CustomMailFromStatus
 -> BehaviorOnMXFailure
 -> IdentityMailFromDomainAttributes)
-> Either String Text
-> Either
     String
     (CustomMailFromStatus
      -> BehaviorOnMXFailure -> IdentityMailFromDomainAttributes)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String Text
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"MailFromDomain")
      Either
  String
  (CustomMailFromStatus
   -> BehaviorOnMXFailure -> IdentityMailFromDomainAttributes)
-> Either String CustomMailFromStatus
-> Either
     String (BehaviorOnMXFailure -> IdentityMailFromDomainAttributes)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String CustomMailFromStatus
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"MailFromDomainStatus")
      Either
  String (BehaviorOnMXFailure -> IdentityMailFromDomainAttributes)
-> Either String BehaviorOnMXFailure
-> Either String IdentityMailFromDomainAttributes
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String BehaviorOnMXFailure
forall a. FromXML a => [Node] -> Text -> Either String a
Core..@ Text
"BehaviorOnMXFailure")

instance
  Prelude.Hashable
    IdentityMailFromDomainAttributes

instance
  Prelude.NFData
    IdentityMailFromDomainAttributes