{-# 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.PinpointEmail.Types.MailFromAttributes
-- 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.PinpointEmail.Types.MailFromAttributes where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.PinpointEmail.Types.BehaviorOnMxFailure
import Amazonka.PinpointEmail.Types.MailFromDomainStatus
import qualified Amazonka.Prelude as Prelude

-- | A list of attributes that are associated with a MAIL FROM domain.
--
-- /See:/ 'newMailFromAttributes' smart constructor.
data MailFromAttributes = MailFromAttributes'
  { -- | The name of a domain that an email identity uses as a custom MAIL FROM
    -- domain.
    MailFromAttributes -> Text
mailFromDomain :: Prelude.Text,
    -- | The status of the MAIL FROM domain. This status can have the following
    -- values:
    --
    -- -   @PENDING@ – Amazon Pinpoint hasn\'t started searching for the MX
    --     record yet.
    --
    -- -   @SUCCESS@ – Amazon Pinpoint detected the required MX record for the
    --     MAIL FROM domain.
    --
    -- -   @FAILED@ – Amazon Pinpoint can\'t find the required MX record, or
    --     the record no longer exists.
    --
    -- -   @TEMPORARY_FAILURE@ – A temporary issue occurred, which prevented
    --     Amazon Pinpoint from determining the status of the MAIL FROM domain.
    MailFromAttributes -> MailFromDomainStatus
mailFromDomainStatus :: MailFromDomainStatus,
    -- | The action that Amazon Pinpoint to takes if it can\'t read the required
    -- MX record for a custom MAIL FROM domain. When you set this value to
    -- @UseDefaultValue@, Amazon Pinpoint uses /amazonses.com/ as the MAIL FROM
    -- domain. When you set this value to @RejectMessage@, Amazon Pinpoint
    -- returns a @MailFromDomainNotVerified@ error, and doesn\'t attempt to
    -- deliver the email.
    --
    -- These behaviors are taken when the custom MAIL FROM domain configuration
    -- is in the @Pending@, @Failed@, and @TemporaryFailure@ states.
    MailFromAttributes -> BehaviorOnMxFailure
behaviorOnMxFailure :: BehaviorOnMxFailure
  }
  deriving (MailFromAttributes -> MailFromAttributes -> Bool
(MailFromAttributes -> MailFromAttributes -> Bool)
-> (MailFromAttributes -> MailFromAttributes -> Bool)
-> Eq MailFromAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MailFromAttributes -> MailFromAttributes -> Bool
$c/= :: MailFromAttributes -> MailFromAttributes -> Bool
== :: MailFromAttributes -> MailFromAttributes -> Bool
$c== :: MailFromAttributes -> MailFromAttributes -> Bool
Prelude.Eq, ReadPrec [MailFromAttributes]
ReadPrec MailFromAttributes
Int -> ReadS MailFromAttributes
ReadS [MailFromAttributes]
(Int -> ReadS MailFromAttributes)
-> ReadS [MailFromAttributes]
-> ReadPrec MailFromAttributes
-> ReadPrec [MailFromAttributes]
-> Read MailFromAttributes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MailFromAttributes]
$creadListPrec :: ReadPrec [MailFromAttributes]
readPrec :: ReadPrec MailFromAttributes
$creadPrec :: ReadPrec MailFromAttributes
readList :: ReadS [MailFromAttributes]
$creadList :: ReadS [MailFromAttributes]
readsPrec :: Int -> ReadS MailFromAttributes
$creadsPrec :: Int -> ReadS MailFromAttributes
Prelude.Read, Int -> MailFromAttributes -> ShowS
[MailFromAttributes] -> ShowS
MailFromAttributes -> String
(Int -> MailFromAttributes -> ShowS)
-> (MailFromAttributes -> String)
-> ([MailFromAttributes] -> ShowS)
-> Show MailFromAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MailFromAttributes] -> ShowS
$cshowList :: [MailFromAttributes] -> ShowS
show :: MailFromAttributes -> String
$cshow :: MailFromAttributes -> String
showsPrec :: Int -> MailFromAttributes -> ShowS
$cshowsPrec :: Int -> MailFromAttributes -> ShowS
Prelude.Show, (forall x. MailFromAttributes -> Rep MailFromAttributes x)
-> (forall x. Rep MailFromAttributes x -> MailFromAttributes)
-> Generic MailFromAttributes
forall x. Rep MailFromAttributes x -> MailFromAttributes
forall x. MailFromAttributes -> Rep MailFromAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MailFromAttributes x -> MailFromAttributes
$cfrom :: forall x. MailFromAttributes -> Rep MailFromAttributes x
Prelude.Generic)

-- |
-- Create a value of 'MailFromAttributes' 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', 'mailFromAttributes_mailFromDomain' - The name of a domain that an email identity uses as a custom MAIL FROM
-- domain.
--
-- 'mailFromDomainStatus', 'mailFromAttributes_mailFromDomainStatus' - The status of the MAIL FROM domain. This status can have the following
-- values:
--
-- -   @PENDING@ – Amazon Pinpoint hasn\'t started searching for the MX
--     record yet.
--
-- -   @SUCCESS@ – Amazon Pinpoint detected the required MX record for the
--     MAIL FROM domain.
--
-- -   @FAILED@ – Amazon Pinpoint can\'t find the required MX record, or
--     the record no longer exists.
--
-- -   @TEMPORARY_FAILURE@ – A temporary issue occurred, which prevented
--     Amazon Pinpoint from determining the status of the MAIL FROM domain.
--
-- 'behaviorOnMxFailure', 'mailFromAttributes_behaviorOnMxFailure' - The action that Amazon Pinpoint to takes if it can\'t read the required
-- MX record for a custom MAIL FROM domain. When you set this value to
-- @UseDefaultValue@, Amazon Pinpoint uses /amazonses.com/ as the MAIL FROM
-- domain. When you set this value to @RejectMessage@, Amazon Pinpoint
-- returns a @MailFromDomainNotVerified@ error, and doesn\'t attempt to
-- deliver the email.
--
-- These behaviors are taken when the custom MAIL FROM domain configuration
-- is in the @Pending@, @Failed@, and @TemporaryFailure@ states.
newMailFromAttributes ::
  -- | 'mailFromDomain'
  Prelude.Text ->
  -- | 'mailFromDomainStatus'
  MailFromDomainStatus ->
  -- | 'behaviorOnMxFailure'
  BehaviorOnMxFailure ->
  MailFromAttributes
newMailFromAttributes :: Text
-> MailFromDomainStatus
-> BehaviorOnMxFailure
-> MailFromAttributes
newMailFromAttributes
  Text
pMailFromDomain_
  MailFromDomainStatus
pMailFromDomainStatus_
  BehaviorOnMxFailure
pBehaviorOnMxFailure_ =
    MailFromAttributes' :: Text
-> MailFromDomainStatus
-> BehaviorOnMxFailure
-> MailFromAttributes
MailFromAttributes'
      { $sel:mailFromDomain:MailFromAttributes' :: Text
mailFromDomain =
          Text
pMailFromDomain_,
        $sel:mailFromDomainStatus:MailFromAttributes' :: MailFromDomainStatus
mailFromDomainStatus = MailFromDomainStatus
pMailFromDomainStatus_,
        $sel:behaviorOnMxFailure:MailFromAttributes' :: BehaviorOnMxFailure
behaviorOnMxFailure = BehaviorOnMxFailure
pBehaviorOnMxFailure_
      }

-- | The name of a domain that an email identity uses as a custom MAIL FROM
-- domain.
mailFromAttributes_mailFromDomain :: Lens.Lens' MailFromAttributes Prelude.Text
mailFromAttributes_mailFromDomain :: (Text -> f Text) -> MailFromAttributes -> f MailFromAttributes
mailFromAttributes_mailFromDomain = (MailFromAttributes -> Text)
-> (MailFromAttributes -> Text -> MailFromAttributes)
-> Lens MailFromAttributes MailFromAttributes Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MailFromAttributes' {Text
mailFromDomain :: Text
$sel:mailFromDomain:MailFromAttributes' :: MailFromAttributes -> Text
mailFromDomain} -> Text
mailFromDomain) (\s :: MailFromAttributes
s@MailFromAttributes' {} Text
a -> MailFromAttributes
s {$sel:mailFromDomain:MailFromAttributes' :: Text
mailFromDomain = Text
a} :: MailFromAttributes)

-- | The status of the MAIL FROM domain. This status can have the following
-- values:
--
-- -   @PENDING@ – Amazon Pinpoint hasn\'t started searching for the MX
--     record yet.
--
-- -   @SUCCESS@ – Amazon Pinpoint detected the required MX record for the
--     MAIL FROM domain.
--
-- -   @FAILED@ – Amazon Pinpoint can\'t find the required MX record, or
--     the record no longer exists.
--
-- -   @TEMPORARY_FAILURE@ – A temporary issue occurred, which prevented
--     Amazon Pinpoint from determining the status of the MAIL FROM domain.
mailFromAttributes_mailFromDomainStatus :: Lens.Lens' MailFromAttributes MailFromDomainStatus
mailFromAttributes_mailFromDomainStatus :: (MailFromDomainStatus -> f MailFromDomainStatus)
-> MailFromAttributes -> f MailFromAttributes
mailFromAttributes_mailFromDomainStatus = (MailFromAttributes -> MailFromDomainStatus)
-> (MailFromAttributes
    -> MailFromDomainStatus -> MailFromAttributes)
-> Lens
     MailFromAttributes
     MailFromAttributes
     MailFromDomainStatus
     MailFromDomainStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MailFromAttributes' {MailFromDomainStatus
mailFromDomainStatus :: MailFromDomainStatus
$sel:mailFromDomainStatus:MailFromAttributes' :: MailFromAttributes -> MailFromDomainStatus
mailFromDomainStatus} -> MailFromDomainStatus
mailFromDomainStatus) (\s :: MailFromAttributes
s@MailFromAttributes' {} MailFromDomainStatus
a -> MailFromAttributes
s {$sel:mailFromDomainStatus:MailFromAttributes' :: MailFromDomainStatus
mailFromDomainStatus = MailFromDomainStatus
a} :: MailFromAttributes)

-- | The action that Amazon Pinpoint to takes if it can\'t read the required
-- MX record for a custom MAIL FROM domain. When you set this value to
-- @UseDefaultValue@, Amazon Pinpoint uses /amazonses.com/ as the MAIL FROM
-- domain. When you set this value to @RejectMessage@, Amazon Pinpoint
-- returns a @MailFromDomainNotVerified@ error, and doesn\'t attempt to
-- deliver the email.
--
-- These behaviors are taken when the custom MAIL FROM domain configuration
-- is in the @Pending@, @Failed@, and @TemporaryFailure@ states.
mailFromAttributes_behaviorOnMxFailure :: Lens.Lens' MailFromAttributes BehaviorOnMxFailure
mailFromAttributes_behaviorOnMxFailure :: (BehaviorOnMxFailure -> f BehaviorOnMxFailure)
-> MailFromAttributes -> f MailFromAttributes
mailFromAttributes_behaviorOnMxFailure = (MailFromAttributes -> BehaviorOnMxFailure)
-> (MailFromAttributes
    -> BehaviorOnMxFailure -> MailFromAttributes)
-> Lens
     MailFromAttributes
     MailFromAttributes
     BehaviorOnMxFailure
     BehaviorOnMxFailure
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MailFromAttributes' {BehaviorOnMxFailure
behaviorOnMxFailure :: BehaviorOnMxFailure
$sel:behaviorOnMxFailure:MailFromAttributes' :: MailFromAttributes -> BehaviorOnMxFailure
behaviorOnMxFailure} -> BehaviorOnMxFailure
behaviorOnMxFailure) (\s :: MailFromAttributes
s@MailFromAttributes' {} BehaviorOnMxFailure
a -> MailFromAttributes
s {$sel:behaviorOnMxFailure:MailFromAttributes' :: BehaviorOnMxFailure
behaviorOnMxFailure = BehaviorOnMxFailure
a} :: MailFromAttributes)

instance Core.FromJSON MailFromAttributes where
  parseJSON :: Value -> Parser MailFromAttributes
parseJSON =
    String
-> (Object -> Parser MailFromAttributes)
-> Value
-> Parser MailFromAttributes
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"MailFromAttributes"
      ( \Object
x ->
          Text
-> MailFromDomainStatus
-> BehaviorOnMxFailure
-> MailFromAttributes
MailFromAttributes'
            (Text
 -> MailFromDomainStatus
 -> BehaviorOnMxFailure
 -> MailFromAttributes)
-> Parser Text
-> Parser
     (MailFromDomainStatus -> BehaviorOnMxFailure -> MailFromAttributes)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MailFromDomain")
            Parser
  (MailFromDomainStatus -> BehaviorOnMxFailure -> MailFromAttributes)
-> Parser MailFromDomainStatus
-> Parser (BehaviorOnMxFailure -> MailFromAttributes)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser MailFromDomainStatus
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MailFromDomainStatus")
            Parser (BehaviorOnMxFailure -> MailFromAttributes)
-> Parser BehaviorOnMxFailure -> Parser MailFromAttributes
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser BehaviorOnMxFailure
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"BehaviorOnMxFailure")
      )

instance Prelude.Hashable MailFromAttributes

instance Prelude.NFData MailFromAttributes