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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 Amazon 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 Amazon SageMaker
    -- account or an algorithm in Amazon Web Services Marketplace that you are
    -- subscribed to.
    SourceAlgorithm -> Text
algorithmName :: Prelude.Text
  }
  deriving (SourceAlgorithm -> SourceAlgorithm -> Bool
(SourceAlgorithm -> SourceAlgorithm -> Bool)
-> (SourceAlgorithm -> SourceAlgorithm -> Bool)
-> Eq SourceAlgorithm
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]
(Int -> ReadS SourceAlgorithm)
-> ReadS [SourceAlgorithm]
-> ReadPrec SourceAlgorithm
-> ReadPrec [SourceAlgorithm]
-> Read 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
(Int -> SourceAlgorithm -> ShowS)
-> (SourceAlgorithm -> String)
-> ([SourceAlgorithm] -> ShowS)
-> Show SourceAlgorithm
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. SourceAlgorithm -> Rep SourceAlgorithm x)
-> (forall x. Rep SourceAlgorithm x -> SourceAlgorithm)
-> Generic SourceAlgorithm
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 Amazon 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' :: Maybe Text -> Text -> SourceAlgorithm
SourceAlgorithm'
    { $sel:modelDataUrl:SourceAlgorithm' :: Maybe Text
modelDataUrl = Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> SourceAlgorithm -> f SourceAlgorithm
sourceAlgorithm_modelDataUrl = (SourceAlgorithm -> Maybe Text)
-> (SourceAlgorithm -> Maybe Text -> SourceAlgorithm)
-> Lens SourceAlgorithm SourceAlgorithm (Maybe Text) (Maybe Text)
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 Amazon SageMaker
-- account or an algorithm in Amazon Web Services Marketplace that you are
-- subscribed to.
sourceAlgorithm_algorithmName :: Lens.Lens' SourceAlgorithm Prelude.Text
sourceAlgorithm_algorithmName :: (Text -> f Text) -> SourceAlgorithm -> f SourceAlgorithm
sourceAlgorithm_algorithmName = (SourceAlgorithm -> Text)
-> (SourceAlgorithm -> Text -> SourceAlgorithm)
-> Lens SourceAlgorithm SourceAlgorithm Text Text
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 Core.FromJSON SourceAlgorithm where
  parseJSON :: Value -> Parser SourceAlgorithm
parseJSON =
    String
-> (Object -> Parser SourceAlgorithm)
-> Value
-> Parser SourceAlgorithm
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SourceAlgorithm"
      ( \Object
x ->
          Maybe Text -> Text -> SourceAlgorithm
SourceAlgorithm'
            (Maybe Text -> Text -> SourceAlgorithm)
-> Parser (Maybe Text) -> Parser (Text -> SourceAlgorithm)
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
"ModelDataUrl")
            Parser (Text -> SourceAlgorithm)
-> Parser Text -> Parser SourceAlgorithm
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"AlgorithmName")
      )

instance Prelude.Hashable SourceAlgorithm

instance Prelude.NFData SourceAlgorithm

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ModelDataUrl" 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
modelDataUrl,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AlgorithmName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
algorithmName)
          ]
      )