{-# 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.SourceAlgorithm
-- 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.SourceAlgorithm 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

-- | Specifies an algorithm that was used to create the model package. The
-- algorithm must be either an algorithm resource in your SageMaker account
-- or an algorithm in Amazon Web Services Marketplace that you are
-- subscribed to.
--
-- /See:/ 'newSourceAlgorithm' smart constructor.
data SourceAlgorithm = SourceAlgorithm'
  { -- | The Amazon S3 path where the model artifacts, which result from model
    -- training, are stored. This path must point to a single @gzip@ compressed
    -- tar archive (@.tar.gz@ suffix).
    --
    -- The model artifacts must be in an S3 bucket that is in the same region
    -- as the algorithm.
    SourceAlgorithm -> Maybe Text
modelDataUrl :: Prelude.Maybe Prelude.Text,
    -- | The name of an algorithm that was used to create the model package. The
    -- algorithm must be either an algorithm resource in your SageMaker account
    -- or an algorithm in Amazon Web Services Marketplace that you are
    -- subscribed to.
    SourceAlgorithm -> Text
algorithmName :: Prelude.Text
  }
  deriving (SourceAlgorithm -> SourceAlgorithm -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SourceAlgorithm -> SourceAlgorithm -> Bool
$c/= :: SourceAlgorithm -> SourceAlgorithm -> Bool
== :: SourceAlgorithm -> SourceAlgorithm -> Bool
$c== :: SourceAlgorithm -> SourceAlgorithm -> Bool
Prelude.Eq, ReadPrec [SourceAlgorithm]
ReadPrec SourceAlgorithm
Int -> ReadS SourceAlgorithm
ReadS [SourceAlgorithm]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SourceAlgorithm]
$creadListPrec :: ReadPrec [SourceAlgorithm]
readPrec :: ReadPrec SourceAlgorithm
$creadPrec :: ReadPrec SourceAlgorithm
readList :: ReadS [SourceAlgorithm]
$creadList :: ReadS [SourceAlgorithm]
readsPrec :: Int -> ReadS SourceAlgorithm
$creadsPrec :: Int -> ReadS SourceAlgorithm
Prelude.Read, Int -> SourceAlgorithm -> ShowS
[SourceAlgorithm] -> ShowS
SourceAlgorithm -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SourceAlgorithm] -> ShowS
$cshowList :: [SourceAlgorithm] -> ShowS
show :: SourceAlgorithm -> String
$cshow :: SourceAlgorithm -> String
showsPrec :: Int -> SourceAlgorithm -> ShowS
$cshowsPrec :: Int -> SourceAlgorithm -> ShowS
Prelude.Show, forall x. Rep SourceAlgorithm x -> SourceAlgorithm
forall x. SourceAlgorithm -> Rep SourceAlgorithm x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SourceAlgorithm x -> SourceAlgorithm
$cfrom :: forall x. SourceAlgorithm -> Rep SourceAlgorithm x
Prelude.Generic)

-- |
-- Create a value of 'SourceAlgorithm' 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:
--
-- 'modelDataUrl', 'sourceAlgorithm_modelDataUrl' - The Amazon S3 path where the model artifacts, which result from model
-- training, are stored. This path must point to a single @gzip@ compressed
-- tar archive (@.tar.gz@ suffix).
--
-- The model artifacts must be in an S3 bucket that is in the same region
-- as the algorithm.
--
-- 'algorithmName', 'sourceAlgorithm_algorithmName' - The name of an algorithm that was used to create the model package. The
-- algorithm must be either an algorithm resource in your SageMaker account
-- or an algorithm in Amazon Web Services Marketplace that you are
-- subscribed to.
newSourceAlgorithm ::
  -- | 'algorithmName'
  Prelude.Text ->
  SourceAlgorithm
newSourceAlgorithm :: Text -> SourceAlgorithm
newSourceAlgorithm Text
pAlgorithmName_ =
  SourceAlgorithm'
    { $sel:modelDataUrl:SourceAlgorithm' :: Maybe Text
modelDataUrl = forall a. Maybe a
Prelude.Nothing,
      $sel:algorithmName:SourceAlgorithm' :: Text
algorithmName = Text
pAlgorithmName_
    }

-- | The Amazon S3 path where the model artifacts, which result from model
-- training, are stored. This path must point to a single @gzip@ compressed
-- tar archive (@.tar.gz@ suffix).
--
-- The model artifacts must be in an S3 bucket that is in the same region
-- as the algorithm.
sourceAlgorithm_modelDataUrl :: Lens.Lens' SourceAlgorithm (Prelude.Maybe Prelude.Text)
sourceAlgorithm_modelDataUrl :: Lens' SourceAlgorithm (Maybe Text)
sourceAlgorithm_modelDataUrl = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceAlgorithm' {Maybe Text
modelDataUrl :: Maybe Text
$sel:modelDataUrl:SourceAlgorithm' :: SourceAlgorithm -> Maybe Text
modelDataUrl} -> Maybe Text
modelDataUrl) (\s :: SourceAlgorithm
s@SourceAlgorithm' {} Maybe Text
a -> SourceAlgorithm
s {$sel:modelDataUrl:SourceAlgorithm' :: Maybe Text
modelDataUrl = Maybe Text
a} :: SourceAlgorithm)

-- | The name of an algorithm that was used to create the model package. The
-- algorithm must be either an algorithm resource in your SageMaker account
-- or an algorithm in Amazon Web Services Marketplace that you are
-- subscribed to.
sourceAlgorithm_algorithmName :: Lens.Lens' SourceAlgorithm Prelude.Text
sourceAlgorithm_algorithmName :: Lens' SourceAlgorithm Text
sourceAlgorithm_algorithmName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SourceAlgorithm' {Text
algorithmName :: Text
$sel:algorithmName:SourceAlgorithm' :: SourceAlgorithm -> Text
algorithmName} -> Text
algorithmName) (\s :: SourceAlgorithm
s@SourceAlgorithm' {} Text
a -> SourceAlgorithm
s {$sel:algorithmName:SourceAlgorithm' :: Text
algorithmName = Text
a} :: SourceAlgorithm)

instance Data.FromJSON SourceAlgorithm where
  parseJSON :: Value -> Parser SourceAlgorithm
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SourceAlgorithm"
      ( \Object
x ->
          Maybe Text -> Text -> SourceAlgorithm
SourceAlgorithm'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ModelDataUrl")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"AlgorithmName")
      )

instance Prelude.Hashable SourceAlgorithm where
  hashWithSalt :: Int -> SourceAlgorithm -> Int
hashWithSalt Int
_salt SourceAlgorithm' {Maybe Text
Text
algorithmName :: Text
modelDataUrl :: Maybe Text
$sel:algorithmName:SourceAlgorithm' :: SourceAlgorithm -> Text
$sel:modelDataUrl:SourceAlgorithm' :: SourceAlgorithm -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
modelDataUrl
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
algorithmName

instance Prelude.NFData SourceAlgorithm where
  rnf :: SourceAlgorithm -> ()
rnf SourceAlgorithm' {Maybe Text
Text
algorithmName :: Text
modelDataUrl :: Maybe Text
$sel:algorithmName:SourceAlgorithm' :: SourceAlgorithm -> Text
$sel:modelDataUrl:SourceAlgorithm' :: SourceAlgorithm -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
modelDataUrl
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
algorithmName

instance Data.ToJSON SourceAlgorithm where
  toJSON :: SourceAlgorithm -> Value
toJSON SourceAlgorithm' {Maybe Text
Text
algorithmName :: Text
modelDataUrl :: Maybe Text
$sel:algorithmName:SourceAlgorithm' :: SourceAlgorithm -> Text
$sel:modelDataUrl:SourceAlgorithm' :: SourceAlgorithm -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"ModelDataUrl" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
modelDataUrl,
            forall a. a -> Maybe a
Prelude.Just
              (Key
"AlgorithmName" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
algorithmName)
          ]
      )