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

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

-- | When the solution performs AutoML (@performAutoML@ is true in
-- CreateSolution), Amazon Personalize determines which recipe, from the
-- specified list, optimizes the given metric. Amazon Personalize then uses
-- that recipe for the solution.
--
-- /See:/ 'newAutoMLConfig' smart constructor.
data AutoMLConfig = AutoMLConfig'
  { -- | The list of candidate recipes.
    AutoMLConfig -> Maybe [Text]
recipeList :: Prelude.Maybe [Prelude.Text],
    -- | The metric to optimize.
    AutoMLConfig -> Maybe Text
metricName :: Prelude.Maybe Prelude.Text
  }
  deriving (AutoMLConfig -> AutoMLConfig -> Bool
(AutoMLConfig -> AutoMLConfig -> Bool)
-> (AutoMLConfig -> AutoMLConfig -> Bool) -> Eq AutoMLConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutoMLConfig -> AutoMLConfig -> Bool
$c/= :: AutoMLConfig -> AutoMLConfig -> Bool
== :: AutoMLConfig -> AutoMLConfig -> Bool
$c== :: AutoMLConfig -> AutoMLConfig -> Bool
Prelude.Eq, ReadPrec [AutoMLConfig]
ReadPrec AutoMLConfig
Int -> ReadS AutoMLConfig
ReadS [AutoMLConfig]
(Int -> ReadS AutoMLConfig)
-> ReadS [AutoMLConfig]
-> ReadPrec AutoMLConfig
-> ReadPrec [AutoMLConfig]
-> Read AutoMLConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AutoMLConfig]
$creadListPrec :: ReadPrec [AutoMLConfig]
readPrec :: ReadPrec AutoMLConfig
$creadPrec :: ReadPrec AutoMLConfig
readList :: ReadS [AutoMLConfig]
$creadList :: ReadS [AutoMLConfig]
readsPrec :: Int -> ReadS AutoMLConfig
$creadsPrec :: Int -> ReadS AutoMLConfig
Prelude.Read, Int -> AutoMLConfig -> ShowS
[AutoMLConfig] -> ShowS
AutoMLConfig -> String
(Int -> AutoMLConfig -> ShowS)
-> (AutoMLConfig -> String)
-> ([AutoMLConfig] -> ShowS)
-> Show AutoMLConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutoMLConfig] -> ShowS
$cshowList :: [AutoMLConfig] -> ShowS
show :: AutoMLConfig -> String
$cshow :: AutoMLConfig -> String
showsPrec :: Int -> AutoMLConfig -> ShowS
$cshowsPrec :: Int -> AutoMLConfig -> ShowS
Prelude.Show, (forall x. AutoMLConfig -> Rep AutoMLConfig x)
-> (forall x. Rep AutoMLConfig x -> AutoMLConfig)
-> Generic AutoMLConfig
forall x. Rep AutoMLConfig x -> AutoMLConfig
forall x. AutoMLConfig -> Rep AutoMLConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AutoMLConfig x -> AutoMLConfig
$cfrom :: forall x. AutoMLConfig -> Rep AutoMLConfig x
Prelude.Generic)

-- |
-- Create a value of 'AutoMLConfig' 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:
--
-- 'recipeList', 'autoMLConfig_recipeList' - The list of candidate recipes.
--
-- 'metricName', 'autoMLConfig_metricName' - The metric to optimize.
newAutoMLConfig ::
  AutoMLConfig
newAutoMLConfig :: AutoMLConfig
newAutoMLConfig =
  AutoMLConfig' :: Maybe [Text] -> Maybe Text -> AutoMLConfig
AutoMLConfig'
    { $sel:recipeList:AutoMLConfig' :: Maybe [Text]
recipeList = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:metricName:AutoMLConfig' :: Maybe Text
metricName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The list of candidate recipes.
autoMLConfig_recipeList :: Lens.Lens' AutoMLConfig (Prelude.Maybe [Prelude.Text])
autoMLConfig_recipeList :: (Maybe [Text] -> f (Maybe [Text]))
-> AutoMLConfig -> f AutoMLConfig
autoMLConfig_recipeList = (AutoMLConfig -> Maybe [Text])
-> (AutoMLConfig -> Maybe [Text] -> AutoMLConfig)
-> Lens AutoMLConfig AutoMLConfig (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoMLConfig' {Maybe [Text]
recipeList :: Maybe [Text]
$sel:recipeList:AutoMLConfig' :: AutoMLConfig -> Maybe [Text]
recipeList} -> Maybe [Text]
recipeList) (\s :: AutoMLConfig
s@AutoMLConfig' {} Maybe [Text]
a -> AutoMLConfig
s {$sel:recipeList:AutoMLConfig' :: Maybe [Text]
recipeList = Maybe [Text]
a} :: AutoMLConfig) ((Maybe [Text] -> f (Maybe [Text]))
 -> AutoMLConfig -> f AutoMLConfig)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> AutoMLConfig
-> f AutoMLConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The metric to optimize.
autoMLConfig_metricName :: Lens.Lens' AutoMLConfig (Prelude.Maybe Prelude.Text)
autoMLConfig_metricName :: (Maybe Text -> f (Maybe Text)) -> AutoMLConfig -> f AutoMLConfig
autoMLConfig_metricName = (AutoMLConfig -> Maybe Text)
-> (AutoMLConfig -> Maybe Text -> AutoMLConfig)
-> Lens AutoMLConfig AutoMLConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoMLConfig' {Maybe Text
metricName :: Maybe Text
$sel:metricName:AutoMLConfig' :: AutoMLConfig -> Maybe Text
metricName} -> Maybe Text
metricName) (\s :: AutoMLConfig
s@AutoMLConfig' {} Maybe Text
a -> AutoMLConfig
s {$sel:metricName:AutoMLConfig' :: Maybe Text
metricName = Maybe Text
a} :: AutoMLConfig)

instance Core.FromJSON AutoMLConfig where
  parseJSON :: Value -> Parser AutoMLConfig
parseJSON =
    String
-> (Object -> Parser AutoMLConfig) -> Value -> Parser AutoMLConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AutoMLConfig"
      ( \Object
x ->
          Maybe [Text] -> Maybe Text -> AutoMLConfig
AutoMLConfig'
            (Maybe [Text] -> Maybe Text -> AutoMLConfig)
-> Parser (Maybe [Text]) -> Parser (Maybe Text -> AutoMLConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"recipeList" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser (Maybe Text -> AutoMLConfig)
-> Parser (Maybe Text) -> Parser AutoMLConfig
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
"metricName")
      )

instance Prelude.Hashable AutoMLConfig

instance Prelude.NFData AutoMLConfig

instance Core.ToJSON AutoMLConfig where
  toJSON :: AutoMLConfig -> Value
toJSON AutoMLConfig' {Maybe [Text]
Maybe Text
metricName :: Maybe Text
recipeList :: Maybe [Text]
$sel:metricName:AutoMLConfig' :: AutoMLConfig -> Maybe Text
$sel:recipeList:AutoMLConfig' :: AutoMLConfig -> Maybe [Text]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"recipeList" 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]
recipeList,
            (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
          ]
      )