{-# 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.RDS.Types.DBClusterMember
-- 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.RDS.Types.DBClusterMember where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Contains information about an instance that is part of a DB cluster.
--
-- /See:/ 'newDBClusterMember' smart constructor.
data DBClusterMember = DBClusterMember'
  { -- | A value that specifies the order in which an Aurora Replica is promoted
    -- to the primary instance after a failure of the existing primary
    -- instance. For more information, see
    -- <https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.Managing.Backups.html#Aurora.Managing.FaultTolerance Fault Tolerance for an Aurora DB Cluster>
    -- in the /Amazon Aurora User Guide/.
    DBClusterMember -> Maybe Int
promotionTier :: Prelude.Maybe Prelude.Int,
    -- | Specifies the instance identifier for this member of the DB cluster.
    DBClusterMember -> Maybe Text
dbInstanceIdentifier :: Prelude.Maybe Prelude.Text,
    -- | Value that is @true@ if the cluster member is the primary instance for
    -- the DB cluster and @false@ otherwise.
    DBClusterMember -> Maybe Bool
isClusterWriter :: Prelude.Maybe Prelude.Bool,
    -- | Specifies the status of the DB cluster parameter group for this member
    -- of the DB cluster.
    DBClusterMember -> Maybe Text
dbClusterParameterGroupStatus :: Prelude.Maybe Prelude.Text
  }
  deriving (DBClusterMember -> DBClusterMember -> Bool
(DBClusterMember -> DBClusterMember -> Bool)
-> (DBClusterMember -> DBClusterMember -> Bool)
-> Eq DBClusterMember
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DBClusterMember -> DBClusterMember -> Bool
$c/= :: DBClusterMember -> DBClusterMember -> Bool
== :: DBClusterMember -> DBClusterMember -> Bool
$c== :: DBClusterMember -> DBClusterMember -> Bool
Prelude.Eq, ReadPrec [DBClusterMember]
ReadPrec DBClusterMember
Int -> ReadS DBClusterMember
ReadS [DBClusterMember]
(Int -> ReadS DBClusterMember)
-> ReadS [DBClusterMember]
-> ReadPrec DBClusterMember
-> ReadPrec [DBClusterMember]
-> Read DBClusterMember
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DBClusterMember]
$creadListPrec :: ReadPrec [DBClusterMember]
readPrec :: ReadPrec DBClusterMember
$creadPrec :: ReadPrec DBClusterMember
readList :: ReadS [DBClusterMember]
$creadList :: ReadS [DBClusterMember]
readsPrec :: Int -> ReadS DBClusterMember
$creadsPrec :: Int -> ReadS DBClusterMember
Prelude.Read, Int -> DBClusterMember -> ShowS
[DBClusterMember] -> ShowS
DBClusterMember -> String
(Int -> DBClusterMember -> ShowS)
-> (DBClusterMember -> String)
-> ([DBClusterMember] -> ShowS)
-> Show DBClusterMember
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DBClusterMember] -> ShowS
$cshowList :: [DBClusterMember] -> ShowS
show :: DBClusterMember -> String
$cshow :: DBClusterMember -> String
showsPrec :: Int -> DBClusterMember -> ShowS
$cshowsPrec :: Int -> DBClusterMember -> ShowS
Prelude.Show, (forall x. DBClusterMember -> Rep DBClusterMember x)
-> (forall x. Rep DBClusterMember x -> DBClusterMember)
-> Generic DBClusterMember
forall x. Rep DBClusterMember x -> DBClusterMember
forall x. DBClusterMember -> Rep DBClusterMember x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DBClusterMember x -> DBClusterMember
$cfrom :: forall x. DBClusterMember -> Rep DBClusterMember x
Prelude.Generic)

-- |
-- Create a value of 'DBClusterMember' 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:
--
-- 'promotionTier', 'dbClusterMember_promotionTier' - A value that specifies the order in which an Aurora Replica is promoted
-- to the primary instance after a failure of the existing primary
-- instance. For more information, see
-- <https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.Managing.Backups.html#Aurora.Managing.FaultTolerance Fault Tolerance for an Aurora DB Cluster>
-- in the /Amazon Aurora User Guide/.
--
-- 'dbInstanceIdentifier', 'dbClusterMember_dbInstanceIdentifier' - Specifies the instance identifier for this member of the DB cluster.
--
-- 'isClusterWriter', 'dbClusterMember_isClusterWriter' - Value that is @true@ if the cluster member is the primary instance for
-- the DB cluster and @false@ otherwise.
--
-- 'dbClusterParameterGroupStatus', 'dbClusterMember_dbClusterParameterGroupStatus' - Specifies the status of the DB cluster parameter group for this member
-- of the DB cluster.
newDBClusterMember ::
  DBClusterMember
newDBClusterMember :: DBClusterMember
newDBClusterMember =
  DBClusterMember' :: Maybe Int
-> Maybe Text -> Maybe Bool -> Maybe Text -> DBClusterMember
DBClusterMember'
    { $sel:promotionTier:DBClusterMember' :: Maybe Int
promotionTier = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:dbInstanceIdentifier:DBClusterMember' :: Maybe Text
dbInstanceIdentifier = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:isClusterWriter:DBClusterMember' :: Maybe Bool
isClusterWriter = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:dbClusterParameterGroupStatus:DBClusterMember' :: Maybe Text
dbClusterParameterGroupStatus = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A value that specifies the order in which an Aurora Replica is promoted
-- to the primary instance after a failure of the existing primary
-- instance. For more information, see
-- <https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.Managing.Backups.html#Aurora.Managing.FaultTolerance Fault Tolerance for an Aurora DB Cluster>
-- in the /Amazon Aurora User Guide/.
dbClusterMember_promotionTier :: Lens.Lens' DBClusterMember (Prelude.Maybe Prelude.Int)
dbClusterMember_promotionTier :: (Maybe Int -> f (Maybe Int))
-> DBClusterMember -> f DBClusterMember
dbClusterMember_promotionTier = (DBClusterMember -> Maybe Int)
-> (DBClusterMember -> Maybe Int -> DBClusterMember)
-> Lens DBClusterMember DBClusterMember (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBClusterMember' {Maybe Int
promotionTier :: Maybe Int
$sel:promotionTier:DBClusterMember' :: DBClusterMember -> Maybe Int
promotionTier} -> Maybe Int
promotionTier) (\s :: DBClusterMember
s@DBClusterMember' {} Maybe Int
a -> DBClusterMember
s {$sel:promotionTier:DBClusterMember' :: Maybe Int
promotionTier = Maybe Int
a} :: DBClusterMember)

-- | Specifies the instance identifier for this member of the DB cluster.
dbClusterMember_dbInstanceIdentifier :: Lens.Lens' DBClusterMember (Prelude.Maybe Prelude.Text)
dbClusterMember_dbInstanceIdentifier :: (Maybe Text -> f (Maybe Text))
-> DBClusterMember -> f DBClusterMember
dbClusterMember_dbInstanceIdentifier = (DBClusterMember -> Maybe Text)
-> (DBClusterMember -> Maybe Text -> DBClusterMember)
-> Lens DBClusterMember DBClusterMember (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBClusterMember' {Maybe Text
dbInstanceIdentifier :: Maybe Text
$sel:dbInstanceIdentifier:DBClusterMember' :: DBClusterMember -> Maybe Text
dbInstanceIdentifier} -> Maybe Text
dbInstanceIdentifier) (\s :: DBClusterMember
s@DBClusterMember' {} Maybe Text
a -> DBClusterMember
s {$sel:dbInstanceIdentifier:DBClusterMember' :: Maybe Text
dbInstanceIdentifier = Maybe Text
a} :: DBClusterMember)

-- | Value that is @true@ if the cluster member is the primary instance for
-- the DB cluster and @false@ otherwise.
dbClusterMember_isClusterWriter :: Lens.Lens' DBClusterMember (Prelude.Maybe Prelude.Bool)
dbClusterMember_isClusterWriter :: (Maybe Bool -> f (Maybe Bool))
-> DBClusterMember -> f DBClusterMember
dbClusterMember_isClusterWriter = (DBClusterMember -> Maybe Bool)
-> (DBClusterMember -> Maybe Bool -> DBClusterMember)
-> Lens DBClusterMember DBClusterMember (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBClusterMember' {Maybe Bool
isClusterWriter :: Maybe Bool
$sel:isClusterWriter:DBClusterMember' :: DBClusterMember -> Maybe Bool
isClusterWriter} -> Maybe Bool
isClusterWriter) (\s :: DBClusterMember
s@DBClusterMember' {} Maybe Bool
a -> DBClusterMember
s {$sel:isClusterWriter:DBClusterMember' :: Maybe Bool
isClusterWriter = Maybe Bool
a} :: DBClusterMember)

-- | Specifies the status of the DB cluster parameter group for this member
-- of the DB cluster.
dbClusterMember_dbClusterParameterGroupStatus :: Lens.Lens' DBClusterMember (Prelude.Maybe Prelude.Text)
dbClusterMember_dbClusterParameterGroupStatus :: (Maybe Text -> f (Maybe Text))
-> DBClusterMember -> f DBClusterMember
dbClusterMember_dbClusterParameterGroupStatus = (DBClusterMember -> Maybe Text)
-> (DBClusterMember -> Maybe Text -> DBClusterMember)
-> Lens DBClusterMember DBClusterMember (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DBClusterMember' {Maybe Text
dbClusterParameterGroupStatus :: Maybe Text
$sel:dbClusterParameterGroupStatus:DBClusterMember' :: DBClusterMember -> Maybe Text
dbClusterParameterGroupStatus} -> Maybe Text
dbClusterParameterGroupStatus) (\s :: DBClusterMember
s@DBClusterMember' {} Maybe Text
a -> DBClusterMember
s {$sel:dbClusterParameterGroupStatus:DBClusterMember' :: Maybe Text
dbClusterParameterGroupStatus = Maybe Text
a} :: DBClusterMember)

instance Core.FromXML DBClusterMember where
  parseXML :: [Node] -> Either String DBClusterMember
parseXML [Node]
x =
    Maybe Int
-> Maybe Text -> Maybe Bool -> Maybe Text -> DBClusterMember
DBClusterMember'
      (Maybe Int
 -> Maybe Text -> Maybe Bool -> Maybe Text -> DBClusterMember)
-> Either String (Maybe Int)
-> Either
     String (Maybe Text -> Maybe Bool -> Maybe Text -> DBClusterMember)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Int)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"PromotionTier")
      Either
  String (Maybe Text -> Maybe Bool -> Maybe Text -> DBClusterMember)
-> Either String (Maybe Text)
-> Either String (Maybe Bool -> Maybe Text -> DBClusterMember)
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
"DBInstanceIdentifier")
      Either String (Maybe Bool -> Maybe Text -> DBClusterMember)
-> Either String (Maybe Bool)
-> Either String (Maybe Text -> DBClusterMember)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Bool)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"IsClusterWriter")
      Either String (Maybe Text -> DBClusterMember)
-> Either String (Maybe Text) -> Either String DBClusterMember
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
"DBClusterParameterGroupStatus")

instance Prelude.Hashable DBClusterMember

instance Prelude.NFData DBClusterMember