{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# 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.Types.ClusterDbRevision
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Redshift.Types.ClusterDbRevision 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.Internal
import Amazonka.Redshift.Types.RevisionTarget

-- | Describes a @ClusterDbRevision@.
--
-- /See:/ 'newClusterDbRevision' smart constructor.
data ClusterDbRevision = ClusterDbRevision'
  { -- | The unique identifier of the cluster.
    ClusterDbRevision -> Maybe Text
clusterIdentifier :: Prelude.Maybe Prelude.Text,
    -- | A string representing the current cluster version.
    ClusterDbRevision -> Maybe Text
currentDatabaseRevision :: Prelude.Maybe Prelude.Text,
    -- | The date on which the database revision was released.
    ClusterDbRevision -> Maybe ISO8601
databaseRevisionReleaseDate :: Prelude.Maybe Data.ISO8601,
    -- | A list of @RevisionTarget@ objects, where each object describes the
    -- database revision that a cluster can be updated to.
    ClusterDbRevision -> Maybe [RevisionTarget]
revisionTargets :: Prelude.Maybe [RevisionTarget]
  }
  deriving (ClusterDbRevision -> ClusterDbRevision -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClusterDbRevision -> ClusterDbRevision -> Bool
$c/= :: ClusterDbRevision -> ClusterDbRevision -> Bool
== :: ClusterDbRevision -> ClusterDbRevision -> Bool
$c== :: ClusterDbRevision -> ClusterDbRevision -> Bool
Prelude.Eq, ReadPrec [ClusterDbRevision]
ReadPrec ClusterDbRevision
Int -> ReadS ClusterDbRevision
ReadS [ClusterDbRevision]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ClusterDbRevision]
$creadListPrec :: ReadPrec [ClusterDbRevision]
readPrec :: ReadPrec ClusterDbRevision
$creadPrec :: ReadPrec ClusterDbRevision
readList :: ReadS [ClusterDbRevision]
$creadList :: ReadS [ClusterDbRevision]
readsPrec :: Int -> ReadS ClusterDbRevision
$creadsPrec :: Int -> ReadS ClusterDbRevision
Prelude.Read, Int -> ClusterDbRevision -> ShowS
[ClusterDbRevision] -> ShowS
ClusterDbRevision -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClusterDbRevision] -> ShowS
$cshowList :: [ClusterDbRevision] -> ShowS
show :: ClusterDbRevision -> String
$cshow :: ClusterDbRevision -> String
showsPrec :: Int -> ClusterDbRevision -> ShowS
$cshowsPrec :: Int -> ClusterDbRevision -> ShowS
Prelude.Show, forall x. Rep ClusterDbRevision x -> ClusterDbRevision
forall x. ClusterDbRevision -> Rep ClusterDbRevision x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ClusterDbRevision x -> ClusterDbRevision
$cfrom :: forall x. ClusterDbRevision -> Rep ClusterDbRevision x
Prelude.Generic)

-- |
-- Create a value of 'ClusterDbRevision' 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', 'clusterDbRevision_clusterIdentifier' - The unique identifier of the cluster.
--
-- 'currentDatabaseRevision', 'clusterDbRevision_currentDatabaseRevision' - A string representing the current cluster version.
--
-- 'databaseRevisionReleaseDate', 'clusterDbRevision_databaseRevisionReleaseDate' - The date on which the database revision was released.
--
-- 'revisionTargets', 'clusterDbRevision_revisionTargets' - A list of @RevisionTarget@ objects, where each object describes the
-- database revision that a cluster can be updated to.
newClusterDbRevision ::
  ClusterDbRevision
newClusterDbRevision :: ClusterDbRevision
newClusterDbRevision =
  ClusterDbRevision'
    { $sel:clusterIdentifier:ClusterDbRevision' :: Maybe Text
clusterIdentifier =
        forall a. Maybe a
Prelude.Nothing,
      $sel:currentDatabaseRevision:ClusterDbRevision' :: Maybe Text
currentDatabaseRevision = forall a. Maybe a
Prelude.Nothing,
      $sel:databaseRevisionReleaseDate:ClusterDbRevision' :: Maybe ISO8601
databaseRevisionReleaseDate = forall a. Maybe a
Prelude.Nothing,
      $sel:revisionTargets:ClusterDbRevision' :: Maybe [RevisionTarget]
revisionTargets = forall a. Maybe a
Prelude.Nothing
    }

-- | The unique identifier of the cluster.
clusterDbRevision_clusterIdentifier :: Lens.Lens' ClusterDbRevision (Prelude.Maybe Prelude.Text)
clusterDbRevision_clusterIdentifier :: Lens' ClusterDbRevision (Maybe Text)
clusterDbRevision_clusterIdentifier = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterDbRevision' {Maybe Text
clusterIdentifier :: Maybe Text
$sel:clusterIdentifier:ClusterDbRevision' :: ClusterDbRevision -> Maybe Text
clusterIdentifier} -> Maybe Text
clusterIdentifier) (\s :: ClusterDbRevision
s@ClusterDbRevision' {} Maybe Text
a -> ClusterDbRevision
s {$sel:clusterIdentifier:ClusterDbRevision' :: Maybe Text
clusterIdentifier = Maybe Text
a} :: ClusterDbRevision)

-- | A string representing the current cluster version.
clusterDbRevision_currentDatabaseRevision :: Lens.Lens' ClusterDbRevision (Prelude.Maybe Prelude.Text)
clusterDbRevision_currentDatabaseRevision :: Lens' ClusterDbRevision (Maybe Text)
clusterDbRevision_currentDatabaseRevision = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterDbRevision' {Maybe Text
currentDatabaseRevision :: Maybe Text
$sel:currentDatabaseRevision:ClusterDbRevision' :: ClusterDbRevision -> Maybe Text
currentDatabaseRevision} -> Maybe Text
currentDatabaseRevision) (\s :: ClusterDbRevision
s@ClusterDbRevision' {} Maybe Text
a -> ClusterDbRevision
s {$sel:currentDatabaseRevision:ClusterDbRevision' :: Maybe Text
currentDatabaseRevision = Maybe Text
a} :: ClusterDbRevision)

-- | The date on which the database revision was released.
clusterDbRevision_databaseRevisionReleaseDate :: Lens.Lens' ClusterDbRevision (Prelude.Maybe Prelude.UTCTime)
clusterDbRevision_databaseRevisionReleaseDate :: Lens' ClusterDbRevision (Maybe UTCTime)
clusterDbRevision_databaseRevisionReleaseDate = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterDbRevision' {Maybe ISO8601
databaseRevisionReleaseDate :: Maybe ISO8601
$sel:databaseRevisionReleaseDate:ClusterDbRevision' :: ClusterDbRevision -> Maybe ISO8601
databaseRevisionReleaseDate} -> Maybe ISO8601
databaseRevisionReleaseDate) (\s :: ClusterDbRevision
s@ClusterDbRevision' {} Maybe ISO8601
a -> ClusterDbRevision
s {$sel:databaseRevisionReleaseDate:ClusterDbRevision' :: Maybe ISO8601
databaseRevisionReleaseDate = Maybe ISO8601
a} :: ClusterDbRevision) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall (a :: Format). Iso' (Time a) UTCTime
Data._Time

-- | A list of @RevisionTarget@ objects, where each object describes the
-- database revision that a cluster can be updated to.
clusterDbRevision_revisionTargets :: Lens.Lens' ClusterDbRevision (Prelude.Maybe [RevisionTarget])
clusterDbRevision_revisionTargets :: Lens' ClusterDbRevision (Maybe [RevisionTarget])
clusterDbRevision_revisionTargets = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterDbRevision' {Maybe [RevisionTarget]
revisionTargets :: Maybe [RevisionTarget]
$sel:revisionTargets:ClusterDbRevision' :: ClusterDbRevision -> Maybe [RevisionTarget]
revisionTargets} -> Maybe [RevisionTarget]
revisionTargets) (\s :: ClusterDbRevision
s@ClusterDbRevision' {} Maybe [RevisionTarget]
a -> ClusterDbRevision
s {$sel:revisionTargets:ClusterDbRevision' :: Maybe [RevisionTarget]
revisionTargets = Maybe [RevisionTarget]
a} :: ClusterDbRevision) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromXML ClusterDbRevision where
  parseXML :: [Node] -> Either String ClusterDbRevision
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe ISO8601
-> Maybe [RevisionTarget]
-> ClusterDbRevision
ClusterDbRevision'
      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
"ClusterIdentifier")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"CurrentDatabaseRevision")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"DatabaseRevisionReleaseDate")
      forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x
                      forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Data..@? Text
"RevisionTargets"
                      forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                      forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (forall a. FromXML a => Text -> [Node] -> Either String [a]
Data.parseXMLList Text
"RevisionTarget")
                  )

instance Prelude.Hashable ClusterDbRevision where
  hashWithSalt :: Int -> ClusterDbRevision -> Int
hashWithSalt Int
_salt ClusterDbRevision' {Maybe [RevisionTarget]
Maybe Text
Maybe ISO8601
revisionTargets :: Maybe [RevisionTarget]
databaseRevisionReleaseDate :: Maybe ISO8601
currentDatabaseRevision :: Maybe Text
clusterIdentifier :: Maybe Text
$sel:revisionTargets:ClusterDbRevision' :: ClusterDbRevision -> Maybe [RevisionTarget]
$sel:databaseRevisionReleaseDate:ClusterDbRevision' :: ClusterDbRevision -> Maybe ISO8601
$sel:currentDatabaseRevision:ClusterDbRevision' :: ClusterDbRevision -> Maybe Text
$sel:clusterIdentifier:ClusterDbRevision' :: ClusterDbRevision -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
clusterIdentifier
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
currentDatabaseRevision
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ISO8601
databaseRevisionReleaseDate
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [RevisionTarget]
revisionTargets

instance Prelude.NFData ClusterDbRevision where
  rnf :: ClusterDbRevision -> ()
rnf ClusterDbRevision' {Maybe [RevisionTarget]
Maybe Text
Maybe ISO8601
revisionTargets :: Maybe [RevisionTarget]
databaseRevisionReleaseDate :: Maybe ISO8601
currentDatabaseRevision :: Maybe Text
clusterIdentifier :: Maybe Text
$sel:revisionTargets:ClusterDbRevision' :: ClusterDbRevision -> Maybe [RevisionTarget]
$sel:databaseRevisionReleaseDate:ClusterDbRevision' :: ClusterDbRevision -> Maybe ISO8601
$sel:currentDatabaseRevision:ClusterDbRevision' :: ClusterDbRevision -> Maybe Text
$sel:clusterIdentifier:ClusterDbRevision' :: ClusterDbRevision -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
clusterIdentifier
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
currentDatabaseRevision
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ISO8601
databaseRevisionReleaseDate
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [RevisionTarget]
revisionTargets