{-# 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.ResumeCluster
-- 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)
--
-- Resumes a paused cluster.
module Amazonka.Redshift.ResumeCluster
  ( -- * Creating a Request
    ResumeCluster (..),
    newResumeCluster,

    -- * Request Lenses
    resumeCluster_clusterIdentifier,

    -- * Destructuring the Response
    ResumeClusterResponse (..),
    newResumeClusterResponse,

    -- * Response Lenses
    resumeClusterResponse_cluster,
    resumeClusterResponse_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 resume cluster operation. For example, a scheduled action to
-- run the @ResumeCluster@ API operation.
--
-- /See:/ 'newResumeCluster' smart constructor.
data ResumeCluster = ResumeCluster'
  { -- | The identifier of the cluster to be resumed.
    ResumeCluster -> Text
clusterIdentifier :: Prelude.Text
  }
  deriving (ResumeCluster -> ResumeCluster -> Bool
(ResumeCluster -> ResumeCluster -> Bool)
-> (ResumeCluster -> ResumeCluster -> Bool) -> Eq ResumeCluster
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ResumeCluster -> ResumeCluster -> Bool
$c/= :: ResumeCluster -> ResumeCluster -> Bool
== :: ResumeCluster -> ResumeCluster -> Bool
$c== :: ResumeCluster -> ResumeCluster -> Bool
Prelude.Eq, ReadPrec [ResumeCluster]
ReadPrec ResumeCluster
Int -> ReadS ResumeCluster
ReadS [ResumeCluster]
(Int -> ReadS ResumeCluster)
-> ReadS [ResumeCluster]
-> ReadPrec ResumeCluster
-> ReadPrec [ResumeCluster]
-> Read ResumeCluster
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ResumeCluster]
$creadListPrec :: ReadPrec [ResumeCluster]
readPrec :: ReadPrec ResumeCluster
$creadPrec :: ReadPrec ResumeCluster
readList :: ReadS [ResumeCluster]
$creadList :: ReadS [ResumeCluster]
readsPrec :: Int -> ReadS ResumeCluster
$creadsPrec :: Int -> ReadS ResumeCluster
Prelude.Read, Int -> ResumeCluster -> ShowS
[ResumeCluster] -> ShowS
ResumeCluster -> String
(Int -> ResumeCluster -> ShowS)
-> (ResumeCluster -> String)
-> ([ResumeCluster] -> ShowS)
-> Show ResumeCluster
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ResumeCluster] -> ShowS
$cshowList :: [ResumeCluster] -> ShowS
show :: ResumeCluster -> String
$cshow :: ResumeCluster -> String
showsPrec :: Int -> ResumeCluster -> ShowS
$cshowsPrec :: Int -> ResumeCluster -> ShowS
Prelude.Show, (forall x. ResumeCluster -> Rep ResumeCluster x)
-> (forall x. Rep ResumeCluster x -> ResumeCluster)
-> Generic ResumeCluster
forall x. Rep ResumeCluster x -> ResumeCluster
forall x. ResumeCluster -> Rep ResumeCluster x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ResumeCluster x -> ResumeCluster
$cfrom :: forall x. ResumeCluster -> Rep ResumeCluster x
Prelude.Generic)

-- |
-- Create a value of 'ResumeCluster' 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', 'resumeCluster_clusterIdentifier' - The identifier of the cluster to be resumed.
newResumeCluster ::
  -- | 'clusterIdentifier'
  Prelude.Text ->
  ResumeCluster
newResumeCluster :: Text -> ResumeCluster
newResumeCluster Text
pClusterIdentifier_ =
  ResumeCluster' :: Text -> ResumeCluster
ResumeCluster'
    { $sel:clusterIdentifier:ResumeCluster' :: Text
clusterIdentifier =
        Text
pClusterIdentifier_
    }

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

instance Core.AWSRequest ResumeCluster where
  type
    AWSResponse ResumeCluster =
      ResumeClusterResponse
  request :: ResumeCluster -> Request ResumeCluster
request = Service -> ResumeCluster -> Request ResumeCluster
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy ResumeCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ResumeCluster)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse ResumeCluster))
-> Logger
-> Service
-> Proxy ResumeCluster
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse ResumeCluster)))
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
"ResumeClusterResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Maybe Cluster -> Int -> ResumeClusterResponse
ResumeClusterResponse'
            (Maybe Cluster -> Int -> ResumeClusterResponse)
-> Either String (Maybe Cluster)
-> Either String (Int -> ResumeClusterResponse)
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 -> ResumeClusterResponse)
-> Either String Int -> Either String ResumeClusterResponse
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 ResumeCluster

instance Prelude.NFData ResumeCluster

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

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

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

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

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

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

instance Prelude.NFData ResumeClusterResponse