{-# 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.MQ.RebootBroker
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Reboots a broker. Note: This API is asynchronous.
module Amazonka.MQ.RebootBroker
  ( -- * Creating a Request
    RebootBroker (..),
    newRebootBroker,

    -- * Request Lenses
    rebootBroker_brokerId,

    -- * Destructuring the Response
    RebootBrokerResponse (..),
    newRebootBrokerResponse,

    -- * Response Lenses
    rebootBrokerResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.MQ.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newRebootBroker' smart constructor.
data RebootBroker = RebootBroker'
  { -- | The unique ID that Amazon MQ generates for the broker.
    RebootBroker -> Text
brokerId :: Prelude.Text
  }
  deriving (RebootBroker -> RebootBroker -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RebootBroker -> RebootBroker -> Bool
$c/= :: RebootBroker -> RebootBroker -> Bool
== :: RebootBroker -> RebootBroker -> Bool
$c== :: RebootBroker -> RebootBroker -> Bool
Prelude.Eq, ReadPrec [RebootBroker]
ReadPrec RebootBroker
Int -> ReadS RebootBroker
ReadS [RebootBroker]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RebootBroker]
$creadListPrec :: ReadPrec [RebootBroker]
readPrec :: ReadPrec RebootBroker
$creadPrec :: ReadPrec RebootBroker
readList :: ReadS [RebootBroker]
$creadList :: ReadS [RebootBroker]
readsPrec :: Int -> ReadS RebootBroker
$creadsPrec :: Int -> ReadS RebootBroker
Prelude.Read, Int -> RebootBroker -> ShowS
[RebootBroker] -> ShowS
RebootBroker -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RebootBroker] -> ShowS
$cshowList :: [RebootBroker] -> ShowS
show :: RebootBroker -> String
$cshow :: RebootBroker -> String
showsPrec :: Int -> RebootBroker -> ShowS
$cshowsPrec :: Int -> RebootBroker -> ShowS
Prelude.Show, forall x. Rep RebootBroker x -> RebootBroker
forall x. RebootBroker -> Rep RebootBroker x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RebootBroker x -> RebootBroker
$cfrom :: forall x. RebootBroker -> Rep RebootBroker x
Prelude.Generic)

-- |
-- Create a value of 'RebootBroker' 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:
--
-- 'brokerId', 'rebootBroker_brokerId' - The unique ID that Amazon MQ generates for the broker.
newRebootBroker ::
  -- | 'brokerId'
  Prelude.Text ->
  RebootBroker
newRebootBroker :: Text -> RebootBroker
newRebootBroker Text
pBrokerId_ =
  RebootBroker' {$sel:brokerId:RebootBroker' :: Text
brokerId = Text
pBrokerId_}

-- | The unique ID that Amazon MQ generates for the broker.
rebootBroker_brokerId :: Lens.Lens' RebootBroker Prelude.Text
rebootBroker_brokerId :: Lens' RebootBroker Text
rebootBroker_brokerId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RebootBroker' {Text
brokerId :: Text
$sel:brokerId:RebootBroker' :: RebootBroker -> Text
brokerId} -> Text
brokerId) (\s :: RebootBroker
s@RebootBroker' {} Text
a -> RebootBroker
s {$sel:brokerId:RebootBroker' :: Text
brokerId = Text
a} :: RebootBroker)

instance Core.AWSRequest RebootBroker where
  type AWSResponse RebootBroker = RebootBrokerResponse
  request :: (Service -> Service) -> RebootBroker -> Request RebootBroker
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy RebootBroker
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RebootBroker)))
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 -> RebootBrokerResponse
RebootBrokerResponse'
            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 RebootBroker where
  hashWithSalt :: Int -> RebootBroker -> Int
hashWithSalt Int
_salt RebootBroker' {Text
brokerId :: Text
$sel:brokerId:RebootBroker' :: RebootBroker -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
brokerId

instance Prelude.NFData RebootBroker where
  rnf :: RebootBroker -> ()
rnf RebootBroker' {Text
brokerId :: Text
$sel:brokerId:RebootBroker' :: RebootBroker -> Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Text
brokerId

instance Data.ToHeaders RebootBroker where
  toHeaders :: RebootBroker -> 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 RebootBroker where
  toJSON :: RebootBroker -> Value
toJSON = forall a b. a -> b -> a
Prelude.const (Object -> Value
Data.Object forall a. Monoid a => a
Prelude.mempty)

instance Data.ToPath RebootBroker where
  toPath :: RebootBroker -> ByteString
toPath RebootBroker' {Text
brokerId :: Text
$sel:brokerId:RebootBroker' :: RebootBroker -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/v1/brokers/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
brokerId, ByteString
"/reboot"]

instance Data.ToQuery RebootBroker where
  toQuery :: RebootBroker -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newRebootBrokerResponse' smart constructor.
data RebootBrokerResponse = RebootBrokerResponse'
  { -- | The response's http status code.
    RebootBrokerResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (RebootBrokerResponse -> RebootBrokerResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RebootBrokerResponse -> RebootBrokerResponse -> Bool
$c/= :: RebootBrokerResponse -> RebootBrokerResponse -> Bool
== :: RebootBrokerResponse -> RebootBrokerResponse -> Bool
$c== :: RebootBrokerResponse -> RebootBrokerResponse -> Bool
Prelude.Eq, ReadPrec [RebootBrokerResponse]
ReadPrec RebootBrokerResponse
Int -> ReadS RebootBrokerResponse
ReadS [RebootBrokerResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RebootBrokerResponse]
$creadListPrec :: ReadPrec [RebootBrokerResponse]
readPrec :: ReadPrec RebootBrokerResponse
$creadPrec :: ReadPrec RebootBrokerResponse
readList :: ReadS [RebootBrokerResponse]
$creadList :: ReadS [RebootBrokerResponse]
readsPrec :: Int -> ReadS RebootBrokerResponse
$creadsPrec :: Int -> ReadS RebootBrokerResponse
Prelude.Read, Int -> RebootBrokerResponse -> ShowS
[RebootBrokerResponse] -> ShowS
RebootBrokerResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RebootBrokerResponse] -> ShowS
$cshowList :: [RebootBrokerResponse] -> ShowS
show :: RebootBrokerResponse -> String
$cshow :: RebootBrokerResponse -> String
showsPrec :: Int -> RebootBrokerResponse -> ShowS
$cshowsPrec :: Int -> RebootBrokerResponse -> ShowS
Prelude.Show, forall x. Rep RebootBrokerResponse x -> RebootBrokerResponse
forall x. RebootBrokerResponse -> Rep RebootBrokerResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RebootBrokerResponse x -> RebootBrokerResponse
$cfrom :: forall x. RebootBrokerResponse -> Rep RebootBrokerResponse x
Prelude.Generic)

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

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

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