{-# 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.EMR.Types.StepStatus
-- 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.EMR.Types.StepStatus where

import qualified Amazonka.Core as Core
import Amazonka.EMR.Types.FailureDetails
import Amazonka.EMR.Types.StepState
import Amazonka.EMR.Types.StepStateChangeReason
import Amazonka.EMR.Types.StepTimeline
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The execution status details of the cluster step.
--
-- /See:/ 'newStepStatus' smart constructor.
data StepStatus = StepStatus'
  { -- | The execution state of the cluster step.
    StepStatus -> Maybe StepState
state :: Prelude.Maybe StepState,
    -- | The details for the step failure including reason, message, and log file
    -- path where the root cause was identified.
    StepStatus -> Maybe FailureDetails
failureDetails :: Prelude.Maybe FailureDetails,
    -- | The reason for the step execution status change.
    StepStatus -> Maybe StepStateChangeReason
stateChangeReason :: Prelude.Maybe StepStateChangeReason,
    -- | The timeline of the cluster step status over time.
    StepStatus -> Maybe StepTimeline
timeline :: Prelude.Maybe StepTimeline
  }
  deriving (StepStatus -> StepStatus -> Bool
(StepStatus -> StepStatus -> Bool)
-> (StepStatus -> StepStatus -> Bool) -> Eq StepStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StepStatus -> StepStatus -> Bool
$c/= :: StepStatus -> StepStatus -> Bool
== :: StepStatus -> StepStatus -> Bool
$c== :: StepStatus -> StepStatus -> Bool
Prelude.Eq, ReadPrec [StepStatus]
ReadPrec StepStatus
Int -> ReadS StepStatus
ReadS [StepStatus]
(Int -> ReadS StepStatus)
-> ReadS [StepStatus]
-> ReadPrec StepStatus
-> ReadPrec [StepStatus]
-> Read StepStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StepStatus]
$creadListPrec :: ReadPrec [StepStatus]
readPrec :: ReadPrec StepStatus
$creadPrec :: ReadPrec StepStatus
readList :: ReadS [StepStatus]
$creadList :: ReadS [StepStatus]
readsPrec :: Int -> ReadS StepStatus
$creadsPrec :: Int -> ReadS StepStatus
Prelude.Read, Int -> StepStatus -> ShowS
[StepStatus] -> ShowS
StepStatus -> String
(Int -> StepStatus -> ShowS)
-> (StepStatus -> String)
-> ([StepStatus] -> ShowS)
-> Show StepStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StepStatus] -> ShowS
$cshowList :: [StepStatus] -> ShowS
show :: StepStatus -> String
$cshow :: StepStatus -> String
showsPrec :: Int -> StepStatus -> ShowS
$cshowsPrec :: Int -> StepStatus -> ShowS
Prelude.Show, (forall x. StepStatus -> Rep StepStatus x)
-> (forall x. Rep StepStatus x -> StepStatus) -> Generic StepStatus
forall x. Rep StepStatus x -> StepStatus
forall x. StepStatus -> Rep StepStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StepStatus x -> StepStatus
$cfrom :: forall x. StepStatus -> Rep StepStatus x
Prelude.Generic)

-- |
-- Create a value of 'StepStatus' 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:
--
-- 'state', 'stepStatus_state' - The execution state of the cluster step.
--
-- 'failureDetails', 'stepStatus_failureDetails' - The details for the step failure including reason, message, and log file
-- path where the root cause was identified.
--
-- 'stateChangeReason', 'stepStatus_stateChangeReason' - The reason for the step execution status change.
--
-- 'timeline', 'stepStatus_timeline' - The timeline of the cluster step status over time.
newStepStatus ::
  StepStatus
newStepStatus :: StepStatus
newStepStatus =
  StepStatus' :: Maybe StepState
-> Maybe FailureDetails
-> Maybe StepStateChangeReason
-> Maybe StepTimeline
-> StepStatus
StepStatus'
    { $sel:state:StepStatus' :: Maybe StepState
state = Maybe StepState
forall a. Maybe a
Prelude.Nothing,
      $sel:failureDetails:StepStatus' :: Maybe FailureDetails
failureDetails = Maybe FailureDetails
forall a. Maybe a
Prelude.Nothing,
      $sel:stateChangeReason:StepStatus' :: Maybe StepStateChangeReason
stateChangeReason = Maybe StepStateChangeReason
forall a. Maybe a
Prelude.Nothing,
      $sel:timeline:StepStatus' :: Maybe StepTimeline
timeline = Maybe StepTimeline
forall a. Maybe a
Prelude.Nothing
    }

-- | The execution state of the cluster step.
stepStatus_state :: Lens.Lens' StepStatus (Prelude.Maybe StepState)
stepStatus_state :: (Maybe StepState -> f (Maybe StepState))
-> StepStatus -> f StepStatus
stepStatus_state = (StepStatus -> Maybe StepState)
-> (StepStatus -> Maybe StepState -> StepStatus)
-> Lens StepStatus StepStatus (Maybe StepState) (Maybe StepState)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StepStatus' {Maybe StepState
state :: Maybe StepState
$sel:state:StepStatus' :: StepStatus -> Maybe StepState
state} -> Maybe StepState
state) (\s :: StepStatus
s@StepStatus' {} Maybe StepState
a -> StepStatus
s {$sel:state:StepStatus' :: Maybe StepState
state = Maybe StepState
a} :: StepStatus)

-- | The details for the step failure including reason, message, and log file
-- path where the root cause was identified.
stepStatus_failureDetails :: Lens.Lens' StepStatus (Prelude.Maybe FailureDetails)
stepStatus_failureDetails :: (Maybe FailureDetails -> f (Maybe FailureDetails))
-> StepStatus -> f StepStatus
stepStatus_failureDetails = (StepStatus -> Maybe FailureDetails)
-> (StepStatus -> Maybe FailureDetails -> StepStatus)
-> Lens
     StepStatus StepStatus (Maybe FailureDetails) (Maybe FailureDetails)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StepStatus' {Maybe FailureDetails
failureDetails :: Maybe FailureDetails
$sel:failureDetails:StepStatus' :: StepStatus -> Maybe FailureDetails
failureDetails} -> Maybe FailureDetails
failureDetails) (\s :: StepStatus
s@StepStatus' {} Maybe FailureDetails
a -> StepStatus
s {$sel:failureDetails:StepStatus' :: Maybe FailureDetails
failureDetails = Maybe FailureDetails
a} :: StepStatus)

-- | The reason for the step execution status change.
stepStatus_stateChangeReason :: Lens.Lens' StepStatus (Prelude.Maybe StepStateChangeReason)
stepStatus_stateChangeReason :: (Maybe StepStateChangeReason -> f (Maybe StepStateChangeReason))
-> StepStatus -> f StepStatus
stepStatus_stateChangeReason = (StepStatus -> Maybe StepStateChangeReason)
-> (StepStatus -> Maybe StepStateChangeReason -> StepStatus)
-> Lens
     StepStatus
     StepStatus
     (Maybe StepStateChangeReason)
     (Maybe StepStateChangeReason)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StepStatus' {Maybe StepStateChangeReason
stateChangeReason :: Maybe StepStateChangeReason
$sel:stateChangeReason:StepStatus' :: StepStatus -> Maybe StepStateChangeReason
stateChangeReason} -> Maybe StepStateChangeReason
stateChangeReason) (\s :: StepStatus
s@StepStatus' {} Maybe StepStateChangeReason
a -> StepStatus
s {$sel:stateChangeReason:StepStatus' :: Maybe StepStateChangeReason
stateChangeReason = Maybe StepStateChangeReason
a} :: StepStatus)

-- | The timeline of the cluster step status over time.
stepStatus_timeline :: Lens.Lens' StepStatus (Prelude.Maybe StepTimeline)
stepStatus_timeline :: (Maybe StepTimeline -> f (Maybe StepTimeline))
-> StepStatus -> f StepStatus
stepStatus_timeline = (StepStatus -> Maybe StepTimeline)
-> (StepStatus -> Maybe StepTimeline -> StepStatus)
-> Lens
     StepStatus StepStatus (Maybe StepTimeline) (Maybe StepTimeline)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StepStatus' {Maybe StepTimeline
timeline :: Maybe StepTimeline
$sel:timeline:StepStatus' :: StepStatus -> Maybe StepTimeline
timeline} -> Maybe StepTimeline
timeline) (\s :: StepStatus
s@StepStatus' {} Maybe StepTimeline
a -> StepStatus
s {$sel:timeline:StepStatus' :: Maybe StepTimeline
timeline = Maybe StepTimeline
a} :: StepStatus)

instance Core.FromJSON StepStatus where
  parseJSON :: Value -> Parser StepStatus
parseJSON =
    String
-> (Object -> Parser StepStatus) -> Value -> Parser StepStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StepStatus"
      ( \Object
x ->
          Maybe StepState
-> Maybe FailureDetails
-> Maybe StepStateChangeReason
-> Maybe StepTimeline
-> StepStatus
StepStatus'
            (Maybe StepState
 -> Maybe FailureDetails
 -> Maybe StepStateChangeReason
 -> Maybe StepTimeline
 -> StepStatus)
-> Parser (Maybe StepState)
-> Parser
     (Maybe FailureDetails
      -> Maybe StepStateChangeReason -> Maybe StepTimeline -> StepStatus)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe StepState)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"State")
            Parser
  (Maybe FailureDetails
   -> Maybe StepStateChangeReason -> Maybe StepTimeline -> StepStatus)
-> Parser (Maybe FailureDetails)
-> Parser
     (Maybe StepStateChangeReason -> Maybe StepTimeline -> StepStatus)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe FailureDetails)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"FailureDetails")
            Parser
  (Maybe StepStateChangeReason -> Maybe StepTimeline -> StepStatus)
-> Parser (Maybe StepStateChangeReason)
-> Parser (Maybe StepTimeline -> StepStatus)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe StepStateChangeReason)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StateChangeReason")
            Parser (Maybe StepTimeline -> StepStatus)
-> Parser (Maybe StepTimeline) -> Parser StepStatus
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe StepTimeline)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Timeline")
      )

instance Prelude.Hashable StepStatus

instance Prelude.NFData StepStatus