{-# 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.Kafka.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 brokers.
module Amazonka.Kafka.RebootBroker
  ( -- * Creating a Request
    RebootBroker (..),
    newRebootBroker,

    -- * Request Lenses
    rebootBroker_clusterArn,
    rebootBroker_brokerIds,

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

    -- * Response Lenses
    rebootBrokerResponse_clusterArn,
    rebootBrokerResponse_clusterOperationArn,
    rebootBrokerResponse_httpStatus,
  )
where

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

-- | Reboots a node.
--
-- /See:/ 'newRebootBroker' smart constructor.
data RebootBroker = RebootBroker'
  { -- | The Amazon Resource Name (ARN) of the cluster to be updated.
    RebootBroker -> Text
clusterArn :: Prelude.Text,
    -- | The list of broker IDs to be rebooted. The reboot-broker operation
    -- supports rebooting one broker at a time.
    RebootBroker -> [Text]
brokerIds :: [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:
--
-- 'clusterArn', 'rebootBroker_clusterArn' - The Amazon Resource Name (ARN) of the cluster to be updated.
--
-- 'brokerIds', 'rebootBroker_brokerIds' - The list of broker IDs to be rebooted. The reboot-broker operation
-- supports rebooting one broker at a time.
newRebootBroker ::
  -- | 'clusterArn'
  Prelude.Text ->
  RebootBroker
newRebootBroker :: Text -> RebootBroker
newRebootBroker Text
pClusterArn_ =
  RebootBroker' :: Text -> [Text] -> RebootBroker
RebootBroker'
    { $sel:clusterArn:RebootBroker' :: Text
clusterArn = Text
pClusterArn_,
      $sel:brokerIds:RebootBroker' :: [Text]
brokerIds = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | The Amazon Resource Name (ARN) of the cluster to be updated.
rebootBroker_clusterArn :: Lens.Lens' RebootBroker Prelude.Text
rebootBroker_clusterArn :: (Text -> f Text) -> RebootBroker -> f RebootBroker
rebootBroker_clusterArn = (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
clusterArn :: Text
$sel:clusterArn:RebootBroker' :: RebootBroker -> Text
clusterArn} -> Text
clusterArn) (\s :: RebootBroker
s@RebootBroker' {} Text
a -> RebootBroker
s {$sel:clusterArn:RebootBroker' :: Text
clusterArn = Text
a} :: RebootBroker)

-- | The list of broker IDs to be rebooted. The reboot-broker operation
-- supports rebooting one broker at a time.
rebootBroker_brokerIds :: Lens.Lens' RebootBroker [Prelude.Text]
rebootBroker_brokerIds :: ([Text] -> f [Text]) -> RebootBroker -> f RebootBroker
rebootBroker_brokerIds = (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]
brokerIds :: [Text]
$sel:brokerIds:RebootBroker' :: RebootBroker -> [Text]
brokerIds} -> [Text]
brokerIds) (\s :: RebootBroker
s@RebootBroker' {} [Text]
a -> RebootBroker
s {$sel:brokerIds:RebootBroker' :: [Text]
brokerIds = [Text]
a} :: RebootBroker) (([Text] -> f [Text]) -> RebootBroker -> f RebootBroker)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> RebootBroker
-> f RebootBroker
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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.putJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy RebootBroker
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RebootBroker)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse RebootBroker))
-> Logger
-> Service
-> Proxy RebootBroker
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RebootBroker)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Maybe Text -> Int -> RebootBrokerResponse
RebootBrokerResponse'
            (Maybe Text -> Maybe Text -> Int -> RebootBrokerResponse)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Int -> RebootBrokerResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"clusterArn")
            Either String (Maybe Text -> Int -> RebootBrokerResponse)
-> Either String (Maybe Text)
-> Either String (Int -> RebootBrokerResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"clusterOperationArn")
            Either String (Int -> RebootBrokerResponse)
-> Either String Int -> Either String RebootBrokerResponse
forall (f :: * -> *) a b. Applicative f => 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 RebootBroker' {[Text]
Text
brokerIds :: [Text]
clusterArn :: Text
$sel:brokerIds:RebootBroker' :: RebootBroker -> [Text]
$sel:clusterArn:RebootBroker' :: RebootBroker -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"brokerIds" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
brokerIds)]
      )

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

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 Amazon Resource Name (ARN) of the cluster.
    RebootBrokerResponse -> Maybe Text
clusterArn :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the cluster operation.
    RebootBrokerResponse -> Maybe Text
clusterOperationArn :: Prelude.Maybe Prelude.Text,
    -- | 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:
--
-- 'clusterArn', 'rebootBrokerResponse_clusterArn' - The Amazon Resource Name (ARN) of the cluster.
--
-- 'clusterOperationArn', 'rebootBrokerResponse_clusterOperationArn' - The Amazon Resource Name (ARN) of the cluster operation.
--
-- 'httpStatus', 'rebootBrokerResponse_httpStatus' - The response's http status code.
newRebootBrokerResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RebootBrokerResponse
newRebootBrokerResponse :: Int -> RebootBrokerResponse
newRebootBrokerResponse Int
pHttpStatus_ =
  RebootBrokerResponse' :: Maybe Text -> Maybe Text -> Int -> RebootBrokerResponse
RebootBrokerResponse'
    { $sel:clusterArn:RebootBrokerResponse' :: Maybe Text
clusterArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:clusterOperationArn:RebootBrokerResponse' :: Maybe Text
clusterOperationArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:RebootBrokerResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the cluster.
rebootBrokerResponse_clusterArn :: Lens.Lens' RebootBrokerResponse (Prelude.Maybe Prelude.Text)
rebootBrokerResponse_clusterArn :: (Maybe Text -> f (Maybe Text))
-> RebootBrokerResponse -> f RebootBrokerResponse
rebootBrokerResponse_clusterArn = (RebootBrokerResponse -> Maybe Text)
-> (RebootBrokerResponse -> Maybe Text -> RebootBrokerResponse)
-> Lens
     RebootBrokerResponse RebootBrokerResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RebootBrokerResponse' {Maybe Text
clusterArn :: Maybe Text
$sel:clusterArn:RebootBrokerResponse' :: RebootBrokerResponse -> Maybe Text
clusterArn} -> Maybe Text
clusterArn) (\s :: RebootBrokerResponse
s@RebootBrokerResponse' {} Maybe Text
a -> RebootBrokerResponse
s {$sel:clusterArn:RebootBrokerResponse' :: Maybe Text
clusterArn = Maybe Text
a} :: RebootBrokerResponse)

-- | The Amazon Resource Name (ARN) of the cluster operation.
rebootBrokerResponse_clusterOperationArn :: Lens.Lens' RebootBrokerResponse (Prelude.Maybe Prelude.Text)
rebootBrokerResponse_clusterOperationArn :: (Maybe Text -> f (Maybe Text))
-> RebootBrokerResponse -> f RebootBrokerResponse
rebootBrokerResponse_clusterOperationArn = (RebootBrokerResponse -> Maybe Text)
-> (RebootBrokerResponse -> Maybe Text -> RebootBrokerResponse)
-> Lens
     RebootBrokerResponse RebootBrokerResponse (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RebootBrokerResponse' {Maybe Text
clusterOperationArn :: Maybe Text
$sel:clusterOperationArn:RebootBrokerResponse' :: RebootBrokerResponse -> Maybe Text
clusterOperationArn} -> Maybe Text
clusterOperationArn) (\s :: RebootBrokerResponse
s@RebootBrokerResponse' {} Maybe Text
a -> RebootBrokerResponse
s {$sel:clusterOperationArn:RebootBrokerResponse' :: Maybe Text
clusterOperationArn = Maybe Text
a} :: RebootBrokerResponse)

-- | 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