{-# 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.UpdateTarget
-- 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.UpdateTarget 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.SupportedOperation

-- | A maintenance track that you can switch the current track to.
--
-- /See:/ 'newUpdateTarget' smart constructor.
data UpdateTarget = UpdateTarget'
  { -- | The cluster version for the new maintenance track.
    UpdateTarget -> Maybe Text
databaseVersion :: Prelude.Maybe Prelude.Text,
    -- | The name of the new maintenance track.
    UpdateTarget -> Maybe Text
maintenanceTrackName :: Prelude.Maybe Prelude.Text,
    -- | A list of operations supported by the maintenance track.
    UpdateTarget -> Maybe [SupportedOperation]
supportedOperations :: Prelude.Maybe [SupportedOperation]
  }
  deriving (UpdateTarget -> UpdateTarget -> Bool
(UpdateTarget -> UpdateTarget -> Bool)
-> (UpdateTarget -> UpdateTarget -> Bool) -> Eq UpdateTarget
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateTarget -> UpdateTarget -> Bool
$c/= :: UpdateTarget -> UpdateTarget -> Bool
== :: UpdateTarget -> UpdateTarget -> Bool
$c== :: UpdateTarget -> UpdateTarget -> Bool
Prelude.Eq, ReadPrec [UpdateTarget]
ReadPrec UpdateTarget
Int -> ReadS UpdateTarget
ReadS [UpdateTarget]
(Int -> ReadS UpdateTarget)
-> ReadS [UpdateTarget]
-> ReadPrec UpdateTarget
-> ReadPrec [UpdateTarget]
-> Read UpdateTarget
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateTarget]
$creadListPrec :: ReadPrec [UpdateTarget]
readPrec :: ReadPrec UpdateTarget
$creadPrec :: ReadPrec UpdateTarget
readList :: ReadS [UpdateTarget]
$creadList :: ReadS [UpdateTarget]
readsPrec :: Int -> ReadS UpdateTarget
$creadsPrec :: Int -> ReadS UpdateTarget
Prelude.Read, Int -> UpdateTarget -> ShowS
[UpdateTarget] -> ShowS
UpdateTarget -> String
(Int -> UpdateTarget -> ShowS)
-> (UpdateTarget -> String)
-> ([UpdateTarget] -> ShowS)
-> Show UpdateTarget
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateTarget] -> ShowS
$cshowList :: [UpdateTarget] -> ShowS
show :: UpdateTarget -> String
$cshow :: UpdateTarget -> String
showsPrec :: Int -> UpdateTarget -> ShowS
$cshowsPrec :: Int -> UpdateTarget -> ShowS
Prelude.Show, (forall x. UpdateTarget -> Rep UpdateTarget x)
-> (forall x. Rep UpdateTarget x -> UpdateTarget)
-> Generic UpdateTarget
forall x. Rep UpdateTarget x -> UpdateTarget
forall x. UpdateTarget -> Rep UpdateTarget x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateTarget x -> UpdateTarget
$cfrom :: forall x. UpdateTarget -> Rep UpdateTarget x
Prelude.Generic)

-- |
-- Create a value of 'UpdateTarget' 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', 'updateTarget_databaseVersion' - The cluster version for the new maintenance track.
--
-- 'maintenanceTrackName', 'updateTarget_maintenanceTrackName' - The name of the new maintenance track.
--
-- 'supportedOperations', 'updateTarget_supportedOperations' - A list of operations supported by the maintenance track.
newUpdateTarget ::
  UpdateTarget
newUpdateTarget :: UpdateTarget
newUpdateTarget =
  UpdateTarget' :: Maybe Text
-> Maybe Text -> Maybe [SupportedOperation] -> UpdateTarget
UpdateTarget'
    { $sel:databaseVersion:UpdateTarget' :: Maybe Text
databaseVersion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maintenanceTrackName:UpdateTarget' :: Maybe Text
maintenanceTrackName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:supportedOperations:UpdateTarget' :: Maybe [SupportedOperation]
supportedOperations = Maybe [SupportedOperation]
forall a. Maybe a
Prelude.Nothing
    }

-- | The cluster version for the new maintenance track.
updateTarget_databaseVersion :: Lens.Lens' UpdateTarget (Prelude.Maybe Prelude.Text)
updateTarget_databaseVersion :: (Maybe Text -> f (Maybe Text)) -> UpdateTarget -> f UpdateTarget
updateTarget_databaseVersion = (UpdateTarget -> Maybe Text)
-> (UpdateTarget -> Maybe Text -> UpdateTarget)
-> Lens UpdateTarget UpdateTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTarget' {Maybe Text
databaseVersion :: Maybe Text
$sel:databaseVersion:UpdateTarget' :: UpdateTarget -> Maybe Text
databaseVersion} -> Maybe Text
databaseVersion) (\s :: UpdateTarget
s@UpdateTarget' {} Maybe Text
a -> UpdateTarget
s {$sel:databaseVersion:UpdateTarget' :: Maybe Text
databaseVersion = Maybe Text
a} :: UpdateTarget)

-- | The name of the new maintenance track.
updateTarget_maintenanceTrackName :: Lens.Lens' UpdateTarget (Prelude.Maybe Prelude.Text)
updateTarget_maintenanceTrackName :: (Maybe Text -> f (Maybe Text)) -> UpdateTarget -> f UpdateTarget
updateTarget_maintenanceTrackName = (UpdateTarget -> Maybe Text)
-> (UpdateTarget -> Maybe Text -> UpdateTarget)
-> Lens UpdateTarget UpdateTarget (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTarget' {Maybe Text
maintenanceTrackName :: Maybe Text
$sel:maintenanceTrackName:UpdateTarget' :: UpdateTarget -> Maybe Text
maintenanceTrackName} -> Maybe Text
maintenanceTrackName) (\s :: UpdateTarget
s@UpdateTarget' {} Maybe Text
a -> UpdateTarget
s {$sel:maintenanceTrackName:UpdateTarget' :: Maybe Text
maintenanceTrackName = Maybe Text
a} :: UpdateTarget)

-- | A list of operations supported by the maintenance track.
updateTarget_supportedOperations :: Lens.Lens' UpdateTarget (Prelude.Maybe [SupportedOperation])
updateTarget_supportedOperations :: (Maybe [SupportedOperation] -> f (Maybe [SupportedOperation]))
-> UpdateTarget -> f UpdateTarget
updateTarget_supportedOperations = (UpdateTarget -> Maybe [SupportedOperation])
-> (UpdateTarget -> Maybe [SupportedOperation] -> UpdateTarget)
-> Lens
     UpdateTarget
     UpdateTarget
     (Maybe [SupportedOperation])
     (Maybe [SupportedOperation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateTarget' {Maybe [SupportedOperation]
supportedOperations :: Maybe [SupportedOperation]
$sel:supportedOperations:UpdateTarget' :: UpdateTarget -> Maybe [SupportedOperation]
supportedOperations} -> Maybe [SupportedOperation]
supportedOperations) (\s :: UpdateTarget
s@UpdateTarget' {} Maybe [SupportedOperation]
a -> UpdateTarget
s {$sel:supportedOperations:UpdateTarget' :: Maybe [SupportedOperation]
supportedOperations = Maybe [SupportedOperation]
a} :: UpdateTarget) ((Maybe [SupportedOperation] -> f (Maybe [SupportedOperation]))
 -> UpdateTarget -> f UpdateTarget)
-> ((Maybe [SupportedOperation] -> f (Maybe [SupportedOperation]))
    -> Maybe [SupportedOperation] -> f (Maybe [SupportedOperation]))
-> (Maybe [SupportedOperation] -> f (Maybe [SupportedOperation]))
-> UpdateTarget
-> f UpdateTarget
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [SupportedOperation]
  [SupportedOperation]
  [SupportedOperation]
  [SupportedOperation]
-> Iso
     (Maybe [SupportedOperation])
     (Maybe [SupportedOperation])
     (Maybe [SupportedOperation])
     (Maybe [SupportedOperation])
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
  [SupportedOperation]
  [SupportedOperation]
  [SupportedOperation]
  [SupportedOperation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromXML UpdateTarget where
  parseXML :: [Node] -> Either String UpdateTarget
parseXML [Node]
x =
    Maybe Text
-> Maybe Text -> Maybe [SupportedOperation] -> UpdateTarget
UpdateTarget'
      (Maybe Text
 -> Maybe Text -> Maybe [SupportedOperation] -> UpdateTarget)
-> Either String (Maybe Text)
-> Either
     String (Maybe Text -> Maybe [SupportedOperation] -> UpdateTarget)
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 [SupportedOperation] -> UpdateTarget)
-> Either String (Maybe Text)
-> Either String (Maybe [SupportedOperation] -> UpdateTarget)
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 [SupportedOperation] -> UpdateTarget)
-> Either String (Maybe [SupportedOperation])
-> Either String UpdateTarget
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
"SupportedOperations"
                      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 [SupportedOperation]))
-> Either String (Maybe [SupportedOperation])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [SupportedOperation])
-> [Node] -> Either String (Maybe [SupportedOperation])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [SupportedOperation]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"SupportedOperation")
                  )

instance Prelude.Hashable UpdateTarget

instance Prelude.NFData UpdateTarget