{-# 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.Personalize.Types.HPOObjective
-- 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.Personalize.Types.HPOObjective where

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

-- | The metric to optimize during hyperparameter optimization (HPO).
--
-- Amazon Personalize doesn\'t support configuring the @hpoObjective@ at
-- this time.
--
-- /See:/ 'newHPOObjective' smart constructor.
data HPOObjective = HPOObjective'
  { -- | The name of the metric.
    HPOObjective -> Maybe Text
metricName :: Prelude.Maybe Prelude.Text,
    -- | The type of the metric. Valid values are @Maximize@ and @Minimize@.
    HPOObjective -> Maybe Text
type' :: Prelude.Maybe Prelude.Text,
    -- | A regular expression for finding the metric in the training job logs.
    HPOObjective -> Maybe Text
metricRegex :: Prelude.Maybe Prelude.Text
  }
  deriving (HPOObjective -> HPOObjective -> Bool
(HPOObjective -> HPOObjective -> Bool)
-> (HPOObjective -> HPOObjective -> Bool) -> Eq HPOObjective
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HPOObjective -> HPOObjective -> Bool
$c/= :: HPOObjective -> HPOObjective -> Bool
== :: HPOObjective -> HPOObjective -> Bool
$c== :: HPOObjective -> HPOObjective -> Bool
Prelude.Eq, ReadPrec [HPOObjective]
ReadPrec HPOObjective
Int -> ReadS HPOObjective
ReadS [HPOObjective]
(Int -> ReadS HPOObjective)
-> ReadS [HPOObjective]
-> ReadPrec HPOObjective
-> ReadPrec [HPOObjective]
-> Read HPOObjective
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HPOObjective]
$creadListPrec :: ReadPrec [HPOObjective]
readPrec :: ReadPrec HPOObjective
$creadPrec :: ReadPrec HPOObjective
readList :: ReadS [HPOObjective]
$creadList :: ReadS [HPOObjective]
readsPrec :: Int -> ReadS HPOObjective
$creadsPrec :: Int -> ReadS HPOObjective
Prelude.Read, Int -> HPOObjective -> ShowS
[HPOObjective] -> ShowS
HPOObjective -> String
(Int -> HPOObjective -> ShowS)
-> (HPOObjective -> String)
-> ([HPOObjective] -> ShowS)
-> Show HPOObjective
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HPOObjective] -> ShowS
$cshowList :: [HPOObjective] -> ShowS
show :: HPOObjective -> String
$cshow :: HPOObjective -> String
showsPrec :: Int -> HPOObjective -> ShowS
$cshowsPrec :: Int -> HPOObjective -> ShowS
Prelude.Show, (forall x. HPOObjective -> Rep HPOObjective x)
-> (forall x. Rep HPOObjective x -> HPOObjective)
-> Generic HPOObjective
forall x. Rep HPOObjective x -> HPOObjective
forall x. HPOObjective -> Rep HPOObjective x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HPOObjective x -> HPOObjective
$cfrom :: forall x. HPOObjective -> Rep HPOObjective x
Prelude.Generic)

-- |
-- Create a value of 'HPOObjective' 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:
--
-- 'metricName', 'hPOObjective_metricName' - The name of the metric.
--
-- 'type'', 'hPOObjective_type' - The type of the metric. Valid values are @Maximize@ and @Minimize@.
--
-- 'metricRegex', 'hPOObjective_metricRegex' - A regular expression for finding the metric in the training job logs.
newHPOObjective ::
  HPOObjective
newHPOObjective :: HPOObjective
newHPOObjective =
  HPOObjective' :: Maybe Text -> Maybe Text -> Maybe Text -> HPOObjective
HPOObjective'
    { $sel:metricName:HPOObjective' :: Maybe Text
metricName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:type':HPOObjective' :: Maybe Text
type' = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:metricRegex:HPOObjective' :: Maybe Text
metricRegex = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the metric.
hPOObjective_metricName :: Lens.Lens' HPOObjective (Prelude.Maybe Prelude.Text)
hPOObjective_metricName :: (Maybe Text -> f (Maybe Text)) -> HPOObjective -> f HPOObjective
hPOObjective_metricName = (HPOObjective -> Maybe Text)
-> (HPOObjective -> Maybe Text -> HPOObjective)
-> Lens HPOObjective HPOObjective (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HPOObjective' {Maybe Text
metricName :: Maybe Text
$sel:metricName:HPOObjective' :: HPOObjective -> Maybe Text
metricName} -> Maybe Text
metricName) (\s :: HPOObjective
s@HPOObjective' {} Maybe Text
a -> HPOObjective
s {$sel:metricName:HPOObjective' :: Maybe Text
metricName = Maybe Text
a} :: HPOObjective)

-- | The type of the metric. Valid values are @Maximize@ and @Minimize@.
hPOObjective_type :: Lens.Lens' HPOObjective (Prelude.Maybe Prelude.Text)
hPOObjective_type :: (Maybe Text -> f (Maybe Text)) -> HPOObjective -> f HPOObjective
hPOObjective_type = (HPOObjective -> Maybe Text)
-> (HPOObjective -> Maybe Text -> HPOObjective)
-> Lens HPOObjective HPOObjective (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HPOObjective' {Maybe Text
type' :: Maybe Text
$sel:type':HPOObjective' :: HPOObjective -> Maybe Text
type'} -> Maybe Text
type') (\s :: HPOObjective
s@HPOObjective' {} Maybe Text
a -> HPOObjective
s {$sel:type':HPOObjective' :: Maybe Text
type' = Maybe Text
a} :: HPOObjective)

-- | A regular expression for finding the metric in the training job logs.
hPOObjective_metricRegex :: Lens.Lens' HPOObjective (Prelude.Maybe Prelude.Text)
hPOObjective_metricRegex :: (Maybe Text -> f (Maybe Text)) -> HPOObjective -> f HPOObjective
hPOObjective_metricRegex = (HPOObjective -> Maybe Text)
-> (HPOObjective -> Maybe Text -> HPOObjective)
-> Lens HPOObjective HPOObjective (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HPOObjective' {Maybe Text
metricRegex :: Maybe Text
$sel:metricRegex:HPOObjective' :: HPOObjective -> Maybe Text
metricRegex} -> Maybe Text
metricRegex) (\s :: HPOObjective
s@HPOObjective' {} Maybe Text
a -> HPOObjective
s {$sel:metricRegex:HPOObjective' :: Maybe Text
metricRegex = Maybe Text
a} :: HPOObjective)

instance Core.FromJSON HPOObjective where
  parseJSON :: Value -> Parser HPOObjective
parseJSON =
    String
-> (Object -> Parser HPOObjective) -> Value -> Parser HPOObjective
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HPOObjective"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> HPOObjective
HPOObjective'
            (Maybe Text -> Maybe Text -> Maybe Text -> HPOObjective)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> HPOObjective)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"metricName")
            Parser (Maybe Text -> Maybe Text -> HPOObjective)
-> Parser (Maybe Text) -> Parser (Maybe Text -> HPOObjective)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"type")
            Parser (Maybe Text -> HPOObjective)
-> Parser (Maybe Text) -> Parser HPOObjective
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"metricRegex")
      )

instance Prelude.Hashable HPOObjective

instance Prelude.NFData HPOObjective

instance Core.ToJSON HPOObjective where
  toJSON :: HPOObjective -> Value
toJSON HPOObjective' {Maybe Text
metricRegex :: Maybe Text
type' :: Maybe Text
metricName :: Maybe Text
$sel:metricRegex:HPOObjective' :: HPOObjective -> Maybe Text
$sel:type':HPOObjective' :: HPOObjective -> Maybe Text
$sel:metricName:HPOObjective' :: HPOObjective -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"metricName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
metricName,
            (Text
"type" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
type',
            (Text
"metricRegex" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
metricRegex
          ]
      )