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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(ProcessingStoppingCondition
 -> ProcessingStoppingCondition -> Bool)
-> (ProcessingStoppingCondition
    -> ProcessingStoppingCondition -> Bool)
-> Eq ProcessingStoppingCondition
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]
(Int -> ReadS ProcessingStoppingCondition)
-> ReadS [ProcessingStoppingCondition]
-> ReadPrec ProcessingStoppingCondition
-> ReadPrec [ProcessingStoppingCondition]
-> Read 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
(Int -> ProcessingStoppingCondition -> ShowS)
-> (ProcessingStoppingCondition -> String)
-> ([ProcessingStoppingCondition] -> ShowS)
-> Show ProcessingStoppingCondition
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.
 ProcessingStoppingCondition -> Rep ProcessingStoppingCondition x)
-> (forall x.
    Rep ProcessingStoppingCondition x -> ProcessingStoppingCondition)
-> Generic ProcessingStoppingCondition
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' :: Natural -> ProcessingStoppingCondition
ProcessingStoppingCondition'
    { $sel:maxRuntimeInSeconds:ProcessingStoppingCondition' :: Natural
maxRuntimeInSeconds =
        Natural
pMaxRuntimeInSeconds_
    }

-- | Specifies the maximum runtime in seconds.
processingStoppingCondition_maxRuntimeInSeconds :: Lens.Lens' ProcessingStoppingCondition Prelude.Natural
processingStoppingCondition_maxRuntimeInSeconds :: (Natural -> f Natural)
-> ProcessingStoppingCondition -> f ProcessingStoppingCondition
processingStoppingCondition_maxRuntimeInSeconds = (ProcessingStoppingCondition -> Natural)
-> (ProcessingStoppingCondition
    -> Natural -> ProcessingStoppingCondition)
-> Lens
     ProcessingStoppingCondition
     ProcessingStoppingCondition
     Natural
     Natural
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 Core.FromJSON ProcessingStoppingCondition where
  parseJSON :: Value -> Parser ProcessingStoppingCondition
parseJSON =
    String
-> (Object -> Parser ProcessingStoppingCondition)
-> Value
-> Parser ProcessingStoppingCondition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ProcessingStoppingCondition"
      ( \Object
x ->
          Natural -> ProcessingStoppingCondition
ProcessingStoppingCondition'
            (Natural -> ProcessingStoppingCondition)
-> Parser Natural -> Parser ProcessingStoppingCondition
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MaxRuntimeInSeconds")
      )

instance Prelude.Hashable ProcessingStoppingCondition

instance Prelude.NFData ProcessingStoppingCondition

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