{-# 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.SESV2.Types.SuppressionAttributes
-- 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.SESV2.Types.SuppressionAttributes where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SESV2.Types.SuppressionListReason

-- | An object that contains information about the email address suppression
-- preferences for your account in the current Amazon Web Services Region.
--
-- /See:/ 'newSuppressionAttributes' smart constructor.
data SuppressionAttributes = SuppressionAttributes'
  { -- | A list that contains the reasons that email addresses will be
    -- automatically added to the suppression list for your account. This list
    -- can contain any or all of the following:
    --
    -- -   @COMPLAINT@ – Amazon SES adds an email address to the suppression
    --     list for your account when a message sent to that address results in
    --     a complaint.
    --
    -- -   @BOUNCE@ – Amazon SES adds an email address to the suppression list
    --     for your account when a message sent to that address results in a
    --     hard bounce.
    SuppressionAttributes -> Maybe [SuppressionListReason]
suppressedReasons :: Prelude.Maybe [SuppressionListReason]
  }
  deriving (SuppressionAttributes -> SuppressionAttributes -> Bool
(SuppressionAttributes -> SuppressionAttributes -> Bool)
-> (SuppressionAttributes -> SuppressionAttributes -> Bool)
-> Eq SuppressionAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SuppressionAttributes -> SuppressionAttributes -> Bool
$c/= :: SuppressionAttributes -> SuppressionAttributes -> Bool
== :: SuppressionAttributes -> SuppressionAttributes -> Bool
$c== :: SuppressionAttributes -> SuppressionAttributes -> Bool
Prelude.Eq, ReadPrec [SuppressionAttributes]
ReadPrec SuppressionAttributes
Int -> ReadS SuppressionAttributes
ReadS [SuppressionAttributes]
(Int -> ReadS SuppressionAttributes)
-> ReadS [SuppressionAttributes]
-> ReadPrec SuppressionAttributes
-> ReadPrec [SuppressionAttributes]
-> Read SuppressionAttributes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SuppressionAttributes]
$creadListPrec :: ReadPrec [SuppressionAttributes]
readPrec :: ReadPrec SuppressionAttributes
$creadPrec :: ReadPrec SuppressionAttributes
readList :: ReadS [SuppressionAttributes]
$creadList :: ReadS [SuppressionAttributes]
readsPrec :: Int -> ReadS SuppressionAttributes
$creadsPrec :: Int -> ReadS SuppressionAttributes
Prelude.Read, Int -> SuppressionAttributes -> ShowS
[SuppressionAttributes] -> ShowS
SuppressionAttributes -> String
(Int -> SuppressionAttributes -> ShowS)
-> (SuppressionAttributes -> String)
-> ([SuppressionAttributes] -> ShowS)
-> Show SuppressionAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SuppressionAttributes] -> ShowS
$cshowList :: [SuppressionAttributes] -> ShowS
show :: SuppressionAttributes -> String
$cshow :: SuppressionAttributes -> String
showsPrec :: Int -> SuppressionAttributes -> ShowS
$cshowsPrec :: Int -> SuppressionAttributes -> ShowS
Prelude.Show, (forall x. SuppressionAttributes -> Rep SuppressionAttributes x)
-> (forall x. Rep SuppressionAttributes x -> SuppressionAttributes)
-> Generic SuppressionAttributes
forall x. Rep SuppressionAttributes x -> SuppressionAttributes
forall x. SuppressionAttributes -> Rep SuppressionAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SuppressionAttributes x -> SuppressionAttributes
$cfrom :: forall x. SuppressionAttributes -> Rep SuppressionAttributes x
Prelude.Generic)

-- |
-- Create a value of 'SuppressionAttributes' 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:
--
-- 'suppressedReasons', 'suppressionAttributes_suppressedReasons' - A list that contains the reasons that email addresses will be
-- automatically added to the suppression list for your account. This list
-- can contain any or all of the following:
--
-- -   @COMPLAINT@ – Amazon SES adds an email address to the suppression
--     list for your account when a message sent to that address results in
--     a complaint.
--
-- -   @BOUNCE@ – Amazon SES adds an email address to the suppression list
--     for your account when a message sent to that address results in a
--     hard bounce.
newSuppressionAttributes ::
  SuppressionAttributes
newSuppressionAttributes :: SuppressionAttributes
newSuppressionAttributes =
  SuppressionAttributes' :: Maybe [SuppressionListReason] -> SuppressionAttributes
SuppressionAttributes'
    { $sel:suppressedReasons:SuppressionAttributes' :: Maybe [SuppressionListReason]
suppressedReasons =
        Maybe [SuppressionListReason]
forall a. Maybe a
Prelude.Nothing
    }

-- | A list that contains the reasons that email addresses will be
-- automatically added to the suppression list for your account. This list
-- can contain any or all of the following:
--
-- -   @COMPLAINT@ – Amazon SES adds an email address to the suppression
--     list for your account when a message sent to that address results in
--     a complaint.
--
-- -   @BOUNCE@ – Amazon SES adds an email address to the suppression list
--     for your account when a message sent to that address results in a
--     hard bounce.
suppressionAttributes_suppressedReasons :: Lens.Lens' SuppressionAttributes (Prelude.Maybe [SuppressionListReason])
suppressionAttributes_suppressedReasons :: (Maybe [SuppressionListReason]
 -> f (Maybe [SuppressionListReason]))
-> SuppressionAttributes -> f SuppressionAttributes
suppressionAttributes_suppressedReasons = (SuppressionAttributes -> Maybe [SuppressionListReason])
-> (SuppressionAttributes
    -> Maybe [SuppressionListReason] -> SuppressionAttributes)
-> Lens
     SuppressionAttributes
     SuppressionAttributes
     (Maybe [SuppressionListReason])
     (Maybe [SuppressionListReason])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SuppressionAttributes' {Maybe [SuppressionListReason]
suppressedReasons :: Maybe [SuppressionListReason]
$sel:suppressedReasons:SuppressionAttributes' :: SuppressionAttributes -> Maybe [SuppressionListReason]
suppressedReasons} -> Maybe [SuppressionListReason]
suppressedReasons) (\s :: SuppressionAttributes
s@SuppressionAttributes' {} Maybe [SuppressionListReason]
a -> SuppressionAttributes
s {$sel:suppressedReasons:SuppressionAttributes' :: Maybe [SuppressionListReason]
suppressedReasons = Maybe [SuppressionListReason]
a} :: SuppressionAttributes) ((Maybe [SuppressionListReason]
  -> f (Maybe [SuppressionListReason]))
 -> SuppressionAttributes -> f SuppressionAttributes)
-> ((Maybe [SuppressionListReason]
     -> f (Maybe [SuppressionListReason]))
    -> Maybe [SuppressionListReason]
    -> f (Maybe [SuppressionListReason]))
-> (Maybe [SuppressionListReason]
    -> f (Maybe [SuppressionListReason]))
-> SuppressionAttributes
-> f SuppressionAttributes
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [SuppressionListReason]
  [SuppressionListReason]
  [SuppressionListReason]
  [SuppressionListReason]
-> Iso
     (Maybe [SuppressionListReason])
     (Maybe [SuppressionListReason])
     (Maybe [SuppressionListReason])
     (Maybe [SuppressionListReason])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [SuppressionListReason]
  [SuppressionListReason]
  [SuppressionListReason]
  [SuppressionListReason]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON SuppressionAttributes where
  parseJSON :: Value -> Parser SuppressionAttributes
parseJSON =
    String
-> (Object -> Parser SuppressionAttributes)
-> Value
-> Parser SuppressionAttributes
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SuppressionAttributes"
      ( \Object
x ->
          Maybe [SuppressionListReason] -> SuppressionAttributes
SuppressionAttributes'
            (Maybe [SuppressionListReason] -> SuppressionAttributes)
-> Parser (Maybe [SuppressionListReason])
-> Parser SuppressionAttributes
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Parser (Maybe (Maybe [SuppressionListReason]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"SuppressedReasons"
                            Parser (Maybe (Maybe [SuppressionListReason]))
-> Maybe [SuppressionListReason]
-> Parser (Maybe [SuppressionListReason])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [SuppressionListReason]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable SuppressionAttributes

instance Prelude.NFData SuppressionAttributes