{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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.
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'
    { $sel:suppressedReasons:PutAccountSuppressionAttributes' :: Maybe [SuppressionListReason]
suppressedReasons =
        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 :: Lens'
  PutAccountSuppressionAttributes (Maybe [SuppressionListReason])
putAccountSuppressionAttributes_suppressedReasons = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 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 :: (Service -> Service)
-> PutAccountSuppressionAttributes
-> Request PutAccountSuppressionAttributes
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy PutAccountSuppressionAttributes
-> ClientResponse ClientBody
-> m (Either
        Error
        (ClientResponse (AWSResponse PutAccountSuppressionAttributes)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> PutAccountSuppressionAttributesResponse
PutAccountSuppressionAttributesResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance
  Prelude.Hashable
    PutAccountSuppressionAttributes
  where
  hashWithSalt :: Int -> PutAccountSuppressionAttributes -> Int
hashWithSalt
    Int
_salt
    PutAccountSuppressionAttributes' {Maybe [SuppressionListReason]
suppressedReasons :: Maybe [SuppressionListReason]
$sel:suppressedReasons:PutAccountSuppressionAttributes' :: PutAccountSuppressionAttributes -> Maybe [SuppressionListReason]
..} =
      Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [SuppressionListReason]
suppressedReasons

instance
  Prelude.NFData
    PutAccountSuppressionAttributes
  where
  rnf :: PutAccountSuppressionAttributes -> ()
rnf PutAccountSuppressionAttributes' {Maybe [SuppressionListReason]
suppressedReasons :: Maybe [SuppressionListReason]
$sel:suppressedReasons:PutAccountSuppressionAttributes' :: PutAccountSuppressionAttributes -> Maybe [SuppressionListReason]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [SuppressionListReason]
suppressedReasons

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

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

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

instance Data.ToQuery PutAccountSuppressionAttributes where
  toQuery :: PutAccountSuppressionAttributes -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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.
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'
      { $sel:httpStatus:PutAccountSuppressionAttributesResponse' :: Int
httpStatus =
          Int
pHttpStatus_
      }

-- | The response's http status code.
putAccountSuppressionAttributesResponse_httpStatus :: Lens.Lens' PutAccountSuppressionAttributesResponse Prelude.Int
putAccountSuppressionAttributesResponse_httpStatus :: Lens' PutAccountSuppressionAttributesResponse Int
putAccountSuppressionAttributesResponse_httpStatus = 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
  where
  rnf :: PutAccountSuppressionAttributesResponse -> ()
rnf PutAccountSuppressionAttributesResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutAccountSuppressionAttributesResponse' :: PutAccountSuppressionAttributesResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus