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

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

-- | The job completion criteria.
--
-- /See:/ 'newTuningJobCompletionCriteria' smart constructor.
data TuningJobCompletionCriteria = TuningJobCompletionCriteria'
  { -- | The value of the objective metric.
    TuningJobCompletionCriteria -> Double
targetObjectiveMetricValue :: Prelude.Double
  }
  deriving (TuningJobCompletionCriteria -> TuningJobCompletionCriteria -> Bool
(TuningJobCompletionCriteria
 -> TuningJobCompletionCriteria -> Bool)
-> (TuningJobCompletionCriteria
    -> TuningJobCompletionCriteria -> Bool)
-> Eq TuningJobCompletionCriteria
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TuningJobCompletionCriteria -> TuningJobCompletionCriteria -> Bool
$c/= :: TuningJobCompletionCriteria -> TuningJobCompletionCriteria -> Bool
== :: TuningJobCompletionCriteria -> TuningJobCompletionCriteria -> Bool
$c== :: TuningJobCompletionCriteria -> TuningJobCompletionCriteria -> Bool
Prelude.Eq, ReadPrec [TuningJobCompletionCriteria]
ReadPrec TuningJobCompletionCriteria
Int -> ReadS TuningJobCompletionCriteria
ReadS [TuningJobCompletionCriteria]
(Int -> ReadS TuningJobCompletionCriteria)
-> ReadS [TuningJobCompletionCriteria]
-> ReadPrec TuningJobCompletionCriteria
-> ReadPrec [TuningJobCompletionCriteria]
-> Read TuningJobCompletionCriteria
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TuningJobCompletionCriteria]
$creadListPrec :: ReadPrec [TuningJobCompletionCriteria]
readPrec :: ReadPrec TuningJobCompletionCriteria
$creadPrec :: ReadPrec TuningJobCompletionCriteria
readList :: ReadS [TuningJobCompletionCriteria]
$creadList :: ReadS [TuningJobCompletionCriteria]
readsPrec :: Int -> ReadS TuningJobCompletionCriteria
$creadsPrec :: Int -> ReadS TuningJobCompletionCriteria
Prelude.Read, Int -> TuningJobCompletionCriteria -> ShowS
[TuningJobCompletionCriteria] -> ShowS
TuningJobCompletionCriteria -> String
(Int -> TuningJobCompletionCriteria -> ShowS)
-> (TuningJobCompletionCriteria -> String)
-> ([TuningJobCompletionCriteria] -> ShowS)
-> Show TuningJobCompletionCriteria
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TuningJobCompletionCriteria] -> ShowS
$cshowList :: [TuningJobCompletionCriteria] -> ShowS
show :: TuningJobCompletionCriteria -> String
$cshow :: TuningJobCompletionCriteria -> String
showsPrec :: Int -> TuningJobCompletionCriteria -> ShowS
$cshowsPrec :: Int -> TuningJobCompletionCriteria -> ShowS
Prelude.Show, (forall x.
 TuningJobCompletionCriteria -> Rep TuningJobCompletionCriteria x)
-> (forall x.
    Rep TuningJobCompletionCriteria x -> TuningJobCompletionCriteria)
-> Generic TuningJobCompletionCriteria
forall x.
Rep TuningJobCompletionCriteria x -> TuningJobCompletionCriteria
forall x.
TuningJobCompletionCriteria -> Rep TuningJobCompletionCriteria x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep TuningJobCompletionCriteria x -> TuningJobCompletionCriteria
$cfrom :: forall x.
TuningJobCompletionCriteria -> Rep TuningJobCompletionCriteria x
Prelude.Generic)

-- |
-- Create a value of 'TuningJobCompletionCriteria' 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:
--
-- 'targetObjectiveMetricValue', 'tuningJobCompletionCriteria_targetObjectiveMetricValue' - The value of the objective metric.
newTuningJobCompletionCriteria ::
  -- | 'targetObjectiveMetricValue'
  Prelude.Double ->
  TuningJobCompletionCriteria
newTuningJobCompletionCriteria :: Double -> TuningJobCompletionCriteria
newTuningJobCompletionCriteria
  Double
pTargetObjectiveMetricValue_ =
    TuningJobCompletionCriteria' :: Double -> TuningJobCompletionCriteria
TuningJobCompletionCriteria'
      { $sel:targetObjectiveMetricValue:TuningJobCompletionCriteria' :: Double
targetObjectiveMetricValue =
          Double
pTargetObjectiveMetricValue_
      }

-- | The value of the objective metric.
tuningJobCompletionCriteria_targetObjectiveMetricValue :: Lens.Lens' TuningJobCompletionCriteria Prelude.Double
tuningJobCompletionCriteria_targetObjectiveMetricValue :: (Double -> f Double)
-> TuningJobCompletionCriteria -> f TuningJobCompletionCriteria
tuningJobCompletionCriteria_targetObjectiveMetricValue = (TuningJobCompletionCriteria -> Double)
-> (TuningJobCompletionCriteria
    -> Double -> TuningJobCompletionCriteria)
-> Lens
     TuningJobCompletionCriteria
     TuningJobCompletionCriteria
     Double
     Double
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TuningJobCompletionCriteria' {Double
targetObjectiveMetricValue :: Double
$sel:targetObjectiveMetricValue:TuningJobCompletionCriteria' :: TuningJobCompletionCriteria -> Double
targetObjectiveMetricValue} -> Double
targetObjectiveMetricValue) (\s :: TuningJobCompletionCriteria
s@TuningJobCompletionCriteria' {} Double
a -> TuningJobCompletionCriteria
s {$sel:targetObjectiveMetricValue:TuningJobCompletionCriteria' :: Double
targetObjectiveMetricValue = Double
a} :: TuningJobCompletionCriteria)

instance Core.FromJSON TuningJobCompletionCriteria where
  parseJSON :: Value -> Parser TuningJobCompletionCriteria
parseJSON =
    String
-> (Object -> Parser TuningJobCompletionCriteria)
-> Value
-> Parser TuningJobCompletionCriteria
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TuningJobCompletionCriteria"
      ( \Object
x ->
          Double -> TuningJobCompletionCriteria
TuningJobCompletionCriteria'
            (Double -> TuningJobCompletionCriteria)
-> Parser Double -> Parser TuningJobCompletionCriteria
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Double
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"TargetObjectiveMetricValue")
      )

instance Prelude.Hashable TuningJobCompletionCriteria

instance Prelude.NFData TuningJobCompletionCriteria

instance Core.ToJSON TuningJobCompletionCriteria where
  toJSON :: TuningJobCompletionCriteria -> Value
toJSON TuningJobCompletionCriteria' {Double
targetObjectiveMetricValue :: Double
$sel:targetObjectiveMetricValue:TuningJobCompletionCriteria' :: TuningJobCompletionCriteria -> Double
..} =
    [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
"TargetObjectiveMetricValue"
                  Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Double
targetObjectiveMetricValue
              )
          ]
      )