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

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

-- | A time limit for how long the monitoring job is allowed to run before
-- stopping.
--
-- /See:/ 'newMonitoringStoppingCondition' smart constructor.
data MonitoringStoppingCondition = MonitoringStoppingCondition'
  { -- | The maximum runtime allowed in seconds.
    --
    -- The @MaxRuntimeInSeconds@ cannot exceed the frequency of the job. For
    -- data quality and model explainability, this can be up to 3600 seconds
    -- for an hourly schedule. For model bias and model quality hourly
    -- schedules, this can be up to 1800 seconds.
    MonitoringStoppingCondition -> Natural
maxRuntimeInSeconds :: Prelude.Natural
  }
  deriving (MonitoringStoppingCondition -> MonitoringStoppingCondition -> Bool
(MonitoringStoppingCondition
 -> MonitoringStoppingCondition -> Bool)
-> (MonitoringStoppingCondition
    -> MonitoringStoppingCondition -> Bool)
-> Eq MonitoringStoppingCondition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: MonitoringStoppingCondition -> MonitoringStoppingCondition -> Bool
$c/= :: MonitoringStoppingCondition -> MonitoringStoppingCondition -> Bool
== :: MonitoringStoppingCondition -> MonitoringStoppingCondition -> Bool
$c== :: MonitoringStoppingCondition -> MonitoringStoppingCondition -> Bool
Prelude.Eq, ReadPrec [MonitoringStoppingCondition]
ReadPrec MonitoringStoppingCondition
Int -> ReadS MonitoringStoppingCondition
ReadS [MonitoringStoppingCondition]
(Int -> ReadS MonitoringStoppingCondition)
-> ReadS [MonitoringStoppingCondition]
-> ReadPrec MonitoringStoppingCondition
-> ReadPrec [MonitoringStoppingCondition]
-> Read MonitoringStoppingCondition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [MonitoringStoppingCondition]
$creadListPrec :: ReadPrec [MonitoringStoppingCondition]
readPrec :: ReadPrec MonitoringStoppingCondition
$creadPrec :: ReadPrec MonitoringStoppingCondition
readList :: ReadS [MonitoringStoppingCondition]
$creadList :: ReadS [MonitoringStoppingCondition]
readsPrec :: Int -> ReadS MonitoringStoppingCondition
$creadsPrec :: Int -> ReadS MonitoringStoppingCondition
Prelude.Read, Int -> MonitoringStoppingCondition -> ShowS
[MonitoringStoppingCondition] -> ShowS
MonitoringStoppingCondition -> String
(Int -> MonitoringStoppingCondition -> ShowS)
-> (MonitoringStoppingCondition -> String)
-> ([MonitoringStoppingCondition] -> ShowS)
-> Show MonitoringStoppingCondition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [MonitoringStoppingCondition] -> ShowS
$cshowList :: [MonitoringStoppingCondition] -> ShowS
show :: MonitoringStoppingCondition -> String
$cshow :: MonitoringStoppingCondition -> String
showsPrec :: Int -> MonitoringStoppingCondition -> ShowS
$cshowsPrec :: Int -> MonitoringStoppingCondition -> ShowS
Prelude.Show, (forall x.
 MonitoringStoppingCondition -> Rep MonitoringStoppingCondition x)
-> (forall x.
    Rep MonitoringStoppingCondition x -> MonitoringStoppingCondition)
-> Generic MonitoringStoppingCondition
forall x.
Rep MonitoringStoppingCondition x -> MonitoringStoppingCondition
forall x.
MonitoringStoppingCondition -> Rep MonitoringStoppingCondition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep MonitoringStoppingCondition x -> MonitoringStoppingCondition
$cfrom :: forall x.
MonitoringStoppingCondition -> Rep MonitoringStoppingCondition x
Prelude.Generic)

-- |
-- Create a value of 'MonitoringStoppingCondition' 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', 'monitoringStoppingCondition_maxRuntimeInSeconds' - The maximum runtime allowed in seconds.
--
-- The @MaxRuntimeInSeconds@ cannot exceed the frequency of the job. For
-- data quality and model explainability, this can be up to 3600 seconds
-- for an hourly schedule. For model bias and model quality hourly
-- schedules, this can be up to 1800 seconds.
newMonitoringStoppingCondition ::
  -- | 'maxRuntimeInSeconds'
  Prelude.Natural ->
  MonitoringStoppingCondition
newMonitoringStoppingCondition :: Natural -> MonitoringStoppingCondition
newMonitoringStoppingCondition Natural
pMaxRuntimeInSeconds_ =
  MonitoringStoppingCondition' :: Natural -> MonitoringStoppingCondition
MonitoringStoppingCondition'
    { $sel:maxRuntimeInSeconds:MonitoringStoppingCondition' :: Natural
maxRuntimeInSeconds =
        Natural
pMaxRuntimeInSeconds_
    }

-- | The maximum runtime allowed in seconds.
--
-- The @MaxRuntimeInSeconds@ cannot exceed the frequency of the job. For
-- data quality and model explainability, this can be up to 3600 seconds
-- for an hourly schedule. For model bias and model quality hourly
-- schedules, this can be up to 1800 seconds.
monitoringStoppingCondition_maxRuntimeInSeconds :: Lens.Lens' MonitoringStoppingCondition Prelude.Natural
monitoringStoppingCondition_maxRuntimeInSeconds :: (Natural -> f Natural)
-> MonitoringStoppingCondition -> f MonitoringStoppingCondition
monitoringStoppingCondition_maxRuntimeInSeconds = (MonitoringStoppingCondition -> Natural)
-> (MonitoringStoppingCondition
    -> Natural -> MonitoringStoppingCondition)
-> Lens
     MonitoringStoppingCondition
     MonitoringStoppingCondition
     Natural
     Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\MonitoringStoppingCondition' {Natural
maxRuntimeInSeconds :: Natural
$sel:maxRuntimeInSeconds:MonitoringStoppingCondition' :: MonitoringStoppingCondition -> Natural
maxRuntimeInSeconds} -> Natural
maxRuntimeInSeconds) (\s :: MonitoringStoppingCondition
s@MonitoringStoppingCondition' {} Natural
a -> MonitoringStoppingCondition
s {$sel:maxRuntimeInSeconds:MonitoringStoppingCondition' :: Natural
maxRuntimeInSeconds = Natural
a} :: MonitoringStoppingCondition)

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

instance Prelude.NFData MonitoringStoppingCondition

instance Core.ToJSON MonitoringStoppingCondition where
  toJSON :: MonitoringStoppingCondition -> Value
toJSON MonitoringStoppingCondition' {Natural
maxRuntimeInSeconds :: Natural
$sel:maxRuntimeInSeconds:MonitoringStoppingCondition' :: MonitoringStoppingCondition -> 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)
          ]
      )