{-# 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.Redshift.RebootCluster
-- 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 cluster. This action is taken as soon as possible. It results
-- in a momentary outage to the cluster, during which the cluster status is
-- set to @rebooting@. A cluster event is created when the reboot is
-- completed. Any pending cluster modifications (see ModifyCluster) are
-- applied at this reboot. For more information about managing clusters, go
-- to
-- <https://docs.aws.amazon.com/redshift/latest/mgmt/working-with-clusters.html Amazon Redshift Clusters>
-- in the /Amazon Redshift Cluster Management Guide/.
module Amazonka.Redshift.RebootCluster
  ( -- * Creating a Request
    RebootCluster (..),
    newRebootCluster,

    -- * Request Lenses
    rebootCluster_clusterIdentifier,

    -- * Destructuring the Response
    RebootClusterResponse (..),
    newRebootClusterResponse,

    -- * Response Lenses
    rebootClusterResponse_cluster,
    rebootClusterResponse_httpStatus,
  )
where

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

-- |
--
-- /See:/ 'newRebootCluster' smart constructor.
data RebootCluster = RebootCluster'
  { -- | The cluster identifier.
    RebootCluster -> Text
clusterIdentifier :: Prelude.Text
  }
  deriving (RebootCluster -> RebootCluster -> Bool
(RebootCluster -> RebootCluster -> Bool)
-> (RebootCluster -> RebootCluster -> Bool) -> Eq RebootCluster
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RebootCluster -> RebootCluster -> Bool
$c/= :: RebootCluster -> RebootCluster -> Bool
== :: RebootCluster -> RebootCluster -> Bool
$c== :: RebootCluster -> RebootCluster -> Bool
Prelude.Eq, ReadPrec [RebootCluster]
ReadPrec RebootCluster
Int -> ReadS RebootCluster
ReadS [RebootCluster]
(Int -> ReadS RebootCluster)
-> ReadS [RebootCluster]
-> ReadPrec RebootCluster
-> ReadPrec [RebootCluster]
-> Read RebootCluster
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RebootCluster]
$creadListPrec :: ReadPrec [RebootCluster]
readPrec :: ReadPrec RebootCluster
$creadPrec :: ReadPrec RebootCluster
readList :: ReadS [RebootCluster]
$creadList :: ReadS [RebootCluster]
readsPrec :: Int -> ReadS RebootCluster
$creadsPrec :: Int -> ReadS RebootCluster
Prelude.Read, Int -> RebootCluster -> ShowS
[RebootCluster] -> ShowS
RebootCluster -> String
(Int -> RebootCluster -> ShowS)
-> (RebootCluster -> String)
-> ([RebootCluster] -> ShowS)
-> Show RebootCluster
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RebootCluster] -> ShowS
$cshowList :: [RebootCluster] -> ShowS
show :: RebootCluster -> String
$cshow :: RebootCluster -> String
showsPrec :: Int -> RebootCluster -> ShowS
$cshowsPrec :: Int -> RebootCluster -> ShowS
Prelude.Show, (forall x. RebootCluster -> Rep RebootCluster x)
-> (forall x. Rep RebootCluster x -> RebootCluster)
-> Generic RebootCluster
forall x. Rep RebootCluster x -> RebootCluster
forall x. RebootCluster -> Rep RebootCluster x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RebootCluster x -> RebootCluster
$cfrom :: forall x. RebootCluster -> Rep RebootCluster x
Prelude.Generic)

-- |
-- Create a value of 'RebootCluster' 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:
--
-- 'clusterIdentifier', 'rebootCluster_clusterIdentifier' - The cluster identifier.
newRebootCluster ::
  -- | 'clusterIdentifier'
  Prelude.Text ->
  RebootCluster
newRebootCluster :: Text -> RebootCluster
newRebootCluster Text
pClusterIdentifier_ =
  RebootCluster' :: Text -> RebootCluster
RebootCluster'
    { $sel:clusterIdentifier:RebootCluster' :: Text
clusterIdentifier =
        Text
pClusterIdentifier_
    }

-- | The cluster identifier.
rebootCluster_clusterIdentifier :: Lens.Lens' RebootCluster Prelude.Text
rebootCluster_clusterIdentifier :: (Text -> f Text) -> RebootCluster -> f RebootCluster
rebootCluster_clusterIdentifier = (RebootCluster -> Text)
-> (RebootCluster -> Text -> RebootCluster)
-> Lens RebootCluster RebootCluster Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RebootCluster' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:RebootCluster' :: RebootCluster -> Text
clusterIdentifier} -> Text
clusterIdentifier) (\s :: RebootCluster
s@RebootCluster' {} Text
a -> RebootCluster
s {$sel:clusterIdentifier:RebootCluster' :: Text
clusterIdentifier = Text
a} :: RebootCluster)

instance Core.AWSRequest RebootCluster where
  type
    AWSResponse RebootCluster =
      RebootClusterResponse
  request :: RebootCluster -> Request RebootCluster
request = Service -> RebootCluster -> Request RebootCluster
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy RebootCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RebootCluster)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse RebootCluster))
-> Logger
-> Service
-> Proxy RebootCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RebootCluster)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"RebootClusterResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Cluster -> Int -> RebootClusterResponse
RebootClusterResponse'
            (Maybe Cluster -> Int -> RebootClusterResponse)
-> Either String (Maybe Cluster)
-> Either String (Int -> RebootClusterResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Cluster)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Cluster")
            Either String (Int -> RebootClusterResponse)
-> Either String Int -> Either String RebootClusterResponse
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 RebootCluster

instance Prelude.NFData RebootCluster

instance Core.ToHeaders RebootCluster where
  toHeaders :: RebootCluster -> ResponseHeaders
toHeaders = ResponseHeaders -> RebootCluster -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath RebootCluster where
  toPath :: RebootCluster -> ByteString
toPath = ByteString -> RebootCluster -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery RebootCluster where
  toQuery :: RebootCluster -> QueryString
toQuery RebootCluster' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:RebootCluster' :: RebootCluster -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"RebootCluster" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2012-12-01" :: Prelude.ByteString),
        ByteString
"ClusterIdentifier" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
clusterIdentifier
      ]

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

-- |
-- Create a value of 'RebootClusterResponse' 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:
--
-- 'cluster', 'rebootClusterResponse_cluster' - Undocumented member.
--
-- 'httpStatus', 'rebootClusterResponse_httpStatus' - The response's http status code.
newRebootClusterResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  RebootClusterResponse
newRebootClusterResponse :: Int -> RebootClusterResponse
newRebootClusterResponse Int
pHttpStatus_ =
  RebootClusterResponse' :: Maybe Cluster -> Int -> RebootClusterResponse
RebootClusterResponse'
    { $sel:cluster:RebootClusterResponse' :: Maybe Cluster
cluster = Maybe Cluster
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:RebootClusterResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
rebootClusterResponse_cluster :: Lens.Lens' RebootClusterResponse (Prelude.Maybe Cluster)
rebootClusterResponse_cluster :: (Maybe Cluster -> f (Maybe Cluster))
-> RebootClusterResponse -> f RebootClusterResponse
rebootClusterResponse_cluster = (RebootClusterResponse -> Maybe Cluster)
-> (RebootClusterResponse
    -> Maybe Cluster -> RebootClusterResponse)
-> Lens
     RebootClusterResponse
     RebootClusterResponse
     (Maybe Cluster)
     (Maybe Cluster)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RebootClusterResponse' {Maybe Cluster
cluster :: Maybe Cluster
$sel:cluster:RebootClusterResponse' :: RebootClusterResponse -> Maybe Cluster
cluster} -> Maybe Cluster
cluster) (\s :: RebootClusterResponse
s@RebootClusterResponse' {} Maybe Cluster
a -> RebootClusterResponse
s {$sel:cluster:RebootClusterResponse' :: Maybe Cluster
cluster = Maybe Cluster
a} :: RebootClusterResponse)

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

instance Prelude.NFData RebootClusterResponse