{-# 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.NodeOverrides
-- 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.NodeOverrides where

import Amazonka.Batch.Types.NodePropertyOverride
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Object representing any node overrides to a job definition that\'s used
-- in a SubmitJob API operation.
--
-- This isn\'t applicable to jobs that are running on Fargate resources and
-- shouldn\'t be provided; use @containerOverrides@ instead.
--
-- /See:/ 'newNodeOverrides' smart constructor.
data NodeOverrides = NodeOverrides'
  { -- | The number of nodes to use with a multi-node parallel job. This value
    -- overrides the number of nodes that are specified in the job definition.
    -- To use this override:
    --
    -- -   There must be at least one node range in your job definition that
    --     has an open upper boundary (such as @:@ or @n:@).
    --
    -- -   The lower boundary of the node range specified in the job definition
    --     must be fewer than the number of nodes specified in the override.
    --
    -- -   The main node index specified in the job definition must be fewer
    --     than the number of nodes specified in the override.
    NodeOverrides -> Maybe Int
numNodes :: Prelude.Maybe Prelude.Int,
    -- | The node property overrides for the job.
    NodeOverrides -> Maybe [NodePropertyOverride]
nodePropertyOverrides :: Prelude.Maybe [NodePropertyOverride]
  }
  deriving (NodeOverrides -> NodeOverrides -> Bool
(NodeOverrides -> NodeOverrides -> Bool)
-> (NodeOverrides -> NodeOverrides -> Bool) -> Eq NodeOverrides
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: NodeOverrides -> NodeOverrides -> Bool
$c/= :: NodeOverrides -> NodeOverrides -> Bool
== :: NodeOverrides -> NodeOverrides -> Bool
$c== :: NodeOverrides -> NodeOverrides -> Bool
Prelude.Eq, ReadPrec [NodeOverrides]
ReadPrec NodeOverrides
Int -> ReadS NodeOverrides
ReadS [NodeOverrides]
(Int -> ReadS NodeOverrides)
-> ReadS [NodeOverrides]
-> ReadPrec NodeOverrides
-> ReadPrec [NodeOverrides]
-> Read NodeOverrides
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [NodeOverrides]
$creadListPrec :: ReadPrec [NodeOverrides]
readPrec :: ReadPrec NodeOverrides
$creadPrec :: ReadPrec NodeOverrides
readList :: ReadS [NodeOverrides]
$creadList :: ReadS [NodeOverrides]
readsPrec :: Int -> ReadS NodeOverrides
$creadsPrec :: Int -> ReadS NodeOverrides
Prelude.Read, Int -> NodeOverrides -> ShowS
[NodeOverrides] -> ShowS
NodeOverrides -> String
(Int -> NodeOverrides -> ShowS)
-> (NodeOverrides -> String)
-> ([NodeOverrides] -> ShowS)
-> Show NodeOverrides
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [NodeOverrides] -> ShowS
$cshowList :: [NodeOverrides] -> ShowS
show :: NodeOverrides -> String
$cshow :: NodeOverrides -> String
showsPrec :: Int -> NodeOverrides -> ShowS
$cshowsPrec :: Int -> NodeOverrides -> ShowS
Prelude.Show, (forall x. NodeOverrides -> Rep NodeOverrides x)
-> (forall x. Rep NodeOverrides x -> NodeOverrides)
-> Generic NodeOverrides
forall x. Rep NodeOverrides x -> NodeOverrides
forall x. NodeOverrides -> Rep NodeOverrides x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep NodeOverrides x -> NodeOverrides
$cfrom :: forall x. NodeOverrides -> Rep NodeOverrides x
Prelude.Generic)

-- |
-- Create a value of 'NodeOverrides' 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:
--
-- 'numNodes', 'nodeOverrides_numNodes' - The number of nodes to use with a multi-node parallel job. This value
-- overrides the number of nodes that are specified in the job definition.
-- To use this override:
--
-- -   There must be at least one node range in your job definition that
--     has an open upper boundary (such as @:@ or @n:@).
--
-- -   The lower boundary of the node range specified in the job definition
--     must be fewer than the number of nodes specified in the override.
--
-- -   The main node index specified in the job definition must be fewer
--     than the number of nodes specified in the override.
--
-- 'nodePropertyOverrides', 'nodeOverrides_nodePropertyOverrides' - The node property overrides for the job.
newNodeOverrides ::
  NodeOverrides
newNodeOverrides :: NodeOverrides
newNodeOverrides =
  NodeOverrides' :: Maybe Int -> Maybe [NodePropertyOverride] -> NodeOverrides
NodeOverrides'
    { $sel:numNodes:NodeOverrides' :: Maybe Int
numNodes = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:nodePropertyOverrides:NodeOverrides' :: Maybe [NodePropertyOverride]
nodePropertyOverrides = Maybe [NodePropertyOverride]
forall a. Maybe a
Prelude.Nothing
    }

-- | The number of nodes to use with a multi-node parallel job. This value
-- overrides the number of nodes that are specified in the job definition.
-- To use this override:
--
-- -   There must be at least one node range in your job definition that
--     has an open upper boundary (such as @:@ or @n:@).
--
-- -   The lower boundary of the node range specified in the job definition
--     must be fewer than the number of nodes specified in the override.
--
-- -   The main node index specified in the job definition must be fewer
--     than the number of nodes specified in the override.
nodeOverrides_numNodes :: Lens.Lens' NodeOverrides (Prelude.Maybe Prelude.Int)
nodeOverrides_numNodes :: (Maybe Int -> f (Maybe Int)) -> NodeOverrides -> f NodeOverrides
nodeOverrides_numNodes = (NodeOverrides -> Maybe Int)
-> (NodeOverrides -> Maybe Int -> NodeOverrides)
-> Lens NodeOverrides NodeOverrides (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodeOverrides' {Maybe Int
numNodes :: Maybe Int
$sel:numNodes:NodeOverrides' :: NodeOverrides -> Maybe Int
numNodes} -> Maybe Int
numNodes) (\s :: NodeOverrides
s@NodeOverrides' {} Maybe Int
a -> NodeOverrides
s {$sel:numNodes:NodeOverrides' :: Maybe Int
numNodes = Maybe Int
a} :: NodeOverrides)

-- | The node property overrides for the job.
nodeOverrides_nodePropertyOverrides :: Lens.Lens' NodeOverrides (Prelude.Maybe [NodePropertyOverride])
nodeOverrides_nodePropertyOverrides :: (Maybe [NodePropertyOverride] -> f (Maybe [NodePropertyOverride]))
-> NodeOverrides -> f NodeOverrides
nodeOverrides_nodePropertyOverrides = (NodeOverrides -> Maybe [NodePropertyOverride])
-> (NodeOverrides -> Maybe [NodePropertyOverride] -> NodeOverrides)
-> Lens
     NodeOverrides
     NodeOverrides
     (Maybe [NodePropertyOverride])
     (Maybe [NodePropertyOverride])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\NodeOverrides' {Maybe [NodePropertyOverride]
nodePropertyOverrides :: Maybe [NodePropertyOverride]
$sel:nodePropertyOverrides:NodeOverrides' :: NodeOverrides -> Maybe [NodePropertyOverride]
nodePropertyOverrides} -> Maybe [NodePropertyOverride]
nodePropertyOverrides) (\s :: NodeOverrides
s@NodeOverrides' {} Maybe [NodePropertyOverride]
a -> NodeOverrides
s {$sel:nodePropertyOverrides:NodeOverrides' :: Maybe [NodePropertyOverride]
nodePropertyOverrides = Maybe [NodePropertyOverride]
a} :: NodeOverrides) ((Maybe [NodePropertyOverride] -> f (Maybe [NodePropertyOverride]))
 -> NodeOverrides -> f NodeOverrides)
-> ((Maybe [NodePropertyOverride]
     -> f (Maybe [NodePropertyOverride]))
    -> Maybe [NodePropertyOverride]
    -> f (Maybe [NodePropertyOverride]))
-> (Maybe [NodePropertyOverride]
    -> f (Maybe [NodePropertyOverride]))
-> NodeOverrides
-> f NodeOverrides
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [NodePropertyOverride]
  [NodePropertyOverride]
  [NodePropertyOverride]
  [NodePropertyOverride]
-> Iso
     (Maybe [NodePropertyOverride])
     (Maybe [NodePropertyOverride])
     (Maybe [NodePropertyOverride])
     (Maybe [NodePropertyOverride])
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
  [NodePropertyOverride]
  [NodePropertyOverride]
  [NodePropertyOverride]
  [NodePropertyOverride]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable NodeOverrides

instance Prelude.NFData NodeOverrides

instance Core.ToJSON NodeOverrides where
  toJSON :: NodeOverrides -> Value
toJSON NodeOverrides' {Maybe Int
Maybe [NodePropertyOverride]
nodePropertyOverrides :: Maybe [NodePropertyOverride]
numNodes :: Maybe Int
$sel:nodePropertyOverrides:NodeOverrides' :: NodeOverrides -> Maybe [NodePropertyOverride]
$sel:numNodes:NodeOverrides' :: NodeOverrides -> Maybe Int
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"numNodes" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Int -> Pair) -> Maybe Int -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
numNodes,
            (Text
"nodePropertyOverrides" Text -> [NodePropertyOverride] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([NodePropertyOverride] -> Pair)
-> Maybe [NodePropertyOverride] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [NodePropertyOverride]
nodePropertyOverrides
          ]
      )