{-# 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.DAX.Types.Node
-- 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.DAX.Types.Node where

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

-- | Represents an individual node within a DAX cluster.
--
-- /See:/ 'newNode' smart constructor.
data Node = Node'
  { -- | The current status of the node. For example: @available@.
    Node -> Maybe Text
nodeStatus :: Prelude.Maybe Prelude.Text,
    -- | The status of the parameter group associated with this node. For
    -- example, @in-sync@.
    Node -> Maybe Text
parameterGroupStatus :: Prelude.Maybe Prelude.Text,
    -- | The Availability Zone (AZ) in which the node has been deployed.
    Node -> Maybe Text
availabilityZone :: Prelude.Maybe Prelude.Text,
    -- | A system-generated identifier for the node.
    Node -> Maybe Text
nodeId :: Prelude.Maybe Prelude.Text,
    -- | The endpoint for the node, consisting of a DNS name and a port number.
    -- Client applications can connect directly to a node endpoint, if desired
    -- (as an alternative to allowing DAX client software to intelligently
    -- route requests and responses to nodes in the DAX cluster.
    Node -> Maybe Endpoint
endpoint :: Prelude.Maybe Endpoint,
    -- | The date and time (in UNIX epoch format) when the node was launched.
    Node -> Maybe POSIX
nodeCreateTime :: Prelude.Maybe Core.POSIX
  }
  deriving (Node -> Node -> Bool
(Node -> Node -> Bool) -> (Node -> Node -> Bool) -> Eq Node
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Node -> Node -> Bool
$c/= :: Node -> Node -> Bool
== :: Node -> Node -> Bool
$c== :: Node -> Node -> Bool
Prelude.Eq, ReadPrec [Node]
ReadPrec Node
Int -> ReadS Node
ReadS [Node]
(Int -> ReadS Node)
-> ReadS [Node] -> ReadPrec Node -> ReadPrec [Node] -> Read Node
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Node]
$creadListPrec :: ReadPrec [Node]
readPrec :: ReadPrec Node
$creadPrec :: ReadPrec Node
readList :: ReadS [Node]
$creadList :: ReadS [Node]
readsPrec :: Int -> ReadS Node
$creadsPrec :: Int -> ReadS Node
Prelude.Read, Int -> Node -> ShowS
[Node] -> ShowS
Node -> String
(Int -> Node -> ShowS)
-> (Node -> String) -> ([Node] -> ShowS) -> Show Node
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Node] -> ShowS
$cshowList :: [Node] -> ShowS
show :: Node -> String
$cshow :: Node -> String
showsPrec :: Int -> Node -> ShowS
$cshowsPrec :: Int -> Node -> ShowS
Prelude.Show, (forall x. Node -> Rep Node x)
-> (forall x. Rep Node x -> Node) -> Generic Node
forall x. Rep Node x -> Node
forall x. Node -> Rep Node x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Node x -> Node
$cfrom :: forall x. Node -> Rep Node x
Prelude.Generic)

-- |
-- Create a value of 'Node' 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:
--
-- 'nodeStatus', 'node_nodeStatus' - The current status of the node. For example: @available@.
--
-- 'parameterGroupStatus', 'node_parameterGroupStatus' - The status of the parameter group associated with this node. For
-- example, @in-sync@.
--
-- 'availabilityZone', 'node_availabilityZone' - The Availability Zone (AZ) in which the node has been deployed.
--
-- 'nodeId', 'node_nodeId' - A system-generated identifier for the node.
--
-- 'endpoint', 'node_endpoint' - The endpoint for the node, consisting of a DNS name and a port number.
-- Client applications can connect directly to a node endpoint, if desired
-- (as an alternative to allowing DAX client software to intelligently
-- route requests and responses to nodes in the DAX cluster.
--
-- 'nodeCreateTime', 'node_nodeCreateTime' - The date and time (in UNIX epoch format) when the node was launched.
newNode ::
  Node
newNode :: Node
newNode =
  Node' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Endpoint
-> Maybe POSIX
-> Node
Node'
    { $sel:nodeStatus:Node' :: Maybe Text
nodeStatus = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:parameterGroupStatus:Node' :: Maybe Text
parameterGroupStatus = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:availabilityZone:Node' :: Maybe Text
availabilityZone = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nodeId:Node' :: Maybe Text
nodeId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endpoint:Node' :: Maybe Endpoint
endpoint = Maybe Endpoint
forall a. Maybe a
Prelude.Nothing,
      $sel:nodeCreateTime:Node' :: Maybe POSIX
nodeCreateTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The current status of the node. For example: @available@.
node_nodeStatus :: Lens.Lens' Node (Prelude.Maybe Prelude.Text)
node_nodeStatus :: (Maybe Text -> f (Maybe Text)) -> Node -> f Node
node_nodeStatus = (Node -> Maybe Text)
-> (Node -> Maybe Text -> Node)
-> Lens Node Node (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Node' {Maybe Text
nodeStatus :: Maybe Text
$sel:nodeStatus:Node' :: Node -> Maybe Text
nodeStatus} -> Maybe Text
nodeStatus) (\s :: Node
s@Node' {} Maybe Text
a -> Node
s {$sel:nodeStatus:Node' :: Maybe Text
nodeStatus = Maybe Text
a} :: Node)

-- | The status of the parameter group associated with this node. For
-- example, @in-sync@.
node_parameterGroupStatus :: Lens.Lens' Node (Prelude.Maybe Prelude.Text)
node_parameterGroupStatus :: (Maybe Text -> f (Maybe Text)) -> Node -> f Node
node_parameterGroupStatus = (Node -> Maybe Text)
-> (Node -> Maybe Text -> Node)
-> Lens Node Node (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Node' {Maybe Text
parameterGroupStatus :: Maybe Text
$sel:parameterGroupStatus:Node' :: Node -> Maybe Text
parameterGroupStatus} -> Maybe Text
parameterGroupStatus) (\s :: Node
s@Node' {} Maybe Text
a -> Node
s {$sel:parameterGroupStatus:Node' :: Maybe Text
parameterGroupStatus = Maybe Text
a} :: Node)

-- | The Availability Zone (AZ) in which the node has been deployed.
node_availabilityZone :: Lens.Lens' Node (Prelude.Maybe Prelude.Text)
node_availabilityZone :: (Maybe Text -> f (Maybe Text)) -> Node -> f Node
node_availabilityZone = (Node -> Maybe Text)
-> (Node -> Maybe Text -> Node)
-> Lens Node Node (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Node' {Maybe Text
availabilityZone :: Maybe Text
$sel:availabilityZone:Node' :: Node -> Maybe Text
availabilityZone} -> Maybe Text
availabilityZone) (\s :: Node
s@Node' {} Maybe Text
a -> Node
s {$sel:availabilityZone:Node' :: Maybe Text
availabilityZone = Maybe Text
a} :: Node)

-- | A system-generated identifier for the node.
node_nodeId :: Lens.Lens' Node (Prelude.Maybe Prelude.Text)
node_nodeId :: (Maybe Text -> f (Maybe Text)) -> Node -> f Node
node_nodeId = (Node -> Maybe Text)
-> (Node -> Maybe Text -> Node)
-> Lens Node Node (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Node' {Maybe Text
nodeId :: Maybe Text
$sel:nodeId:Node' :: Node -> Maybe Text
nodeId} -> Maybe Text
nodeId) (\s :: Node
s@Node' {} Maybe Text
a -> Node
s {$sel:nodeId:Node' :: Maybe Text
nodeId = Maybe Text
a} :: Node)

-- | The endpoint for the node, consisting of a DNS name and a port number.
-- Client applications can connect directly to a node endpoint, if desired
-- (as an alternative to allowing DAX client software to intelligently
-- route requests and responses to nodes in the DAX cluster.
node_endpoint :: Lens.Lens' Node (Prelude.Maybe Endpoint)
node_endpoint :: (Maybe Endpoint -> f (Maybe Endpoint)) -> Node -> f Node
node_endpoint = (Node -> Maybe Endpoint)
-> (Node -> Maybe Endpoint -> Node)
-> Lens Node Node (Maybe Endpoint) (Maybe Endpoint)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Node' {Maybe Endpoint
endpoint :: Maybe Endpoint
$sel:endpoint:Node' :: Node -> Maybe Endpoint
endpoint} -> Maybe Endpoint
endpoint) (\s :: Node
s@Node' {} Maybe Endpoint
a -> Node
s {$sel:endpoint:Node' :: Maybe Endpoint
endpoint = Maybe Endpoint
a} :: Node)

-- | The date and time (in UNIX epoch format) when the node was launched.
node_nodeCreateTime :: Lens.Lens' Node (Prelude.Maybe Prelude.UTCTime)
node_nodeCreateTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Node -> f Node
node_nodeCreateTime = (Node -> Maybe POSIX)
-> (Node -> Maybe POSIX -> Node)
-> Lens Node Node (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Node' {Maybe POSIX
nodeCreateTime :: Maybe POSIX
$sel:nodeCreateTime:Node' :: Node -> Maybe POSIX
nodeCreateTime} -> Maybe POSIX
nodeCreateTime) (\s :: Node
s@Node' {} Maybe POSIX
a -> Node
s {$sel:nodeCreateTime:Node' :: Maybe POSIX
nodeCreateTime = Maybe POSIX
a} :: Node) ((Maybe POSIX -> f (Maybe POSIX)) -> Node -> f Node)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> Node
-> f Node
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
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 POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

instance Core.FromJSON Node where
  parseJSON :: Value -> Parser Node
parseJSON =
    String -> (Object -> Parser Node) -> Value -> Parser Node
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Node"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Endpoint
-> Maybe POSIX
-> Node
Node'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Endpoint
 -> Maybe POSIX
 -> Node)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Endpoint
      -> Maybe POSIX
      -> Node)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NodeStatus")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Endpoint
   -> Maybe POSIX
   -> Node)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Endpoint -> Maybe POSIX -> Node)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ParameterGroupStatus")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Endpoint -> Maybe POSIX -> Node)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Endpoint -> Maybe POSIX -> Node)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AvailabilityZone")
            Parser (Maybe Text -> Maybe Endpoint -> Maybe POSIX -> Node)
-> Parser (Maybe Text)
-> Parser (Maybe Endpoint -> Maybe POSIX -> Node)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NodeId")
            Parser (Maybe Endpoint -> Maybe POSIX -> Node)
-> Parser (Maybe Endpoint) -> Parser (Maybe POSIX -> Node)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Endpoint)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Endpoint")
            Parser (Maybe POSIX -> Node) -> Parser (Maybe POSIX) -> Parser Node
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"NodeCreateTime")
      )

instance Prelude.Hashable Node

instance Prelude.NFData Node