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

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

-- | An object representing the details of a multi-node parallel job node.
--
-- /See:/ 'newNodeDetails' smart constructor.
data NodeDetails = NodeDetails'
  { -- | The node index for the node. Node index numbering begins 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,
    -- | Specifies whether the current node is the main node for a multi-node
    -- parallel job.
    NodeDetails -> Maybe Bool
isMainNode :: Prelude.Maybe Prelude.Bool
  }
  deriving (NodeDetails -> NodeDetails -> Bool
(NodeDetails -> NodeDetails -> Bool)
-> (NodeDetails -> NodeDetails -> Bool) -> Eq NodeDetails
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]
(Int -> ReadS NodeDetails)
-> ReadS [NodeDetails]
-> ReadPrec NodeDetails
-> ReadPrec [NodeDetails]
-> Read 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
(Int -> NodeDetails -> ShowS)
-> (NodeDetails -> String)
-> ([NodeDetails] -> ShowS)
-> Show NodeDetails
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. NodeDetails -> Rep NodeDetails x)
-> (forall x. Rep NodeDetails x -> NodeDetails)
-> Generic NodeDetails
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:
--
-- 'nodeIndex', 'nodeDetails_nodeIndex' - The node index for the node. Node index numbering begins at zero. This
-- index is also available on the node with the @AWS_BATCH_JOB_NODE_INDEX@
-- environment variable.
--
-- 'isMainNode', 'nodeDetails_isMainNode' - Specifies whether the current node is the main node for a multi-node
-- parallel job.
newNodeDetails ::
  NodeDetails
newNodeDetails :: NodeDetails
newNodeDetails =
  NodeDetails' :: Maybe Int -> Maybe Bool -> NodeDetails
NodeDetails'
    { $sel:nodeIndex:NodeDetails' :: Maybe Int
nodeIndex = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:isMainNode:NodeDetails' :: Maybe Bool
isMainNode = Maybe Bool
forall a. Maybe a
Prelude.Nothing
    }

-- | The node index for the node. Node index numbering begins 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 :: (Maybe Int -> f (Maybe Int)) -> NodeDetails -> f NodeDetails
nodeDetails_nodeIndex = (NodeDetails -> Maybe Int)
-> (NodeDetails -> Maybe Int -> NodeDetails)
-> Lens NodeDetails NodeDetails (Maybe Int) (Maybe Int)
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)

-- | 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 :: (Maybe Bool -> f (Maybe Bool)) -> NodeDetails -> f NodeDetails
nodeDetails_isMainNode = (NodeDetails -> Maybe Bool)
-> (NodeDetails -> Maybe Bool -> NodeDetails)
-> Lens NodeDetails NodeDetails (Maybe Bool) (Maybe Bool)
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)

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

instance Prelude.Hashable NodeDetails

instance Prelude.NFData NodeDetails