{-# 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.GlobalClusterMember
-- 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.GlobalClusterMember where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.RDS.Types.WriteForwardingStatus

-- | A data structure with information about any primary and secondary
-- clusters associated with an Aurora global database.
--
-- /See:/ 'newGlobalClusterMember' smart constructor.
data GlobalClusterMember = GlobalClusterMember'
  { -- | The Amazon Resource Name (ARN) for each read-only secondary cluster
    -- associated with the Aurora global database.
    GlobalClusterMember -> Maybe [Text]
readers :: Prelude.Maybe [Prelude.Text],
    -- | The Amazon Resource Name (ARN) for each Aurora cluster.
    GlobalClusterMember -> Maybe Text
dbClusterArn :: Prelude.Maybe Prelude.Text,
    -- | Specifies whether the Aurora cluster is the primary cluster (that is,
    -- has read-write capability) for the Aurora global database with which it
    -- is associated.
    GlobalClusterMember -> Maybe Bool
isWriter :: Prelude.Maybe Prelude.Bool,
    -- | Specifies whether a secondary cluster in an Aurora global database has
    -- write forwarding enabled, not enabled, or is in the process of enabling
    -- it.
    GlobalClusterMember -> Maybe WriteForwardingStatus
globalWriteForwardingStatus :: Prelude.Maybe WriteForwardingStatus
  }
  deriving (GlobalClusterMember -> GlobalClusterMember -> Bool
(GlobalClusterMember -> GlobalClusterMember -> Bool)
-> (GlobalClusterMember -> GlobalClusterMember -> Bool)
-> Eq GlobalClusterMember
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GlobalClusterMember -> GlobalClusterMember -> Bool
$c/= :: GlobalClusterMember -> GlobalClusterMember -> Bool
== :: GlobalClusterMember -> GlobalClusterMember -> Bool
$c== :: GlobalClusterMember -> GlobalClusterMember -> Bool
Prelude.Eq, ReadPrec [GlobalClusterMember]
ReadPrec GlobalClusterMember
Int -> ReadS GlobalClusterMember
ReadS [GlobalClusterMember]
(Int -> ReadS GlobalClusterMember)
-> ReadS [GlobalClusterMember]
-> ReadPrec GlobalClusterMember
-> ReadPrec [GlobalClusterMember]
-> Read GlobalClusterMember
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GlobalClusterMember]
$creadListPrec :: ReadPrec [GlobalClusterMember]
readPrec :: ReadPrec GlobalClusterMember
$creadPrec :: ReadPrec GlobalClusterMember
readList :: ReadS [GlobalClusterMember]
$creadList :: ReadS [GlobalClusterMember]
readsPrec :: Int -> ReadS GlobalClusterMember
$creadsPrec :: Int -> ReadS GlobalClusterMember
Prelude.Read, Int -> GlobalClusterMember -> ShowS
[GlobalClusterMember] -> ShowS
GlobalClusterMember -> String
(Int -> GlobalClusterMember -> ShowS)
-> (GlobalClusterMember -> String)
-> ([GlobalClusterMember] -> ShowS)
-> Show GlobalClusterMember
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GlobalClusterMember] -> ShowS
$cshowList :: [GlobalClusterMember] -> ShowS
show :: GlobalClusterMember -> String
$cshow :: GlobalClusterMember -> String
showsPrec :: Int -> GlobalClusterMember -> ShowS
$cshowsPrec :: Int -> GlobalClusterMember -> ShowS
Prelude.Show, (forall x. GlobalClusterMember -> Rep GlobalClusterMember x)
-> (forall x. Rep GlobalClusterMember x -> GlobalClusterMember)
-> Generic GlobalClusterMember
forall x. Rep GlobalClusterMember x -> GlobalClusterMember
forall x. GlobalClusterMember -> Rep GlobalClusterMember x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GlobalClusterMember x -> GlobalClusterMember
$cfrom :: forall x. GlobalClusterMember -> Rep GlobalClusterMember x
Prelude.Generic)

-- |
-- Create a value of 'GlobalClusterMember' 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:
--
-- 'readers', 'globalClusterMember_readers' - The Amazon Resource Name (ARN) for each read-only secondary cluster
-- associated with the Aurora global database.
--
-- 'dbClusterArn', 'globalClusterMember_dbClusterArn' - The Amazon Resource Name (ARN) for each Aurora cluster.
--
-- 'isWriter', 'globalClusterMember_isWriter' - Specifies whether the Aurora cluster is the primary cluster (that is,
-- has read-write capability) for the Aurora global database with which it
-- is associated.
--
-- 'globalWriteForwardingStatus', 'globalClusterMember_globalWriteForwardingStatus' - Specifies whether a secondary cluster in an Aurora global database has
-- write forwarding enabled, not enabled, or is in the process of enabling
-- it.
newGlobalClusterMember ::
  GlobalClusterMember
newGlobalClusterMember :: GlobalClusterMember
newGlobalClusterMember =
  GlobalClusterMember' :: Maybe [Text]
-> Maybe Text
-> Maybe Bool
-> Maybe WriteForwardingStatus
-> GlobalClusterMember
GlobalClusterMember'
    { $sel:readers:GlobalClusterMember' :: Maybe [Text]
readers = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:dbClusterArn:GlobalClusterMember' :: Maybe Text
dbClusterArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:isWriter:GlobalClusterMember' :: Maybe Bool
isWriter = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:globalWriteForwardingStatus:GlobalClusterMember' :: Maybe WriteForwardingStatus
globalWriteForwardingStatus = Maybe WriteForwardingStatus
forall a. Maybe a
Prelude.Nothing
    }

-- | The Amazon Resource Name (ARN) for each read-only secondary cluster
-- associated with the Aurora global database.
globalClusterMember_readers :: Lens.Lens' GlobalClusterMember (Prelude.Maybe [Prelude.Text])
globalClusterMember_readers :: (Maybe [Text] -> f (Maybe [Text]))
-> GlobalClusterMember -> f GlobalClusterMember
globalClusterMember_readers = (GlobalClusterMember -> Maybe [Text])
-> (GlobalClusterMember -> Maybe [Text] -> GlobalClusterMember)
-> Lens
     GlobalClusterMember
     GlobalClusterMember
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalClusterMember' {Maybe [Text]
readers :: Maybe [Text]
$sel:readers:GlobalClusterMember' :: GlobalClusterMember -> Maybe [Text]
readers} -> Maybe [Text]
readers) (\s :: GlobalClusterMember
s@GlobalClusterMember' {} Maybe [Text]
a -> GlobalClusterMember
s {$sel:readers:GlobalClusterMember' :: Maybe [Text]
readers = Maybe [Text]
a} :: GlobalClusterMember) ((Maybe [Text] -> f (Maybe [Text]))
 -> GlobalClusterMember -> f GlobalClusterMember)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> GlobalClusterMember
-> f GlobalClusterMember
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
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 [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The Amazon Resource Name (ARN) for each Aurora cluster.
globalClusterMember_dbClusterArn :: Lens.Lens' GlobalClusterMember (Prelude.Maybe Prelude.Text)
globalClusterMember_dbClusterArn :: (Maybe Text -> f (Maybe Text))
-> GlobalClusterMember -> f GlobalClusterMember
globalClusterMember_dbClusterArn = (GlobalClusterMember -> Maybe Text)
-> (GlobalClusterMember -> Maybe Text -> GlobalClusterMember)
-> Lens
     GlobalClusterMember GlobalClusterMember (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalClusterMember' {Maybe Text
dbClusterArn :: Maybe Text
$sel:dbClusterArn:GlobalClusterMember' :: GlobalClusterMember -> Maybe Text
dbClusterArn} -> Maybe Text
dbClusterArn) (\s :: GlobalClusterMember
s@GlobalClusterMember' {} Maybe Text
a -> GlobalClusterMember
s {$sel:dbClusterArn:GlobalClusterMember' :: Maybe Text
dbClusterArn = Maybe Text
a} :: GlobalClusterMember)

-- | Specifies whether the Aurora cluster is the primary cluster (that is,
-- has read-write capability) for the Aurora global database with which it
-- is associated.
globalClusterMember_isWriter :: Lens.Lens' GlobalClusterMember (Prelude.Maybe Prelude.Bool)
globalClusterMember_isWriter :: (Maybe Bool -> f (Maybe Bool))
-> GlobalClusterMember -> f GlobalClusterMember
globalClusterMember_isWriter = (GlobalClusterMember -> Maybe Bool)
-> (GlobalClusterMember -> Maybe Bool -> GlobalClusterMember)
-> Lens
     GlobalClusterMember GlobalClusterMember (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalClusterMember' {Maybe Bool
isWriter :: Maybe Bool
$sel:isWriter:GlobalClusterMember' :: GlobalClusterMember -> Maybe Bool
isWriter} -> Maybe Bool
isWriter) (\s :: GlobalClusterMember
s@GlobalClusterMember' {} Maybe Bool
a -> GlobalClusterMember
s {$sel:isWriter:GlobalClusterMember' :: Maybe Bool
isWriter = Maybe Bool
a} :: GlobalClusterMember)

-- | Specifies whether a secondary cluster in an Aurora global database has
-- write forwarding enabled, not enabled, or is in the process of enabling
-- it.
globalClusterMember_globalWriteForwardingStatus :: Lens.Lens' GlobalClusterMember (Prelude.Maybe WriteForwardingStatus)
globalClusterMember_globalWriteForwardingStatus :: (Maybe WriteForwardingStatus -> f (Maybe WriteForwardingStatus))
-> GlobalClusterMember -> f GlobalClusterMember
globalClusterMember_globalWriteForwardingStatus = (GlobalClusterMember -> Maybe WriteForwardingStatus)
-> (GlobalClusterMember
    -> Maybe WriteForwardingStatus -> GlobalClusterMember)
-> Lens
     GlobalClusterMember
     GlobalClusterMember
     (Maybe WriteForwardingStatus)
     (Maybe WriteForwardingStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GlobalClusterMember' {Maybe WriteForwardingStatus
globalWriteForwardingStatus :: Maybe WriteForwardingStatus
$sel:globalWriteForwardingStatus:GlobalClusterMember' :: GlobalClusterMember -> Maybe WriteForwardingStatus
globalWriteForwardingStatus} -> Maybe WriteForwardingStatus
globalWriteForwardingStatus) (\s :: GlobalClusterMember
s@GlobalClusterMember' {} Maybe WriteForwardingStatus
a -> GlobalClusterMember
s {$sel:globalWriteForwardingStatus:GlobalClusterMember' :: Maybe WriteForwardingStatus
globalWriteForwardingStatus = Maybe WriteForwardingStatus
a} :: GlobalClusterMember)

instance Core.FromXML GlobalClusterMember where
  parseXML :: [Node] -> Either String GlobalClusterMember
parseXML [Node]
x =
    Maybe [Text]
-> Maybe Text
-> Maybe Bool
-> Maybe WriteForwardingStatus
-> GlobalClusterMember
GlobalClusterMember'
      (Maybe [Text]
 -> Maybe Text
 -> Maybe Bool
 -> Maybe WriteForwardingStatus
 -> GlobalClusterMember)
-> Either String (Maybe [Text])
-> Either
     String
     (Maybe Text
      -> Maybe Bool
      -> Maybe WriteForwardingStatus
      -> GlobalClusterMember)
forall (f :: * -> *) a b. Functor 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
"Readers" 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 [Text]))
-> Either String (Maybe [Text])
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
Prelude.>>= ([Node] -> Either String [Text])
-> [Node] -> Either String (Maybe [Text])
forall (f :: * -> *) a b.
Applicative f =>
([a] -> f b) -> [a] -> f (Maybe b)
Core.may (Text -> [Node] -> Either String [Text]
forall a. FromXML a => Text -> [Node] -> Either String [a]
Core.parseXMLList Text
"member")
                  )
      Either
  String
  (Maybe Text
   -> Maybe Bool
   -> Maybe WriteForwardingStatus
   -> GlobalClusterMember)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Bool -> Maybe WriteForwardingStatus -> GlobalClusterMember)
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
"DBClusterArn")
      Either
  String
  (Maybe Bool -> Maybe WriteForwardingStatus -> GlobalClusterMember)
-> Either String (Maybe Bool)
-> Either
     String (Maybe WriteForwardingStatus -> GlobalClusterMember)
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
"IsWriter")
      Either String (Maybe WriteForwardingStatus -> GlobalClusterMember)
-> Either String (Maybe WriteForwardingStatus)
-> Either String GlobalClusterMember
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe WriteForwardingStatus)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"GlobalWriteForwardingStatus")

instance Prelude.Hashable GlobalClusterMember

instance Prelude.NFData GlobalClusterMember