{-# 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.MaintenanceTrack
-- 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)
module Amazonka.Redshift.Types.MaintenanceTrack where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Redshift.Internal
import Amazonka.Redshift.Types.UpdateTarget

-- | Defines a maintenance track that determines which Amazon Redshift
-- version to apply during a maintenance window. If the value for
-- @MaintenanceTrack@ is @current@, the cluster is updated to the most
-- recently certified maintenance release. If the value is @trailing@, the
-- cluster is updated to the previously certified maintenance release.
--
-- /See:/ 'newMaintenanceTrack' smart constructor.
data MaintenanceTrack = MaintenanceTrack'
  { -- | The version number for the cluster release.
    MaintenanceTrack -> Maybe Text
databaseVersion :: Prelude.Maybe Prelude.Text,
    -- | The name of the maintenance track. Possible values are @current@ and
    -- @trailing@.
    MaintenanceTrack -> Maybe Text
maintenanceTrackName :: Prelude.Maybe Prelude.Text,
    -- | An array of UpdateTarget objects to update with the maintenance track.
    MaintenanceTrack -> Maybe [UpdateTarget]
updateTargets :: Prelude.Maybe [UpdateTarget]
  }
  deriving (MaintenanceTrack -> MaintenanceTrack -> Bool
(MaintenanceTrack -> MaintenanceTrack -> Bool)
-> (MaintenanceTrack -> MaintenanceTrack -> Bool)
-> Eq MaintenanceTrack
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MaintenanceTrack -> MaintenanceTrack -> Bool
$c/= :: MaintenanceTrack -> MaintenanceTrack -> Bool
== :: MaintenanceTrack -> MaintenanceTrack -> Bool
$c== :: MaintenanceTrack -> MaintenanceTrack -> Bool
Prelude.Eq, ReadPrec [MaintenanceTrack]
ReadPrec MaintenanceTrack
Int -> ReadS MaintenanceTrack
ReadS [MaintenanceTrack]
(Int -> ReadS MaintenanceTrack)
-> ReadS [MaintenanceTrack]
-> ReadPrec MaintenanceTrack
-> ReadPrec [MaintenanceTrack]
-> Read MaintenanceTrack
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MaintenanceTrack]
$creadListPrec :: ReadPrec [MaintenanceTrack]
readPrec :: ReadPrec MaintenanceTrack
$creadPrec :: ReadPrec MaintenanceTrack
readList :: ReadS [MaintenanceTrack]
$creadList :: ReadS [MaintenanceTrack]
readsPrec :: Int -> ReadS MaintenanceTrack
$creadsPrec :: Int -> ReadS MaintenanceTrack
Prelude.Read, Int -> MaintenanceTrack -> ShowS
[MaintenanceTrack] -> ShowS
MaintenanceTrack -> String
(Int -> MaintenanceTrack -> ShowS)
-> (MaintenanceTrack -> String)
-> ([MaintenanceTrack] -> ShowS)
-> Show MaintenanceTrack
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MaintenanceTrack] -> ShowS
$cshowList :: [MaintenanceTrack] -> ShowS
show :: MaintenanceTrack -> String
$cshow :: MaintenanceTrack -> String
showsPrec :: Int -> MaintenanceTrack -> ShowS
$cshowsPrec :: Int -> MaintenanceTrack -> ShowS
Prelude.Show, (forall x. MaintenanceTrack -> Rep MaintenanceTrack x)
-> (forall x. Rep MaintenanceTrack x -> MaintenanceTrack)
-> Generic MaintenanceTrack
forall x. Rep MaintenanceTrack x -> MaintenanceTrack
forall x. MaintenanceTrack -> Rep MaintenanceTrack x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep MaintenanceTrack x -> MaintenanceTrack
$cfrom :: forall x. MaintenanceTrack -> Rep MaintenanceTrack x
Prelude.Generic)

-- |
-- Create a value of 'MaintenanceTrack' 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:
--
-- 'databaseVersion', 'maintenanceTrack_databaseVersion' - The version number for the cluster release.
--
-- 'maintenanceTrackName', 'maintenanceTrack_maintenanceTrackName' - The name of the maintenance track. Possible values are @current@ and
-- @trailing@.
--
-- 'updateTargets', 'maintenanceTrack_updateTargets' - An array of UpdateTarget objects to update with the maintenance track.
newMaintenanceTrack ::
  MaintenanceTrack
newMaintenanceTrack :: MaintenanceTrack
newMaintenanceTrack =
  MaintenanceTrack' :: Maybe Text
-> Maybe Text -> Maybe [UpdateTarget] -> MaintenanceTrack
MaintenanceTrack'
    { $sel:databaseVersion:MaintenanceTrack' :: Maybe Text
databaseVersion =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maintenanceTrackName:MaintenanceTrack' :: Maybe Text
maintenanceTrackName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:updateTargets:MaintenanceTrack' :: Maybe [UpdateTarget]
updateTargets = Maybe [UpdateTarget]
forall a. Maybe a
Prelude.Nothing
    }

-- | The version number for the cluster release.
maintenanceTrack_databaseVersion :: Lens.Lens' MaintenanceTrack (Prelude.Maybe Prelude.Text)
maintenanceTrack_databaseVersion :: (Maybe Text -> f (Maybe Text))
-> MaintenanceTrack -> f MaintenanceTrack
maintenanceTrack_databaseVersion = (MaintenanceTrack -> Maybe Text)
-> (MaintenanceTrack -> Maybe Text -> MaintenanceTrack)
-> Lens MaintenanceTrack MaintenanceTrack (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MaintenanceTrack' {Maybe Text
databaseVersion :: Maybe Text
$sel:databaseVersion:MaintenanceTrack' :: MaintenanceTrack -> Maybe Text
databaseVersion} -> Maybe Text
databaseVersion) (\s :: MaintenanceTrack
s@MaintenanceTrack' {} Maybe Text
a -> MaintenanceTrack
s {$sel:databaseVersion:MaintenanceTrack' :: Maybe Text
databaseVersion = Maybe Text
a} :: MaintenanceTrack)

-- | The name of the maintenance track. Possible values are @current@ and
-- @trailing@.
maintenanceTrack_maintenanceTrackName :: Lens.Lens' MaintenanceTrack (Prelude.Maybe Prelude.Text)
maintenanceTrack_maintenanceTrackName :: (Maybe Text -> f (Maybe Text))
-> MaintenanceTrack -> f MaintenanceTrack
maintenanceTrack_maintenanceTrackName = (MaintenanceTrack -> Maybe Text)
-> (MaintenanceTrack -> Maybe Text -> MaintenanceTrack)
-> Lens MaintenanceTrack MaintenanceTrack (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MaintenanceTrack' {Maybe Text
maintenanceTrackName :: Maybe Text
$sel:maintenanceTrackName:MaintenanceTrack' :: MaintenanceTrack -> Maybe Text
maintenanceTrackName} -> Maybe Text
maintenanceTrackName) (\s :: MaintenanceTrack
s@MaintenanceTrack' {} Maybe Text
a -> MaintenanceTrack
s {$sel:maintenanceTrackName:MaintenanceTrack' :: Maybe Text
maintenanceTrackName = Maybe Text
a} :: MaintenanceTrack)

-- | An array of UpdateTarget objects to update with the maintenance track.
maintenanceTrack_updateTargets :: Lens.Lens' MaintenanceTrack (Prelude.Maybe [UpdateTarget])
maintenanceTrack_updateTargets :: (Maybe [UpdateTarget] -> f (Maybe [UpdateTarget]))
-> MaintenanceTrack -> f MaintenanceTrack
maintenanceTrack_updateTargets = (MaintenanceTrack -> Maybe [UpdateTarget])
-> (MaintenanceTrack -> Maybe [UpdateTarget] -> MaintenanceTrack)
-> Lens
     MaintenanceTrack
     MaintenanceTrack
     (Maybe [UpdateTarget])
     (Maybe [UpdateTarget])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MaintenanceTrack' {Maybe [UpdateTarget]
updateTargets :: Maybe [UpdateTarget]
$sel:updateTargets:MaintenanceTrack' :: MaintenanceTrack -> Maybe [UpdateTarget]
updateTargets} -> Maybe [UpdateTarget]
updateTargets) (\s :: MaintenanceTrack
s@MaintenanceTrack' {} Maybe [UpdateTarget]
a -> MaintenanceTrack
s {$sel:updateTargets:MaintenanceTrack' :: Maybe [UpdateTarget]
updateTargets = Maybe [UpdateTarget]
a} :: MaintenanceTrack) ((Maybe [UpdateTarget] -> f (Maybe [UpdateTarget]))
 -> MaintenanceTrack -> f MaintenanceTrack)
-> ((Maybe [UpdateTarget] -> f (Maybe [UpdateTarget]))
    -> Maybe [UpdateTarget] -> f (Maybe [UpdateTarget]))
-> (Maybe [UpdateTarget] -> f (Maybe [UpdateTarget]))
-> MaintenanceTrack
-> f MaintenanceTrack
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [UpdateTarget] [UpdateTarget] [UpdateTarget] [UpdateTarget]
-> Iso
     (Maybe [UpdateTarget])
     (Maybe [UpdateTarget])
     (Maybe [UpdateTarget])
     (Maybe [UpdateTarget])
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 AnIso [UpdateTarget] [UpdateTarget] [UpdateTarget] [UpdateTarget]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromXML MaintenanceTrack where
  parseXML :: [Node] -> Either String MaintenanceTrack
parseXML [Node]
x =
    Maybe Text
-> Maybe Text -> Maybe [UpdateTarget] -> MaintenanceTrack
MaintenanceTrack'
      (Maybe Text
 -> Maybe Text -> Maybe [UpdateTarget] -> MaintenanceTrack)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Maybe [UpdateTarget] -> MaintenanceTrack)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"DatabaseVersion")
      Either
  String (Maybe Text -> Maybe [UpdateTarget] -> MaintenanceTrack)
-> Either String (Maybe Text)
-> Either String (Maybe [UpdateTarget] -> MaintenanceTrack)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Text)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"MaintenanceTrackName")
      Either String (Maybe [UpdateTarget] -> MaintenanceTrack)
-> Either String (Maybe [UpdateTarget])
-> Either String MaintenanceTrack
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( [Node]
x [Node] -> Text -> Either String (Maybe [Node])
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"UpdateTargets" Either String (Maybe [Node]) -> [Node] -> Either String [Node]
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ [Node]
forall a. Monoid a => a
Prelude.mempty
                      Either String [Node]
-> ([Node] -> Either String (Maybe [UpdateTarget]))
-> Either String (Maybe [UpdateTarget])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [UpdateTarget])
-> [Node] -> Either String (Maybe [UpdateTarget])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [UpdateTarget]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"UpdateTarget")
                  )

instance Prelude.Hashable MaintenanceTrack

instance Prelude.NFData MaintenanceTrack