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

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

-- | Associates a SageMaker job as a trial component with an experiment and
-- trial. Specified when you call the following APIs:
--
-- -   CreateProcessingJob
--
-- -   CreateTrainingJob
--
-- -   CreateTransformJob
--
-- /See:/ 'newExperimentConfig' smart constructor.
data ExperimentConfig = ExperimentConfig'
  { -- | The display name for the trial component. If this key isn\'t specified,
    -- the display name is the trial component name.
    ExperimentConfig -> Maybe Text
trialComponentDisplayName :: Prelude.Maybe Prelude.Text,
    -- | The name of an existing experiment to associate the trial component
    -- with.
    ExperimentConfig -> Maybe Text
experimentName :: Prelude.Maybe Prelude.Text,
    -- | The name of an existing trial to associate the trial component with. If
    -- not specified, a new trial is created.
    ExperimentConfig -> Maybe Text
trialName :: Prelude.Maybe Prelude.Text
  }
  deriving (ExperimentConfig -> ExperimentConfig -> Bool
(ExperimentConfig -> ExperimentConfig -> Bool)
-> (ExperimentConfig -> ExperimentConfig -> Bool)
-> Eq ExperimentConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ExperimentConfig -> ExperimentConfig -> Bool
$c/= :: ExperimentConfig -> ExperimentConfig -> Bool
== :: ExperimentConfig -> ExperimentConfig -> Bool
$c== :: ExperimentConfig -> ExperimentConfig -> Bool
Prelude.Eq, ReadPrec [ExperimentConfig]
ReadPrec ExperimentConfig
Int -> ReadS ExperimentConfig
ReadS [ExperimentConfig]
(Int -> ReadS ExperimentConfig)
-> ReadS [ExperimentConfig]
-> ReadPrec ExperimentConfig
-> ReadPrec [ExperimentConfig]
-> Read ExperimentConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ExperimentConfig]
$creadListPrec :: ReadPrec [ExperimentConfig]
readPrec :: ReadPrec ExperimentConfig
$creadPrec :: ReadPrec ExperimentConfig
readList :: ReadS [ExperimentConfig]
$creadList :: ReadS [ExperimentConfig]
readsPrec :: Int -> ReadS ExperimentConfig
$creadsPrec :: Int -> ReadS ExperimentConfig
Prelude.Read, Int -> ExperimentConfig -> ShowS
[ExperimentConfig] -> ShowS
ExperimentConfig -> String
(Int -> ExperimentConfig -> ShowS)
-> (ExperimentConfig -> String)
-> ([ExperimentConfig] -> ShowS)
-> Show ExperimentConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ExperimentConfig] -> ShowS
$cshowList :: [ExperimentConfig] -> ShowS
show :: ExperimentConfig -> String
$cshow :: ExperimentConfig -> String
showsPrec :: Int -> ExperimentConfig -> ShowS
$cshowsPrec :: Int -> ExperimentConfig -> ShowS
Prelude.Show, (forall x. ExperimentConfig -> Rep ExperimentConfig x)
-> (forall x. Rep ExperimentConfig x -> ExperimentConfig)
-> Generic ExperimentConfig
forall x. Rep ExperimentConfig x -> ExperimentConfig
forall x. ExperimentConfig -> Rep ExperimentConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ExperimentConfig x -> ExperimentConfig
$cfrom :: forall x. ExperimentConfig -> Rep ExperimentConfig x
Prelude.Generic)

-- |
-- Create a value of 'ExperimentConfig' 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:
--
-- 'trialComponentDisplayName', 'experimentConfig_trialComponentDisplayName' - The display name for the trial component. If this key isn\'t specified,
-- the display name is the trial component name.
--
-- 'experimentName', 'experimentConfig_experimentName' - The name of an existing experiment to associate the trial component
-- with.
--
-- 'trialName', 'experimentConfig_trialName' - The name of an existing trial to associate the trial component with. If
-- not specified, a new trial is created.
newExperimentConfig ::
  ExperimentConfig
newExperimentConfig :: ExperimentConfig
newExperimentConfig =
  ExperimentConfig' :: Maybe Text -> Maybe Text -> Maybe Text -> ExperimentConfig
ExperimentConfig'
    { $sel:trialComponentDisplayName:ExperimentConfig' :: Maybe Text
trialComponentDisplayName =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:experimentName:ExperimentConfig' :: Maybe Text
experimentName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:trialName:ExperimentConfig' :: Maybe Text
trialName = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The display name for the trial component. If this key isn\'t specified,
-- the display name is the trial component name.
experimentConfig_trialComponentDisplayName :: Lens.Lens' ExperimentConfig (Prelude.Maybe Prelude.Text)
experimentConfig_trialComponentDisplayName :: (Maybe Text -> f (Maybe Text))
-> ExperimentConfig -> f ExperimentConfig
experimentConfig_trialComponentDisplayName = (ExperimentConfig -> Maybe Text)
-> (ExperimentConfig -> Maybe Text -> ExperimentConfig)
-> Lens ExperimentConfig ExperimentConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExperimentConfig' {Maybe Text
trialComponentDisplayName :: Maybe Text
$sel:trialComponentDisplayName:ExperimentConfig' :: ExperimentConfig -> Maybe Text
trialComponentDisplayName} -> Maybe Text
trialComponentDisplayName) (\s :: ExperimentConfig
s@ExperimentConfig' {} Maybe Text
a -> ExperimentConfig
s {$sel:trialComponentDisplayName:ExperimentConfig' :: Maybe Text
trialComponentDisplayName = Maybe Text
a} :: ExperimentConfig)

-- | The name of an existing experiment to associate the trial component
-- with.
experimentConfig_experimentName :: Lens.Lens' ExperimentConfig (Prelude.Maybe Prelude.Text)
experimentConfig_experimentName :: (Maybe Text -> f (Maybe Text))
-> ExperimentConfig -> f ExperimentConfig
experimentConfig_experimentName = (ExperimentConfig -> Maybe Text)
-> (ExperimentConfig -> Maybe Text -> ExperimentConfig)
-> Lens ExperimentConfig ExperimentConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExperimentConfig' {Maybe Text
experimentName :: Maybe Text
$sel:experimentName:ExperimentConfig' :: ExperimentConfig -> Maybe Text
experimentName} -> Maybe Text
experimentName) (\s :: ExperimentConfig
s@ExperimentConfig' {} Maybe Text
a -> ExperimentConfig
s {$sel:experimentName:ExperimentConfig' :: Maybe Text
experimentName = Maybe Text
a} :: ExperimentConfig)

-- | The name of an existing trial to associate the trial component with. If
-- not specified, a new trial is created.
experimentConfig_trialName :: Lens.Lens' ExperimentConfig (Prelude.Maybe Prelude.Text)
experimentConfig_trialName :: (Maybe Text -> f (Maybe Text))
-> ExperimentConfig -> f ExperimentConfig
experimentConfig_trialName = (ExperimentConfig -> Maybe Text)
-> (ExperimentConfig -> Maybe Text -> ExperimentConfig)
-> Lens ExperimentConfig ExperimentConfig (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ExperimentConfig' {Maybe Text
trialName :: Maybe Text
$sel:trialName:ExperimentConfig' :: ExperimentConfig -> Maybe Text
trialName} -> Maybe Text
trialName) (\s :: ExperimentConfig
s@ExperimentConfig' {} Maybe Text
a -> ExperimentConfig
s {$sel:trialName:ExperimentConfig' :: Maybe Text
trialName = Maybe Text
a} :: ExperimentConfig)

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

instance Prelude.Hashable ExperimentConfig

instance Prelude.NFData ExperimentConfig

instance Core.ToJSON ExperimentConfig where
  toJSON :: ExperimentConfig -> Value
toJSON ExperimentConfig' {Maybe Text
trialName :: Maybe Text
experimentName :: Maybe Text
trialComponentDisplayName :: Maybe Text
$sel:trialName:ExperimentConfig' :: ExperimentConfig -> Maybe Text
$sel:experimentName:ExperimentConfig' :: ExperimentConfig -> Maybe Text
$sel:trialComponentDisplayName:ExperimentConfig' :: ExperimentConfig -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"TrialComponentDisplayName" 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
trialComponentDisplayName,
            (Text
"ExperimentName" 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
experimentName,
            (Text
"TrialName" 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
trialName
          ]
      )