{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.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 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
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]
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
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.
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'
    { $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 :: Lens' PutSuppressedDestination Text
putSuppressedDestination_emailAddress = 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 :: Lens' PutSuppressedDestination SuppressionListReason
putSuppressedDestination_reason = 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 :: (Service -> Service)
-> PutSuppressedDestination -> Request PutSuppressedDestination
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 PutSuppressedDestination
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutSuppressedDestination)))
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 -> PutSuppressedDestinationResponse
PutSuppressedDestinationResponse'
            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 PutSuppressedDestination where
  hashWithSalt :: Int -> PutSuppressedDestination -> Int
hashWithSalt Int
_salt PutSuppressedDestination' {Text
SuppressionListReason
reason :: SuppressionListReason
emailAddress :: Text
$sel:reason:PutSuppressedDestination' :: PutSuppressedDestination -> SuppressionListReason
$sel:emailAddress:PutSuppressedDestination' :: PutSuppressedDestination -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
emailAddress
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` SuppressionListReason
reason

instance Prelude.NFData PutSuppressedDestination where
  rnf :: PutSuppressedDestination -> ()
rnf PutSuppressedDestination' {Text
SuppressionListReason
reason :: SuppressionListReason
emailAddress :: Text
$sel:reason:PutSuppressedDestination' :: PutSuppressedDestination -> SuppressionListReason
$sel:emailAddress:PutSuppressedDestination' :: PutSuppressedDestination -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
emailAddress
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf SuppressionListReason
reason

instance Data.ToHeaders PutSuppressedDestination where
  toHeaders :: PutSuppressedDestination -> 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 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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"EmailAddress" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
emailAddress),
            forall a. a -> Maybe a
Prelude.Just (Key
"Reason" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= SuppressionListReason
reason)
          ]
      )

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

instance Data.ToQuery PutSuppressedDestination where
  toQuery :: PutSuppressedDestination -> 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:/ 'newPutSuppressedDestinationResponse' smart constructor.
data PutSuppressedDestinationResponse = PutSuppressedDestinationResponse'
  { -- | The response's http status code.
    PutSuppressedDestinationResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PutSuppressedDestinationResponse
-> PutSuppressedDestinationResponse -> Bool
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]
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
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.
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'
    { $sel:httpStatus:PutSuppressedDestinationResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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