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

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

-- | Describes the resource configuration for hyperparameter optimization
-- (HPO).
--
-- /See:/ 'newHPOResourceConfig' smart constructor.
data HPOResourceConfig = HPOResourceConfig'
  { -- | The maximum number of training jobs when you create a solution version.
    -- The maximum value for @maxNumberOfTrainingJobs@ is @40@.
    HPOResourceConfig -> Maybe Text
maxNumberOfTrainingJobs :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of parallel training jobs when you create a solution
    -- version. The maximum value for @maxParallelTrainingJobs@ is @10@.
    HPOResourceConfig -> Maybe Text
maxParallelTrainingJobs :: Prelude.Maybe Prelude.Text
  }
  deriving (HPOResourceConfig -> HPOResourceConfig -> Bool
(HPOResourceConfig -> HPOResourceConfig -> Bool)
-> (HPOResourceConfig -> HPOResourceConfig -> Bool)
-> Eq HPOResourceConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HPOResourceConfig -> HPOResourceConfig -> Bool
$c/= :: HPOResourceConfig -> HPOResourceConfig -> Bool
== :: HPOResourceConfig -> HPOResourceConfig -> Bool
$c== :: HPOResourceConfig -> HPOResourceConfig -> Bool
Prelude.Eq, ReadPrec [HPOResourceConfig]
ReadPrec HPOResourceConfig
Int -> ReadS HPOResourceConfig
ReadS [HPOResourceConfig]
(Int -> ReadS HPOResourceConfig)
-> ReadS [HPOResourceConfig]
-> ReadPrec HPOResourceConfig
-> ReadPrec [HPOResourceConfig]
-> Read HPOResourceConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HPOResourceConfig]
$creadListPrec :: ReadPrec [HPOResourceConfig]
readPrec :: ReadPrec HPOResourceConfig
$creadPrec :: ReadPrec HPOResourceConfig
readList :: ReadS [HPOResourceConfig]
$creadList :: ReadS [HPOResourceConfig]
readsPrec :: Int -> ReadS HPOResourceConfig
$creadsPrec :: Int -> ReadS HPOResourceConfig
Prelude.Read, Int -> HPOResourceConfig -> ShowS
[HPOResourceConfig] -> ShowS
HPOResourceConfig -> String
(Int -> HPOResourceConfig -> ShowS)
-> (HPOResourceConfig -> String)
-> ([HPOResourceConfig] -> ShowS)
-> Show HPOResourceConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HPOResourceConfig] -> ShowS
$cshowList :: [HPOResourceConfig] -> ShowS
show :: HPOResourceConfig -> String
$cshow :: HPOResourceConfig -> String
showsPrec :: Int -> HPOResourceConfig -> ShowS
$cshowsPrec :: Int -> HPOResourceConfig -> ShowS
Prelude.Show, (forall x. HPOResourceConfig -> Rep HPOResourceConfig x)
-> (forall x. Rep HPOResourceConfig x -> HPOResourceConfig)
-> Generic HPOResourceConfig
forall x. Rep HPOResourceConfig x -> HPOResourceConfig
forall x. HPOResourceConfig -> Rep HPOResourceConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep HPOResourceConfig x -> HPOResourceConfig
$cfrom :: forall x. HPOResourceConfig -> Rep HPOResourceConfig x
Prelude.Generic)

-- |
-- Create a value of 'HPOResourceConfig' 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:
--
-- 'maxNumberOfTrainingJobs', 'hPOResourceConfig_maxNumberOfTrainingJobs' - The maximum number of training jobs when you create a solution version.
-- The maximum value for @maxNumberOfTrainingJobs@ is @40@.
--
-- 'maxParallelTrainingJobs', 'hPOResourceConfig_maxParallelTrainingJobs' - The maximum number of parallel training jobs when you create a solution
-- version. The maximum value for @maxParallelTrainingJobs@ is @10@.
newHPOResourceConfig ::
  HPOResourceConfig
newHPOResourceConfig :: HPOResourceConfig
newHPOResourceConfig =
  HPOResourceConfig' :: Maybe Text -> Maybe Text -> HPOResourceConfig
HPOResourceConfig'
    { $sel:maxNumberOfTrainingJobs:HPOResourceConfig' :: Maybe Text
maxNumberOfTrainingJobs =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxParallelTrainingJobs:HPOResourceConfig' :: Maybe Text
maxParallelTrainingJobs = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The maximum number of training jobs when you create a solution version.
-- The maximum value for @maxNumberOfTrainingJobs@ is @40@.
hPOResourceConfig_maxNumberOfTrainingJobs :: Lens.Lens' HPOResourceConfig (Prelude.Maybe Prelude.Text)
hPOResourceConfig_maxNumberOfTrainingJobs :: (Maybe Text -> f (Maybe Text))
-> HPOResourceConfig -> f HPOResourceConfig
hPOResourceConfig_maxNumberOfTrainingJobs = (HPOResourceConfig -> Maybe Text)
-> (HPOResourceConfig -> Maybe Text -> HPOResourceConfig)
-> Lens
     HPOResourceConfig HPOResourceConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HPOResourceConfig' {Maybe Text
maxNumberOfTrainingJobs :: Maybe Text
$sel:maxNumberOfTrainingJobs:HPOResourceConfig' :: HPOResourceConfig -> Maybe Text
maxNumberOfTrainingJobs} -> Maybe Text
maxNumberOfTrainingJobs) (\s :: HPOResourceConfig
s@HPOResourceConfig' {} Maybe Text
a -> HPOResourceConfig
s {$sel:maxNumberOfTrainingJobs:HPOResourceConfig' :: Maybe Text
maxNumberOfTrainingJobs = Maybe Text
a} :: HPOResourceConfig)

-- | The maximum number of parallel training jobs when you create a solution
-- version. The maximum value for @maxParallelTrainingJobs@ is @10@.
hPOResourceConfig_maxParallelTrainingJobs :: Lens.Lens' HPOResourceConfig (Prelude.Maybe Prelude.Text)
hPOResourceConfig_maxParallelTrainingJobs :: (Maybe Text -> f (Maybe Text))
-> HPOResourceConfig -> f HPOResourceConfig
hPOResourceConfig_maxParallelTrainingJobs = (HPOResourceConfig -> Maybe Text)
-> (HPOResourceConfig -> Maybe Text -> HPOResourceConfig)
-> Lens
     HPOResourceConfig HPOResourceConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HPOResourceConfig' {Maybe Text
maxParallelTrainingJobs :: Maybe Text
$sel:maxParallelTrainingJobs:HPOResourceConfig' :: HPOResourceConfig -> Maybe Text
maxParallelTrainingJobs} -> Maybe Text
maxParallelTrainingJobs) (\s :: HPOResourceConfig
s@HPOResourceConfig' {} Maybe Text
a -> HPOResourceConfig
s {$sel:maxParallelTrainingJobs:HPOResourceConfig' :: Maybe Text
maxParallelTrainingJobs = Maybe Text
a} :: HPOResourceConfig)

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

instance Prelude.Hashable HPOResourceConfig

instance Prelude.NFData HPOResourceConfig

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