{-# 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.JobTimeout
-- 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.JobTimeout 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 a job timeout configuration.
--
-- /See:/ 'newJobTimeout' smart constructor.
data JobTimeout = JobTimeout'
  { -- | The job timeout time (in seconds) that\'s measured from the job
    -- attempt\'s @startedAt@ timestamp. After this time passes, Batch
    -- terminates your jobs if they aren\'t finished. The minimum value for the
    -- timeout is 60 seconds.
    --
    -- For array jobs, the timeout applies to the child jobs, not to the parent
    -- array job.
    --
    -- For multi-node parallel (MNP) jobs, the timeout applies to the whole
    -- job, not to the individual nodes.
    JobTimeout -> Maybe Int
attemptDurationSeconds :: Prelude.Maybe Prelude.Int
  }
  deriving (JobTimeout -> JobTimeout -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: JobTimeout -> JobTimeout -> Bool
$c/= :: JobTimeout -> JobTimeout -> Bool
== :: JobTimeout -> JobTimeout -> Bool
$c== :: JobTimeout -> JobTimeout -> Bool
Prelude.Eq, ReadPrec [JobTimeout]
ReadPrec JobTimeout
Int -> ReadS JobTimeout
ReadS [JobTimeout]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [JobTimeout]
$creadListPrec :: ReadPrec [JobTimeout]
readPrec :: ReadPrec JobTimeout
$creadPrec :: ReadPrec JobTimeout
readList :: ReadS [JobTimeout]
$creadList :: ReadS [JobTimeout]
readsPrec :: Int -> ReadS JobTimeout
$creadsPrec :: Int -> ReadS JobTimeout
Prelude.Read, Int -> JobTimeout -> ShowS
[JobTimeout] -> ShowS
JobTimeout -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [JobTimeout] -> ShowS
$cshowList :: [JobTimeout] -> ShowS
show :: JobTimeout -> String
$cshow :: JobTimeout -> String
showsPrec :: Int -> JobTimeout -> ShowS
$cshowsPrec :: Int -> JobTimeout -> ShowS
Prelude.Show, forall x. Rep JobTimeout x -> JobTimeout
forall x. JobTimeout -> Rep JobTimeout x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep JobTimeout x -> JobTimeout
$cfrom :: forall x. JobTimeout -> Rep JobTimeout x
Prelude.Generic)

-- |
-- Create a value of 'JobTimeout' 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:
--
-- 'attemptDurationSeconds', 'jobTimeout_attemptDurationSeconds' - The job timeout time (in seconds) that\'s measured from the job
-- attempt\'s @startedAt@ timestamp. After this time passes, Batch
-- terminates your jobs if they aren\'t finished. The minimum value for the
-- timeout is 60 seconds.
--
-- For array jobs, the timeout applies to the child jobs, not to the parent
-- array job.
--
-- For multi-node parallel (MNP) jobs, the timeout applies to the whole
-- job, not to the individual nodes.
newJobTimeout ::
  JobTimeout
newJobTimeout :: JobTimeout
newJobTimeout =
  JobTimeout'
    { $sel:attemptDurationSeconds:JobTimeout' :: Maybe Int
attemptDurationSeconds =
        forall a. Maybe a
Prelude.Nothing
    }

-- | The job timeout time (in seconds) that\'s measured from the job
-- attempt\'s @startedAt@ timestamp. After this time passes, Batch
-- terminates your jobs if they aren\'t finished. The minimum value for the
-- timeout is 60 seconds.
--
-- For array jobs, the timeout applies to the child jobs, not to the parent
-- array job.
--
-- For multi-node parallel (MNP) jobs, the timeout applies to the whole
-- job, not to the individual nodes.
jobTimeout_attemptDurationSeconds :: Lens.Lens' JobTimeout (Prelude.Maybe Prelude.Int)
jobTimeout_attemptDurationSeconds :: Lens' JobTimeout (Maybe Int)
jobTimeout_attemptDurationSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\JobTimeout' {Maybe Int
attemptDurationSeconds :: Maybe Int
$sel:attemptDurationSeconds:JobTimeout' :: JobTimeout -> Maybe Int
attemptDurationSeconds} -> Maybe Int
attemptDurationSeconds) (\s :: JobTimeout
s@JobTimeout' {} Maybe Int
a -> JobTimeout
s {$sel:attemptDurationSeconds:JobTimeout' :: Maybe Int
attemptDurationSeconds = Maybe Int
a} :: JobTimeout)

instance Data.FromJSON JobTimeout where
  parseJSON :: Value -> Parser JobTimeout
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"JobTimeout"
      ( \Object
x ->
          Maybe Int -> JobTimeout
JobTimeout'
            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
"attemptDurationSeconds")
      )

instance Prelude.Hashable JobTimeout where
  hashWithSalt :: Int -> JobTimeout -> Int
hashWithSalt Int
_salt JobTimeout' {Maybe Int
attemptDurationSeconds :: Maybe Int
$sel:attemptDurationSeconds:JobTimeout' :: JobTimeout -> Maybe Int
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
attemptDurationSeconds

instance Prelude.NFData JobTimeout where
  rnf :: JobTimeout -> ()
rnf JobTimeout' {Maybe Int
attemptDurationSeconds :: Maybe Int
$sel:attemptDurationSeconds:JobTimeout' :: JobTimeout -> Maybe Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
attemptDurationSeconds

instance Data.ToJSON JobTimeout where
  toJSON :: JobTimeout -> Value
toJSON JobTimeout' {Maybe Int
attemptDurationSeconds :: Maybe Int
$sel:attemptDurationSeconds:JobTimeout' :: JobTimeout -> Maybe Int
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"attemptDurationSeconds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Int
attemptDurationSeconds
          ]
      )