{-# 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-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)
--
-- 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.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

-- | 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
(PauseCluster -> PauseCluster -> Bool)
-> (PauseCluster -> PauseCluster -> Bool) -> Eq PauseCluster
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]
(Int -> ReadS PauseCluster)
-> ReadS [PauseCluster]
-> ReadPrec PauseCluster
-> ReadPrec [PauseCluster]
-> Read 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
(Int -> PauseCluster -> ShowS)
-> (PauseCluster -> String)
-> ([PauseCluster] -> ShowS)
-> Show PauseCluster
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. PauseCluster -> Rep PauseCluster x)
-> (forall x. Rep PauseCluster x -> PauseCluster)
-> Generic PauseCluster
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' :: Text -> PauseCluster
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 :: (Text -> f Text) -> PauseCluster -> f PauseCluster
pauseCluster_clusterIdentifier = (PauseCluster -> Text)
-> (PauseCluster -> Text -> PauseCluster)
-> Lens PauseCluster PauseCluster Text Text
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 :: PauseCluster -> Request PauseCluster
request = Service -> PauseCluster -> Request PauseCluster
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy PauseCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PauseCluster)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse PauseCluster))
-> Logger
-> Service
-> Proxy PauseCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse PauseCluster)))
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
"PauseClusterResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Cluster -> Int -> PauseClusterResponse
PauseClusterResponse'
            (Maybe Cluster -> Int -> PauseClusterResponse)
-> Either String (Maybe Cluster)
-> Either String (Int -> PauseClusterResponse)
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 -> PauseClusterResponse)
-> Either String Int -> Either String PauseClusterResponse
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 PauseCluster

instance Prelude.NFData PauseCluster

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

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

instance Core.ToQuery PauseCluster where
  toQuery :: PauseCluster -> QueryString
toQuery PauseCluster' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:PauseCluster' :: PauseCluster -> 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
"PauseCluster" :: 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:/ '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
(PauseClusterResponse -> PauseClusterResponse -> Bool)
-> (PauseClusterResponse -> PauseClusterResponse -> Bool)
-> Eq PauseClusterResponse
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]
(Int -> ReadS PauseClusterResponse)
-> ReadS [PauseClusterResponse]
-> ReadPrec PauseClusterResponse
-> ReadPrec [PauseClusterResponse]
-> Read 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
(Int -> PauseClusterResponse -> ShowS)
-> (PauseClusterResponse -> String)
-> ([PauseClusterResponse] -> ShowS)
-> Show PauseClusterResponse
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. PauseClusterResponse -> Rep PauseClusterResponse x)
-> (forall x. Rep PauseClusterResponse x -> PauseClusterResponse)
-> Generic PauseClusterResponse
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' :: Maybe Cluster -> Int -> PauseClusterResponse
PauseClusterResponse'
    { $sel:cluster:PauseClusterResponse' :: Maybe Cluster
cluster = Maybe 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 :: (Maybe Cluster -> f (Maybe Cluster))
-> PauseClusterResponse -> f PauseClusterResponse
pauseClusterResponse_cluster = (PauseClusterResponse -> Maybe Cluster)
-> (PauseClusterResponse -> Maybe Cluster -> PauseClusterResponse)
-> Lens
     PauseClusterResponse
     PauseClusterResponse
     (Maybe Cluster)
     (Maybe 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 :: (Int -> f Int) -> PauseClusterResponse -> f PauseClusterResponse
pauseClusterResponse_httpStatus = (PauseClusterResponse -> Int)
-> (PauseClusterResponse -> Int -> PauseClusterResponse)
-> Lens PauseClusterResponse PauseClusterResponse Int Int
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