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

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

-- | Represents an individual node within a cluster. Each node runs its own
-- instance of the cluster\'s protocol-compliant caching software.
--
-- /See:/ 'newNode' smart constructor.
data Node = Node'
  { -- | The status of the service update on the node
    Node -> Maybe Text
status :: Prelude.Maybe Prelude.Text,
    -- | The Availability Zone in which the node resides
    Node -> Maybe Text
availabilityZone :: Prelude.Maybe Prelude.Text,
    -- | The node identifier. A node name is a numeric identifier (0001, 0002,
    -- etc.). The combination of cluster name, shard name and node name
    -- uniquely identifies every node used in a customer\'s Amazon account.
    Node -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The hostname for connecting to this node.
    Node -> Maybe Endpoint
endpoint :: Prelude.Maybe Endpoint,
    -- | The date and time when the node was created.
    Node -> Maybe POSIX
createTime :: 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:
--
-- 'status', 'node_status' - The status of the service update on the node
--
-- 'availabilityZone', 'node_availabilityZone' - The Availability Zone in which the node resides
--
-- 'name', 'node_name' - The node identifier. A node name is a numeric identifier (0001, 0002,
-- etc.). The combination of cluster name, shard name and node name
-- uniquely identifies every node used in a customer\'s Amazon account.
--
-- 'endpoint', 'node_endpoint' - The hostname for connecting to this node.
--
-- 'createTime', 'node_createTime' - The date and time when the node was created.
newNode ::
  Node
newNode :: Node
newNode =
  Node' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Endpoint
-> Maybe POSIX
-> Node
Node'
    { $sel:status:Node' :: Maybe Text
status = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:availabilityZone:Node' :: Maybe Text
availabilityZone = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:Node' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endpoint:Node' :: Maybe Endpoint
endpoint = Maybe Endpoint
forall a. Maybe a
Prelude.Nothing,
      $sel:createTime:Node' :: Maybe POSIX
createTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing
    }

-- | The status of the service update on the node
node_status :: Lens.Lens' Node (Prelude.Maybe Prelude.Text)
node_status :: (Maybe Text -> f (Maybe Text)) -> Node -> f Node
node_status = (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
status :: Maybe Text
$sel:status:Node' :: Node -> Maybe Text
status} -> Maybe Text
status) (\s :: Node
s@Node' {} Maybe Text
a -> Node
s {$sel:status:Node' :: Maybe Text
status = Maybe Text
a} :: Node)

-- | The Availability Zone in which the node resides
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)

-- | The node identifier. A node name is a numeric identifier (0001, 0002,
-- etc.). The combination of cluster name, shard name and node name
-- uniquely identifies every node used in a customer\'s Amazon account.
node_name :: Lens.Lens' Node (Prelude.Maybe Prelude.Text)
node_name :: (Maybe Text -> f (Maybe Text)) -> Node -> f Node
node_name = (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
name :: Maybe Text
$sel:name:Node' :: Node -> Maybe Text
name} -> Maybe Text
name) (\s :: Node
s@Node' {} Maybe Text
a -> Node
s {$sel:name:Node' :: Maybe Text
name = Maybe Text
a} :: Node)

-- | The hostname for connecting to this node.
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 when the node was created.
node_createTime :: Lens.Lens' Node (Prelude.Maybe Prelude.UTCTime)
node_createTime :: (Maybe UTCTime -> f (Maybe UTCTime)) -> Node -> f Node
node_createTime = (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
createTime :: Maybe POSIX
$sel:createTime:Node' :: Node -> Maybe POSIX
createTime} -> Maybe POSIX
createTime) (\s :: Node
s@Node' {} Maybe POSIX
a -> Node
s {$sel:createTime:Node' :: Maybe POSIX
createTime = 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 Endpoint
-> Maybe POSIX
-> Node
Node'
            (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. 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
"Status")
            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
"Name")
            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
"CreateTime")
      )

instance Prelude.Hashable Node

instance Prelude.NFData Node