{-# 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.ModifyClusterDbRevision
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Modifies the database revision of a cluster. The database revision is a
-- unique revision of the database running in a cluster.
module Amazonka.Redshift.ModifyClusterDbRevision
  ( -- * Creating a Request
    ModifyClusterDbRevision (..),
    newModifyClusterDbRevision,

    -- * Request Lenses
    modifyClusterDbRevision_clusterIdentifier,
    modifyClusterDbRevision_revisionTarget,

    -- * Destructuring the Response
    ModifyClusterDbRevisionResponse (..),
    newModifyClusterDbRevisionResponse,

    -- * Response Lenses
    modifyClusterDbRevisionResponse_cluster,
    modifyClusterDbRevisionResponse_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:/ 'newModifyClusterDbRevision' smart constructor.
data ModifyClusterDbRevision = ModifyClusterDbRevision'
  { -- | The unique identifier of a cluster whose database revision you want to
    -- modify.
    --
    -- Example: @examplecluster@
    ModifyClusterDbRevision -> Text
clusterIdentifier :: Prelude.Text,
    -- | The identifier of the database revision. You can retrieve this value
    -- from the response to the DescribeClusterDbRevisions request.
    ModifyClusterDbRevision -> Text
revisionTarget :: Prelude.Text
  }
  deriving (ModifyClusterDbRevision -> ModifyClusterDbRevision -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ModifyClusterDbRevision -> ModifyClusterDbRevision -> Bool
$c/= :: ModifyClusterDbRevision -> ModifyClusterDbRevision -> Bool
== :: ModifyClusterDbRevision -> ModifyClusterDbRevision -> Bool
$c== :: ModifyClusterDbRevision -> ModifyClusterDbRevision -> Bool
Prelude.Eq, ReadPrec [ModifyClusterDbRevision]
ReadPrec ModifyClusterDbRevision
Int -> ReadS ModifyClusterDbRevision
ReadS [ModifyClusterDbRevision]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ModifyClusterDbRevision]
$creadListPrec :: ReadPrec [ModifyClusterDbRevision]
readPrec :: ReadPrec ModifyClusterDbRevision
$creadPrec :: ReadPrec ModifyClusterDbRevision
readList :: ReadS [ModifyClusterDbRevision]
$creadList :: ReadS [ModifyClusterDbRevision]
readsPrec :: Int -> ReadS ModifyClusterDbRevision
$creadsPrec :: Int -> ReadS ModifyClusterDbRevision
Prelude.Read, Int -> ModifyClusterDbRevision -> ShowS
[ModifyClusterDbRevision] -> ShowS
ModifyClusterDbRevision -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ModifyClusterDbRevision] -> ShowS
$cshowList :: [ModifyClusterDbRevision] -> ShowS
show :: ModifyClusterDbRevision -> String
$cshow :: ModifyClusterDbRevision -> String
showsPrec :: Int -> ModifyClusterDbRevision -> ShowS
$cshowsPrec :: Int -> ModifyClusterDbRevision -> ShowS
Prelude.Show, forall x. Rep ModifyClusterDbRevision x -> ModifyClusterDbRevision
forall x. ModifyClusterDbRevision -> Rep ModifyClusterDbRevision x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ModifyClusterDbRevision x -> ModifyClusterDbRevision
$cfrom :: forall x. ModifyClusterDbRevision -> Rep ModifyClusterDbRevision x
Prelude.Generic)

-- |
-- Create a value of 'ModifyClusterDbRevision' 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', 'modifyClusterDbRevision_clusterIdentifier' - The unique identifier of a cluster whose database revision you want to
-- modify.
--
-- Example: @examplecluster@
--
-- 'revisionTarget', 'modifyClusterDbRevision_revisionTarget' - The identifier of the database revision. You can retrieve this value
-- from the response to the DescribeClusterDbRevisions request.
newModifyClusterDbRevision ::
  -- | 'clusterIdentifier'
  Prelude.Text ->
  -- | 'revisionTarget'
  Prelude.Text ->
  ModifyClusterDbRevision
newModifyClusterDbRevision :: Text -> Text -> ModifyClusterDbRevision
newModifyClusterDbRevision
  Text
pClusterIdentifier_
  Text
pRevisionTarget_ =
    ModifyClusterDbRevision'
      { $sel:clusterIdentifier:ModifyClusterDbRevision' :: Text
clusterIdentifier =
          Text
pClusterIdentifier_,
        $sel:revisionTarget:ModifyClusterDbRevision' :: Text
revisionTarget = Text
pRevisionTarget_
      }

-- | The unique identifier of a cluster whose database revision you want to
-- modify.
--
-- Example: @examplecluster@
modifyClusterDbRevision_clusterIdentifier :: Lens.Lens' ModifyClusterDbRevision Prelude.Text
modifyClusterDbRevision_clusterIdentifier :: Lens' ModifyClusterDbRevision Text
modifyClusterDbRevision_clusterIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyClusterDbRevision' {Text
clusterIdentifier :: Text
$sel:clusterIdentifier:ModifyClusterDbRevision' :: ModifyClusterDbRevision -> Text
clusterIdentifier} -> Text
clusterIdentifier) (\s :: ModifyClusterDbRevision
s@ModifyClusterDbRevision' {} Text
a -> ModifyClusterDbRevision
s {$sel:clusterIdentifier:ModifyClusterDbRevision' :: Text
clusterIdentifier = Text
a} :: ModifyClusterDbRevision)

-- | The identifier of the database revision. You can retrieve this value
-- from the response to the DescribeClusterDbRevisions request.
modifyClusterDbRevision_revisionTarget :: Lens.Lens' ModifyClusterDbRevision Prelude.Text
modifyClusterDbRevision_revisionTarget :: Lens' ModifyClusterDbRevision Text
modifyClusterDbRevision_revisionTarget = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ModifyClusterDbRevision' {Text
revisionTarget :: Text
$sel:revisionTarget:ModifyClusterDbRevision' :: ModifyClusterDbRevision -> Text
revisionTarget} -> Text
revisionTarget) (\s :: ModifyClusterDbRevision
s@ModifyClusterDbRevision' {} Text
a -> ModifyClusterDbRevision
s {$sel:revisionTarget:ModifyClusterDbRevision' :: Text
revisionTarget = Text
a} :: ModifyClusterDbRevision)

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

instance Prelude.NFData ModifyClusterDbRevision where
  rnf :: ModifyClusterDbRevision -> ()
rnf ModifyClusterDbRevision' {Text
revisionTarget :: Text
clusterIdentifier :: Text
$sel:revisionTarget:ModifyClusterDbRevision' :: ModifyClusterDbRevision -> Text
$sel:clusterIdentifier:ModifyClusterDbRevision' :: ModifyClusterDbRevision -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
clusterIdentifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
revisionTarget

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

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

instance Data.ToQuery ModifyClusterDbRevision where
  toQuery :: ModifyClusterDbRevision -> QueryString
toQuery ModifyClusterDbRevision' {Text
revisionTarget :: Text
clusterIdentifier :: Text
$sel:revisionTarget:ModifyClusterDbRevision' :: ModifyClusterDbRevision -> Text
$sel:clusterIdentifier:ModifyClusterDbRevision' :: ModifyClusterDbRevision -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: (ByteString
"ModifyClusterDbRevision" :: 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,
        ByteString
"RevisionTarget" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Text
revisionTarget
      ]

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

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

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

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

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