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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.AlgorithmValidationProfile

-- | Specifies configurations for one or more training jobs that Amazon
-- SageMaker runs to test the algorithm.
--
-- /See:/ 'newAlgorithmValidationSpecification' smart constructor.
data AlgorithmValidationSpecification = AlgorithmValidationSpecification'
  { -- | The IAM roles that Amazon SageMaker uses to run the training jobs.
    AlgorithmValidationSpecification -> Text
validationRole :: Prelude.Text,
    -- | An array of @AlgorithmValidationProfile@ objects, each of which
    -- specifies a training job and batch transform job that Amazon SageMaker
    -- runs to validate your algorithm.
    AlgorithmValidationSpecification
-> NonEmpty AlgorithmValidationProfile
validationProfiles :: Prelude.NonEmpty AlgorithmValidationProfile
  }
  deriving (AlgorithmValidationSpecification
-> AlgorithmValidationSpecification -> Bool
(AlgorithmValidationSpecification
 -> AlgorithmValidationSpecification -> Bool)
-> (AlgorithmValidationSpecification
    -> AlgorithmValidationSpecification -> Bool)
-> Eq AlgorithmValidationSpecification
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AlgorithmValidationSpecification
-> AlgorithmValidationSpecification -> Bool
$c/= :: AlgorithmValidationSpecification
-> AlgorithmValidationSpecification -> Bool
== :: AlgorithmValidationSpecification
-> AlgorithmValidationSpecification -> Bool
$c== :: AlgorithmValidationSpecification
-> AlgorithmValidationSpecification -> Bool
Prelude.Eq, ReadPrec [AlgorithmValidationSpecification]
ReadPrec AlgorithmValidationSpecification
Int -> ReadS AlgorithmValidationSpecification
ReadS [AlgorithmValidationSpecification]
(Int -> ReadS AlgorithmValidationSpecification)
-> ReadS [AlgorithmValidationSpecification]
-> ReadPrec AlgorithmValidationSpecification
-> ReadPrec [AlgorithmValidationSpecification]
-> Read AlgorithmValidationSpecification
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AlgorithmValidationSpecification]
$creadListPrec :: ReadPrec [AlgorithmValidationSpecification]
readPrec :: ReadPrec AlgorithmValidationSpecification
$creadPrec :: ReadPrec AlgorithmValidationSpecification
readList :: ReadS [AlgorithmValidationSpecification]
$creadList :: ReadS [AlgorithmValidationSpecification]
readsPrec :: Int -> ReadS AlgorithmValidationSpecification
$creadsPrec :: Int -> ReadS AlgorithmValidationSpecification
Prelude.Read, Int -> AlgorithmValidationSpecification -> ShowS
[AlgorithmValidationSpecification] -> ShowS
AlgorithmValidationSpecification -> String
(Int -> AlgorithmValidationSpecification -> ShowS)
-> (AlgorithmValidationSpecification -> String)
-> ([AlgorithmValidationSpecification] -> ShowS)
-> Show AlgorithmValidationSpecification
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AlgorithmValidationSpecification] -> ShowS
$cshowList :: [AlgorithmValidationSpecification] -> ShowS
show :: AlgorithmValidationSpecification -> String
$cshow :: AlgorithmValidationSpecification -> String
showsPrec :: Int -> AlgorithmValidationSpecification -> ShowS
$cshowsPrec :: Int -> AlgorithmValidationSpecification -> ShowS
Prelude.Show, (forall x.
 AlgorithmValidationSpecification
 -> Rep AlgorithmValidationSpecification x)
-> (forall x.
    Rep AlgorithmValidationSpecification x
    -> AlgorithmValidationSpecification)
-> Generic AlgorithmValidationSpecification
forall x.
Rep AlgorithmValidationSpecification x
-> AlgorithmValidationSpecification
forall x.
AlgorithmValidationSpecification
-> Rep AlgorithmValidationSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AlgorithmValidationSpecification x
-> AlgorithmValidationSpecification
$cfrom :: forall x.
AlgorithmValidationSpecification
-> Rep AlgorithmValidationSpecification x
Prelude.Generic)

-- |
-- Create a value of 'AlgorithmValidationSpecification' 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:
--
-- 'validationRole', 'algorithmValidationSpecification_validationRole' - The IAM roles that Amazon SageMaker uses to run the training jobs.
--
-- 'validationProfiles', 'algorithmValidationSpecification_validationProfiles' - An array of @AlgorithmValidationProfile@ objects, each of which
-- specifies a training job and batch transform job that Amazon SageMaker
-- runs to validate your algorithm.
newAlgorithmValidationSpecification ::
  -- | 'validationRole'
  Prelude.Text ->
  -- | 'validationProfiles'
  Prelude.NonEmpty AlgorithmValidationProfile ->
  AlgorithmValidationSpecification
newAlgorithmValidationSpecification :: Text
-> NonEmpty AlgorithmValidationProfile
-> AlgorithmValidationSpecification
newAlgorithmValidationSpecification
  Text
pValidationRole_
  NonEmpty AlgorithmValidationProfile
pValidationProfiles_ =
    AlgorithmValidationSpecification' :: Text
-> NonEmpty AlgorithmValidationProfile
-> AlgorithmValidationSpecification
AlgorithmValidationSpecification'
      { $sel:validationRole:AlgorithmValidationSpecification' :: Text
validationRole =
          Text
pValidationRole_,
        $sel:validationProfiles:AlgorithmValidationSpecification' :: NonEmpty AlgorithmValidationProfile
validationProfiles =
          Tagged
  (NonEmpty AlgorithmValidationProfile)
  (Identity (NonEmpty AlgorithmValidationProfile))
-> Tagged
     (NonEmpty AlgorithmValidationProfile)
     (Identity (NonEmpty AlgorithmValidationProfile))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
            (Tagged
   (NonEmpty AlgorithmValidationProfile)
   (Identity (NonEmpty AlgorithmValidationProfile))
 -> Tagged
      (NonEmpty AlgorithmValidationProfile)
      (Identity (NonEmpty AlgorithmValidationProfile)))
-> NonEmpty AlgorithmValidationProfile
-> NonEmpty AlgorithmValidationProfile
forall t b. AReview t b -> b -> t
Lens.# NonEmpty AlgorithmValidationProfile
pValidationProfiles_
      }

-- | The IAM roles that Amazon SageMaker uses to run the training jobs.
algorithmValidationSpecification_validationRole :: Lens.Lens' AlgorithmValidationSpecification Prelude.Text
algorithmValidationSpecification_validationRole :: (Text -> f Text)
-> AlgorithmValidationSpecification
-> f AlgorithmValidationSpecification
algorithmValidationSpecification_validationRole = (AlgorithmValidationSpecification -> Text)
-> (AlgorithmValidationSpecification
    -> Text -> AlgorithmValidationSpecification)
-> Lens
     AlgorithmValidationSpecification
     AlgorithmValidationSpecification
     Text
     Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlgorithmValidationSpecification' {Text
validationRole :: Text
$sel:validationRole:AlgorithmValidationSpecification' :: AlgorithmValidationSpecification -> Text
validationRole} -> Text
validationRole) (\s :: AlgorithmValidationSpecification
s@AlgorithmValidationSpecification' {} Text
a -> AlgorithmValidationSpecification
s {$sel:validationRole:AlgorithmValidationSpecification' :: Text
validationRole = Text
a} :: AlgorithmValidationSpecification)

-- | An array of @AlgorithmValidationProfile@ objects, each of which
-- specifies a training job and batch transform job that Amazon SageMaker
-- runs to validate your algorithm.
algorithmValidationSpecification_validationProfiles :: Lens.Lens' AlgorithmValidationSpecification (Prelude.NonEmpty AlgorithmValidationProfile)
algorithmValidationSpecification_validationProfiles :: (NonEmpty AlgorithmValidationProfile
 -> f (NonEmpty AlgorithmValidationProfile))
-> AlgorithmValidationSpecification
-> f AlgorithmValidationSpecification
algorithmValidationSpecification_validationProfiles = (AlgorithmValidationSpecification
 -> NonEmpty AlgorithmValidationProfile)
-> (AlgorithmValidationSpecification
    -> NonEmpty AlgorithmValidationProfile
    -> AlgorithmValidationSpecification)
-> Lens
     AlgorithmValidationSpecification
     AlgorithmValidationSpecification
     (NonEmpty AlgorithmValidationProfile)
     (NonEmpty AlgorithmValidationProfile)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AlgorithmValidationSpecification' {NonEmpty AlgorithmValidationProfile
validationProfiles :: NonEmpty AlgorithmValidationProfile
$sel:validationProfiles:AlgorithmValidationSpecification' :: AlgorithmValidationSpecification
-> NonEmpty AlgorithmValidationProfile
validationProfiles} -> NonEmpty AlgorithmValidationProfile
validationProfiles) (\s :: AlgorithmValidationSpecification
s@AlgorithmValidationSpecification' {} NonEmpty AlgorithmValidationProfile
a -> AlgorithmValidationSpecification
s {$sel:validationProfiles:AlgorithmValidationSpecification' :: NonEmpty AlgorithmValidationProfile
validationProfiles = NonEmpty AlgorithmValidationProfile
a} :: AlgorithmValidationSpecification) ((NonEmpty AlgorithmValidationProfile
  -> f (NonEmpty AlgorithmValidationProfile))
 -> AlgorithmValidationSpecification
 -> f AlgorithmValidationSpecification)
-> ((NonEmpty AlgorithmValidationProfile
     -> f (NonEmpty AlgorithmValidationProfile))
    -> NonEmpty AlgorithmValidationProfile
    -> f (NonEmpty AlgorithmValidationProfile))
-> (NonEmpty AlgorithmValidationProfile
    -> f (NonEmpty AlgorithmValidationProfile))
-> AlgorithmValidationSpecification
-> f AlgorithmValidationSpecification
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty AlgorithmValidationProfile
 -> f (NonEmpty AlgorithmValidationProfile))
-> NonEmpty AlgorithmValidationProfile
-> f (NonEmpty AlgorithmValidationProfile)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance
  Core.FromJSON
    AlgorithmValidationSpecification
  where
  parseJSON :: Value -> Parser AlgorithmValidationSpecification
parseJSON =
    String
-> (Object -> Parser AlgorithmValidationSpecification)
-> Value
-> Parser AlgorithmValidationSpecification
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AlgorithmValidationSpecification"
      ( \Object
x ->
          Text
-> NonEmpty AlgorithmValidationProfile
-> AlgorithmValidationSpecification
AlgorithmValidationSpecification'
            (Text
 -> NonEmpty AlgorithmValidationProfile
 -> AlgorithmValidationSpecification)
-> Parser Text
-> Parser
     (NonEmpty AlgorithmValidationProfile
      -> AlgorithmValidationSpecification)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ValidationRole")
            Parser
  (NonEmpty AlgorithmValidationProfile
   -> AlgorithmValidationSpecification)
-> Parser (NonEmpty AlgorithmValidationProfile)
-> Parser AlgorithmValidationSpecification
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (NonEmpty AlgorithmValidationProfile)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ValidationProfiles")
      )

instance
  Prelude.Hashable
    AlgorithmValidationSpecification

instance
  Prelude.NFData
    AlgorithmValidationSpecification

instance Core.ToJSON AlgorithmValidationSpecification where
  toJSON :: AlgorithmValidationSpecification -> Value
toJSON AlgorithmValidationSpecification' {NonEmpty AlgorithmValidationProfile
Text
validationProfiles :: NonEmpty AlgorithmValidationProfile
validationRole :: Text
$sel:validationProfiles:AlgorithmValidationSpecification' :: AlgorithmValidationSpecification
-> NonEmpty AlgorithmValidationProfile
$sel:validationRole:AlgorithmValidationSpecification' :: AlgorithmValidationSpecification -> Text
..} =
    [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
"ValidationRole" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
validationRole),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"ValidationProfiles" Text -> NonEmpty AlgorithmValidationProfile -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty AlgorithmValidationProfile
validationProfiles)
          ]
      )