{-# 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.PutAccountSendingAttributes
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Enable or disable the ability of your account to send email.
module Amazonka.PinpointEmail.PutAccountSendingAttributes
  ( -- * Creating a Request
    PutAccountSendingAttributes (..),
    newPutAccountSendingAttributes,

    -- * Request Lenses
    putAccountSendingAttributes_sendingEnabled,

    -- * Destructuring the Response
    PutAccountSendingAttributesResponse (..),
    newPutAccountSendingAttributesResponse,

    -- * Response Lenses
    putAccountSendingAttributesResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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 change the ability of your account to send email.
--
-- /See:/ 'newPutAccountSendingAttributes' smart constructor.
data PutAccountSendingAttributes = PutAccountSendingAttributes'
  { -- | Enables or disables your account\'s ability to send email. Set to @true@
    -- to enable email sending, or set to @false@ to disable email sending.
    --
    -- If AWS paused your account\'s ability to send email, you can\'t use this
    -- operation to resume your account\'s ability to send email.
    PutAccountSendingAttributes -> Maybe Bool
sendingEnabled :: Prelude.Maybe Prelude.Bool
  }
  deriving (PutAccountSendingAttributes -> PutAccountSendingAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PutAccountSendingAttributes -> PutAccountSendingAttributes -> Bool
$c/= :: PutAccountSendingAttributes -> PutAccountSendingAttributes -> Bool
== :: PutAccountSendingAttributes -> PutAccountSendingAttributes -> Bool
$c== :: PutAccountSendingAttributes -> PutAccountSendingAttributes -> Bool
Prelude.Eq, ReadPrec [PutAccountSendingAttributes]
ReadPrec PutAccountSendingAttributes
Int -> ReadS PutAccountSendingAttributes
ReadS [PutAccountSendingAttributes]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PutAccountSendingAttributes]
$creadListPrec :: ReadPrec [PutAccountSendingAttributes]
readPrec :: ReadPrec PutAccountSendingAttributes
$creadPrec :: ReadPrec PutAccountSendingAttributes
readList :: ReadS [PutAccountSendingAttributes]
$creadList :: ReadS [PutAccountSendingAttributes]
readsPrec :: Int -> ReadS PutAccountSendingAttributes
$creadsPrec :: Int -> ReadS PutAccountSendingAttributes
Prelude.Read, Int -> PutAccountSendingAttributes -> ShowS
[PutAccountSendingAttributes] -> ShowS
PutAccountSendingAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PutAccountSendingAttributes] -> ShowS
$cshowList :: [PutAccountSendingAttributes] -> ShowS
show :: PutAccountSendingAttributes -> String
$cshow :: PutAccountSendingAttributes -> String
showsPrec :: Int -> PutAccountSendingAttributes -> ShowS
$cshowsPrec :: Int -> PutAccountSendingAttributes -> ShowS
Prelude.Show, forall x.
Rep PutAccountSendingAttributes x -> PutAccountSendingAttributes
forall x.
PutAccountSendingAttributes -> Rep PutAccountSendingAttributes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep PutAccountSendingAttributes x -> PutAccountSendingAttributes
$cfrom :: forall x.
PutAccountSendingAttributes -> Rep PutAccountSendingAttributes x
Prelude.Generic)

-- |
-- Create a value of 'PutAccountSendingAttributes' 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', 'putAccountSendingAttributes_sendingEnabled' - Enables or disables your account\'s ability to send email. Set to @true@
-- to enable email sending, or set to @false@ to disable email sending.
--
-- If AWS paused your account\'s ability to send email, you can\'t use this
-- operation to resume your account\'s ability to send email.
newPutAccountSendingAttributes ::
  PutAccountSendingAttributes
newPutAccountSendingAttributes :: PutAccountSendingAttributes
newPutAccountSendingAttributes =
  PutAccountSendingAttributes'
    { $sel:sendingEnabled:PutAccountSendingAttributes' :: Maybe Bool
sendingEnabled =
        forall a. Maybe a
Prelude.Nothing
    }

-- | Enables or disables your account\'s ability to send email. Set to @true@
-- to enable email sending, or set to @false@ to disable email sending.
--
-- If AWS paused your account\'s ability to send email, you can\'t use this
-- operation to resume your account\'s ability to send email.
putAccountSendingAttributes_sendingEnabled :: Lens.Lens' PutAccountSendingAttributes (Prelude.Maybe Prelude.Bool)
putAccountSendingAttributes_sendingEnabled :: Lens' PutAccountSendingAttributes (Maybe Bool)
putAccountSendingAttributes_sendingEnabled = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PutAccountSendingAttributes' {Maybe Bool
sendingEnabled :: Maybe Bool
$sel:sendingEnabled:PutAccountSendingAttributes' :: PutAccountSendingAttributes -> Maybe Bool
sendingEnabled} -> Maybe Bool
sendingEnabled) (\s :: PutAccountSendingAttributes
s@PutAccountSendingAttributes' {} Maybe Bool
a -> PutAccountSendingAttributes
s {$sel:sendingEnabled:PutAccountSendingAttributes' :: Maybe Bool
sendingEnabled = Maybe Bool
a} :: PutAccountSendingAttributes)

instance Core.AWSRequest PutAccountSendingAttributes where
  type
    AWSResponse PutAccountSendingAttributes =
      PutAccountSendingAttributesResponse
  request :: (Service -> Service)
-> PutAccountSendingAttributes
-> Request PutAccountSendingAttributes
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 PutAccountSendingAttributes
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PutAccountSendingAttributes)))
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 -> PutAccountSendingAttributesResponse
PutAccountSendingAttributesResponse'
            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 PutAccountSendingAttributes where
  hashWithSalt :: Int -> PutAccountSendingAttributes -> Int
hashWithSalt Int
_salt PutAccountSendingAttributes' {Maybe Bool
sendingEnabled :: Maybe Bool
$sel:sendingEnabled:PutAccountSendingAttributes' :: PutAccountSendingAttributes -> Maybe Bool
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
sendingEnabled

instance Prelude.NFData PutAccountSendingAttributes where
  rnf :: PutAccountSendingAttributes -> ()
rnf PutAccountSendingAttributes' {Maybe Bool
sendingEnabled :: Maybe Bool
$sel:sendingEnabled:PutAccountSendingAttributes' :: PutAccountSendingAttributes -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
sendingEnabled

instance Data.ToHeaders PutAccountSendingAttributes where
  toHeaders :: PutAccountSendingAttributes -> 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 PutAccountSendingAttributes where
  toJSON :: PutAccountSendingAttributes -> Value
toJSON PutAccountSendingAttributes' {Maybe Bool
sendingEnabled :: Maybe Bool
$sel:sendingEnabled:PutAccountSendingAttributes' :: PutAccountSendingAttributes -> Maybe Bool
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"SendingEnabled" 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 Bool
sendingEnabled
          ]
      )

instance Data.ToPath PutAccountSendingAttributes where
  toPath :: PutAccountSendingAttributes -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/v1/email/account/sending"

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

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

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

instance
  Prelude.NFData
    PutAccountSendingAttributesResponse
  where
  rnf :: PutAccountSendingAttributesResponse -> ()
rnf PutAccountSendingAttributesResponse' {Int
httpStatus :: Int
$sel:httpStatus:PutAccountSendingAttributesResponse' :: PutAccountSendingAttributesResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus