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

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

-- | A custom SageMaker image. For more information, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/studio-byoi.html Bring your own SageMaker image>.
--
-- /See:/ 'newCustomImage' smart constructor.
data CustomImage = CustomImage'
  { -- | The version number of the CustomImage.
    CustomImage -> Maybe Natural
imageVersionNumber :: Prelude.Maybe Prelude.Natural,
    -- | The name of the CustomImage. Must be unique to your account.
    CustomImage -> Text
imageName :: Prelude.Text,
    -- | The name of the AppImageConfig.
    CustomImage -> Text
appImageConfigName :: Prelude.Text
  }
  deriving (CustomImage -> CustomImage -> Bool
(CustomImage -> CustomImage -> Bool)
-> (CustomImage -> CustomImage -> Bool) -> Eq CustomImage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CustomImage -> CustomImage -> Bool
$c/= :: CustomImage -> CustomImage -> Bool
== :: CustomImage -> CustomImage -> Bool
$c== :: CustomImage -> CustomImage -> Bool
Prelude.Eq, ReadPrec [CustomImage]
ReadPrec CustomImage
Int -> ReadS CustomImage
ReadS [CustomImage]
(Int -> ReadS CustomImage)
-> ReadS [CustomImage]
-> ReadPrec CustomImage
-> ReadPrec [CustomImage]
-> Read CustomImage
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CustomImage]
$creadListPrec :: ReadPrec [CustomImage]
readPrec :: ReadPrec CustomImage
$creadPrec :: ReadPrec CustomImage
readList :: ReadS [CustomImage]
$creadList :: ReadS [CustomImage]
readsPrec :: Int -> ReadS CustomImage
$creadsPrec :: Int -> ReadS CustomImage
Prelude.Read, Int -> CustomImage -> ShowS
[CustomImage] -> ShowS
CustomImage -> String
(Int -> CustomImage -> ShowS)
-> (CustomImage -> String)
-> ([CustomImage] -> ShowS)
-> Show CustomImage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CustomImage] -> ShowS
$cshowList :: [CustomImage] -> ShowS
show :: CustomImage -> String
$cshow :: CustomImage -> String
showsPrec :: Int -> CustomImage -> ShowS
$cshowsPrec :: Int -> CustomImage -> ShowS
Prelude.Show, (forall x. CustomImage -> Rep CustomImage x)
-> (forall x. Rep CustomImage x -> CustomImage)
-> Generic CustomImage
forall x. Rep CustomImage x -> CustomImage
forall x. CustomImage -> Rep CustomImage x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CustomImage x -> CustomImage
$cfrom :: forall x. CustomImage -> Rep CustomImage x
Prelude.Generic)

-- |
-- Create a value of 'CustomImage' 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:
--
-- 'imageVersionNumber', 'customImage_imageVersionNumber' - The version number of the CustomImage.
--
-- 'imageName', 'customImage_imageName' - The name of the CustomImage. Must be unique to your account.
--
-- 'appImageConfigName', 'customImage_appImageConfigName' - The name of the AppImageConfig.
newCustomImage ::
  -- | 'imageName'
  Prelude.Text ->
  -- | 'appImageConfigName'
  Prelude.Text ->
  CustomImage
newCustomImage :: Text -> Text -> CustomImage
newCustomImage Text
pImageName_ Text
pAppImageConfigName_ =
  CustomImage' :: Maybe Natural -> Text -> Text -> CustomImage
CustomImage'
    { $sel:imageVersionNumber:CustomImage' :: Maybe Natural
imageVersionNumber = Maybe Natural
forall a. Maybe a
Prelude.Nothing,
      $sel:imageName:CustomImage' :: Text
imageName = Text
pImageName_,
      $sel:appImageConfigName:CustomImage' :: Text
appImageConfigName = Text
pAppImageConfigName_
    }

-- | The version number of the CustomImage.
customImage_imageVersionNumber :: Lens.Lens' CustomImage (Prelude.Maybe Prelude.Natural)
customImage_imageVersionNumber :: (Maybe Natural -> f (Maybe Natural))
-> CustomImage -> f CustomImage
customImage_imageVersionNumber = (CustomImage -> Maybe Natural)
-> (CustomImage -> Maybe Natural -> CustomImage)
-> Lens CustomImage CustomImage (Maybe Natural) (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomImage' {Maybe Natural
imageVersionNumber :: Maybe Natural
$sel:imageVersionNumber:CustomImage' :: CustomImage -> Maybe Natural
imageVersionNumber} -> Maybe Natural
imageVersionNumber) (\s :: CustomImage
s@CustomImage' {} Maybe Natural
a -> CustomImage
s {$sel:imageVersionNumber:CustomImage' :: Maybe Natural
imageVersionNumber = Maybe Natural
a} :: CustomImage)

-- | The name of the CustomImage. Must be unique to your account.
customImage_imageName :: Lens.Lens' CustomImage Prelude.Text
customImage_imageName :: (Text -> f Text) -> CustomImage -> f CustomImage
customImage_imageName = (CustomImage -> Text)
-> (CustomImage -> Text -> CustomImage)
-> Lens CustomImage CustomImage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomImage' {Text
imageName :: Text
$sel:imageName:CustomImage' :: CustomImage -> Text
imageName} -> Text
imageName) (\s :: CustomImage
s@CustomImage' {} Text
a -> CustomImage
s {$sel:imageName:CustomImage' :: Text
imageName = Text
a} :: CustomImage)

-- | The name of the AppImageConfig.
customImage_appImageConfigName :: Lens.Lens' CustomImage Prelude.Text
customImage_appImageConfigName :: (Text -> f Text) -> CustomImage -> f CustomImage
customImage_appImageConfigName = (CustomImage -> Text)
-> (CustomImage -> Text -> CustomImage)
-> Lens CustomImage CustomImage Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CustomImage' {Text
appImageConfigName :: Text
$sel:appImageConfigName:CustomImage' :: CustomImage -> Text
appImageConfigName} -> Text
appImageConfigName) (\s :: CustomImage
s@CustomImage' {} Text
a -> CustomImage
s {$sel:appImageConfigName:CustomImage' :: Text
appImageConfigName = Text
a} :: CustomImage)

instance Core.FromJSON CustomImage where
  parseJSON :: Value -> Parser CustomImage
parseJSON =
    String
-> (Object -> Parser CustomImage) -> Value -> Parser CustomImage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"CustomImage"
      ( \Object
x ->
          Maybe Natural -> Text -> Text -> CustomImage
CustomImage'
            (Maybe Natural -> Text -> Text -> CustomImage)
-> Parser (Maybe Natural) -> Parser (Text -> Text -> CustomImage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Natural)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ImageVersionNumber")
            Parser (Text -> Text -> CustomImage)
-> Parser Text -> Parser (Text -> CustomImage)
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
"ImageName")
            Parser (Text -> CustomImage) -> Parser Text -> Parser CustomImage
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
"AppImageConfigName")
      )

instance Prelude.Hashable CustomImage

instance Prelude.NFData CustomImage

instance Core.ToJSON CustomImage where
  toJSON :: CustomImage -> Value
toJSON CustomImage' {Maybe Natural
Text
appImageConfigName :: Text
imageName :: Text
imageVersionNumber :: Maybe Natural
$sel:appImageConfigName:CustomImage' :: CustomImage -> Text
$sel:imageName:CustomImage' :: CustomImage -> Text
$sel:imageVersionNumber:CustomImage' :: CustomImage -> Maybe Natural
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"ImageVersionNumber" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (Natural -> Pair) -> Maybe Natural -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
imageVersionNumber,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ImageName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
imageName),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"AppImageConfigName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
appImageConfigName)
          ]
      )