{-# 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.SageMaker.Types.ProcessingStoppingCondition
-- 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.SageMaker.Types.ProcessingStoppingCondition 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

-- | Configures conditions under which the processing job should be stopped,
-- such as how long the processing job has been running. After the
-- condition is met, the processing job is stopped.
--
-- /See:/ 'newProcessingStoppingCondition' smart constructor.
data ProcessingStoppingCondition = ProcessingStoppingCondition'
  { -- | Specifies the maximum runtime in seconds.
    ProcessingStoppingCondition -> Natural
maxRuntimeInSeconds :: Prelude.Natural
  }
  deriving (ProcessingStoppingCondition -> ProcessingStoppingCondition -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ProcessingStoppingCondition -> ProcessingStoppingCondition -> Bool
$c/= :: ProcessingStoppingCondition -> ProcessingStoppingCondition -> Bool
== :: ProcessingStoppingCondition -> ProcessingStoppingCondition -> Bool
$c== :: ProcessingStoppingCondition -> ProcessingStoppingCondition -> Bool
Prelude.Eq, ReadPrec [ProcessingStoppingCondition]
ReadPrec ProcessingStoppingCondition
Int -> ReadS ProcessingStoppingCondition
ReadS [ProcessingStoppingCondition]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ProcessingStoppingCondition]
$creadListPrec :: ReadPrec [ProcessingStoppingCondition]
readPrec :: ReadPrec ProcessingStoppingCondition
$creadPrec :: ReadPrec ProcessingStoppingCondition
readList :: ReadS [ProcessingStoppingCondition]
$creadList :: ReadS [ProcessingStoppingCondition]
readsPrec :: Int -> ReadS ProcessingStoppingCondition
$creadsPrec :: Int -> ReadS ProcessingStoppingCondition
Prelude.Read, Int -> ProcessingStoppingCondition -> ShowS
[ProcessingStoppingCondition] -> ShowS
ProcessingStoppingCondition -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ProcessingStoppingCondition] -> ShowS
$cshowList :: [ProcessingStoppingCondition] -> ShowS
show :: ProcessingStoppingCondition -> String
$cshow :: ProcessingStoppingCondition -> String
showsPrec :: Int -> ProcessingStoppingCondition -> ShowS
$cshowsPrec :: Int -> ProcessingStoppingCondition -> ShowS
Prelude.Show, forall x.
Rep ProcessingStoppingCondition x -> ProcessingStoppingCondition
forall x.
ProcessingStoppingCondition -> Rep ProcessingStoppingCondition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ProcessingStoppingCondition x -> ProcessingStoppingCondition
$cfrom :: forall x.
ProcessingStoppingCondition -> Rep ProcessingStoppingCondition x
Prelude.Generic)

-- |
-- Create a value of 'ProcessingStoppingCondition' 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:
--
-- 'maxRuntimeInSeconds', 'processingStoppingCondition_maxRuntimeInSeconds' - Specifies the maximum runtime in seconds.
newProcessingStoppingCondition ::
  -- | 'maxRuntimeInSeconds'
  Prelude.Natural ->
  ProcessingStoppingCondition
newProcessingStoppingCondition :: Natural -> ProcessingStoppingCondition
newProcessingStoppingCondition Natural
pMaxRuntimeInSeconds_ =
  ProcessingStoppingCondition'
    { $sel:maxRuntimeInSeconds:ProcessingStoppingCondition' :: Natural
maxRuntimeInSeconds =
        Natural
pMaxRuntimeInSeconds_
    }

-- | Specifies the maximum runtime in seconds.
processingStoppingCondition_maxRuntimeInSeconds :: Lens.Lens' ProcessingStoppingCondition Prelude.Natural
processingStoppingCondition_maxRuntimeInSeconds :: Lens' ProcessingStoppingCondition Natural
processingStoppingCondition_maxRuntimeInSeconds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ProcessingStoppingCondition' {Natural
maxRuntimeInSeconds :: Natural
$sel:maxRuntimeInSeconds:ProcessingStoppingCondition' :: ProcessingStoppingCondition -> Natural
maxRuntimeInSeconds} -> Natural
maxRuntimeInSeconds) (\s :: ProcessingStoppingCondition
s@ProcessingStoppingCondition' {} Natural
a -> ProcessingStoppingCondition
s {$sel:maxRuntimeInSeconds:ProcessingStoppingCondition' :: Natural
maxRuntimeInSeconds = Natural
a} :: ProcessingStoppingCondition)

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

instance Prelude.Hashable ProcessingStoppingCondition where
  hashWithSalt :: Int -> ProcessingStoppingCondition -> Int
hashWithSalt Int
_salt ProcessingStoppingCondition' {Natural
maxRuntimeInSeconds :: Natural
$sel:maxRuntimeInSeconds:ProcessingStoppingCondition' :: ProcessingStoppingCondition -> Natural
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
maxRuntimeInSeconds

instance Prelude.NFData ProcessingStoppingCondition where
  rnf :: ProcessingStoppingCondition -> ()
rnf ProcessingStoppingCondition' {Natural
maxRuntimeInSeconds :: Natural
$sel:maxRuntimeInSeconds:ProcessingStoppingCondition' :: ProcessingStoppingCondition -> Natural
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Natural
maxRuntimeInSeconds

instance Data.ToJSON ProcessingStoppingCondition where
  toJSON :: ProcessingStoppingCondition -> Value
toJSON ProcessingStoppingCondition' {Natural
maxRuntimeInSeconds :: Natural
$sel:maxRuntimeInSeconds:ProcessingStoppingCondition' :: ProcessingStoppingCondition -> Natural
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"MaxRuntimeInSeconds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
maxRuntimeInSeconds)
          ]
      )