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

-- | 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
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]
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
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.
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'
    { $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 :: Lens' MonitoringStoppingCondition Natural
monitoringStoppingCondition_maxRuntimeInSeconds = 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 Data.FromJSON MonitoringStoppingCondition where
  parseJSON :: Value -> Parser MonitoringStoppingCondition
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"MonitoringStoppingCondition"
      ( \Object
x ->
          Natural -> MonitoringStoppingCondition
MonitoringStoppingCondition'
            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 MonitoringStoppingCondition where
  hashWithSalt :: Int -> MonitoringStoppingCondition -> Int
hashWithSalt Int
_salt MonitoringStoppingCondition' {Natural
maxRuntimeInSeconds :: Natural
$sel:maxRuntimeInSeconds:MonitoringStoppingCondition' :: MonitoringStoppingCondition -> Natural
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
maxRuntimeInSeconds

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

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