{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | An object that represents a job attempt.
--
-- /See:/ 'newAttemptDetail' smart constructor.
data AttemptDetail = AttemptDetail'
  { -- | The details for the container in this job attempt.
    AttemptDetail -> Maybe AttemptContainerDetail
container :: Prelude.Maybe AttemptContainerDetail,
    -- | 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,
    -- | A short, human-readable string to provide additional details for the
    -- current status of the job attempt.
    AttemptDetail -> Maybe Text
statusReason :: Prelude.Maybe Prelude.Text,
    -- | 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
  }
  deriving (AttemptDetail -> AttemptDetail -> Bool
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]
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
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. 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:
--
-- 'container', 'attemptDetail_container' - The details for the container in this job attempt.
--
-- '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).
--
-- 'statusReason', 'attemptDetail_statusReason' - A short, human-readable string to provide additional details for the
-- current status of the job attempt.
--
-- '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@).
newAttemptDetail ::
  AttemptDetail
newAttemptDetail :: AttemptDetail
newAttemptDetail =
  AttemptDetail'
    { $sel:container:AttemptDetail' :: Maybe AttemptContainerDetail
container = forall a. Maybe a
Prelude.Nothing,
      $sel:startedAt:AttemptDetail' :: Maybe Integer
startedAt = forall a. Maybe a
Prelude.Nothing,
      $sel:statusReason:AttemptDetail' :: Maybe Text
statusReason = forall a. Maybe a
Prelude.Nothing,
      $sel:stoppedAt:AttemptDetail' :: Maybe Integer
stoppedAt = forall a. Maybe a
Prelude.Nothing
    }

-- | The details for the container in this job attempt.
attemptDetail_container :: Lens.Lens' AttemptDetail (Prelude.Maybe AttemptContainerDetail)
attemptDetail_container :: Lens' AttemptDetail (Maybe AttemptContainerDetail)
attemptDetail_container = 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)

-- | 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 :: Lens' AttemptDetail (Maybe Integer)
attemptDetail_startedAt = 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)

-- | A short, human-readable string to provide additional details for the
-- current status of the job attempt.
attemptDetail_statusReason :: Lens.Lens' AttemptDetail (Prelude.Maybe Prelude.Text)
attemptDetail_statusReason :: Lens' AttemptDetail (Maybe Text)
attemptDetail_statusReason = 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)

-- | 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 :: Lens' AttemptDetail (Maybe Integer)
attemptDetail_stoppedAt = 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)

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

instance Prelude.Hashable AttemptDetail where
  hashWithSalt :: Int -> AttemptDetail -> Int
hashWithSalt Int
_salt AttemptDetail' {Maybe Integer
Maybe Text
Maybe AttemptContainerDetail
stoppedAt :: Maybe Integer
statusReason :: Maybe Text
startedAt :: Maybe Integer
container :: Maybe AttemptContainerDetail
$sel:stoppedAt:AttemptDetail' :: AttemptDetail -> Maybe Integer
$sel:statusReason:AttemptDetail' :: AttemptDetail -> Maybe Text
$sel:startedAt:AttemptDetail' :: AttemptDetail -> Maybe Integer
$sel:container:AttemptDetail' :: AttemptDetail -> Maybe AttemptContainerDetail
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe AttemptContainerDetail
container
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
startedAt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
statusReason
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Integer
stoppedAt

instance Prelude.NFData AttemptDetail where
  rnf :: AttemptDetail -> ()
rnf AttemptDetail' {Maybe Integer
Maybe Text
Maybe AttemptContainerDetail
stoppedAt :: Maybe Integer
statusReason :: Maybe Text
startedAt :: Maybe Integer
container :: Maybe AttemptContainerDetail
$sel:stoppedAt:AttemptDetail' :: AttemptDetail -> Maybe Integer
$sel:statusReason:AttemptDetail' :: AttemptDetail -> Maybe Text
$sel:startedAt:AttemptDetail' :: AttemptDetail -> Maybe Integer
$sel:container:AttemptDetail' :: AttemptDetail -> Maybe AttemptContainerDetail
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe AttemptContainerDetail
container
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
startedAt
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
statusReason
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Integer
stoppedAt