{-# 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.DataSync.Types.HdfsNameNode
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.DataSync.Types.HdfsNameNode where

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

-- | The NameNode of the Hadoop Distributed File System (HDFS). The NameNode
-- manages the file system\'s namespace. The NameNode performs operations
-- such as opening, closing, and renaming files and directories. The
-- NameNode contains the information to map blocks of data to the
-- DataNodes.
--
-- /See:/ 'newHdfsNameNode' smart constructor.
data HdfsNameNode = HdfsNameNode'
  { -- | The hostname of the NameNode in the HDFS cluster. This value is the IP
    -- address or Domain Name Service (DNS) name of the NameNode. An agent
    -- that\'s installed on-premises uses this hostname to communicate with the
    -- NameNode in the network.
    HdfsNameNode -> Text
hostname :: Prelude.Text,
    -- | The port that the NameNode uses to listen to client requests.
    HdfsNameNode -> Natural
port :: Prelude.Natural
  }
  deriving (HdfsNameNode -> HdfsNameNode -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HdfsNameNode -> HdfsNameNode -> Bool
$c/= :: HdfsNameNode -> HdfsNameNode -> Bool
== :: HdfsNameNode -> HdfsNameNode -> Bool
$c== :: HdfsNameNode -> HdfsNameNode -> Bool
Prelude.Eq, ReadPrec [HdfsNameNode]
ReadPrec HdfsNameNode
Int -> ReadS HdfsNameNode
ReadS [HdfsNameNode]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HdfsNameNode]
$creadListPrec :: ReadPrec [HdfsNameNode]
readPrec :: ReadPrec HdfsNameNode
$creadPrec :: ReadPrec HdfsNameNode
readList :: ReadS [HdfsNameNode]
$creadList :: ReadS [HdfsNameNode]
readsPrec :: Int -> ReadS HdfsNameNode
$creadsPrec :: Int -> ReadS HdfsNameNode
Prelude.Read, Int -> HdfsNameNode -> ShowS
[HdfsNameNode] -> ShowS
HdfsNameNode -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HdfsNameNode] -> ShowS
$cshowList :: [HdfsNameNode] -> ShowS
show :: HdfsNameNode -> String
$cshow :: HdfsNameNode -> String
showsPrec :: Int -> HdfsNameNode -> ShowS
$cshowsPrec :: Int -> HdfsNameNode -> ShowS
Prelude.Show, forall x. Rep HdfsNameNode x -> HdfsNameNode
forall x. HdfsNameNode -> Rep HdfsNameNode x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HdfsNameNode x -> HdfsNameNode
$cfrom :: forall x. HdfsNameNode -> Rep HdfsNameNode x
Prelude.Generic)

-- |
-- Create a value of 'HdfsNameNode' 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:
--
-- 'hostname', 'hdfsNameNode_hostname' - The hostname of the NameNode in the HDFS cluster. This value is the IP
-- address or Domain Name Service (DNS) name of the NameNode. An agent
-- that\'s installed on-premises uses this hostname to communicate with the
-- NameNode in the network.
--
-- 'port', 'hdfsNameNode_port' - The port that the NameNode uses to listen to client requests.
newHdfsNameNode ::
  -- | 'hostname'
  Prelude.Text ->
  -- | 'port'
  Prelude.Natural ->
  HdfsNameNode
newHdfsNameNode :: Text -> Natural -> HdfsNameNode
newHdfsNameNode Text
pHostname_ Natural
pPort_ =
  HdfsNameNode' {$sel:hostname:HdfsNameNode' :: Text
hostname = Text
pHostname_, $sel:port:HdfsNameNode' :: Natural
port = Natural
pPort_}

-- | The hostname of the NameNode in the HDFS cluster. This value is the IP
-- address or Domain Name Service (DNS) name of the NameNode. An agent
-- that\'s installed on-premises uses this hostname to communicate with the
-- NameNode in the network.
hdfsNameNode_hostname :: Lens.Lens' HdfsNameNode Prelude.Text
hdfsNameNode_hostname :: Lens' HdfsNameNode Text
hdfsNameNode_hostname = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HdfsNameNode' {Text
hostname :: Text
$sel:hostname:HdfsNameNode' :: HdfsNameNode -> Text
hostname} -> Text
hostname) (\s :: HdfsNameNode
s@HdfsNameNode' {} Text
a -> HdfsNameNode
s {$sel:hostname:HdfsNameNode' :: Text
hostname = Text
a} :: HdfsNameNode)

-- | The port that the NameNode uses to listen to client requests.
hdfsNameNode_port :: Lens.Lens' HdfsNameNode Prelude.Natural
hdfsNameNode_port :: Lens' HdfsNameNode Natural
hdfsNameNode_port = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HdfsNameNode' {Natural
port :: Natural
$sel:port:HdfsNameNode' :: HdfsNameNode -> Natural
port} -> Natural
port) (\s :: HdfsNameNode
s@HdfsNameNode' {} Natural
a -> HdfsNameNode
s {$sel:port:HdfsNameNode' :: Natural
port = Natural
a} :: HdfsNameNode)

instance Data.FromJSON HdfsNameNode where
  parseJSON :: Value -> Parser HdfsNameNode
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"HdfsNameNode"
      ( \Object
x ->
          Text -> Natural -> HdfsNameNode
HdfsNameNode'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Hostname")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Port")
      )

instance Prelude.Hashable HdfsNameNode where
  hashWithSalt :: Int -> HdfsNameNode -> Int
hashWithSalt Int
_salt HdfsNameNode' {Natural
Text
port :: Natural
hostname :: Text
$sel:port:HdfsNameNode' :: HdfsNameNode -> Natural
$sel:hostname:HdfsNameNode' :: HdfsNameNode -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
hostname
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
port

instance Prelude.NFData HdfsNameNode where
  rnf :: HdfsNameNode -> ()
rnf HdfsNameNode' {Natural
Text
port :: Natural
hostname :: Text
$sel:port:HdfsNameNode' :: HdfsNameNode -> Natural
$sel:hostname:HdfsNameNode' :: HdfsNameNode -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
hostname seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
port

instance Data.ToJSON HdfsNameNode where
  toJSON :: HdfsNameNode -> Value
toJSON HdfsNameNode' {Natural
Text
port :: Natural
hostname :: Text
$sel:port:HdfsNameNode' :: HdfsNameNode -> Natural
$sel:hostname:HdfsNameNode' :: HdfsNameNode -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Hostname" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
hostname),
            forall a. a -> Maybe a
Prelude.Just (Key
"Port" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
port)
          ]
      )