{-# 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.ElastiCache.Types.GlobalReplicationGroupMember
-- 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.ElastiCache.Types.GlobalReplicationGroupMember where

import qualified Amazonka.Core as Core
import Amazonka.ElastiCache.Types.AutomaticFailoverStatus
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | A member of a Global datastore. It contains the Replication Group Id,
-- the Amazon region and the role of the replication group.
--
-- /See:/ 'newGlobalReplicationGroupMember' smart constructor.
data GlobalReplicationGroupMember = GlobalReplicationGroupMember'
  { -- | The status of the membership of the replication group.
    GlobalReplicationGroupMember -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | The Amazon region of the Global datastore member.
    GlobalReplicationGroupMember -> Maybe Text
replicationGroupRegion :: Prelude.Maybe Prelude.Text,
    -- | Indicates the role of the replication group, primary or secondary.
    GlobalReplicationGroupMember -> Maybe Text
role' :: Prelude.Maybe Prelude.Text,
    -- | The replication group id of the Global datastore member.
    GlobalReplicationGroupMember -> Maybe Text
replicationGroupId :: Prelude.Maybe Prelude.Text,
    -- | Indicates whether automatic failover is enabled for the replication
    -- group.
    GlobalReplicationGroupMember -> Maybe AutomaticFailoverStatus
automaticFailover :: Prelude.Maybe AutomaticFailoverStatus
  }
  deriving (GlobalReplicationGroupMember
-> GlobalReplicationGroupMember -> Bool
(GlobalReplicationGroupMember
 -> GlobalReplicationGroupMember -> Bool)
-> (GlobalReplicationGroupMember
    -> GlobalReplicationGroupMember -> Bool)
-> Eq GlobalReplicationGroupMember
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GlobalReplicationGroupMember
-> GlobalReplicationGroupMember -> Bool
$c/= :: GlobalReplicationGroupMember
-> GlobalReplicationGroupMember -> Bool
== :: GlobalReplicationGroupMember
-> GlobalReplicationGroupMember -> Bool
$c== :: GlobalReplicationGroupMember
-> GlobalReplicationGroupMember -> Bool
Prelude.Eq, ReadPrec [GlobalReplicationGroupMember]
ReadPrec GlobalReplicationGroupMember
Int -> ReadS GlobalReplicationGroupMember
ReadS [GlobalReplicationGroupMember]
(Int -> ReadS GlobalReplicationGroupMember)
-> ReadS [GlobalReplicationGroupMember]
-> ReadPrec GlobalReplicationGroupMember
-> ReadPrec [GlobalReplicationGroupMember]
-> Read GlobalReplicationGroupMember
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GlobalReplicationGroupMember]
$creadListPrec :: ReadPrec [GlobalReplicationGroupMember]
readPrec :: ReadPrec GlobalReplicationGroupMember
$creadPrec :: ReadPrec GlobalReplicationGroupMember
readList :: ReadS [GlobalReplicationGroupMember]
$creadList :: ReadS [GlobalReplicationGroupMember]
readsPrec :: Int -> ReadS GlobalReplicationGroupMember
$creadsPrec :: Int -> ReadS GlobalReplicationGroupMember
Prelude.Read, Int -> GlobalReplicationGroupMember -> ShowS
[GlobalReplicationGroupMember] -> ShowS
GlobalReplicationGroupMember -> String
(Int -> GlobalReplicationGroupMember -> ShowS)
-> (GlobalReplicationGroupMember -> String)
-> ([GlobalReplicationGroupMember] -> ShowS)
-> Show GlobalReplicationGroupMember
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GlobalReplicationGroupMember] -> ShowS
$cshowList :: [GlobalReplicationGroupMember] -> ShowS
show :: GlobalReplicationGroupMember -> String
$cshow :: GlobalReplicationGroupMember -> String
showsPrec :: Int -> GlobalReplicationGroupMember -> ShowS
$cshowsPrec :: Int -> GlobalReplicationGroupMember -> ShowS
Prelude.Show, (forall x.
 GlobalReplicationGroupMember -> Rep GlobalReplicationGroupMember x)
-> (forall x.
    Rep GlobalReplicationGroupMember x -> GlobalReplicationGroupMember)
-> Generic GlobalReplicationGroupMember
forall x.
Rep GlobalReplicationGroupMember x -> GlobalReplicationGroupMember
forall x.
GlobalReplicationGroupMember -> Rep GlobalReplicationGroupMember x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep GlobalReplicationGroupMember x -> GlobalReplicationGroupMember
$cfrom :: forall x.
GlobalReplicationGroupMember -> Rep GlobalReplicationGroupMember x
Prelude.Generic)

-- |
-- Create a value of 'GlobalReplicationGroupMember' 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:
--
-- 'status', 'globalReplicationGroupMember_status' - The status of the membership of the replication group.
--
-- 'replicationGroupRegion', 'globalReplicationGroupMember_replicationGroupRegion' - The Amazon region of the Global datastore member.
--
-- 'role'', 'globalReplicationGroupMember_role' - Indicates the role of the replication group, primary or secondary.
--
-- 'replicationGroupId', 'globalReplicationGroupMember_replicationGroupId' - The replication group id of the Global datastore member.
--
-- 'automaticFailover', 'globalReplicationGroupMember_automaticFailover' - Indicates whether automatic failover is enabled for the replication
-- group.
newGlobalReplicationGroupMember ::
  GlobalReplicationGroupMember
newGlobalReplicationGroupMember :: GlobalReplicationGroupMember
newGlobalReplicationGroupMember =
  GlobalReplicationGroupMember' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe AutomaticFailoverStatus
-> GlobalReplicationGroupMember
GlobalReplicationGroupMember'
    { $sel:status:GlobalReplicationGroupMember' :: Maybe Text
status =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:replicationGroupRegion:GlobalReplicationGroupMember' :: Maybe Text
replicationGroupRegion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:role':GlobalReplicationGroupMember' :: Maybe Text
role' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:replicationGroupId:GlobalReplicationGroupMember' :: Maybe Text
replicationGroupId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:automaticFailover:GlobalReplicationGroupMember' :: Maybe AutomaticFailoverStatus
automaticFailover = Maybe AutomaticFailoverStatus
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of the membership of the replication group.
globalReplicationGroupMember_status :: Lens.Lens' GlobalReplicationGroupMember (Prelude.Maybe Prelude.Text)
globalReplicationGroupMember_status :: (Maybe Text -> f (Maybe Text))
-> GlobalReplicationGroupMember -> f GlobalReplicationGroupMember
globalReplicationGroupMember_status = (GlobalReplicationGroupMember -> Maybe Text)
-> (GlobalReplicationGroupMember
    -> Maybe Text -> GlobalReplicationGroupMember)
-> Lens
     GlobalReplicationGroupMember
     GlobalReplicationGroupMember
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalReplicationGroupMember' {Maybe Text
status :: Maybe Text
$sel:status:GlobalReplicationGroupMember' :: GlobalReplicationGroupMember -> Maybe Text
status} -> Maybe Text
status) (\s :: GlobalReplicationGroupMember
s@GlobalReplicationGroupMember' {} Maybe Text
a -> GlobalReplicationGroupMember
s {$sel:status:GlobalReplicationGroupMember' :: Maybe Text
status = Maybe Text
a} :: GlobalReplicationGroupMember)

-- | The Amazon region of the Global datastore member.
globalReplicationGroupMember_replicationGroupRegion :: Lens.Lens' GlobalReplicationGroupMember (Prelude.Maybe Prelude.Text)
globalReplicationGroupMember_replicationGroupRegion :: (Maybe Text -> f (Maybe Text))
-> GlobalReplicationGroupMember -> f GlobalReplicationGroupMember
globalReplicationGroupMember_replicationGroupRegion = (GlobalReplicationGroupMember -> Maybe Text)
-> (GlobalReplicationGroupMember
    -> Maybe Text -> GlobalReplicationGroupMember)
-> Lens
     GlobalReplicationGroupMember
     GlobalReplicationGroupMember
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalReplicationGroupMember' {Maybe Text
replicationGroupRegion :: Maybe Text
$sel:replicationGroupRegion:GlobalReplicationGroupMember' :: GlobalReplicationGroupMember -> Maybe Text
replicationGroupRegion} -> Maybe Text
replicationGroupRegion) (\s :: GlobalReplicationGroupMember
s@GlobalReplicationGroupMember' {} Maybe Text
a -> GlobalReplicationGroupMember
s {$sel:replicationGroupRegion:GlobalReplicationGroupMember' :: Maybe Text
replicationGroupRegion = Maybe Text
a} :: GlobalReplicationGroupMember)

-- | Indicates the role of the replication group, primary or secondary.
globalReplicationGroupMember_role :: Lens.Lens' GlobalReplicationGroupMember (Prelude.Maybe Prelude.Text)
globalReplicationGroupMember_role :: (Maybe Text -> f (Maybe Text))
-> GlobalReplicationGroupMember -> f GlobalReplicationGroupMember
globalReplicationGroupMember_role = (GlobalReplicationGroupMember -> Maybe Text)
-> (GlobalReplicationGroupMember
    -> Maybe Text -> GlobalReplicationGroupMember)
-> Lens
     GlobalReplicationGroupMember
     GlobalReplicationGroupMember
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalReplicationGroupMember' {Maybe Text
role' :: Maybe Text
$sel:role':GlobalReplicationGroupMember' :: GlobalReplicationGroupMember -> Maybe Text
role'} -> Maybe Text
role') (\s :: GlobalReplicationGroupMember
s@GlobalReplicationGroupMember' {} Maybe Text
a -> GlobalReplicationGroupMember
s {$sel:role':GlobalReplicationGroupMember' :: Maybe Text
role' = Maybe Text
a} :: GlobalReplicationGroupMember)

-- | The replication group id of the Global datastore member.
globalReplicationGroupMember_replicationGroupId :: Lens.Lens' GlobalReplicationGroupMember (Prelude.Maybe Prelude.Text)
globalReplicationGroupMember_replicationGroupId :: (Maybe Text -> f (Maybe Text))
-> GlobalReplicationGroupMember -> f GlobalReplicationGroupMember
globalReplicationGroupMember_replicationGroupId = (GlobalReplicationGroupMember -> Maybe Text)
-> (GlobalReplicationGroupMember
    -> Maybe Text -> GlobalReplicationGroupMember)
-> Lens
     GlobalReplicationGroupMember
     GlobalReplicationGroupMember
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalReplicationGroupMember' {Maybe Text
replicationGroupId :: Maybe Text
$sel:replicationGroupId:GlobalReplicationGroupMember' :: GlobalReplicationGroupMember -> Maybe Text
replicationGroupId} -> Maybe Text
replicationGroupId) (\s :: GlobalReplicationGroupMember
s@GlobalReplicationGroupMember' {} Maybe Text
a -> GlobalReplicationGroupMember
s {$sel:replicationGroupId:GlobalReplicationGroupMember' :: Maybe Text
replicationGroupId = Maybe Text
a} :: GlobalReplicationGroupMember)

-- | Indicates whether automatic failover is enabled for the replication
-- group.
globalReplicationGroupMember_automaticFailover :: Lens.Lens' GlobalReplicationGroupMember (Prelude.Maybe AutomaticFailoverStatus)
globalReplicationGroupMember_automaticFailover :: (Maybe AutomaticFailoverStatus
 -> f (Maybe AutomaticFailoverStatus))
-> GlobalReplicationGroupMember -> f GlobalReplicationGroupMember
globalReplicationGroupMember_automaticFailover = (GlobalReplicationGroupMember -> Maybe AutomaticFailoverStatus)
-> (GlobalReplicationGroupMember
    -> Maybe AutomaticFailoverStatus -> GlobalReplicationGroupMember)
-> Lens
     GlobalReplicationGroupMember
     GlobalReplicationGroupMember
     (Maybe AutomaticFailoverStatus)
     (Maybe AutomaticFailoverStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalReplicationGroupMember' {Maybe AutomaticFailoverStatus
automaticFailover :: Maybe AutomaticFailoverStatus
$sel:automaticFailover:GlobalReplicationGroupMember' :: GlobalReplicationGroupMember -> Maybe AutomaticFailoverStatus
automaticFailover} -> Maybe AutomaticFailoverStatus
automaticFailover) (\s :: GlobalReplicationGroupMember
s@GlobalReplicationGroupMember' {} Maybe AutomaticFailoverStatus
a -> GlobalReplicationGroupMember
s {$sel:automaticFailover:GlobalReplicationGroupMember' :: Maybe AutomaticFailoverStatus
automaticFailover = Maybe AutomaticFailoverStatus
a} :: GlobalReplicationGroupMember)

instance Core.FromXML GlobalReplicationGroupMember where
  parseXML :: [Node] -> Either String GlobalReplicationGroupMember
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe AutomaticFailoverStatus
-> GlobalReplicationGroupMember
GlobalReplicationGroupMember'
      (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe AutomaticFailoverStatus
 -> GlobalReplicationGroupMember)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe AutomaticFailoverStatus
      -> GlobalReplicationGroupMember)
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
"Status")
      Either
  String
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe AutomaticFailoverStatus
   -> GlobalReplicationGroupMember)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe AutomaticFailoverStatus
      -> GlobalReplicationGroupMember)
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
"ReplicationGroupRegion")
      Either
  String
  (Maybe Text
   -> Maybe Text
   -> Maybe AutomaticFailoverStatus
   -> GlobalReplicationGroupMember)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe AutomaticFailoverStatus -> GlobalReplicationGroupMember)
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
"Role")
      Either
  String
  (Maybe Text
   -> Maybe AutomaticFailoverStatus -> GlobalReplicationGroupMember)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe AutomaticFailoverStatus -> GlobalReplicationGroupMember)
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
"ReplicationGroupId")
      Either
  String
  (Maybe AutomaticFailoverStatus -> GlobalReplicationGroupMember)
-> Either String (Maybe AutomaticFailoverStatus)
-> Either String GlobalReplicationGroupMember
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe AutomaticFailoverStatus)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"AutomaticFailover")

instance
  Prelude.Hashable
    GlobalReplicationGroupMember

instance Prelude.NFData GlobalReplicationGroupMember