{-# 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.PinpointEmail.PutConfigurationSetSendingOptions
-- 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)
--
-- Enable or disable email sending for messages that use a particular
-- configuration set in a specific AWS Region.
module Amazonka.PinpointEmail.PutConfigurationSetSendingOptions
  ( -- * Creating a Request
    PutConfigurationSetSendingOptions (..),
    newPutConfigurationSetSendingOptions,

    -- * Request Lenses
    putConfigurationSetSendingOptions_sendingEnabled,
    putConfigurationSetSendingOptions_configurationSetName,

    -- * Destructuring the Response
    PutConfigurationSetSendingOptionsResponse (..),
    newPutConfigurationSetSendingOptionsResponse,

    -- * Response Lenses
    putConfigurationSetSendingOptionsResponse_httpStatus,
  )
where

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

-- | A request to enable or disable the ability of Amazon Pinpoint to send
-- emails that use a specific configuration set.
--
-- /See:/ 'newPutConfigurationSetSendingOptions' smart constructor.
data PutConfigurationSetSendingOptions = PutConfigurationSetSendingOptions'
  { -- | If @true@, email sending is enabled for the configuration set. If
    -- @false@, email sending is disabled for the configuration set.
    PutConfigurationSetSendingOptions -> Maybe Bool
sendingEnabled :: Prelude.Maybe Prelude.Bool,
    -- | The name of the configuration set that you want to enable or disable
    -- email sending for.
    PutConfigurationSetSendingOptions -> Text
configurationSetName :: Prelude.Text
  }
  deriving (PutConfigurationSetSendingOptions
-> PutConfigurationSetSendingOptions -> Bool
(PutConfigurationSetSendingOptions
 -> PutConfigurationSetSendingOptions -> Bool)
-> (PutConfigurationSetSendingOptions
    -> PutConfigurationSetSendingOptions -> Bool)
-> Eq PutConfigurationSetSendingOptions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutConfigurationSetSendingOptions
-> PutConfigurationSetSendingOptions -> Bool
$c/= :: PutConfigurationSetSendingOptions
-> PutConfigurationSetSendingOptions -> Bool
== :: PutConfigurationSetSendingOptions
-> PutConfigurationSetSendingOptions -> Bool
$c== :: PutConfigurationSetSendingOptions
-> PutConfigurationSetSendingOptions -> Bool
Prelude.Eq, ReadPrec [PutConfigurationSetSendingOptions]
ReadPrec PutConfigurationSetSendingOptions
Int -> ReadS PutConfigurationSetSendingOptions
ReadS [PutConfigurationSetSendingOptions]
(Int -> ReadS PutConfigurationSetSendingOptions)
-> ReadS [PutConfigurationSetSendingOptions]
-> ReadPrec PutConfigurationSetSendingOptions
-> ReadPrec [PutConfigurationSetSendingOptions]
-> Read PutConfigurationSetSendingOptions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutConfigurationSetSendingOptions]
$creadListPrec :: ReadPrec [PutConfigurationSetSendingOptions]
readPrec :: ReadPrec PutConfigurationSetSendingOptions
$creadPrec :: ReadPrec PutConfigurationSetSendingOptions
readList :: ReadS [PutConfigurationSetSendingOptions]
$creadList :: ReadS [PutConfigurationSetSendingOptions]
readsPrec :: Int -> ReadS PutConfigurationSetSendingOptions
$creadsPrec :: Int -> ReadS PutConfigurationSetSendingOptions
Prelude.Read, Int -> PutConfigurationSetSendingOptions -> ShowS
[PutConfigurationSetSendingOptions] -> ShowS
PutConfigurationSetSendingOptions -> String
(Int -> PutConfigurationSetSendingOptions -> ShowS)
-> (PutConfigurationSetSendingOptions -> String)
-> ([PutConfigurationSetSendingOptions] -> ShowS)
-> Show PutConfigurationSetSendingOptions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutConfigurationSetSendingOptions] -> ShowS
$cshowList :: [PutConfigurationSetSendingOptions] -> ShowS
show :: PutConfigurationSetSendingOptions -> String
$cshow :: PutConfigurationSetSendingOptions -> String
showsPrec :: Int -> PutConfigurationSetSendingOptions -> ShowS
$cshowsPrec :: Int -> PutConfigurationSetSendingOptions -> ShowS
Prelude.Show, (forall x.
 PutConfigurationSetSendingOptions
 -> Rep PutConfigurationSetSendingOptions x)
-> (forall x.
    Rep PutConfigurationSetSendingOptions x
    -> PutConfigurationSetSendingOptions)
-> Generic PutConfigurationSetSendingOptions
forall x.
Rep PutConfigurationSetSendingOptions x
-> PutConfigurationSetSendingOptions
forall x.
PutConfigurationSetSendingOptions
-> Rep PutConfigurationSetSendingOptions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutConfigurationSetSendingOptions x
-> PutConfigurationSetSendingOptions
$cfrom :: forall x.
PutConfigurationSetSendingOptions
-> Rep PutConfigurationSetSendingOptions x
Prelude.Generic)

-- |
-- Create a value of 'PutConfigurationSetSendingOptions' 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:
--
-- 'sendingEnabled', 'putConfigurationSetSendingOptions_sendingEnabled' - If @true@, email sending is enabled for the configuration set. If
-- @false@, email sending is disabled for the configuration set.
--
-- 'configurationSetName', 'putConfigurationSetSendingOptions_configurationSetName' - The name of the configuration set that you want to enable or disable
-- email sending for.
newPutConfigurationSetSendingOptions ::
  -- | 'configurationSetName'
  Prelude.Text ->
  PutConfigurationSetSendingOptions
newPutConfigurationSetSendingOptions :: Text -> PutConfigurationSetSendingOptions
newPutConfigurationSetSendingOptions
  Text
pConfigurationSetName_ =
    PutConfigurationSetSendingOptions' :: Maybe Bool -> Text -> PutConfigurationSetSendingOptions
PutConfigurationSetSendingOptions'
      { $sel:sendingEnabled:PutConfigurationSetSendingOptions' :: Maybe Bool
sendingEnabled =
          Maybe Bool
forall a. Maybe a
Prelude.Nothing,
        $sel:configurationSetName:PutConfigurationSetSendingOptions' :: Text
configurationSetName =
          Text
pConfigurationSetName_
      }

-- | If @true@, email sending is enabled for the configuration set. If
-- @false@, email sending is disabled for the configuration set.
putConfigurationSetSendingOptions_sendingEnabled :: Lens.Lens' PutConfigurationSetSendingOptions (Prelude.Maybe Prelude.Bool)
putConfigurationSetSendingOptions_sendingEnabled :: (Maybe Bool -> f (Maybe Bool))
-> PutConfigurationSetSendingOptions
-> f PutConfigurationSetSendingOptions
putConfigurationSetSendingOptions_sendingEnabled = (PutConfigurationSetSendingOptions -> Maybe Bool)
-> (PutConfigurationSetSendingOptions
    -> Maybe Bool -> PutConfigurationSetSendingOptions)
-> Lens
     PutConfigurationSetSendingOptions
     PutConfigurationSetSendingOptions
     (Maybe Bool)
     (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutConfigurationSetSendingOptions' {Maybe Bool
sendingEnabled :: Maybe Bool
$sel:sendingEnabled:PutConfigurationSetSendingOptions' :: PutConfigurationSetSendingOptions -> Maybe Bool
sendingEnabled} -> Maybe Bool
sendingEnabled) (\s :: PutConfigurationSetSendingOptions
s@PutConfigurationSetSendingOptions' {} Maybe Bool
a -> PutConfigurationSetSendingOptions
s {$sel:sendingEnabled:PutConfigurationSetSendingOptions' :: Maybe Bool
sendingEnabled = Maybe Bool
a} :: PutConfigurationSetSendingOptions)

-- | The name of the configuration set that you want to enable or disable
-- email sending for.
putConfigurationSetSendingOptions_configurationSetName :: Lens.Lens' PutConfigurationSetSendingOptions Prelude.Text
putConfigurationSetSendingOptions_configurationSetName :: (Text -> f Text)
-> PutConfigurationSetSendingOptions
-> f PutConfigurationSetSendingOptions
putConfigurationSetSendingOptions_configurationSetName = (PutConfigurationSetSendingOptions -> Text)
-> (PutConfigurationSetSendingOptions
    -> Text -> PutConfigurationSetSendingOptions)
-> Lens
     PutConfigurationSetSendingOptions
     PutConfigurationSetSendingOptions
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutConfigurationSetSendingOptions' {Text
configurationSetName :: Text
$sel:configurationSetName:PutConfigurationSetSendingOptions' :: PutConfigurationSetSendingOptions -> Text
configurationSetName} -> Text
configurationSetName) (\s :: PutConfigurationSetSendingOptions
s@PutConfigurationSetSendingOptions' {} Text
a -> PutConfigurationSetSendingOptions
s {$sel:configurationSetName:PutConfigurationSetSendingOptions' :: Text
configurationSetName = Text
a} :: PutConfigurationSetSendingOptions)

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

instance
  Prelude.NFData
    PutConfigurationSetSendingOptions

instance
  Core.ToHeaders
    PutConfigurationSetSendingOptions
  where
  toHeaders :: PutConfigurationSetSendingOptions -> ResponseHeaders
toHeaders =
    ResponseHeaders
-> PutConfigurationSetSendingOptions -> 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
    PutConfigurationSetSendingOptions
  where
  toJSON :: PutConfigurationSetSendingOptions -> Value
toJSON PutConfigurationSetSendingOptions' {Maybe Bool
Text
configurationSetName :: Text
sendingEnabled :: Maybe Bool
$sel:configurationSetName:PutConfigurationSetSendingOptions' :: PutConfigurationSetSendingOptions -> Text
$sel:sendingEnabled:PutConfigurationSetSendingOptions' :: PutConfigurationSetSendingOptions -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"SendingEnabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
sendingEnabled
          ]
      )

instance
  Core.ToPath
    PutConfigurationSetSendingOptions
  where
  toPath :: PutConfigurationSetSendingOptions -> ByteString
toPath PutConfigurationSetSendingOptions' {Maybe Bool
Text
configurationSetName :: Text
sendingEnabled :: Maybe Bool
$sel:configurationSetName:PutConfigurationSetSendingOptions' :: PutConfigurationSetSendingOptions -> Text
$sel:sendingEnabled:PutConfigurationSetSendingOptions' :: PutConfigurationSetSendingOptions -> Maybe Bool
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v1/email/configuration-sets/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
configurationSetName,
        ByteString
"/sending"
      ]

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

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

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

instance
  Prelude.NFData
    PutConfigurationSetSendingOptionsResponse