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

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

-- | Represents a single node within a node group (shard).
--
-- /See:/ 'newNodeGroupMember' smart constructor.
data NodeGroupMember = NodeGroupMember'
  { -- | The ID of the cluster to which the node belongs.
    NodeGroupMember -> Maybe Text
cacheClusterId :: Prelude.Maybe Prelude.Text,
    -- | The ID of the node within its cluster. A node ID is a numeric identifier
    -- (0001, 0002, etc.).
    NodeGroupMember -> Maybe Text
cacheNodeId :: Prelude.Maybe Prelude.Text,
    -- | The name of the Availability Zone in which the node is located.
    NodeGroupMember -> Maybe Text
preferredAvailabilityZone :: Prelude.Maybe Prelude.Text,
    -- | The role that is currently assigned to the node - @primary@ or
    -- @replica@. This member is only applicable for Redis (cluster mode
    -- disabled) replication groups.
    NodeGroupMember -> Maybe Text
currentRole :: Prelude.Maybe Prelude.Text,
    -- | The outpost ARN of the node group member.
    NodeGroupMember -> Maybe Text
preferredOutpostArn :: Prelude.Maybe Prelude.Text,
    -- | The information required for client programs to connect to a node for
    -- read operations. The read endpoint is only applicable on Redis (cluster
    -- mode disabled) clusters.
    NodeGroupMember -> Maybe Endpoint
readEndpoint :: Prelude.Maybe Endpoint
  }
  deriving (NodeGroupMember -> NodeGroupMember -> Bool
(NodeGroupMember -> NodeGroupMember -> Bool)
-> (NodeGroupMember -> NodeGroupMember -> Bool)
-> Eq NodeGroupMember
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NodeGroupMember -> NodeGroupMember -> Bool
$c/= :: NodeGroupMember -> NodeGroupMember -> Bool
== :: NodeGroupMember -> NodeGroupMember -> Bool
$c== :: NodeGroupMember -> NodeGroupMember -> Bool
Prelude.Eq, ReadPrec [NodeGroupMember]
ReadPrec NodeGroupMember
Int -> ReadS NodeGroupMember
ReadS [NodeGroupMember]
(Int -> ReadS NodeGroupMember)
-> ReadS [NodeGroupMember]
-> ReadPrec NodeGroupMember
-> ReadPrec [NodeGroupMember]
-> Read NodeGroupMember
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NodeGroupMember]
$creadListPrec :: ReadPrec [NodeGroupMember]
readPrec :: ReadPrec NodeGroupMember
$creadPrec :: ReadPrec NodeGroupMember
readList :: ReadS [NodeGroupMember]
$creadList :: ReadS [NodeGroupMember]
readsPrec :: Int -> ReadS NodeGroupMember
$creadsPrec :: Int -> ReadS NodeGroupMember
Prelude.Read, Int -> NodeGroupMember -> ShowS
[NodeGroupMember] -> ShowS
NodeGroupMember -> String
(Int -> NodeGroupMember -> ShowS)
-> (NodeGroupMember -> String)
-> ([NodeGroupMember] -> ShowS)
-> Show NodeGroupMember
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NodeGroupMember] -> ShowS
$cshowList :: [NodeGroupMember] -> ShowS
show :: NodeGroupMember -> String
$cshow :: NodeGroupMember -> String
showsPrec :: Int -> NodeGroupMember -> ShowS
$cshowsPrec :: Int -> NodeGroupMember -> ShowS
Prelude.Show, (forall x. NodeGroupMember -> Rep NodeGroupMember x)
-> (forall x. Rep NodeGroupMember x -> NodeGroupMember)
-> Generic NodeGroupMember
forall x. Rep NodeGroupMember x -> NodeGroupMember
forall x. NodeGroupMember -> Rep NodeGroupMember x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NodeGroupMember x -> NodeGroupMember
$cfrom :: forall x. NodeGroupMember -> Rep NodeGroupMember x
Prelude.Generic)

-- |
-- Create a value of 'NodeGroupMember' 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:
--
-- 'cacheClusterId', 'nodeGroupMember_cacheClusterId' - The ID of the cluster to which the node belongs.
--
-- 'cacheNodeId', 'nodeGroupMember_cacheNodeId' - The ID of the node within its cluster. A node ID is a numeric identifier
-- (0001, 0002, etc.).
--
-- 'preferredAvailabilityZone', 'nodeGroupMember_preferredAvailabilityZone' - The name of the Availability Zone in which the node is located.
--
-- 'currentRole', 'nodeGroupMember_currentRole' - The role that is currently assigned to the node - @primary@ or
-- @replica@. This member is only applicable for Redis (cluster mode
-- disabled) replication groups.
--
-- 'preferredOutpostArn', 'nodeGroupMember_preferredOutpostArn' - The outpost ARN of the node group member.
--
-- 'readEndpoint', 'nodeGroupMember_readEndpoint' - The information required for client programs to connect to a node for
-- read operations. The read endpoint is only applicable on Redis (cluster
-- mode disabled) clusters.
newNodeGroupMember ::
  NodeGroupMember
newNodeGroupMember :: NodeGroupMember
newNodeGroupMember =
  NodeGroupMember' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Endpoint
-> NodeGroupMember
NodeGroupMember'
    { $sel:cacheClusterId:NodeGroupMember' :: Maybe Text
cacheClusterId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:cacheNodeId:NodeGroupMember' :: Maybe Text
cacheNodeId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:preferredAvailabilityZone:NodeGroupMember' :: Maybe Text
preferredAvailabilityZone = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:currentRole:NodeGroupMember' :: Maybe Text
currentRole = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:preferredOutpostArn:NodeGroupMember' :: Maybe Text
preferredOutpostArn = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:readEndpoint:NodeGroupMember' :: Maybe Endpoint
readEndpoint = Maybe Endpoint
forall a. Maybe a
Prelude.Nothing
    }

-- | The ID of the cluster to which the node belongs.
nodeGroupMember_cacheClusterId :: Lens.Lens' NodeGroupMember (Prelude.Maybe Prelude.Text)
nodeGroupMember_cacheClusterId :: (Maybe Text -> f (Maybe Text))
-> NodeGroupMember -> f NodeGroupMember
nodeGroupMember_cacheClusterId = (NodeGroupMember -> Maybe Text)
-> (NodeGroupMember -> Maybe Text -> NodeGroupMember)
-> Lens NodeGroupMember NodeGroupMember (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodeGroupMember' {Maybe Text
cacheClusterId :: Maybe Text
$sel:cacheClusterId:NodeGroupMember' :: NodeGroupMember -> Maybe Text
cacheClusterId} -> Maybe Text
cacheClusterId) (\s :: NodeGroupMember
s@NodeGroupMember' {} Maybe Text
a -> NodeGroupMember
s {$sel:cacheClusterId:NodeGroupMember' :: Maybe Text
cacheClusterId = Maybe Text
a} :: NodeGroupMember)

-- | The ID of the node within its cluster. A node ID is a numeric identifier
-- (0001, 0002, etc.).
nodeGroupMember_cacheNodeId :: Lens.Lens' NodeGroupMember (Prelude.Maybe Prelude.Text)
nodeGroupMember_cacheNodeId :: (Maybe Text -> f (Maybe Text))
-> NodeGroupMember -> f NodeGroupMember
nodeGroupMember_cacheNodeId = (NodeGroupMember -> Maybe Text)
-> (NodeGroupMember -> Maybe Text -> NodeGroupMember)
-> Lens NodeGroupMember NodeGroupMember (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodeGroupMember' {Maybe Text
cacheNodeId :: Maybe Text
$sel:cacheNodeId:NodeGroupMember' :: NodeGroupMember -> Maybe Text
cacheNodeId} -> Maybe Text
cacheNodeId) (\s :: NodeGroupMember
s@NodeGroupMember' {} Maybe Text
a -> NodeGroupMember
s {$sel:cacheNodeId:NodeGroupMember' :: Maybe Text
cacheNodeId = Maybe Text
a} :: NodeGroupMember)

-- | The name of the Availability Zone in which the node is located.
nodeGroupMember_preferredAvailabilityZone :: Lens.Lens' NodeGroupMember (Prelude.Maybe Prelude.Text)
nodeGroupMember_preferredAvailabilityZone :: (Maybe Text -> f (Maybe Text))
-> NodeGroupMember -> f NodeGroupMember
nodeGroupMember_preferredAvailabilityZone = (NodeGroupMember -> Maybe Text)
-> (NodeGroupMember -> Maybe Text -> NodeGroupMember)
-> Lens NodeGroupMember NodeGroupMember (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodeGroupMember' {Maybe Text
preferredAvailabilityZone :: Maybe Text
$sel:preferredAvailabilityZone:NodeGroupMember' :: NodeGroupMember -> Maybe Text
preferredAvailabilityZone} -> Maybe Text
preferredAvailabilityZone) (\s :: NodeGroupMember
s@NodeGroupMember' {} Maybe Text
a -> NodeGroupMember
s {$sel:preferredAvailabilityZone:NodeGroupMember' :: Maybe Text
preferredAvailabilityZone = Maybe Text
a} :: NodeGroupMember)

-- | The role that is currently assigned to the node - @primary@ or
-- @replica@. This member is only applicable for Redis (cluster mode
-- disabled) replication groups.
nodeGroupMember_currentRole :: Lens.Lens' NodeGroupMember (Prelude.Maybe Prelude.Text)
nodeGroupMember_currentRole :: (Maybe Text -> f (Maybe Text))
-> NodeGroupMember -> f NodeGroupMember
nodeGroupMember_currentRole = (NodeGroupMember -> Maybe Text)
-> (NodeGroupMember -> Maybe Text -> NodeGroupMember)
-> Lens NodeGroupMember NodeGroupMember (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodeGroupMember' {Maybe Text
currentRole :: Maybe Text
$sel:currentRole:NodeGroupMember' :: NodeGroupMember -> Maybe Text
currentRole} -> Maybe Text
currentRole) (\s :: NodeGroupMember
s@NodeGroupMember' {} Maybe Text
a -> NodeGroupMember
s {$sel:currentRole:NodeGroupMember' :: Maybe Text
currentRole = Maybe Text
a} :: NodeGroupMember)

-- | The outpost ARN of the node group member.
nodeGroupMember_preferredOutpostArn :: Lens.Lens' NodeGroupMember (Prelude.Maybe Prelude.Text)
nodeGroupMember_preferredOutpostArn :: (Maybe Text -> f (Maybe Text))
-> NodeGroupMember -> f NodeGroupMember
nodeGroupMember_preferredOutpostArn = (NodeGroupMember -> Maybe Text)
-> (NodeGroupMember -> Maybe Text -> NodeGroupMember)
-> Lens NodeGroupMember NodeGroupMember (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodeGroupMember' {Maybe Text
preferredOutpostArn :: Maybe Text
$sel:preferredOutpostArn:NodeGroupMember' :: NodeGroupMember -> Maybe Text
preferredOutpostArn} -> Maybe Text
preferredOutpostArn) (\s :: NodeGroupMember
s@NodeGroupMember' {} Maybe Text
a -> NodeGroupMember
s {$sel:preferredOutpostArn:NodeGroupMember' :: Maybe Text
preferredOutpostArn = Maybe Text
a} :: NodeGroupMember)

-- | The information required for client programs to connect to a node for
-- read operations. The read endpoint is only applicable on Redis (cluster
-- mode disabled) clusters.
nodeGroupMember_readEndpoint :: Lens.Lens' NodeGroupMember (Prelude.Maybe Endpoint)
nodeGroupMember_readEndpoint :: (Maybe Endpoint -> f (Maybe Endpoint))
-> NodeGroupMember -> f NodeGroupMember
nodeGroupMember_readEndpoint = (NodeGroupMember -> Maybe Endpoint)
-> (NodeGroupMember -> Maybe Endpoint -> NodeGroupMember)
-> Lens
     NodeGroupMember NodeGroupMember (Maybe Endpoint) (Maybe Endpoint)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodeGroupMember' {Maybe Endpoint
readEndpoint :: Maybe Endpoint
$sel:readEndpoint:NodeGroupMember' :: NodeGroupMember -> Maybe Endpoint
readEndpoint} -> Maybe Endpoint
readEndpoint) (\s :: NodeGroupMember
s@NodeGroupMember' {} Maybe Endpoint
a -> NodeGroupMember
s {$sel:readEndpoint:NodeGroupMember' :: Maybe Endpoint
readEndpoint = Maybe Endpoint
a} :: NodeGroupMember)

instance Core.FromXML NodeGroupMember where
  parseXML :: [Node] -> Either String NodeGroupMember
parseXML [Node]
x =
    Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Endpoint
-> NodeGroupMember
NodeGroupMember'
      (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Endpoint
 -> NodeGroupMember)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Endpoint
      -> NodeGroupMember)
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
"CacheClusterId")
      Either
  String
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Endpoint
   -> NodeGroupMember)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text
      -> Maybe Text -> Maybe Text -> Maybe Endpoint -> NodeGroupMember)
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
"CacheNodeId")
      Either
  String
  (Maybe Text
   -> Maybe Text -> Maybe Text -> Maybe Endpoint -> NodeGroupMember)
-> Either String (Maybe Text)
-> Either
     String
     (Maybe Text -> Maybe Text -> Maybe Endpoint -> NodeGroupMember)
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
"PreferredAvailabilityZone")
      Either
  String
  (Maybe Text -> Maybe Text -> Maybe Endpoint -> NodeGroupMember)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Maybe Endpoint -> NodeGroupMember)
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
"CurrentRole")
      Either String (Maybe Text -> Maybe Endpoint -> NodeGroupMember)
-> Either String (Maybe Text)
-> Either String (Maybe Endpoint -> NodeGroupMember)
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
"PreferredOutpostArn")
      Either String (Maybe Endpoint -> NodeGroupMember)
-> Either String (Maybe Endpoint) -> Either String NodeGroupMember
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Endpoint)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"ReadEndpoint")

instance Prelude.Hashable NodeGroupMember

instance Prelude.NFData NodeGroupMember