{-# 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.PutSuppressedDestination
-- 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)
--
-- Adds an email address to the suppression list for your account.
module Amazonka.SESV2.PutSuppressedDestination
  ( -- * Creating a Request
    PutSuppressedDestination (..),
    newPutSuppressedDestination,

    -- * Request Lenses
    putSuppressedDestination_emailAddress,
    putSuppressedDestination_reason,

    -- * Destructuring the Response
    PutSuppressedDestinationResponse (..),
    newPutSuppressedDestinationResponse,

    -- * Response Lenses
    putSuppressedDestinationResponse_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 add an email destination to the suppression list for your
-- account.
--
-- /See:/ 'newPutSuppressedDestination' smart constructor.
data PutSuppressedDestination = PutSuppressedDestination'
  { -- | The email address that should be added to the suppression list for your
    -- account.
    PutSuppressedDestination -> Text
emailAddress :: Prelude.Text,
    -- | The factors that should cause the email address to be added to the
    -- suppression list for your account.
    PutSuppressedDestination -> SuppressionListReason
reason :: SuppressionListReason
  }
  deriving (PutSuppressedDestination -> PutSuppressedDestination -> Bool
(PutSuppressedDestination -> PutSuppressedDestination -> Bool)
-> (PutSuppressedDestination -> PutSuppressedDestination -> Bool)
-> Eq PutSuppressedDestination
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutSuppressedDestination -> PutSuppressedDestination -> Bool
$c/= :: PutSuppressedDestination -> PutSuppressedDestination -> Bool
== :: PutSuppressedDestination -> PutSuppressedDestination -> Bool
$c== :: PutSuppressedDestination -> PutSuppressedDestination -> Bool
Prelude.Eq, ReadPrec [PutSuppressedDestination]
ReadPrec PutSuppressedDestination
Int -> ReadS PutSuppressedDestination
ReadS [PutSuppressedDestination]
(Int -> ReadS PutSuppressedDestination)
-> ReadS [PutSuppressedDestination]
-> ReadPrec PutSuppressedDestination
-> ReadPrec [PutSuppressedDestination]
-> Read PutSuppressedDestination
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutSuppressedDestination]
$creadListPrec :: ReadPrec [PutSuppressedDestination]
readPrec :: ReadPrec PutSuppressedDestination
$creadPrec :: ReadPrec PutSuppressedDestination
readList :: ReadS [PutSuppressedDestination]
$creadList :: ReadS [PutSuppressedDestination]
readsPrec :: Int -> ReadS PutSuppressedDestination
$creadsPrec :: Int -> ReadS PutSuppressedDestination
Prelude.Read, Int -> PutSuppressedDestination -> ShowS
[PutSuppressedDestination] -> ShowS
PutSuppressedDestination -> String
(Int -> PutSuppressedDestination -> ShowS)
-> (PutSuppressedDestination -> String)
-> ([PutSuppressedDestination] -> ShowS)
-> Show PutSuppressedDestination
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutSuppressedDestination] -> ShowS
$cshowList :: [PutSuppressedDestination] -> ShowS
show :: PutSuppressedDestination -> String
$cshow :: PutSuppressedDestination -> String
showsPrec :: Int -> PutSuppressedDestination -> ShowS
$cshowsPrec :: Int -> PutSuppressedDestination -> ShowS
Prelude.Show, (forall x.
 PutSuppressedDestination -> Rep PutSuppressedDestination x)
-> (forall x.
    Rep PutSuppressedDestination x -> PutSuppressedDestination)
-> Generic PutSuppressedDestination
forall x.
Rep PutSuppressedDestination x -> PutSuppressedDestination
forall x.
PutSuppressedDestination -> Rep PutSuppressedDestination x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutSuppressedDestination x -> PutSuppressedDestination
$cfrom :: forall x.
PutSuppressedDestination -> Rep PutSuppressedDestination x
Prelude.Generic)

-- |
-- Create a value of 'PutSuppressedDestination' 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:
--
-- 'emailAddress', 'putSuppressedDestination_emailAddress' - The email address that should be added to the suppression list for your
-- account.
--
-- 'reason', 'putSuppressedDestination_reason' - The factors that should cause the email address to be added to the
-- suppression list for your account.
newPutSuppressedDestination ::
  -- | 'emailAddress'
  Prelude.Text ->
  -- | 'reason'
  SuppressionListReason ->
  PutSuppressedDestination
newPutSuppressedDestination :: Text -> SuppressionListReason -> PutSuppressedDestination
newPutSuppressedDestination Text
pEmailAddress_ SuppressionListReason
pReason_ =
  PutSuppressedDestination' :: Text -> SuppressionListReason -> PutSuppressedDestination
PutSuppressedDestination'
    { $sel:emailAddress:PutSuppressedDestination' :: Text
emailAddress =
        Text
pEmailAddress_,
      $sel:reason:PutSuppressedDestination' :: SuppressionListReason
reason = SuppressionListReason
pReason_
    }

-- | The email address that should be added to the suppression list for your
-- account.
putSuppressedDestination_emailAddress :: Lens.Lens' PutSuppressedDestination Prelude.Text
putSuppressedDestination_emailAddress :: (Text -> f Text)
-> PutSuppressedDestination -> f PutSuppressedDestination
putSuppressedDestination_emailAddress = (PutSuppressedDestination -> Text)
-> (PutSuppressedDestination -> Text -> PutSuppressedDestination)
-> Lens PutSuppressedDestination PutSuppressedDestination Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutSuppressedDestination' {Text
emailAddress :: Text
$sel:emailAddress:PutSuppressedDestination' :: PutSuppressedDestination -> Text
emailAddress} -> Text
emailAddress) (\s :: PutSuppressedDestination
s@PutSuppressedDestination' {} Text
a -> PutSuppressedDestination
s {$sel:emailAddress:PutSuppressedDestination' :: Text
emailAddress = Text
a} :: PutSuppressedDestination)

-- | The factors that should cause the email address to be added to the
-- suppression list for your account.
putSuppressedDestination_reason :: Lens.Lens' PutSuppressedDestination SuppressionListReason
putSuppressedDestination_reason :: (SuppressionListReason -> f SuppressionListReason)
-> PutSuppressedDestination -> f PutSuppressedDestination
putSuppressedDestination_reason = (PutSuppressedDestination -> SuppressionListReason)
-> (PutSuppressedDestination
    -> SuppressionListReason -> PutSuppressedDestination)
-> Lens
     PutSuppressedDestination
     PutSuppressedDestination
     SuppressionListReason
     SuppressionListReason
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutSuppressedDestination' {SuppressionListReason
reason :: SuppressionListReason
$sel:reason:PutSuppressedDestination' :: PutSuppressedDestination -> SuppressionListReason
reason} -> SuppressionListReason
reason) (\s :: PutSuppressedDestination
s@PutSuppressedDestination' {} SuppressionListReason
a -> PutSuppressedDestination
s {$sel:reason:PutSuppressedDestination' :: SuppressionListReason
reason = SuppressionListReason
a} :: PutSuppressedDestination)

instance Core.AWSRequest PutSuppressedDestination where
  type
    AWSResponse PutSuppressedDestination =
      PutSuppressedDestinationResponse
  request :: PutSuppressedDestination -> Request PutSuppressedDestination
request = Service
-> PutSuppressedDestination -> Request PutSuppressedDestination
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PutSuppressedDestination
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutSuppressedDestination)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse PutSuppressedDestination))
-> Logger
-> Service
-> Proxy PutSuppressedDestination
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutSuppressedDestination)))
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 -> PutSuppressedDestinationResponse
PutSuppressedDestinationResponse'
            (Int -> PutSuppressedDestinationResponse)
-> Either String Int
-> Either String PutSuppressedDestinationResponse
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 PutSuppressedDestination

instance Prelude.NFData PutSuppressedDestination

instance Core.ToHeaders PutSuppressedDestination where
  toHeaders :: PutSuppressedDestination -> ResponseHeaders
toHeaders =
    ResponseHeaders -> PutSuppressedDestination -> 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 PutSuppressedDestination where
  toJSON :: PutSuppressedDestination -> Value
toJSON PutSuppressedDestination' {Text
SuppressionListReason
reason :: SuppressionListReason
emailAddress :: Text
$sel:reason:PutSuppressedDestination' :: PutSuppressedDestination -> SuppressionListReason
$sel:emailAddress:PutSuppressedDestination' :: PutSuppressedDestination -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"EmailAddress" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
emailAddress),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Reason" Text -> SuppressionListReason -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= SuppressionListReason
reason)
          ]
      )

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

instance Core.ToQuery PutSuppressedDestination where
  toQuery :: PutSuppressedDestination -> QueryString
toQuery = QueryString -> PutSuppressedDestination -> 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:/ 'newPutSuppressedDestinationResponse' smart constructor.
data PutSuppressedDestinationResponse = PutSuppressedDestinationResponse'
  { -- | The response's http status code.
    PutSuppressedDestinationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutSuppressedDestinationResponse
-> PutSuppressedDestinationResponse -> Bool
(PutSuppressedDestinationResponse
 -> PutSuppressedDestinationResponse -> Bool)
-> (PutSuppressedDestinationResponse
    -> PutSuppressedDestinationResponse -> Bool)
-> Eq PutSuppressedDestinationResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutSuppressedDestinationResponse
-> PutSuppressedDestinationResponse -> Bool
$c/= :: PutSuppressedDestinationResponse
-> PutSuppressedDestinationResponse -> Bool
== :: PutSuppressedDestinationResponse
-> PutSuppressedDestinationResponse -> Bool
$c== :: PutSuppressedDestinationResponse
-> PutSuppressedDestinationResponse -> Bool
Prelude.Eq, ReadPrec [PutSuppressedDestinationResponse]
ReadPrec PutSuppressedDestinationResponse
Int -> ReadS PutSuppressedDestinationResponse
ReadS [PutSuppressedDestinationResponse]
(Int -> ReadS PutSuppressedDestinationResponse)
-> ReadS [PutSuppressedDestinationResponse]
-> ReadPrec PutSuppressedDestinationResponse
-> ReadPrec [PutSuppressedDestinationResponse]
-> Read PutSuppressedDestinationResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutSuppressedDestinationResponse]
$creadListPrec :: ReadPrec [PutSuppressedDestinationResponse]
readPrec :: ReadPrec PutSuppressedDestinationResponse
$creadPrec :: ReadPrec PutSuppressedDestinationResponse
readList :: ReadS [PutSuppressedDestinationResponse]
$creadList :: ReadS [PutSuppressedDestinationResponse]
readsPrec :: Int -> ReadS PutSuppressedDestinationResponse
$creadsPrec :: Int -> ReadS PutSuppressedDestinationResponse
Prelude.Read, Int -> PutSuppressedDestinationResponse -> ShowS
[PutSuppressedDestinationResponse] -> ShowS
PutSuppressedDestinationResponse -> String
(Int -> PutSuppressedDestinationResponse -> ShowS)
-> (PutSuppressedDestinationResponse -> String)
-> ([PutSuppressedDestinationResponse] -> ShowS)
-> Show PutSuppressedDestinationResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutSuppressedDestinationResponse] -> ShowS
$cshowList :: [PutSuppressedDestinationResponse] -> ShowS
show :: PutSuppressedDestinationResponse -> String
$cshow :: PutSuppressedDestinationResponse -> String
showsPrec :: Int -> PutSuppressedDestinationResponse -> ShowS
$cshowsPrec :: Int -> PutSuppressedDestinationResponse -> ShowS
Prelude.Show, (forall x.
 PutSuppressedDestinationResponse
 -> Rep PutSuppressedDestinationResponse x)
-> (forall x.
    Rep PutSuppressedDestinationResponse x
    -> PutSuppressedDestinationResponse)
-> Generic PutSuppressedDestinationResponse
forall x.
Rep PutSuppressedDestinationResponse x
-> PutSuppressedDestinationResponse
forall x.
PutSuppressedDestinationResponse
-> Rep PutSuppressedDestinationResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutSuppressedDestinationResponse x
-> PutSuppressedDestinationResponse
$cfrom :: forall x.
PutSuppressedDestinationResponse
-> Rep PutSuppressedDestinationResponse x
Prelude.Generic)

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

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

instance
  Prelude.NFData
    PutSuppressedDestinationResponse