{-# 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.Batch.Types.AttemptDetail
-- 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.Batch.Types.AttemptDetail where

import Amazonka.Batch.Types.AttemptContainerDetail
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | An object representing a job attempt.
--
-- /See:/ 'newAttemptDetail' smart constructor.
data AttemptDetail = AttemptDetail'
  { -- | The Unix timestamp (in milliseconds) for when the attempt was stopped
    -- (when the attempt transitioned from the @RUNNING@ state to a terminal
    -- state, such as @SUCCEEDED@ or @FAILED@).
    AttemptDetail -> Maybe Integer
stoppedAt :: Prelude.Maybe Prelude.Integer,
    -- | The Unix timestamp (in milliseconds) for when the attempt was started
    -- (when the attempt transitioned from the @STARTING@ state to the
    -- @RUNNING@ state).
    AttemptDetail -> Maybe Integer
startedAt :: Prelude.Maybe Prelude.Integer,
    -- | Details about the container in this job attempt.
    AttemptDetail -> Maybe AttemptContainerDetail
container :: Prelude.Maybe AttemptContainerDetail,
    -- | A short, human-readable string to provide additional details about the
    -- current status of the job attempt.
    AttemptDetail -> Maybe Text
statusReason :: Prelude.Maybe Prelude.Text
  }
  deriving (AttemptDetail -> AttemptDetail -> Bool
(AttemptDetail -> AttemptDetail -> Bool)
-> (AttemptDetail -> AttemptDetail -> Bool) -> Eq AttemptDetail
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AttemptDetail -> AttemptDetail -> Bool
$c/= :: AttemptDetail -> AttemptDetail -> Bool
== :: AttemptDetail -> AttemptDetail -> Bool
$c== :: AttemptDetail -> AttemptDetail -> Bool
Prelude.Eq, ReadPrec [AttemptDetail]
ReadPrec AttemptDetail
Int -> ReadS AttemptDetail
ReadS [AttemptDetail]
(Int -> ReadS AttemptDetail)
-> ReadS [AttemptDetail]
-> ReadPrec AttemptDetail
-> ReadPrec [AttemptDetail]
-> Read AttemptDetail
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AttemptDetail]
$creadListPrec :: ReadPrec [AttemptDetail]
readPrec :: ReadPrec AttemptDetail
$creadPrec :: ReadPrec AttemptDetail
readList :: ReadS [AttemptDetail]
$creadList :: ReadS [AttemptDetail]
readsPrec :: Int -> ReadS AttemptDetail
$creadsPrec :: Int -> ReadS AttemptDetail
Prelude.Read, Int -> AttemptDetail -> ShowS
[AttemptDetail] -> ShowS
AttemptDetail -> String
(Int -> AttemptDetail -> ShowS)
-> (AttemptDetail -> String)
-> ([AttemptDetail] -> ShowS)
-> Show AttemptDetail
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AttemptDetail] -> ShowS
$cshowList :: [AttemptDetail] -> ShowS
show :: AttemptDetail -> String
$cshow :: AttemptDetail -> String
showsPrec :: Int -> AttemptDetail -> ShowS
$cshowsPrec :: Int -> AttemptDetail -> ShowS
Prelude.Show, (forall x. AttemptDetail -> Rep AttemptDetail x)
-> (forall x. Rep AttemptDetail x -> AttemptDetail)
-> Generic AttemptDetail
forall x. Rep AttemptDetail x -> AttemptDetail
forall x. AttemptDetail -> Rep AttemptDetail x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AttemptDetail x -> AttemptDetail
$cfrom :: forall x. AttemptDetail -> Rep AttemptDetail x
Prelude.Generic)

-- |
-- Create a value of 'AttemptDetail' 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:
--
-- 'stoppedAt', 'attemptDetail_stoppedAt' - The Unix timestamp (in milliseconds) for when the attempt was stopped
-- (when the attempt transitioned from the @RUNNING@ state to a terminal
-- state, such as @SUCCEEDED@ or @FAILED@).
--
-- 'startedAt', 'attemptDetail_startedAt' - The Unix timestamp (in milliseconds) for when the attempt was started
-- (when the attempt transitioned from the @STARTING@ state to the
-- @RUNNING@ state).
--
-- 'container', 'attemptDetail_container' - Details about the container in this job attempt.
--
-- 'statusReason', 'attemptDetail_statusReason' - A short, human-readable string to provide additional details about the
-- current status of the job attempt.
newAttemptDetail ::
  AttemptDetail
newAttemptDetail :: AttemptDetail
newAttemptDetail =
  AttemptDetail' :: Maybe Integer
-> Maybe Integer
-> Maybe AttemptContainerDetail
-> Maybe Text
-> AttemptDetail
AttemptDetail'
    { $sel:stoppedAt:AttemptDetail' :: Maybe Integer
stoppedAt = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:startedAt:AttemptDetail' :: Maybe Integer
startedAt = Maybe Integer
forall a. Maybe a
Prelude.Nothing,
      $sel:container:AttemptDetail' :: Maybe AttemptContainerDetail
container = Maybe AttemptContainerDetail
forall a. Maybe a
Prelude.Nothing,
      $sel:statusReason:AttemptDetail' :: Maybe Text
statusReason = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The Unix timestamp (in milliseconds) for when the attempt was stopped
-- (when the attempt transitioned from the @RUNNING@ state to a terminal
-- state, such as @SUCCEEDED@ or @FAILED@).
attemptDetail_stoppedAt :: Lens.Lens' AttemptDetail (Prelude.Maybe Prelude.Integer)
attemptDetail_stoppedAt :: (Maybe Integer -> f (Maybe Integer))
-> AttemptDetail -> f AttemptDetail
attemptDetail_stoppedAt = (AttemptDetail -> Maybe Integer)
-> (AttemptDetail -> Maybe Integer -> AttemptDetail)
-> Lens AttemptDetail AttemptDetail (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttemptDetail' {Maybe Integer
stoppedAt :: Maybe Integer
$sel:stoppedAt:AttemptDetail' :: AttemptDetail -> Maybe Integer
stoppedAt} -> Maybe Integer
stoppedAt) (\s :: AttemptDetail
s@AttemptDetail' {} Maybe Integer
a -> AttemptDetail
s {$sel:stoppedAt:AttemptDetail' :: Maybe Integer
stoppedAt = Maybe Integer
a} :: AttemptDetail)

-- | The Unix timestamp (in milliseconds) for when the attempt was started
-- (when the attempt transitioned from the @STARTING@ state to the
-- @RUNNING@ state).
attemptDetail_startedAt :: Lens.Lens' AttemptDetail (Prelude.Maybe Prelude.Integer)
attemptDetail_startedAt :: (Maybe Integer -> f (Maybe Integer))
-> AttemptDetail -> f AttemptDetail
attemptDetail_startedAt = (AttemptDetail -> Maybe Integer)
-> (AttemptDetail -> Maybe Integer -> AttemptDetail)
-> Lens AttemptDetail AttemptDetail (Maybe Integer) (Maybe Integer)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttemptDetail' {Maybe Integer
startedAt :: Maybe Integer
$sel:startedAt:AttemptDetail' :: AttemptDetail -> Maybe Integer
startedAt} -> Maybe Integer
startedAt) (\s :: AttemptDetail
s@AttemptDetail' {} Maybe Integer
a -> AttemptDetail
s {$sel:startedAt:AttemptDetail' :: Maybe Integer
startedAt = Maybe Integer
a} :: AttemptDetail)

-- | Details about the container in this job attempt.
attemptDetail_container :: Lens.Lens' AttemptDetail (Prelude.Maybe AttemptContainerDetail)
attemptDetail_container :: (Maybe AttemptContainerDetail -> f (Maybe AttemptContainerDetail))
-> AttemptDetail -> f AttemptDetail
attemptDetail_container = (AttemptDetail -> Maybe AttemptContainerDetail)
-> (AttemptDetail -> Maybe AttemptContainerDetail -> AttemptDetail)
-> Lens
     AttemptDetail
     AttemptDetail
     (Maybe AttemptContainerDetail)
     (Maybe AttemptContainerDetail)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttemptDetail' {Maybe AttemptContainerDetail
container :: Maybe AttemptContainerDetail
$sel:container:AttemptDetail' :: AttemptDetail -> Maybe AttemptContainerDetail
container} -> Maybe AttemptContainerDetail
container) (\s :: AttemptDetail
s@AttemptDetail' {} Maybe AttemptContainerDetail
a -> AttemptDetail
s {$sel:container:AttemptDetail' :: Maybe AttemptContainerDetail
container = Maybe AttemptContainerDetail
a} :: AttemptDetail)

-- | A short, human-readable string to provide additional details about the
-- current status of the job attempt.
attemptDetail_statusReason :: Lens.Lens' AttemptDetail (Prelude.Maybe Prelude.Text)
attemptDetail_statusReason :: (Maybe Text -> f (Maybe Text)) -> AttemptDetail -> f AttemptDetail
attemptDetail_statusReason = (AttemptDetail -> Maybe Text)
-> (AttemptDetail -> Maybe Text -> AttemptDetail)
-> Lens AttemptDetail AttemptDetail (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AttemptDetail' {Maybe Text
statusReason :: Maybe Text
$sel:statusReason:AttemptDetail' :: AttemptDetail -> Maybe Text
statusReason} -> Maybe Text
statusReason) (\s :: AttemptDetail
s@AttemptDetail' {} Maybe Text
a -> AttemptDetail
s {$sel:statusReason:AttemptDetail' :: Maybe Text
statusReason = Maybe Text
a} :: AttemptDetail)

instance Core.FromJSON AttemptDetail where
  parseJSON :: Value -> Parser AttemptDetail
parseJSON =
    String
-> (Object -> Parser AttemptDetail)
-> Value
-> Parser AttemptDetail
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AttemptDetail"
      ( \Object
x ->
          Maybe Integer
-> Maybe Integer
-> Maybe AttemptContainerDetail
-> Maybe Text
-> AttemptDetail
AttemptDetail'
            (Maybe Integer
 -> Maybe Integer
 -> Maybe AttemptContainerDetail
 -> Maybe Text
 -> AttemptDetail)
-> Parser (Maybe Integer)
-> Parser
     (Maybe Integer
      -> Maybe AttemptContainerDetail -> Maybe Text -> AttemptDetail)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"stoppedAt")
            Parser
  (Maybe Integer
   -> Maybe AttemptContainerDetail -> Maybe Text -> AttemptDetail)
-> Parser (Maybe Integer)
-> Parser
     (Maybe AttemptContainerDetail -> Maybe Text -> AttemptDetail)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Integer)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"startedAt")
            Parser
  (Maybe AttemptContainerDetail -> Maybe Text -> AttemptDetail)
-> Parser (Maybe AttemptContainerDetail)
-> Parser (Maybe Text -> AttemptDetail)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AttemptContainerDetail)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"container")
            Parser (Maybe Text -> AttemptDetail)
-> Parser (Maybe Text) -> Parser AttemptDetail
forall (f :: * -> *) a b. Applicative f => 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
"statusReason")
      )

instance Prelude.Hashable AttemptDetail

instance Prelude.NFData AttemptDetail