{-# 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.SourceAlgorithmSpecification
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SageMaker.Types.SourceAlgorithmSpecification where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.SourceAlgorithm

-- | A list of algorithms that were used to create a model package.
--
-- /See:/ 'newSourceAlgorithmSpecification' smart constructor.
data SourceAlgorithmSpecification = SourceAlgorithmSpecification'
  { -- | A list of the algorithms that were used to create a model package.
    SourceAlgorithmSpecification -> NonEmpty SourceAlgorithm
sourceAlgorithms :: Prelude.NonEmpty SourceAlgorithm
  }
  deriving (SourceAlgorithmSpecification
-> SourceAlgorithmSpecification -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceAlgorithmSpecification
-> SourceAlgorithmSpecification -> Bool
$c/= :: SourceAlgorithmSpecification
-> SourceAlgorithmSpecification -> Bool
== :: SourceAlgorithmSpecification
-> SourceAlgorithmSpecification -> Bool
$c== :: SourceAlgorithmSpecification
-> SourceAlgorithmSpecification -> Bool
Prelude.Eq, ReadPrec [SourceAlgorithmSpecification]
ReadPrec SourceAlgorithmSpecification
Int -> ReadS SourceAlgorithmSpecification
ReadS [SourceAlgorithmSpecification]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SourceAlgorithmSpecification]
$creadListPrec :: ReadPrec [SourceAlgorithmSpecification]
readPrec :: ReadPrec SourceAlgorithmSpecification
$creadPrec :: ReadPrec SourceAlgorithmSpecification
readList :: ReadS [SourceAlgorithmSpecification]
$creadList :: ReadS [SourceAlgorithmSpecification]
readsPrec :: Int -> ReadS SourceAlgorithmSpecification
$creadsPrec :: Int -> ReadS SourceAlgorithmSpecification
Prelude.Read, Int -> SourceAlgorithmSpecification -> ShowS
[SourceAlgorithmSpecification] -> ShowS
SourceAlgorithmSpecification -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceAlgorithmSpecification] -> ShowS
$cshowList :: [SourceAlgorithmSpecification] -> ShowS
show :: SourceAlgorithmSpecification -> String
$cshow :: SourceAlgorithmSpecification -> String
showsPrec :: Int -> SourceAlgorithmSpecification -> ShowS
$cshowsPrec :: Int -> SourceAlgorithmSpecification -> ShowS
Prelude.Show, forall x.
Rep SourceAlgorithmSpecification x -> SourceAlgorithmSpecification
forall x.
SourceAlgorithmSpecification -> Rep SourceAlgorithmSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SourceAlgorithmSpecification x -> SourceAlgorithmSpecification
$cfrom :: forall x.
SourceAlgorithmSpecification -> Rep SourceAlgorithmSpecification x
Prelude.Generic)

-- |
-- Create a value of 'SourceAlgorithmSpecification' 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:
--
-- 'sourceAlgorithms', 'sourceAlgorithmSpecification_sourceAlgorithms' - A list of the algorithms that were used to create a model package.
newSourceAlgorithmSpecification ::
  -- | 'sourceAlgorithms'
  Prelude.NonEmpty SourceAlgorithm ->
  SourceAlgorithmSpecification
newSourceAlgorithmSpecification :: NonEmpty SourceAlgorithm -> SourceAlgorithmSpecification
newSourceAlgorithmSpecification NonEmpty SourceAlgorithm
pSourceAlgorithms_ =
  SourceAlgorithmSpecification'
    { $sel:sourceAlgorithms:SourceAlgorithmSpecification' :: NonEmpty SourceAlgorithm
sourceAlgorithms =
        forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty SourceAlgorithm
pSourceAlgorithms_
    }

-- | A list of the algorithms that were used to create a model package.
sourceAlgorithmSpecification_sourceAlgorithms :: Lens.Lens' SourceAlgorithmSpecification (Prelude.NonEmpty SourceAlgorithm)
sourceAlgorithmSpecification_sourceAlgorithms :: Lens' SourceAlgorithmSpecification (NonEmpty SourceAlgorithm)
sourceAlgorithmSpecification_sourceAlgorithms = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceAlgorithmSpecification' {NonEmpty SourceAlgorithm
sourceAlgorithms :: NonEmpty SourceAlgorithm
$sel:sourceAlgorithms:SourceAlgorithmSpecification' :: SourceAlgorithmSpecification -> NonEmpty SourceAlgorithm
sourceAlgorithms} -> NonEmpty SourceAlgorithm
sourceAlgorithms) (\s :: SourceAlgorithmSpecification
s@SourceAlgorithmSpecification' {} NonEmpty SourceAlgorithm
a -> SourceAlgorithmSpecification
s {$sel:sourceAlgorithms:SourceAlgorithmSpecification' :: NonEmpty SourceAlgorithm
sourceAlgorithms = NonEmpty SourceAlgorithm
a} :: SourceAlgorithmSpecification) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Data.FromJSON SourceAlgorithmSpecification where
  parseJSON :: Value -> Parser SourceAlgorithmSpecification
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SourceAlgorithmSpecification"
      ( \Object
x ->
          NonEmpty SourceAlgorithm -> SourceAlgorithmSpecification
SourceAlgorithmSpecification'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"SourceAlgorithms")
      )

instance
  Prelude.Hashable
    SourceAlgorithmSpecification
  where
  hashWithSalt :: Int -> SourceAlgorithmSpecification -> Int
hashWithSalt Int
_salt SourceAlgorithmSpecification' {NonEmpty SourceAlgorithm
sourceAlgorithms :: NonEmpty SourceAlgorithm
$sel:sourceAlgorithms:SourceAlgorithmSpecification' :: SourceAlgorithmSpecification -> NonEmpty SourceAlgorithm
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty SourceAlgorithm
sourceAlgorithms

instance Prelude.NFData SourceAlgorithmSpecification where
  rnf :: SourceAlgorithmSpecification -> ()
rnf SourceAlgorithmSpecification' {NonEmpty SourceAlgorithm
sourceAlgorithms :: NonEmpty SourceAlgorithm
$sel:sourceAlgorithms:SourceAlgorithmSpecification' :: SourceAlgorithmSpecification -> NonEmpty SourceAlgorithm
..} =
    forall a. NFData a => a -> ()
Prelude.rnf NonEmpty SourceAlgorithm
sourceAlgorithms

instance Data.ToJSON SourceAlgorithmSpecification where
  toJSON :: SourceAlgorithmSpecification -> Value
toJSON SourceAlgorithmSpecification' {NonEmpty SourceAlgorithm
sourceAlgorithms :: NonEmpty SourceAlgorithm
$sel:sourceAlgorithms:SourceAlgorithmSpecification' :: SourceAlgorithmSpecification -> NonEmpty SourceAlgorithm
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"SourceAlgorithms" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty SourceAlgorithm
sourceAlgorithms)
          ]
      )