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

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

-- | The reason that the cluster changed to its current state.
--
-- /See:/ 'newClusterStateChangeReason' smart constructor.
data ClusterStateChangeReason = ClusterStateChangeReason'
  { -- | The programmatic code for the state change reason.
    ClusterStateChangeReason -> Maybe ClusterStateChangeReasonCode
code :: Prelude.Maybe ClusterStateChangeReasonCode,
    -- | The descriptive message for the state change reason.
    ClusterStateChangeReason -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (ClusterStateChangeReason -> ClusterStateChangeReason -> Bool
(ClusterStateChangeReason -> ClusterStateChangeReason -> Bool)
-> (ClusterStateChangeReason -> ClusterStateChangeReason -> Bool)
-> Eq ClusterStateChangeReason
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ClusterStateChangeReason -> ClusterStateChangeReason -> Bool
$c/= :: ClusterStateChangeReason -> ClusterStateChangeReason -> Bool
== :: ClusterStateChangeReason -> ClusterStateChangeReason -> Bool
$c== :: ClusterStateChangeReason -> ClusterStateChangeReason -> Bool
Prelude.Eq, ReadPrec [ClusterStateChangeReason]
ReadPrec ClusterStateChangeReason
Int -> ReadS ClusterStateChangeReason
ReadS [ClusterStateChangeReason]
(Int -> ReadS ClusterStateChangeReason)
-> ReadS [ClusterStateChangeReason]
-> ReadPrec ClusterStateChangeReason
-> ReadPrec [ClusterStateChangeReason]
-> Read ClusterStateChangeReason
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ClusterStateChangeReason]
$creadListPrec :: ReadPrec [ClusterStateChangeReason]
readPrec :: ReadPrec ClusterStateChangeReason
$creadPrec :: ReadPrec ClusterStateChangeReason
readList :: ReadS [ClusterStateChangeReason]
$creadList :: ReadS [ClusterStateChangeReason]
readsPrec :: Int -> ReadS ClusterStateChangeReason
$creadsPrec :: Int -> ReadS ClusterStateChangeReason
Prelude.Read, Int -> ClusterStateChangeReason -> ShowS
[ClusterStateChangeReason] -> ShowS
ClusterStateChangeReason -> String
(Int -> ClusterStateChangeReason -> ShowS)
-> (ClusterStateChangeReason -> String)
-> ([ClusterStateChangeReason] -> ShowS)
-> Show ClusterStateChangeReason
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ClusterStateChangeReason] -> ShowS
$cshowList :: [ClusterStateChangeReason] -> ShowS
show :: ClusterStateChangeReason -> String
$cshow :: ClusterStateChangeReason -> String
showsPrec :: Int -> ClusterStateChangeReason -> ShowS
$cshowsPrec :: Int -> ClusterStateChangeReason -> ShowS
Prelude.Show, (forall x.
 ClusterStateChangeReason -> Rep ClusterStateChangeReason x)
-> (forall x.
    Rep ClusterStateChangeReason x -> ClusterStateChangeReason)
-> Generic ClusterStateChangeReason
forall x.
Rep ClusterStateChangeReason x -> ClusterStateChangeReason
forall x.
ClusterStateChangeReason -> Rep ClusterStateChangeReason x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ClusterStateChangeReason x -> ClusterStateChangeReason
$cfrom :: forall x.
ClusterStateChangeReason -> Rep ClusterStateChangeReason x
Prelude.Generic)

-- |
-- Create a value of 'ClusterStateChangeReason' 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', 'clusterStateChangeReason_code' - The programmatic code for the state change reason.
--
-- 'message', 'clusterStateChangeReason_message' - The descriptive message for the state change reason.
newClusterStateChangeReason ::
  ClusterStateChangeReason
newClusterStateChangeReason :: ClusterStateChangeReason
newClusterStateChangeReason =
  ClusterStateChangeReason' :: Maybe ClusterStateChangeReasonCode
-> Maybe Text -> ClusterStateChangeReason
ClusterStateChangeReason'
    { $sel:code:ClusterStateChangeReason' :: Maybe ClusterStateChangeReasonCode
code = Maybe ClusterStateChangeReasonCode
forall a. Maybe a
Prelude.Nothing,
      $sel:message:ClusterStateChangeReason' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The programmatic code for the state change reason.
clusterStateChangeReason_code :: Lens.Lens' ClusterStateChangeReason (Prelude.Maybe ClusterStateChangeReasonCode)
clusterStateChangeReason_code :: (Maybe ClusterStateChangeReasonCode
 -> f (Maybe ClusterStateChangeReasonCode))
-> ClusterStateChangeReason -> f ClusterStateChangeReason
clusterStateChangeReason_code = (ClusterStateChangeReason -> Maybe ClusterStateChangeReasonCode)
-> (ClusterStateChangeReason
    -> Maybe ClusterStateChangeReasonCode -> ClusterStateChangeReason)
-> Lens
     ClusterStateChangeReason
     ClusterStateChangeReason
     (Maybe ClusterStateChangeReasonCode)
     (Maybe ClusterStateChangeReasonCode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ClusterStateChangeReason' {Maybe ClusterStateChangeReasonCode
code :: Maybe ClusterStateChangeReasonCode
$sel:code:ClusterStateChangeReason' :: ClusterStateChangeReason -> Maybe ClusterStateChangeReasonCode
code} -> Maybe ClusterStateChangeReasonCode
code) (\s :: ClusterStateChangeReason
s@ClusterStateChangeReason' {} Maybe ClusterStateChangeReasonCode
a -> ClusterStateChangeReason
s {$sel:code:ClusterStateChangeReason' :: Maybe ClusterStateChangeReasonCode
code = Maybe ClusterStateChangeReasonCode
a} :: ClusterStateChangeReason)

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

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

instance Prelude.NFData ClusterStateChangeReason