{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.PutAccountSuppressionAttributes
-- 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)
--
-- Change the settings for the account-level suppression list.
module Amazonka.SESV2.PutAccountSuppressionAttributes
  ( -- * Creating a Request
    PutAccountSuppressionAttributes (..),
    newPutAccountSuppressionAttributes,

    -- * Request Lenses
    putAccountSuppressionAttributes_suppressedReasons,

    -- * Destructuring the Response
    PutAccountSuppressionAttributesResponse (..),
    newPutAccountSuppressionAttributesResponse,

    -- * Response Lenses
    putAccountSuppressionAttributesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SESV2.Types

-- | A request to change your account\'s suppression preferences.
--
-- /See:/ 'newPutAccountSuppressionAttributes' smart constructor.
data PutAccountSuppressionAttributes = PutAccountSuppressionAttributes'
  { -- | 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.
    PutAccountSuppressionAttributes -> Maybe [SuppressionListReason]
suppressedReasons :: Prelude.Maybe [SuppressionListReason]
  }
  deriving (PutAccountSuppressionAttributes
-> PutAccountSuppressionAttributes -> Bool
(PutAccountSuppressionAttributes
 -> PutAccountSuppressionAttributes -> Bool)
-> (PutAccountSuppressionAttributes
    -> PutAccountSuppressionAttributes -> Bool)
-> Eq PutAccountSuppressionAttributes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutAccountSuppressionAttributes
-> PutAccountSuppressionAttributes -> Bool
$c/= :: PutAccountSuppressionAttributes
-> PutAccountSuppressionAttributes -> Bool
== :: PutAccountSuppressionAttributes
-> PutAccountSuppressionAttributes -> Bool
$c== :: PutAccountSuppressionAttributes
-> PutAccountSuppressionAttributes -> Bool
Prelude.Eq, ReadPrec [PutAccountSuppressionAttributes]
ReadPrec PutAccountSuppressionAttributes
Int -> ReadS PutAccountSuppressionAttributes
ReadS [PutAccountSuppressionAttributes]
(Int -> ReadS PutAccountSuppressionAttributes)
-> ReadS [PutAccountSuppressionAttributes]
-> ReadPrec PutAccountSuppressionAttributes
-> ReadPrec [PutAccountSuppressionAttributes]
-> Read PutAccountSuppressionAttributes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutAccountSuppressionAttributes]
$creadListPrec :: ReadPrec [PutAccountSuppressionAttributes]
readPrec :: ReadPrec PutAccountSuppressionAttributes
$creadPrec :: ReadPrec PutAccountSuppressionAttributes
readList :: ReadS [PutAccountSuppressionAttributes]
$creadList :: ReadS [PutAccountSuppressionAttributes]
readsPrec :: Int -> ReadS PutAccountSuppressionAttributes
$creadsPrec :: Int -> ReadS PutAccountSuppressionAttributes
Prelude.Read, Int -> PutAccountSuppressionAttributes -> ShowS
[PutAccountSuppressionAttributes] -> ShowS
PutAccountSuppressionAttributes -> String
(Int -> PutAccountSuppressionAttributes -> ShowS)
-> (PutAccountSuppressionAttributes -> String)
-> ([PutAccountSuppressionAttributes] -> ShowS)
-> Show PutAccountSuppressionAttributes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutAccountSuppressionAttributes] -> ShowS
$cshowList :: [PutAccountSuppressionAttributes] -> ShowS
show :: PutAccountSuppressionAttributes -> String
$cshow :: PutAccountSuppressionAttributes -> String
showsPrec :: Int -> PutAccountSuppressionAttributes -> ShowS
$cshowsPrec :: Int -> PutAccountSuppressionAttributes -> ShowS
Prelude.Show, (forall x.
 PutAccountSuppressionAttributes
 -> Rep PutAccountSuppressionAttributes x)
-> (forall x.
    Rep PutAccountSuppressionAttributes x
    -> PutAccountSuppressionAttributes)
-> Generic PutAccountSuppressionAttributes
forall x.
Rep PutAccountSuppressionAttributes x
-> PutAccountSuppressionAttributes
forall x.
PutAccountSuppressionAttributes
-> Rep PutAccountSuppressionAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutAccountSuppressionAttributes x
-> PutAccountSuppressionAttributes
$cfrom :: forall x.
PutAccountSuppressionAttributes
-> Rep PutAccountSuppressionAttributes x
Prelude.Generic)

-- |
-- Create a value of 'PutAccountSuppressionAttributes' 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', 'putAccountSuppressionAttributes_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.
newPutAccountSuppressionAttributes ::
  PutAccountSuppressionAttributes
newPutAccountSuppressionAttributes :: PutAccountSuppressionAttributes
newPutAccountSuppressionAttributes =
  PutAccountSuppressionAttributes' :: Maybe [SuppressionListReason] -> PutAccountSuppressionAttributes
PutAccountSuppressionAttributes'
    { $sel:suppressedReasons:PutAccountSuppressionAttributes' :: 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.
putAccountSuppressionAttributes_suppressedReasons :: Lens.Lens' PutAccountSuppressionAttributes (Prelude.Maybe [SuppressionListReason])
putAccountSuppressionAttributes_suppressedReasons :: (Maybe [SuppressionListReason]
 -> f (Maybe [SuppressionListReason]))
-> PutAccountSuppressionAttributes
-> f PutAccountSuppressionAttributes
putAccountSuppressionAttributes_suppressedReasons = (PutAccountSuppressionAttributes -> Maybe [SuppressionListReason])
-> (PutAccountSuppressionAttributes
    -> Maybe [SuppressionListReason]
    -> PutAccountSuppressionAttributes)
-> Lens
     PutAccountSuppressionAttributes
     PutAccountSuppressionAttributes
     (Maybe [SuppressionListReason])
     (Maybe [SuppressionListReason])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAccountSuppressionAttributes' {Maybe [SuppressionListReason]
suppressedReasons :: Maybe [SuppressionListReason]
$sel:suppressedReasons:PutAccountSuppressionAttributes' :: PutAccountSuppressionAttributes -> Maybe [SuppressionListReason]
suppressedReasons} -> Maybe [SuppressionListReason]
suppressedReasons) (\s :: PutAccountSuppressionAttributes
s@PutAccountSuppressionAttributes' {} Maybe [SuppressionListReason]
a -> PutAccountSuppressionAttributes
s {$sel:suppressedReasons:PutAccountSuppressionAttributes' :: Maybe [SuppressionListReason]
suppressedReasons = Maybe [SuppressionListReason]
a} :: PutAccountSuppressionAttributes) ((Maybe [SuppressionListReason]
  -> f (Maybe [SuppressionListReason]))
 -> PutAccountSuppressionAttributes
 -> f PutAccountSuppressionAttributes)
-> ((Maybe [SuppressionListReason]
     -> f (Maybe [SuppressionListReason]))
    -> Maybe [SuppressionListReason]
    -> f (Maybe [SuppressionListReason]))
-> (Maybe [SuppressionListReason]
    -> f (Maybe [SuppressionListReason]))
-> PutAccountSuppressionAttributes
-> f PutAccountSuppressionAttributes
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.AWSRequest
    PutAccountSuppressionAttributes
  where
  type
    AWSResponse PutAccountSuppressionAttributes =
      PutAccountSuppressionAttributesResponse
  request :: PutAccountSuppressionAttributes
-> Request PutAccountSuppressionAttributes
request = Service
-> PutAccountSuppressionAttributes
-> Request PutAccountSuppressionAttributes
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutAccountSuppressionAttributes
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse PutAccountSuppressionAttributes)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse PutAccountSuppressionAttributes))
-> Logger
-> Service
-> Proxy PutAccountSuppressionAttributes
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse PutAccountSuppressionAttributes)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> PutAccountSuppressionAttributesResponse
PutAccountSuppressionAttributesResponse'
            (Int -> PutAccountSuppressionAttributesResponse)
-> Either String Int
-> Either String PutAccountSuppressionAttributesResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance
  Prelude.Hashable
    PutAccountSuppressionAttributes

instance
  Prelude.NFData
    PutAccountSuppressionAttributes

instance
  Core.ToHeaders
    PutAccountSuppressionAttributes
  where
  toHeaders :: PutAccountSuppressionAttributes -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> PutAccountSuppressionAttributes -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Core.ToJSON PutAccountSuppressionAttributes where
  toJSON :: PutAccountSuppressionAttributes -> Value
toJSON PutAccountSuppressionAttributes' {Maybe [SuppressionListReason]
suppressedReasons :: Maybe [SuppressionListReason]
$sel:suppressedReasons:PutAccountSuppressionAttributes' :: PutAccountSuppressionAttributes -> Maybe [SuppressionListReason]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SuppressedReasons" Text -> [SuppressionListReason] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([SuppressionListReason] -> Pair)
-> Maybe [SuppressionListReason] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [SuppressionListReason]
suppressedReasons
          ]
      )

instance Core.ToPath PutAccountSuppressionAttributes where
  toPath :: PutAccountSuppressionAttributes -> ByteString
toPath =
    ByteString -> PutAccountSuppressionAttributes -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/v2/email/account/suppression"

instance Core.ToQuery PutAccountSuppressionAttributes where
  toQuery :: PutAccountSuppressionAttributes -> QueryString
toQuery = QueryString -> PutAccountSuppressionAttributes -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty

-- | An HTTP 200 response if the request succeeds, or an error message if the
-- request fails.
--
-- /See:/ 'newPutAccountSuppressionAttributesResponse' smart constructor.
data PutAccountSuppressionAttributesResponse = PutAccountSuppressionAttributesResponse'
  { -- | The response's http status code.
    PutAccountSuppressionAttributesResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutAccountSuppressionAttributesResponse
-> PutAccountSuppressionAttributesResponse -> Bool
(PutAccountSuppressionAttributesResponse
 -> PutAccountSuppressionAttributesResponse -> Bool)
-> (PutAccountSuppressionAttributesResponse
    -> PutAccountSuppressionAttributesResponse -> Bool)
-> Eq PutAccountSuppressionAttributesResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutAccountSuppressionAttributesResponse
-> PutAccountSuppressionAttributesResponse -> Bool
$c/= :: PutAccountSuppressionAttributesResponse
-> PutAccountSuppressionAttributesResponse -> Bool
== :: PutAccountSuppressionAttributesResponse
-> PutAccountSuppressionAttributesResponse -> Bool
$c== :: PutAccountSuppressionAttributesResponse
-> PutAccountSuppressionAttributesResponse -> Bool
Prelude.Eq, ReadPrec [PutAccountSuppressionAttributesResponse]
ReadPrec PutAccountSuppressionAttributesResponse
Int -> ReadS PutAccountSuppressionAttributesResponse
ReadS [PutAccountSuppressionAttributesResponse]
(Int -> ReadS PutAccountSuppressionAttributesResponse)
-> ReadS [PutAccountSuppressionAttributesResponse]
-> ReadPrec PutAccountSuppressionAttributesResponse
-> ReadPrec [PutAccountSuppressionAttributesResponse]
-> Read PutAccountSuppressionAttributesResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutAccountSuppressionAttributesResponse]
$creadListPrec :: ReadPrec [PutAccountSuppressionAttributesResponse]
readPrec :: ReadPrec PutAccountSuppressionAttributesResponse
$creadPrec :: ReadPrec PutAccountSuppressionAttributesResponse
readList :: ReadS [PutAccountSuppressionAttributesResponse]
$creadList :: ReadS [PutAccountSuppressionAttributesResponse]
readsPrec :: Int -> ReadS PutAccountSuppressionAttributesResponse
$creadsPrec :: Int -> ReadS PutAccountSuppressionAttributesResponse
Prelude.Read, Int -> PutAccountSuppressionAttributesResponse -> ShowS
[PutAccountSuppressionAttributesResponse] -> ShowS
PutAccountSuppressionAttributesResponse -> String
(Int -> PutAccountSuppressionAttributesResponse -> ShowS)
-> (PutAccountSuppressionAttributesResponse -> String)
-> ([PutAccountSuppressionAttributesResponse] -> ShowS)
-> Show PutAccountSuppressionAttributesResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutAccountSuppressionAttributesResponse] -> ShowS
$cshowList :: [PutAccountSuppressionAttributesResponse] -> ShowS
show :: PutAccountSuppressionAttributesResponse -> String
$cshow :: PutAccountSuppressionAttributesResponse -> String
showsPrec :: Int -> PutAccountSuppressionAttributesResponse -> ShowS
$cshowsPrec :: Int -> PutAccountSuppressionAttributesResponse -> ShowS
Prelude.Show, (forall x.
 PutAccountSuppressionAttributesResponse
 -> Rep PutAccountSuppressionAttributesResponse x)
-> (forall x.
    Rep PutAccountSuppressionAttributesResponse x
    -> PutAccountSuppressionAttributesResponse)
-> Generic PutAccountSuppressionAttributesResponse
forall x.
Rep PutAccountSuppressionAttributesResponse x
-> PutAccountSuppressionAttributesResponse
forall x.
PutAccountSuppressionAttributesResponse
-> Rep PutAccountSuppressionAttributesResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutAccountSuppressionAttributesResponse x
-> PutAccountSuppressionAttributesResponse
$cfrom :: forall x.
PutAccountSuppressionAttributesResponse
-> Rep PutAccountSuppressionAttributesResponse x
Prelude.Generic)

-- |
-- Create a value of 'PutAccountSuppressionAttributesResponse' 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:
--
-- 'httpStatus', 'putAccountSuppressionAttributesResponse_httpStatus' - The response's http status code.
newPutAccountSuppressionAttributesResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  PutAccountSuppressionAttributesResponse
newPutAccountSuppressionAttributesResponse :: Int -> PutAccountSuppressionAttributesResponse
newPutAccountSuppressionAttributesResponse
  Int
pHttpStatus_ =
    PutAccountSuppressionAttributesResponse' :: Int -> PutAccountSuppressionAttributesResponse
PutAccountSuppressionAttributesResponse'
      { $sel:httpStatus:PutAccountSuppressionAttributesResponse' :: Int
httpStatus =
          Int
pHttpStatus_
      }

-- | The response's http status code.
putAccountSuppressionAttributesResponse_httpStatus :: Lens.Lens' PutAccountSuppressionAttributesResponse Prelude.Int
putAccountSuppressionAttributesResponse_httpStatus :: (Int -> f Int)
-> PutAccountSuppressionAttributesResponse
-> f PutAccountSuppressionAttributesResponse
putAccountSuppressionAttributesResponse_httpStatus = (PutAccountSuppressionAttributesResponse -> Int)
-> (PutAccountSuppressionAttributesResponse
    -> Int -> PutAccountSuppressionAttributesResponse)
-> Lens
     PutAccountSuppressionAttributesResponse
     PutAccountSuppressionAttributesResponse
     Int
     Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAccountSuppressionAttributesResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutAccountSuppressionAttributesResponse' :: PutAccountSuppressionAttributesResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: PutAccountSuppressionAttributesResponse
s@PutAccountSuppressionAttributesResponse' {} Int
a -> PutAccountSuppressionAttributesResponse
s {$sel:httpStatus:PutAccountSuppressionAttributesResponse' :: Int
httpStatus = Int
a} :: PutAccountSuppressionAttributesResponse)

instance
  Prelude.NFData
    PutAccountSuppressionAttributesResponse