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

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

-- | A version of a SageMaker @Image@. A version represents an existing
-- container image.
--
-- /See:/ 'newImageVersion' smart constructor.
data ImageVersion = ImageVersion'
  { -- | When a create or delete operation fails, the reason for the failure.
    ImageVersion -> Maybe Text
failureReason :: Prelude.Maybe Prelude.Text,
    -- | When the version was created.
    ImageVersion -> POSIX
creationTime :: Core.POSIX,
    -- | The Amazon Resource Name (ARN) of the image the version is based on.
    ImageVersion -> Text
imageArn :: Prelude.Text,
    -- | The ARN of the version.
    ImageVersion -> Text
imageVersionArn :: Prelude.Text,
    -- | The status of the version.
    ImageVersion -> ImageVersionStatus
imageVersionStatus :: ImageVersionStatus,
    -- | When the version was last modified.
    ImageVersion -> POSIX
lastModifiedTime :: Core.POSIX,
    -- | The version number.
    ImageVersion -> Natural
version :: Prelude.Natural
  }
  deriving (ImageVersion -> ImageVersion -> Bool
(ImageVersion -> ImageVersion -> Bool)
-> (ImageVersion -> ImageVersion -> Bool) -> Eq ImageVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ImageVersion -> ImageVersion -> Bool
$c/= :: ImageVersion -> ImageVersion -> Bool
== :: ImageVersion -> ImageVersion -> Bool
$c== :: ImageVersion -> ImageVersion -> Bool
Prelude.Eq, ReadPrec [ImageVersion]
ReadPrec ImageVersion
Int -> ReadS ImageVersion
ReadS [ImageVersion]
(Int -> ReadS ImageVersion)
-> ReadS [ImageVersion]
-> ReadPrec ImageVersion
-> ReadPrec [ImageVersion]
-> Read ImageVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ImageVersion]
$creadListPrec :: ReadPrec [ImageVersion]
readPrec :: ReadPrec ImageVersion
$creadPrec :: ReadPrec ImageVersion
readList :: ReadS [ImageVersion]
$creadList :: ReadS [ImageVersion]
readsPrec :: Int -> ReadS ImageVersion
$creadsPrec :: Int -> ReadS ImageVersion
Prelude.Read, Int -> ImageVersion -> ShowS
[ImageVersion] -> ShowS
ImageVersion -> String
(Int -> ImageVersion -> ShowS)
-> (ImageVersion -> String)
-> ([ImageVersion] -> ShowS)
-> Show ImageVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ImageVersion] -> ShowS
$cshowList :: [ImageVersion] -> ShowS
show :: ImageVersion -> String
$cshow :: ImageVersion -> String
showsPrec :: Int -> ImageVersion -> ShowS
$cshowsPrec :: Int -> ImageVersion -> ShowS
Prelude.Show, (forall x. ImageVersion -> Rep ImageVersion x)
-> (forall x. Rep ImageVersion x -> ImageVersion)
-> Generic ImageVersion
forall x. Rep ImageVersion x -> ImageVersion
forall x. ImageVersion -> Rep ImageVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ImageVersion x -> ImageVersion
$cfrom :: forall x. ImageVersion -> Rep ImageVersion x
Prelude.Generic)

-- |
-- Create a value of 'ImageVersion' 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:
--
-- 'failureReason', 'imageVersion_failureReason' - When a create or delete operation fails, the reason for the failure.
--
-- 'creationTime', 'imageVersion_creationTime' - When the version was created.
--
-- 'imageArn', 'imageVersion_imageArn' - The Amazon Resource Name (ARN) of the image the version is based on.
--
-- 'imageVersionArn', 'imageVersion_imageVersionArn' - The ARN of the version.
--
-- 'imageVersionStatus', 'imageVersion_imageVersionStatus' - The status of the version.
--
-- 'lastModifiedTime', 'imageVersion_lastModifiedTime' - When the version was last modified.
--
-- 'version', 'imageVersion_version' - The version number.
newImageVersion ::
  -- | 'creationTime'
  Prelude.UTCTime ->
  -- | 'imageArn'
  Prelude.Text ->
  -- | 'imageVersionArn'
  Prelude.Text ->
  -- | 'imageVersionStatus'
  ImageVersionStatus ->
  -- | 'lastModifiedTime'
  Prelude.UTCTime ->
  -- | 'version'
  Prelude.Natural ->
  ImageVersion
newImageVersion :: UTCTime
-> Text
-> Text
-> ImageVersionStatus
-> UTCTime
-> Natural
-> ImageVersion
newImageVersion
  UTCTime
pCreationTime_
  Text
pImageArn_
  Text
pImageVersionArn_
  ImageVersionStatus
pImageVersionStatus_
  UTCTime
pLastModifiedTime_
  Natural
pVersion_ =
    ImageVersion' :: Maybe Text
-> POSIX
-> Text
-> Text
-> ImageVersionStatus
-> POSIX
-> Natural
-> ImageVersion
ImageVersion'
      { $sel:failureReason:ImageVersion' :: Maybe Text
failureReason = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:creationTime:ImageVersion' :: POSIX
creationTime = Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pCreationTime_,
        $sel:imageArn:ImageVersion' :: Text
imageArn = Text
pImageArn_,
        $sel:imageVersionArn:ImageVersion' :: Text
imageVersionArn = Text
pImageVersionArn_,
        $sel:imageVersionStatus:ImageVersion' :: ImageVersionStatus
imageVersionStatus = ImageVersionStatus
pImageVersionStatus_,
        $sel:lastModifiedTime:ImageVersion' :: POSIX
lastModifiedTime =
          Tagged UTCTime (Identity UTCTime) -> Tagged POSIX (Identity POSIX)
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time (Tagged UTCTime (Identity UTCTime)
 -> Tagged POSIX (Identity POSIX))
-> UTCTime -> POSIX
forall t b. AReview t b -> b -> t
Lens.# UTCTime
pLastModifiedTime_,
        $sel:version:ImageVersion' :: Natural
version = Natural
pVersion_
      }

-- | When a create or delete operation fails, the reason for the failure.
imageVersion_failureReason :: Lens.Lens' ImageVersion (Prelude.Maybe Prelude.Text)
imageVersion_failureReason :: (Maybe Text -> f (Maybe Text)) -> ImageVersion -> f ImageVersion
imageVersion_failureReason = (ImageVersion -> Maybe Text)
-> (ImageVersion -> Maybe Text -> ImageVersion)
-> Lens ImageVersion ImageVersion (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageVersion' {Maybe Text
failureReason :: Maybe Text
$sel:failureReason:ImageVersion' :: ImageVersion -> Maybe Text
failureReason} -> Maybe Text
failureReason) (\s :: ImageVersion
s@ImageVersion' {} Maybe Text
a -> ImageVersion
s {$sel:failureReason:ImageVersion' :: Maybe Text
failureReason = Maybe Text
a} :: ImageVersion)

-- | When the version was created.
imageVersion_creationTime :: Lens.Lens' ImageVersion Prelude.UTCTime
imageVersion_creationTime :: (UTCTime -> f UTCTime) -> ImageVersion -> f ImageVersion
imageVersion_creationTime = (ImageVersion -> POSIX)
-> (ImageVersion -> POSIX -> ImageVersion)
-> Lens ImageVersion ImageVersion POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageVersion' {POSIX
creationTime :: POSIX
$sel:creationTime:ImageVersion' :: ImageVersion -> POSIX
creationTime} -> POSIX
creationTime) (\s :: ImageVersion
s@ImageVersion' {} POSIX
a -> ImageVersion
s {$sel:creationTime:ImageVersion' :: POSIX
creationTime = POSIX
a} :: ImageVersion) ((POSIX -> f POSIX) -> ImageVersion -> f ImageVersion)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ImageVersion
-> f ImageVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The Amazon Resource Name (ARN) of the image the version is based on.
imageVersion_imageArn :: Lens.Lens' ImageVersion Prelude.Text
imageVersion_imageArn :: (Text -> f Text) -> ImageVersion -> f ImageVersion
imageVersion_imageArn = (ImageVersion -> Text)
-> (ImageVersion -> Text -> ImageVersion)
-> Lens ImageVersion ImageVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageVersion' {Text
imageArn :: Text
$sel:imageArn:ImageVersion' :: ImageVersion -> Text
imageArn} -> Text
imageArn) (\s :: ImageVersion
s@ImageVersion' {} Text
a -> ImageVersion
s {$sel:imageArn:ImageVersion' :: Text
imageArn = Text
a} :: ImageVersion)

-- | The ARN of the version.
imageVersion_imageVersionArn :: Lens.Lens' ImageVersion Prelude.Text
imageVersion_imageVersionArn :: (Text -> f Text) -> ImageVersion -> f ImageVersion
imageVersion_imageVersionArn = (ImageVersion -> Text)
-> (ImageVersion -> Text -> ImageVersion)
-> Lens ImageVersion ImageVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageVersion' {Text
imageVersionArn :: Text
$sel:imageVersionArn:ImageVersion' :: ImageVersion -> Text
imageVersionArn} -> Text
imageVersionArn) (\s :: ImageVersion
s@ImageVersion' {} Text
a -> ImageVersion
s {$sel:imageVersionArn:ImageVersion' :: Text
imageVersionArn = Text
a} :: ImageVersion)

-- | The status of the version.
imageVersion_imageVersionStatus :: Lens.Lens' ImageVersion ImageVersionStatus
imageVersion_imageVersionStatus :: (ImageVersionStatus -> f ImageVersionStatus)
-> ImageVersion -> f ImageVersion
imageVersion_imageVersionStatus = (ImageVersion -> ImageVersionStatus)
-> (ImageVersion -> ImageVersionStatus -> ImageVersion)
-> Lens
     ImageVersion ImageVersion ImageVersionStatus ImageVersionStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageVersion' {ImageVersionStatus
imageVersionStatus :: ImageVersionStatus
$sel:imageVersionStatus:ImageVersion' :: ImageVersion -> ImageVersionStatus
imageVersionStatus} -> ImageVersionStatus
imageVersionStatus) (\s :: ImageVersion
s@ImageVersion' {} ImageVersionStatus
a -> ImageVersion
s {$sel:imageVersionStatus:ImageVersion' :: ImageVersionStatus
imageVersionStatus = ImageVersionStatus
a} :: ImageVersion)

-- | When the version was last modified.
imageVersion_lastModifiedTime :: Lens.Lens' ImageVersion Prelude.UTCTime
imageVersion_lastModifiedTime :: (UTCTime -> f UTCTime) -> ImageVersion -> f ImageVersion
imageVersion_lastModifiedTime = (ImageVersion -> POSIX)
-> (ImageVersion -> POSIX -> ImageVersion)
-> Lens ImageVersion ImageVersion POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageVersion' {POSIX
lastModifiedTime :: POSIX
$sel:lastModifiedTime:ImageVersion' :: ImageVersion -> POSIX
lastModifiedTime} -> POSIX
lastModifiedTime) (\s :: ImageVersion
s@ImageVersion' {} POSIX
a -> ImageVersion
s {$sel:lastModifiedTime:ImageVersion' :: POSIX
lastModifiedTime = POSIX
a} :: ImageVersion) ((POSIX -> f POSIX) -> ImageVersion -> f ImageVersion)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> ImageVersion
-> f ImageVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (UTCTime -> f UTCTime) -> POSIX -> f POSIX
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | The version number.
imageVersion_version :: Lens.Lens' ImageVersion Prelude.Natural
imageVersion_version :: (Natural -> f Natural) -> ImageVersion -> f ImageVersion
imageVersion_version = (ImageVersion -> Natural)
-> (ImageVersion -> Natural -> ImageVersion)
-> Lens ImageVersion ImageVersion Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ImageVersion' {Natural
version :: Natural
$sel:version:ImageVersion' :: ImageVersion -> Natural
version} -> Natural
version) (\s :: ImageVersion
s@ImageVersion' {} Natural
a -> ImageVersion
s {$sel:version:ImageVersion' :: Natural
version = Natural
a} :: ImageVersion)

instance Core.FromJSON ImageVersion where
  parseJSON :: Value -> Parser ImageVersion
parseJSON =
    String
-> (Object -> Parser ImageVersion) -> Value -> Parser ImageVersion
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ImageVersion"
      ( \Object
x ->
          Maybe Text
-> POSIX
-> Text
-> Text
-> ImageVersionStatus
-> POSIX
-> Natural
-> ImageVersion
ImageVersion'
            (Maybe Text
 -> POSIX
 -> Text
 -> Text
 -> ImageVersionStatus
 -> POSIX
 -> Natural
 -> ImageVersion)
-> Parser (Maybe Text)
-> Parser
     (POSIX
      -> Text
      -> Text
      -> ImageVersionStatus
      -> POSIX
      -> Natural
      -> ImageVersion)
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
"FailureReason")
            Parser
  (POSIX
   -> Text
   -> Text
   -> ImageVersionStatus
   -> POSIX
   -> Natural
   -> ImageVersion)
-> Parser POSIX
-> Parser
     (Text
      -> Text -> ImageVersionStatus -> POSIX -> Natural -> ImageVersion)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"CreationTime")
            Parser
  (Text
   -> Text -> ImageVersionStatus -> POSIX -> Natural -> ImageVersion)
-> Parser Text
-> Parser
     (Text -> ImageVersionStatus -> POSIX -> Natural -> ImageVersion)
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
"ImageArn")
            Parser
  (Text -> ImageVersionStatus -> POSIX -> Natural -> ImageVersion)
-> Parser Text
-> Parser (ImageVersionStatus -> POSIX -> Natural -> ImageVersion)
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
"ImageVersionArn")
            Parser (ImageVersionStatus -> POSIX -> Natural -> ImageVersion)
-> Parser ImageVersionStatus
-> Parser (POSIX -> Natural -> ImageVersion)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ImageVersionStatus
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ImageVersionStatus")
            Parser (POSIX -> Natural -> ImageVersion)
-> Parser POSIX -> Parser (Natural -> ImageVersion)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser POSIX
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"LastModifiedTime")
            Parser (Natural -> ImageVersion)
-> Parser Natural -> Parser ImageVersion
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Version")
      )

instance Prelude.Hashable ImageVersion

instance Prelude.NFData ImageVersion