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

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

-- | An array element of
-- DescribeTrainingJobResponse$SecondaryStatusTransitions. It provides
-- additional details about a status that the training job has transitioned
-- through. A training job can be in one of several states, for example,
-- starting, downloading, training, or uploading. Within each state, there
-- are a number of intermediate states. For example, within the starting
-- state, Amazon SageMaker could be starting the training job or launching
-- the ML instances. These transitional states are referred to as the
-- job\'s secondary status.
--
-- /See:/ 'newSecondaryStatusTransition' smart constructor.
data SecondaryStatusTransition = SecondaryStatusTransition'
  { -- | A detailed description of the progress within a secondary status.
    --
    -- Amazon SageMaker provides secondary statuses and status messages that
    -- apply to each of them:
    --
    -- [Starting]
    --     -   Starting the training job.
    --
    --     -   Launching requested ML instances.
    --
    --     -   Insufficient capacity error from EC2 while launching instances,
    --         retrying!
    --
    --     -   Launched instance was unhealthy, replacing it!
    --
    --     -   Preparing the instances for training.
    --
    -- [Training]
    --     -   Downloading the training image.
    --
    --     -   Training image download completed. Training in progress.
    --
    -- Status messages are subject to change. Therefore, we recommend not
    -- including them in code that programmatically initiates actions. For
    -- examples, don\'t use status messages in if statements.
    --
    -- To have an overview of your training job\'s progress, view
    -- @TrainingJobStatus@ and @SecondaryStatus@ in DescribeTrainingJob, and
    -- @StatusMessage@ together. For example, at the start of a training job,
    -- you might see the following:
    --
    -- -   @TrainingJobStatus@ - InProgress
    --
    -- -   @SecondaryStatus@ - Training
    --
    -- -   @StatusMessage@ - Downloading the training image
    SecondaryStatusTransition -> Maybe Text
statusMessage :: Prelude.Maybe Prelude.Text,
    -- | A timestamp that shows when the training job transitioned out of this
    -- secondary status state into another secondary status state or when the
    -- training job has ended.
    SecondaryStatusTransition -> Maybe POSIX
endTime :: Prelude.Maybe Core.POSIX,
    -- | Contains a secondary status information from a training job.
    --
    -- Status might be one of the following secondary statuses:
    --
    -- [InProgress]
    --     -   @Starting@ - Starting the training job.
    --
    --     -   @Downloading@ - An optional stage for algorithms that support
    --         @File@ training input mode. It indicates that data is being
    --         downloaded to the ML storage volumes.
    --
    --     -   @Training@ - Training is in progress.
    --
    --     -   @Uploading@ - Training is complete and the model artifacts are
    --         being uploaded to the S3 location.
    --
    -- [Completed]
    --     -   @Completed@ - The training job has completed.
    --
    -- [Failed]
    --     -   @Failed@ - The training job has failed. The reason for the
    --         failure is returned in the @FailureReason@ field of
    --         @DescribeTrainingJobResponse@.
    --
    -- [Stopped]
    --     -   @MaxRuntimeExceeded@ - The job stopped because it exceeded the
    --         maximum allowed runtime.
    --
    --     -   @Stopped@ - The training job has stopped.
    --
    -- [Stopping]
    --     -   @Stopping@ - Stopping the training job.
    --
    -- We no longer support the following secondary statuses:
    --
    -- -   @LaunchingMLInstances@
    --
    -- -   @PreparingTrainingStack@
    --
    -- -   @DownloadingTrainingImage@
    SecondaryStatusTransition -> SecondaryStatus
status :: SecondaryStatus,
    -- | A timestamp that shows when the training job transitioned to the current
    -- secondary status state.
    SecondaryStatusTransition -> POSIX
startTime :: Core.POSIX
  }
  deriving (SecondaryStatusTransition -> SecondaryStatusTransition -> Bool
(SecondaryStatusTransition -> SecondaryStatusTransition -> Bool)
-> (SecondaryStatusTransition -> SecondaryStatusTransition -> Bool)
-> Eq SecondaryStatusTransition
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SecondaryStatusTransition -> SecondaryStatusTransition -> Bool
$c/= :: SecondaryStatusTransition -> SecondaryStatusTransition -> Bool
== :: SecondaryStatusTransition -> SecondaryStatusTransition -> Bool
$c== :: SecondaryStatusTransition -> SecondaryStatusTransition -> Bool
Prelude.Eq, ReadPrec [SecondaryStatusTransition]
ReadPrec SecondaryStatusTransition
Int -> ReadS SecondaryStatusTransition
ReadS [SecondaryStatusTransition]
(Int -> ReadS SecondaryStatusTransition)
-> ReadS [SecondaryStatusTransition]
-> ReadPrec SecondaryStatusTransition
-> ReadPrec [SecondaryStatusTransition]
-> Read SecondaryStatusTransition
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SecondaryStatusTransition]
$creadListPrec :: ReadPrec [SecondaryStatusTransition]
readPrec :: ReadPrec SecondaryStatusTransition
$creadPrec :: ReadPrec SecondaryStatusTransition
readList :: ReadS [SecondaryStatusTransition]
$creadList :: ReadS [SecondaryStatusTransition]
readsPrec :: Int -> ReadS SecondaryStatusTransition
$creadsPrec :: Int -> ReadS SecondaryStatusTransition
Prelude.Read, Int -> SecondaryStatusTransition -> ShowS
[SecondaryStatusTransition] -> ShowS
SecondaryStatusTransition -> String
(Int -> SecondaryStatusTransition -> ShowS)
-> (SecondaryStatusTransition -> String)
-> ([SecondaryStatusTransition] -> ShowS)
-> Show SecondaryStatusTransition
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SecondaryStatusTransition] -> ShowS
$cshowList :: [SecondaryStatusTransition] -> ShowS
show :: SecondaryStatusTransition -> String
$cshow :: SecondaryStatusTransition -> String
showsPrec :: Int -> SecondaryStatusTransition -> ShowS
$cshowsPrec :: Int -> SecondaryStatusTransition -> ShowS
Prelude.Show, (forall x.
 SecondaryStatusTransition -> Rep SecondaryStatusTransition x)
-> (forall x.
    Rep SecondaryStatusTransition x -> SecondaryStatusTransition)
-> Generic SecondaryStatusTransition
forall x.
Rep SecondaryStatusTransition x -> SecondaryStatusTransition
forall x.
SecondaryStatusTransition -> Rep SecondaryStatusTransition x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SecondaryStatusTransition x -> SecondaryStatusTransition
$cfrom :: forall x.
SecondaryStatusTransition -> Rep SecondaryStatusTransition x
Prelude.Generic)

-- |
-- Create a value of 'SecondaryStatusTransition' 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:
--
-- 'statusMessage', 'secondaryStatusTransition_statusMessage' - A detailed description of the progress within a secondary status.
--
-- Amazon SageMaker provides secondary statuses and status messages that
-- apply to each of them:
--
-- [Starting]
--     -   Starting the training job.
--
--     -   Launching requested ML instances.
--
--     -   Insufficient capacity error from EC2 while launching instances,
--         retrying!
--
--     -   Launched instance was unhealthy, replacing it!
--
--     -   Preparing the instances for training.
--
-- [Training]
--     -   Downloading the training image.
--
--     -   Training image download completed. Training in progress.
--
-- Status messages are subject to change. Therefore, we recommend not
-- including them in code that programmatically initiates actions. For
-- examples, don\'t use status messages in if statements.
--
-- To have an overview of your training job\'s progress, view
-- @TrainingJobStatus@ and @SecondaryStatus@ in DescribeTrainingJob, and
-- @StatusMessage@ together. For example, at the start of a training job,
-- you might see the following:
--
-- -   @TrainingJobStatus@ - InProgress
--
-- -   @SecondaryStatus@ - Training
--
-- -   @StatusMessage@ - Downloading the training image
--
-- 'endTime', 'secondaryStatusTransition_endTime' - A timestamp that shows when the training job transitioned out of this
-- secondary status state into another secondary status state or when the
-- training job has ended.
--
-- 'status', 'secondaryStatusTransition_status' - Contains a secondary status information from a training job.
--
-- Status might be one of the following secondary statuses:
--
-- [InProgress]
--     -   @Starting@ - Starting the training job.
--
--     -   @Downloading@ - An optional stage for algorithms that support
--         @File@ training input mode. It indicates that data is being
--         downloaded to the ML storage volumes.
--
--     -   @Training@ - Training is in progress.
--
--     -   @Uploading@ - Training is complete and the model artifacts are
--         being uploaded to the S3 location.
--
-- [Completed]
--     -   @Completed@ - The training job has completed.
--
-- [Failed]
--     -   @Failed@ - The training job has failed. The reason for the
--         failure is returned in the @FailureReason@ field of
--         @DescribeTrainingJobResponse@.
--
-- [Stopped]
--     -   @MaxRuntimeExceeded@ - The job stopped because it exceeded the
--         maximum allowed runtime.
--
--     -   @Stopped@ - The training job has stopped.
--
-- [Stopping]
--     -   @Stopping@ - Stopping the training job.
--
-- We no longer support the following secondary statuses:
--
-- -   @LaunchingMLInstances@
--
-- -   @PreparingTrainingStack@
--
-- -   @DownloadingTrainingImage@
--
-- 'startTime', 'secondaryStatusTransition_startTime' - A timestamp that shows when the training job transitioned to the current
-- secondary status state.
newSecondaryStatusTransition ::
  -- | 'status'
  SecondaryStatus ->
  -- | 'startTime'
  Prelude.UTCTime ->
  SecondaryStatusTransition
newSecondaryStatusTransition :: SecondaryStatus -> UTCTime -> SecondaryStatusTransition
newSecondaryStatusTransition SecondaryStatus
pStatus_ UTCTime
pStartTime_ =
  SecondaryStatusTransition' :: Maybe Text
-> Maybe POSIX
-> SecondaryStatus
-> POSIX
-> SecondaryStatusTransition
SecondaryStatusTransition'
    { $sel:statusMessage:SecondaryStatusTransition' :: Maybe Text
statusMessage =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:endTime:SecondaryStatusTransition' :: Maybe POSIX
endTime = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:status:SecondaryStatusTransition' :: SecondaryStatus
status = SecondaryStatus
pStatus_,
      $sel:startTime:SecondaryStatusTransition' :: POSIX
startTime = 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
pStartTime_
    }

-- | A detailed description of the progress within a secondary status.
--
-- Amazon SageMaker provides secondary statuses and status messages that
-- apply to each of them:
--
-- [Starting]
--     -   Starting the training job.
--
--     -   Launching requested ML instances.
--
--     -   Insufficient capacity error from EC2 while launching instances,
--         retrying!
--
--     -   Launched instance was unhealthy, replacing it!
--
--     -   Preparing the instances for training.
--
-- [Training]
--     -   Downloading the training image.
--
--     -   Training image download completed. Training in progress.
--
-- Status messages are subject to change. Therefore, we recommend not
-- including them in code that programmatically initiates actions. For
-- examples, don\'t use status messages in if statements.
--
-- To have an overview of your training job\'s progress, view
-- @TrainingJobStatus@ and @SecondaryStatus@ in DescribeTrainingJob, and
-- @StatusMessage@ together. For example, at the start of a training job,
-- you might see the following:
--
-- -   @TrainingJobStatus@ - InProgress
--
-- -   @SecondaryStatus@ - Training
--
-- -   @StatusMessage@ - Downloading the training image
secondaryStatusTransition_statusMessage :: Lens.Lens' SecondaryStatusTransition (Prelude.Maybe Prelude.Text)
secondaryStatusTransition_statusMessage :: (Maybe Text -> f (Maybe Text))
-> SecondaryStatusTransition -> f SecondaryStatusTransition
secondaryStatusTransition_statusMessage = (SecondaryStatusTransition -> Maybe Text)
-> (SecondaryStatusTransition
    -> Maybe Text -> SecondaryStatusTransition)
-> Lens
     SecondaryStatusTransition
     SecondaryStatusTransition
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecondaryStatusTransition' {Maybe Text
statusMessage :: Maybe Text
$sel:statusMessage:SecondaryStatusTransition' :: SecondaryStatusTransition -> Maybe Text
statusMessage} -> Maybe Text
statusMessage) (\s :: SecondaryStatusTransition
s@SecondaryStatusTransition' {} Maybe Text
a -> SecondaryStatusTransition
s {$sel:statusMessage:SecondaryStatusTransition' :: Maybe Text
statusMessage = Maybe Text
a} :: SecondaryStatusTransition)

-- | A timestamp that shows when the training job transitioned out of this
-- secondary status state into another secondary status state or when the
-- training job has ended.
secondaryStatusTransition_endTime :: Lens.Lens' SecondaryStatusTransition (Prelude.Maybe Prelude.UTCTime)
secondaryStatusTransition_endTime :: (Maybe UTCTime -> f (Maybe UTCTime))
-> SecondaryStatusTransition -> f SecondaryStatusTransition
secondaryStatusTransition_endTime = (SecondaryStatusTransition -> Maybe POSIX)
-> (SecondaryStatusTransition
    -> Maybe POSIX -> SecondaryStatusTransition)
-> Lens
     SecondaryStatusTransition
     SecondaryStatusTransition
     (Maybe POSIX)
     (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecondaryStatusTransition' {Maybe POSIX
endTime :: Maybe POSIX
$sel:endTime:SecondaryStatusTransition' :: SecondaryStatusTransition -> Maybe POSIX
endTime} -> Maybe POSIX
endTime) (\s :: SecondaryStatusTransition
s@SecondaryStatusTransition' {} Maybe POSIX
a -> SecondaryStatusTransition
s {$sel:endTime:SecondaryStatusTransition' :: Maybe POSIX
endTime = Maybe POSIX
a} :: SecondaryStatusTransition) ((Maybe POSIX -> f (Maybe POSIX))
 -> SecondaryStatusTransition -> f SecondaryStatusTransition)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> SecondaryStatusTransition
-> f SecondaryStatusTransition
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Contains a secondary status information from a training job.
--
-- Status might be one of the following secondary statuses:
--
-- [InProgress]
--     -   @Starting@ - Starting the training job.
--
--     -   @Downloading@ - An optional stage for algorithms that support
--         @File@ training input mode. It indicates that data is being
--         downloaded to the ML storage volumes.
--
--     -   @Training@ - Training is in progress.
--
--     -   @Uploading@ - Training is complete and the model artifacts are
--         being uploaded to the S3 location.
--
-- [Completed]
--     -   @Completed@ - The training job has completed.
--
-- [Failed]
--     -   @Failed@ - The training job has failed. The reason for the
--         failure is returned in the @FailureReason@ field of
--         @DescribeTrainingJobResponse@.
--
-- [Stopped]
--     -   @MaxRuntimeExceeded@ - The job stopped because it exceeded the
--         maximum allowed runtime.
--
--     -   @Stopped@ - The training job has stopped.
--
-- [Stopping]
--     -   @Stopping@ - Stopping the training job.
--
-- We no longer support the following secondary statuses:
--
-- -   @LaunchingMLInstances@
--
-- -   @PreparingTrainingStack@
--
-- -   @DownloadingTrainingImage@
secondaryStatusTransition_status :: Lens.Lens' SecondaryStatusTransition SecondaryStatus
secondaryStatusTransition_status :: (SecondaryStatus -> f SecondaryStatus)
-> SecondaryStatusTransition -> f SecondaryStatusTransition
secondaryStatusTransition_status = (SecondaryStatusTransition -> SecondaryStatus)
-> (SecondaryStatusTransition
    -> SecondaryStatus -> SecondaryStatusTransition)
-> Lens
     SecondaryStatusTransition
     SecondaryStatusTransition
     SecondaryStatus
     SecondaryStatus
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecondaryStatusTransition' {SecondaryStatus
status :: SecondaryStatus
$sel:status:SecondaryStatusTransition' :: SecondaryStatusTransition -> SecondaryStatus
status} -> SecondaryStatus
status) (\s :: SecondaryStatusTransition
s@SecondaryStatusTransition' {} SecondaryStatus
a -> SecondaryStatusTransition
s {$sel:status:SecondaryStatusTransition' :: SecondaryStatus
status = SecondaryStatus
a} :: SecondaryStatusTransition)

-- | A timestamp that shows when the training job transitioned to the current
-- secondary status state.
secondaryStatusTransition_startTime :: Lens.Lens' SecondaryStatusTransition Prelude.UTCTime
secondaryStatusTransition_startTime :: (UTCTime -> f UTCTime)
-> SecondaryStatusTransition -> f SecondaryStatusTransition
secondaryStatusTransition_startTime = (SecondaryStatusTransition -> POSIX)
-> (SecondaryStatusTransition
    -> POSIX -> SecondaryStatusTransition)
-> Lens
     SecondaryStatusTransition SecondaryStatusTransition POSIX POSIX
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SecondaryStatusTransition' {POSIX
startTime :: POSIX
$sel:startTime:SecondaryStatusTransition' :: SecondaryStatusTransition -> POSIX
startTime} -> POSIX
startTime) (\s :: SecondaryStatusTransition
s@SecondaryStatusTransition' {} POSIX
a -> SecondaryStatusTransition
s {$sel:startTime:SecondaryStatusTransition' :: POSIX
startTime = POSIX
a} :: SecondaryStatusTransition) ((POSIX -> f POSIX)
 -> SecondaryStatusTransition -> f SecondaryStatusTransition)
-> ((UTCTime -> f UTCTime) -> POSIX -> f POSIX)
-> (UTCTime -> f UTCTime)
-> SecondaryStatusTransition
-> f SecondaryStatusTransition
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

instance Core.FromJSON SecondaryStatusTransition where
  parseJSON :: Value -> Parser SecondaryStatusTransition
parseJSON =
    String
-> (Object -> Parser SecondaryStatusTransition)
-> Value
-> Parser SecondaryStatusTransition
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SecondaryStatusTransition"
      ( \Object
x ->
          Maybe Text
-> Maybe POSIX
-> SecondaryStatus
-> POSIX
-> SecondaryStatusTransition
SecondaryStatusTransition'
            (Maybe Text
 -> Maybe POSIX
 -> SecondaryStatus
 -> POSIX
 -> SecondaryStatusTransition)
-> Parser (Maybe Text)
-> Parser
     (Maybe POSIX
      -> SecondaryStatus -> POSIX -> SecondaryStatusTransition)
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
"StatusMessage")
            Parser
  (Maybe POSIX
   -> SecondaryStatus -> POSIX -> SecondaryStatusTransition)
-> Parser (Maybe POSIX)
-> Parser (SecondaryStatus -> POSIX -> SecondaryStatusTransition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"EndTime")
            Parser (SecondaryStatus -> POSIX -> SecondaryStatusTransition)
-> Parser SecondaryStatus
-> Parser (POSIX -> SecondaryStatusTransition)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser SecondaryStatus
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Status")
            Parser (POSIX -> SecondaryStatusTransition)
-> Parser POSIX -> Parser SecondaryStatusTransition
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
"StartTime")
      )

instance Prelude.Hashable SecondaryStatusTransition

instance Prelude.NFData SecondaryStatusTransition