{-# 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-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)
--
-- 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.Lens as Lens
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
(RebootBroker -> RebootBroker -> Bool)
-> (RebootBroker -> RebootBroker -> Bool) -> Eq RebootBroker
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]
(Int -> ReadS RebootBroker)
-> ReadS [RebootBroker]
-> ReadPrec RebootBroker
-> ReadPrec [RebootBroker]
-> Read 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
(Int -> RebootBroker -> ShowS)
-> (RebootBroker -> String)
-> ([RebootBroker] -> ShowS)
-> Show RebootBroker
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. RebootBroker -> Rep RebootBroker x)
-> (forall x. Rep RebootBroker x -> RebootBroker)
-> Generic RebootBroker
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' :: Text -> RebootBroker
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 :: (Text -> f Text) -> RebootBroker -> f RebootBroker
rebootBroker_brokerId = (RebootBroker -> Text)
-> (RebootBroker -> Text -> RebootBroker)
-> Lens RebootBroker RebootBroker Text Text
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 :: RebootBroker -> Request RebootBroker
request = Service -> RebootBroker -> Request RebootBroker
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RebootBroker
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RebootBroker)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse RebootBroker))
-> Logger
-> Service
-> Proxy RebootBroker
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RebootBroker)))
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 -> RebootBrokerResponse
RebootBrokerResponse'
            (Int -> RebootBrokerResponse)
-> Either String Int -> Either String RebootBrokerResponse
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 RebootBroker

instance Prelude.NFData RebootBroker

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

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

instance Core.ToQuery RebootBroker where
  toQuery :: RebootBroker -> QueryString
toQuery = QueryString -> RebootBroker -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(RebootBrokerResponse -> RebootBrokerResponse -> Bool)
-> (RebootBrokerResponse -> RebootBrokerResponse -> Bool)
-> Eq RebootBrokerResponse
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]
(Int -> ReadS RebootBrokerResponse)
-> ReadS [RebootBrokerResponse]
-> ReadPrec RebootBrokerResponse
-> ReadPrec [RebootBrokerResponse]
-> Read 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
(Int -> RebootBrokerResponse -> ShowS)
-> (RebootBrokerResponse -> String)
-> ([RebootBrokerResponse] -> ShowS)
-> Show RebootBrokerResponse
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. RebootBrokerResponse -> Rep RebootBrokerResponse x)
-> (forall x. Rep RebootBrokerResponse x -> RebootBrokerResponse)
-> Generic RebootBrokerResponse
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' :: Int -> RebootBrokerResponse
RebootBrokerResponse' {$sel:httpStatus:RebootBrokerResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
rebootBrokerResponse_httpStatus :: Lens.Lens' RebootBrokerResponse Prelude.Int
rebootBrokerResponse_httpStatus :: (Int -> f Int) -> RebootBrokerResponse -> f RebootBrokerResponse
rebootBrokerResponse_httpStatus = (RebootBrokerResponse -> Int)
-> (RebootBrokerResponse -> Int -> RebootBrokerResponse)
-> Lens RebootBrokerResponse RebootBrokerResponse Int Int
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