{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.PinpointEmail.Types.MailFromAttributes where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
      { $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 :: Lens' MailFromAttributes Text
mailFromAttributes_mailFromDomain = 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 :: Lens' MailFromAttributes MailFromDomainStatus
mailFromAttributes_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 :: Lens' MailFromAttributes BehaviorOnMxFailure
mailFromAttributes_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 Data.FromJSON MailFromAttributes where
  parseJSON :: Value -> Parser MailFromAttributes
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MailFromAttributes"
      ( \Object
x ->
          Text
-> MailFromDomainStatus
-> BehaviorOnMxFailure
-> MailFromAttributes
MailFromAttributes'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"MailFromDomain")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"MailFromDomainStatus")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"BehaviorOnMxFailure")
      )

instance Prelude.Hashable MailFromAttributes where
  hashWithSalt :: Int -> MailFromAttributes -> Int
hashWithSalt Int
_salt MailFromAttributes' {Text
BehaviorOnMxFailure
MailFromDomainStatus
behaviorOnMxFailure :: BehaviorOnMxFailure
mailFromDomainStatus :: MailFromDomainStatus
mailFromDomain :: Text
$sel:behaviorOnMxFailure:MailFromAttributes' :: MailFromAttributes -> BehaviorOnMxFailure
$sel:mailFromDomainStatus:MailFromAttributes' :: MailFromAttributes -> MailFromDomainStatus
$sel:mailFromDomain:MailFromAttributes' :: MailFromAttributes -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
mailFromDomain
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` MailFromDomainStatus
mailFromDomainStatus
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` BehaviorOnMxFailure
behaviorOnMxFailure

instance Prelude.NFData MailFromAttributes where
  rnf :: MailFromAttributes -> ()
rnf MailFromAttributes' {Text
BehaviorOnMxFailure
MailFromDomainStatus
behaviorOnMxFailure :: BehaviorOnMxFailure
mailFromDomainStatus :: MailFromDomainStatus
mailFromDomain :: Text
$sel:behaviorOnMxFailure:MailFromAttributes' :: MailFromAttributes -> BehaviorOnMxFailure
$sel:mailFromDomainStatus:MailFromAttributes' :: MailFromAttributes -> MailFromDomainStatus
$sel:mailFromDomain:MailFromAttributes' :: MailFromAttributes -> 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 MailFromDomainStatus
mailFromDomainStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf BehaviorOnMxFailure
behaviorOnMxFailure