{-# 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.Batch.Types.NodeDetails
-- 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.Batch.Types.NodeDetails 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

-- | An object that represents the details of a multi-node parallel job node.
--
-- /See:/ 'newNodeDetails' smart constructor.
data NodeDetails = NodeDetails'
  { -- | Specifies whether the current node is the main node for a multi-node
    -- parallel job.
    NodeDetails -> Maybe Bool
isMainNode :: Prelude.Maybe Prelude.Bool,
    -- | The node index for the node. Node index numbering starts at zero. This
    -- index is also available on the node with the @AWS_BATCH_JOB_NODE_INDEX@
    -- environment variable.
    NodeDetails -> Maybe Int
nodeIndex :: Prelude.Maybe Prelude.Int
  }
  deriving (NodeDetails -> NodeDetails -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NodeDetails -> NodeDetails -> Bool
$c/= :: NodeDetails -> NodeDetails -> Bool
== :: NodeDetails -> NodeDetails -> Bool
$c== :: NodeDetails -> NodeDetails -> Bool
Prelude.Eq, ReadPrec [NodeDetails]
ReadPrec NodeDetails
Int -> ReadS NodeDetails
ReadS [NodeDetails]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NodeDetails]
$creadListPrec :: ReadPrec [NodeDetails]
readPrec :: ReadPrec NodeDetails
$creadPrec :: ReadPrec NodeDetails
readList :: ReadS [NodeDetails]
$creadList :: ReadS [NodeDetails]
readsPrec :: Int -> ReadS NodeDetails
$creadsPrec :: Int -> ReadS NodeDetails
Prelude.Read, Int -> NodeDetails -> ShowS
[NodeDetails] -> ShowS
NodeDetails -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NodeDetails] -> ShowS
$cshowList :: [NodeDetails] -> ShowS
show :: NodeDetails -> String
$cshow :: NodeDetails -> String
showsPrec :: Int -> NodeDetails -> ShowS
$cshowsPrec :: Int -> NodeDetails -> ShowS
Prelude.Show, forall x. Rep NodeDetails x -> NodeDetails
forall x. NodeDetails -> Rep NodeDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NodeDetails x -> NodeDetails
$cfrom :: forall x. NodeDetails -> Rep NodeDetails x
Prelude.Generic)

-- |
-- Create a value of 'NodeDetails' 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:
--
-- 'isMainNode', 'nodeDetails_isMainNode' - Specifies whether the current node is the main node for a multi-node
-- parallel job.
--
-- 'nodeIndex', 'nodeDetails_nodeIndex' - The node index for the node. Node index numbering starts at zero. This
-- index is also available on the node with the @AWS_BATCH_JOB_NODE_INDEX@
-- environment variable.
newNodeDetails ::
  NodeDetails
newNodeDetails :: NodeDetails
newNodeDetails =
  NodeDetails'
    { $sel:isMainNode:NodeDetails' :: Maybe Bool
isMainNode = forall a. Maybe a
Prelude.Nothing,
      $sel:nodeIndex:NodeDetails' :: Maybe Int
nodeIndex = forall a. Maybe a
Prelude.Nothing
    }

-- | Specifies whether the current node is the main node for a multi-node
-- parallel job.
nodeDetails_isMainNode :: Lens.Lens' NodeDetails (Prelude.Maybe Prelude.Bool)
nodeDetails_isMainNode :: Lens' NodeDetails (Maybe Bool)
nodeDetails_isMainNode = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodeDetails' {Maybe Bool
isMainNode :: Maybe Bool
$sel:isMainNode:NodeDetails' :: NodeDetails -> Maybe Bool
isMainNode} -> Maybe Bool
isMainNode) (\s :: NodeDetails
s@NodeDetails' {} Maybe Bool
a -> NodeDetails
s {$sel:isMainNode:NodeDetails' :: Maybe Bool
isMainNode = Maybe Bool
a} :: NodeDetails)

-- | The node index for the node. Node index numbering starts at zero. This
-- index is also available on the node with the @AWS_BATCH_JOB_NODE_INDEX@
-- environment variable.
nodeDetails_nodeIndex :: Lens.Lens' NodeDetails (Prelude.Maybe Prelude.Int)
nodeDetails_nodeIndex :: Lens' NodeDetails (Maybe Int)
nodeDetails_nodeIndex = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodeDetails' {Maybe Int
nodeIndex :: Maybe Int
$sel:nodeIndex:NodeDetails' :: NodeDetails -> Maybe Int
nodeIndex} -> Maybe Int
nodeIndex) (\s :: NodeDetails
s@NodeDetails' {} Maybe Int
a -> NodeDetails
s {$sel:nodeIndex:NodeDetails' :: Maybe Int
nodeIndex = Maybe Int
a} :: NodeDetails)

instance Data.FromJSON NodeDetails where
  parseJSON :: Value -> Parser NodeDetails
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"NodeDetails"
      ( \Object
x ->
          Maybe Bool -> Maybe Int -> NodeDetails
NodeDetails'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"isMainNode")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"nodeIndex")
      )

instance Prelude.Hashable NodeDetails where
  hashWithSalt :: Int -> NodeDetails -> Int
hashWithSalt Int
_salt NodeDetails' {Maybe Bool
Maybe Int
nodeIndex :: Maybe Int
isMainNode :: Maybe Bool
$sel:nodeIndex:NodeDetails' :: NodeDetails -> Maybe Int
$sel:isMainNode:NodeDetails' :: NodeDetails -> Maybe Bool
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Bool
isMainNode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
nodeIndex

instance Prelude.NFData NodeDetails where
  rnf :: NodeDetails -> ()
rnf NodeDetails' {Maybe Bool
Maybe Int
nodeIndex :: Maybe Int
isMainNode :: Maybe Bool
$sel:nodeIndex:NodeDetails' :: NodeDetails -> Maybe Int
$sel:isMainNode:NodeDetails' :: NodeDetails -> Maybe Bool
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Bool
isMainNode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
nodeIndex