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

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

-- | The identifier of a node in a cluster.
--
-- /See:/ 'newClusterNode' smart constructor.
data ClusterNode = ClusterNode'
  { -- | Whether the node is a leader node or a compute node.
    ClusterNode -> Maybe Text
nodeRole :: Prelude.Maybe Prelude.Text,
    -- | The private IP address of a node within a cluster.
    ClusterNode -> Maybe Text
privateIPAddress :: Prelude.Maybe Prelude.Text,
    -- | The public IP address of a node within a cluster.
    ClusterNode -> Maybe Text
publicIPAddress :: Prelude.Maybe Prelude.Text
  }
  deriving (ClusterNode -> ClusterNode -> Bool
(ClusterNode -> ClusterNode -> Bool)
-> (ClusterNode -> ClusterNode -> Bool) -> Eq ClusterNode
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClusterNode -> ClusterNode -> Bool
$c/= :: ClusterNode -> ClusterNode -> Bool
== :: ClusterNode -> ClusterNode -> Bool
$c== :: ClusterNode -> ClusterNode -> Bool
Prelude.Eq, ReadPrec [ClusterNode]
ReadPrec ClusterNode
Int -> ReadS ClusterNode
ReadS [ClusterNode]
(Int -> ReadS ClusterNode)
-> ReadS [ClusterNode]
-> ReadPrec ClusterNode
-> ReadPrec [ClusterNode]
-> Read ClusterNode
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ClusterNode]
$creadListPrec :: ReadPrec [ClusterNode]
readPrec :: ReadPrec ClusterNode
$creadPrec :: ReadPrec ClusterNode
readList :: ReadS [ClusterNode]
$creadList :: ReadS [ClusterNode]
readsPrec :: Int -> ReadS ClusterNode
$creadsPrec :: Int -> ReadS ClusterNode
Prelude.Read, Int -> ClusterNode -> ShowS
[ClusterNode] -> ShowS
ClusterNode -> String
(Int -> ClusterNode -> ShowS)
-> (ClusterNode -> String)
-> ([ClusterNode] -> ShowS)
-> Show ClusterNode
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClusterNode] -> ShowS
$cshowList :: [ClusterNode] -> ShowS
show :: ClusterNode -> String
$cshow :: ClusterNode -> String
showsPrec :: Int -> ClusterNode -> ShowS
$cshowsPrec :: Int -> ClusterNode -> ShowS
Prelude.Show, (forall x. ClusterNode -> Rep ClusterNode x)
-> (forall x. Rep ClusterNode x -> ClusterNode)
-> Generic ClusterNode
forall x. Rep ClusterNode x -> ClusterNode
forall x. ClusterNode -> Rep ClusterNode x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ClusterNode x -> ClusterNode
$cfrom :: forall x. ClusterNode -> Rep ClusterNode x
Prelude.Generic)

-- |
-- Create a value of 'ClusterNode' 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:
--
-- 'nodeRole', 'clusterNode_nodeRole' - Whether the node is a leader node or a compute node.
--
-- 'privateIPAddress', 'clusterNode_privateIPAddress' - The private IP address of a node within a cluster.
--
-- 'publicIPAddress', 'clusterNode_publicIPAddress' - The public IP address of a node within a cluster.
newClusterNode ::
  ClusterNode
newClusterNode :: ClusterNode
newClusterNode =
  ClusterNode' :: Maybe Text -> Maybe Text -> Maybe Text -> ClusterNode
ClusterNode'
    { $sel:nodeRole:ClusterNode' :: Maybe Text
nodeRole = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:privateIPAddress:ClusterNode' :: Maybe Text
privateIPAddress = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:publicIPAddress:ClusterNode' :: Maybe Text
publicIPAddress = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | Whether the node is a leader node or a compute node.
clusterNode_nodeRole :: Lens.Lens' ClusterNode (Prelude.Maybe Prelude.Text)
clusterNode_nodeRole :: (Maybe Text -> f (Maybe Text)) -> ClusterNode -> f ClusterNode
clusterNode_nodeRole = (ClusterNode -> Maybe Text)
-> (ClusterNode -> Maybe Text -> ClusterNode)
-> Lens ClusterNode ClusterNode (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterNode' {Maybe Text
nodeRole :: Maybe Text
$sel:nodeRole:ClusterNode' :: ClusterNode -> Maybe Text
nodeRole} -> Maybe Text
nodeRole) (\s :: ClusterNode
s@ClusterNode' {} Maybe Text
a -> ClusterNode
s {$sel:nodeRole:ClusterNode' :: Maybe Text
nodeRole = Maybe Text
a} :: ClusterNode)

-- | The private IP address of a node within a cluster.
clusterNode_privateIPAddress :: Lens.Lens' ClusterNode (Prelude.Maybe Prelude.Text)
clusterNode_privateIPAddress :: (Maybe Text -> f (Maybe Text)) -> ClusterNode -> f ClusterNode
clusterNode_privateIPAddress = (ClusterNode -> Maybe Text)
-> (ClusterNode -> Maybe Text -> ClusterNode)
-> Lens ClusterNode ClusterNode (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterNode' {Maybe Text
privateIPAddress :: Maybe Text
$sel:privateIPAddress:ClusterNode' :: ClusterNode -> Maybe Text
privateIPAddress} -> Maybe Text
privateIPAddress) (\s :: ClusterNode
s@ClusterNode' {} Maybe Text
a -> ClusterNode
s {$sel:privateIPAddress:ClusterNode' :: Maybe Text
privateIPAddress = Maybe Text
a} :: ClusterNode)

-- | The public IP address of a node within a cluster.
clusterNode_publicIPAddress :: Lens.Lens' ClusterNode (Prelude.Maybe Prelude.Text)
clusterNode_publicIPAddress :: (Maybe Text -> f (Maybe Text)) -> ClusterNode -> f ClusterNode
clusterNode_publicIPAddress = (ClusterNode -> Maybe Text)
-> (ClusterNode -> Maybe Text -> ClusterNode)
-> Lens ClusterNode ClusterNode (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterNode' {Maybe Text
publicIPAddress :: Maybe Text
$sel:publicIPAddress:ClusterNode' :: ClusterNode -> Maybe Text
publicIPAddress} -> Maybe Text
publicIPAddress) (\s :: ClusterNode
s@ClusterNode' {} Maybe Text
a -> ClusterNode
s {$sel:publicIPAddress:ClusterNode' :: Maybe Text
publicIPAddress = Maybe Text
a} :: ClusterNode)

instance Core.FromXML ClusterNode where
  parseXML :: [Node] -> Either String ClusterNode
parseXML [Node]
x =
    Maybe Text -> Maybe Text -> Maybe Text -> ClusterNode
ClusterNode'
      (Maybe Text -> Maybe Text -> Maybe Text -> ClusterNode)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> Maybe Text -> ClusterNode)
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
"NodeRole")
      Either String (Maybe Text -> Maybe Text -> ClusterNode)
-> Either String (Maybe Text)
-> Either String (Maybe Text -> ClusterNode)
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
"PrivateIPAddress")
      Either String (Maybe Text -> ClusterNode)
-> Either String (Maybe Text) -> Either String ClusterNode
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
"PublicIPAddress")

instance Prelude.Hashable ClusterNode

instance Prelude.NFData ClusterNode