{-# 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.PauseCluster
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Pauses a cluster.
module Amazonka.Redshift.PauseCluster
  ( -- * Creating a Request
    PauseCluster (..),
    newPauseCluster,

    -- * Request Lenses
    pauseCluster_clusterIdentifier,

    -- * Destructuring the Response
    PauseClusterResponse (..),
    newPauseClusterResponse,

    -- * Response Lenses
    pauseClusterResponse_cluster,
    pauseClusterResponse_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

-- | Describes a pause cluster operation. For example, a scheduled action to
-- run the @PauseCluster@ API operation.
--
-- /See:/ 'newPauseCluster' smart constructor.
data PauseCluster = PauseCluster'
  { -- | The identifier of the cluster to be paused.
    PauseCluster -> Text
clusterIdentifier :: Prelude.Text
  }
  deriving (PauseCluster -> PauseCluster -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PauseCluster -> PauseCluster -> Bool
$c/= :: PauseCluster -> PauseCluster -> Bool
== :: PauseCluster -> PauseCluster -> Bool
$c== :: PauseCluster -> PauseCluster -> Bool
Prelude.Eq, ReadPrec [PauseCluster]
ReadPrec PauseCluster
Int -> ReadS PauseCluster
ReadS [PauseCluster]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PauseCluster]
$creadListPrec :: ReadPrec [PauseCluster]
readPrec :: ReadPrec PauseCluster
$creadPrec :: ReadPrec PauseCluster
readList :: ReadS [PauseCluster]
$creadList :: ReadS [PauseCluster]
readsPrec :: Int -> ReadS PauseCluster
$creadsPrec :: Int -> ReadS PauseCluster
Prelude.Read, Int -> PauseCluster -> ShowS
[PauseCluster] -> ShowS
PauseCluster -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PauseCluster] -> ShowS
$cshowList :: [PauseCluster] -> ShowS
show :: PauseCluster -> String
$cshow :: PauseCluster -> String
showsPrec :: Int -> PauseCluster -> ShowS
$cshowsPrec :: Int -> PauseCluster -> ShowS
Prelude.Show, forall x. Rep PauseCluster x -> PauseCluster
forall x. PauseCluster -> Rep PauseCluster x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PauseCluster x -> PauseCluster
$cfrom :: forall x. PauseCluster -> Rep PauseCluster x
Prelude.Generic)

-- |
-- Create a value of 'PauseCluster' 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', 'pauseCluster_clusterIdentifier' - The identifier of the cluster to be paused.
newPauseCluster ::
  -- | 'clusterIdentifier'
  Prelude.Text ->
  PauseCluster
newPauseCluster :: Text -> PauseCluster
newPauseCluster Text
pClusterIdentifier_ =
  PauseCluster'
    { $sel:clusterIdentifier:PauseCluster' :: Text
clusterIdentifier =
        Text
pClusterIdentifier_
    }

-- | The identifier of the cluster to be paused.
pauseCluster_clusterIdentifier :: Lens.Lens' PauseCluster Prelude.Text
pauseCluster_clusterIdentifier :: Lens' PauseCluster Text
pauseCluster_clusterIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PauseCluster' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:PauseCluster' :: PauseCluster -> Text
clusterIdentifier} -> Text
clusterIdentifier) (\s :: PauseCluster
s@PauseCluster' {} Text
a -> PauseCluster
s {$sel:clusterIdentifier:PauseCluster' :: Text
clusterIdentifier = Text
a} :: PauseCluster)

instance Core.AWSRequest PauseCluster where
  type AWSResponse PauseCluster = PauseClusterResponse
  request :: (Service -> Service) -> PauseCluster -> Request PauseCluster
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 PauseCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PauseCluster)))
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
"PauseClusterResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Cluster -> Int -> PauseClusterResponse
PauseClusterResponse'
            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 PauseCluster where
  hashWithSalt :: Int -> PauseCluster -> Int
hashWithSalt Int
_salt PauseCluster' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:PauseCluster' :: PauseCluster -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
clusterIdentifier

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

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

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

instance Data.ToQuery PauseCluster where
  toQuery :: PauseCluster -> QueryString
toQuery PauseCluster' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:PauseCluster' :: PauseCluster -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"PauseCluster" :: 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:/ 'newPauseClusterResponse' smart constructor.
data PauseClusterResponse = PauseClusterResponse'
  { PauseClusterResponse -> Maybe Cluster
cluster :: Prelude.Maybe Cluster,
    -- | The response's http status code.
    PauseClusterResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (PauseClusterResponse -> PauseClusterResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PauseClusterResponse -> PauseClusterResponse -> Bool
$c/= :: PauseClusterResponse -> PauseClusterResponse -> Bool
== :: PauseClusterResponse -> PauseClusterResponse -> Bool
$c== :: PauseClusterResponse -> PauseClusterResponse -> Bool
Prelude.Eq, ReadPrec [PauseClusterResponse]
ReadPrec PauseClusterResponse
Int -> ReadS PauseClusterResponse
ReadS [PauseClusterResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PauseClusterResponse]
$creadListPrec :: ReadPrec [PauseClusterResponse]
readPrec :: ReadPrec PauseClusterResponse
$creadPrec :: ReadPrec PauseClusterResponse
readList :: ReadS [PauseClusterResponse]
$creadList :: ReadS [PauseClusterResponse]
readsPrec :: Int -> ReadS PauseClusterResponse
$creadsPrec :: Int -> ReadS PauseClusterResponse
Prelude.Read, Int -> PauseClusterResponse -> ShowS
[PauseClusterResponse] -> ShowS
PauseClusterResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PauseClusterResponse] -> ShowS
$cshowList :: [PauseClusterResponse] -> ShowS
show :: PauseClusterResponse -> String
$cshow :: PauseClusterResponse -> String
showsPrec :: Int -> PauseClusterResponse -> ShowS
$cshowsPrec :: Int -> PauseClusterResponse -> ShowS
Prelude.Show, forall x. Rep PauseClusterResponse x -> PauseClusterResponse
forall x. PauseClusterResponse -> Rep PauseClusterResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PauseClusterResponse x -> PauseClusterResponse
$cfrom :: forall x. PauseClusterResponse -> Rep PauseClusterResponse x
Prelude.Generic)

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

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

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

instance Prelude.NFData PauseClusterResponse where
  rnf :: PauseClusterResponse -> ()
rnf PauseClusterResponse' {Int
Maybe Cluster
httpStatus :: Int
cluster :: Maybe Cluster
$sel:httpStatus:PauseClusterResponse' :: PauseClusterResponse -> Int
$sel:cluster:PauseClusterResponse' :: PauseClusterResponse -> 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