{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
    { $sel:clusterIdentifier:RebootCluster' :: Text
clusterIdentifier =
        Text
pClusterIdentifier_
    }

-- | The cluster identifier.
rebootCluster_clusterIdentifier :: Lens.Lens' RebootCluster Prelude.Text
rebootCluster_clusterIdentifier :: Lens' RebootCluster Text
rebootCluster_clusterIdentifier = 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 :: (Service -> Service) -> RebootCluster -> Request RebootCluster
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.postQuery (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy RebootCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse RebootCluster)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> 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'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"Cluster")
            forall (f :: * -> *) a b. Applicative f => 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 RebootCluster where
  hashWithSalt :: Int -> RebootCluster -> Int
hashWithSalt Int
_salt RebootCluster' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:RebootCluster' :: RebootCluster -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
clusterIdentifier

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

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

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

instance Data.ToQuery RebootCluster where
  toQuery :: RebootCluster -> QueryString
toQuery RebootCluster' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:RebootCluster' :: RebootCluster -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"RebootCluster" :: Prelude.ByteString),
        ByteString
"Version"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"2012-12-01" :: Prelude.ByteString),
        ByteString
"ClusterIdentifier" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: 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
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]
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
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. 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'
    { $sel:cluster:RebootClusterResponse' :: Maybe Cluster
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 :: Lens' RebootClusterResponse (Maybe Cluster)
rebootClusterResponse_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 :: Lens' RebootClusterResponse Int
rebootClusterResponse_httpStatus = 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 where
  rnf :: RebootClusterResponse -> ()
rnf RebootClusterResponse' {Int
Maybe Cluster
httpStatus :: Int
cluster :: Maybe Cluster
$sel:httpStatus:RebootClusterResponse' :: RebootClusterResponse -> Int
$sel:cluster:RebootClusterResponse' :: RebootClusterResponse -> Maybe Cluster
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Cluster
cluster
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus