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

import qualified Amazonka.Core as Core
import Amazonka.EMR.Types.StepStateChangeReasonCode
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The details of the step state change reason.
--
-- /See:/ 'newStepStateChangeReason' smart constructor.
data StepStateChangeReason = StepStateChangeReason'
  { -- | The programmable code for the state change reason. Note: Currently, the
    -- service provides no code for the state change.
    StepStateChangeReason -> Maybe StepStateChangeReasonCode
code :: Prelude.Maybe StepStateChangeReasonCode,
    -- | The descriptive message for the state change reason.
    StepStateChangeReason -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (StepStateChangeReason -> StepStateChangeReason -> Bool
(StepStateChangeReason -> StepStateChangeReason -> Bool)
-> (StepStateChangeReason -> StepStateChangeReason -> Bool)
-> Eq StepStateChangeReason
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StepStateChangeReason -> StepStateChangeReason -> Bool
$c/= :: StepStateChangeReason -> StepStateChangeReason -> Bool
== :: StepStateChangeReason -> StepStateChangeReason -> Bool
$c== :: StepStateChangeReason -> StepStateChangeReason -> Bool
Prelude.Eq, ReadPrec [StepStateChangeReason]
ReadPrec StepStateChangeReason
Int -> ReadS StepStateChangeReason
ReadS [StepStateChangeReason]
(Int -> ReadS StepStateChangeReason)
-> ReadS [StepStateChangeReason]
-> ReadPrec StepStateChangeReason
-> ReadPrec [StepStateChangeReason]
-> Read StepStateChangeReason
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StepStateChangeReason]
$creadListPrec :: ReadPrec [StepStateChangeReason]
readPrec :: ReadPrec StepStateChangeReason
$creadPrec :: ReadPrec StepStateChangeReason
readList :: ReadS [StepStateChangeReason]
$creadList :: ReadS [StepStateChangeReason]
readsPrec :: Int -> ReadS StepStateChangeReason
$creadsPrec :: Int -> ReadS StepStateChangeReason
Prelude.Read, Int -> StepStateChangeReason -> ShowS
[StepStateChangeReason] -> ShowS
StepStateChangeReason -> String
(Int -> StepStateChangeReason -> ShowS)
-> (StepStateChangeReason -> String)
-> ([StepStateChangeReason] -> ShowS)
-> Show StepStateChangeReason
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StepStateChangeReason] -> ShowS
$cshowList :: [StepStateChangeReason] -> ShowS
show :: StepStateChangeReason -> String
$cshow :: StepStateChangeReason -> String
showsPrec :: Int -> StepStateChangeReason -> ShowS
$cshowsPrec :: Int -> StepStateChangeReason -> ShowS
Prelude.Show, (forall x. StepStateChangeReason -> Rep StepStateChangeReason x)
-> (forall x. Rep StepStateChangeReason x -> StepStateChangeReason)
-> Generic StepStateChangeReason
forall x. Rep StepStateChangeReason x -> StepStateChangeReason
forall x. StepStateChangeReason -> Rep StepStateChangeReason x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StepStateChangeReason x -> StepStateChangeReason
$cfrom :: forall x. StepStateChangeReason -> Rep StepStateChangeReason x
Prelude.Generic)

-- |
-- Create a value of 'StepStateChangeReason' 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:
--
-- 'code', 'stepStateChangeReason_code' - The programmable code for the state change reason. Note: Currently, the
-- service provides no code for the state change.
--
-- 'message', 'stepStateChangeReason_message' - The descriptive message for the state change reason.
newStepStateChangeReason ::
  StepStateChangeReason
newStepStateChangeReason :: StepStateChangeReason
newStepStateChangeReason =
  StepStateChangeReason' :: Maybe StepStateChangeReasonCode
-> Maybe Text -> StepStateChangeReason
StepStateChangeReason'
    { $sel:code:StepStateChangeReason' :: Maybe StepStateChangeReasonCode
code = Maybe StepStateChangeReasonCode
forall a. Maybe a
Prelude.Nothing,
      $sel:message:StepStateChangeReason' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The programmable code for the state change reason. Note: Currently, the
-- service provides no code for the state change.
stepStateChangeReason_code :: Lens.Lens' StepStateChangeReason (Prelude.Maybe StepStateChangeReasonCode)
stepStateChangeReason_code :: (Maybe StepStateChangeReasonCode
 -> f (Maybe StepStateChangeReasonCode))
-> StepStateChangeReason -> f StepStateChangeReason
stepStateChangeReason_code = (StepStateChangeReason -> Maybe StepStateChangeReasonCode)
-> (StepStateChangeReason
    -> Maybe StepStateChangeReasonCode -> StepStateChangeReason)
-> Lens
     StepStateChangeReason
     StepStateChangeReason
     (Maybe StepStateChangeReasonCode)
     (Maybe StepStateChangeReasonCode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StepStateChangeReason' {Maybe StepStateChangeReasonCode
code :: Maybe StepStateChangeReasonCode
$sel:code:StepStateChangeReason' :: StepStateChangeReason -> Maybe StepStateChangeReasonCode
code} -> Maybe StepStateChangeReasonCode
code) (\s :: StepStateChangeReason
s@StepStateChangeReason' {} Maybe StepStateChangeReasonCode
a -> StepStateChangeReason
s {$sel:code:StepStateChangeReason' :: Maybe StepStateChangeReasonCode
code = Maybe StepStateChangeReasonCode
a} :: StepStateChangeReason)

-- | The descriptive message for the state change reason.
stepStateChangeReason_message :: Lens.Lens' StepStateChangeReason (Prelude.Maybe Prelude.Text)
stepStateChangeReason_message :: (Maybe Text -> f (Maybe Text))
-> StepStateChangeReason -> f StepStateChangeReason
stepStateChangeReason_message = (StepStateChangeReason -> Maybe Text)
-> (StepStateChangeReason -> Maybe Text -> StepStateChangeReason)
-> Lens
     StepStateChangeReason
     StepStateChangeReason
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StepStateChangeReason' {Maybe Text
message :: Maybe Text
$sel:message:StepStateChangeReason' :: StepStateChangeReason -> Maybe Text
message} -> Maybe Text
message) (\s :: StepStateChangeReason
s@StepStateChangeReason' {} Maybe Text
a -> StepStateChangeReason
s {$sel:message:StepStateChangeReason' :: Maybe Text
message = Maybe Text
a} :: StepStateChangeReason)

instance Core.FromJSON StepStateChangeReason where
  parseJSON :: Value -> Parser StepStateChangeReason
parseJSON =
    String
-> (Object -> Parser StepStateChangeReason)
-> Value
-> Parser StepStateChangeReason
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"StepStateChangeReason"
      ( \Object
x ->
          Maybe StepStateChangeReasonCode
-> Maybe Text -> StepStateChangeReason
StepStateChangeReason'
            (Maybe StepStateChangeReasonCode
 -> Maybe Text -> StepStateChangeReason)
-> Parser (Maybe StepStateChangeReasonCode)
-> Parser (Maybe Text -> StepStateChangeReason)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe StepStateChangeReasonCode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Code")
            Parser (Maybe Text -> StepStateChangeReason)
-> Parser (Maybe Text) -> Parser StepStateChangeReason
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
"Message")
      )

instance Prelude.Hashable StepStateChangeReason

instance Prelude.NFData StepStateChangeReason