{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.EMR.Types.ClusterStateChangeReason where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.EMR.Types.ClusterStateChangeReasonCode
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
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]
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
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.
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'
    { $sel:code:ClusterStateChangeReason' :: Maybe ClusterStateChangeReasonCode
code = forall a. Maybe a
Prelude.Nothing,
      $sel:message:ClusterStateChangeReason' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing
    }

-- | The programmatic code for the state change reason.
clusterStateChangeReason_code :: Lens.Lens' ClusterStateChangeReason (Prelude.Maybe ClusterStateChangeReasonCode)
clusterStateChangeReason_code :: Lens' ClusterStateChangeReason (Maybe ClusterStateChangeReasonCode)
clusterStateChangeReason_code = 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 :: Lens' ClusterStateChangeReason (Maybe Text)
clusterStateChangeReason_message = 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 Data.FromJSON ClusterStateChangeReason where
  parseJSON :: Value -> Parser ClusterStateChangeReason
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ClusterStateChangeReason"
      ( \Object
x ->
          Maybe ClusterStateChangeReasonCode
-> Maybe Text -> ClusterStateChangeReason
ClusterStateChangeReason'
            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
"Code")
            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
"Message")
      )

instance Prelude.Hashable ClusterStateChangeReason where
  hashWithSalt :: Int -> ClusterStateChangeReason -> Int
hashWithSalt Int
_salt ClusterStateChangeReason' {Maybe Text
Maybe ClusterStateChangeReasonCode
message :: Maybe Text
code :: Maybe ClusterStateChangeReasonCode
$sel:message:ClusterStateChangeReason' :: ClusterStateChangeReason -> Maybe Text
$sel:code:ClusterStateChangeReason' :: ClusterStateChangeReason -> Maybe ClusterStateChangeReasonCode
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ClusterStateChangeReasonCode
code
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message

instance Prelude.NFData ClusterStateChangeReason where
  rnf :: ClusterStateChangeReason -> ()
rnf ClusterStateChangeReason' {Maybe Text
Maybe ClusterStateChangeReasonCode
message :: Maybe Text
code :: Maybe ClusterStateChangeReasonCode
$sel:message:ClusterStateChangeReason' :: ClusterStateChangeReason -> Maybe Text
$sel:code:ClusterStateChangeReason' :: ClusterStateChangeReason -> Maybe ClusterStateChangeReasonCode
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe ClusterStateChangeReasonCode
code seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
message