{-# 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.InstanceGroupStateChangeReason
-- 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.InstanceGroupStateChangeReason 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.InstanceGroupStateChangeReasonCode
import qualified Amazonka.Prelude as Prelude

-- | The status change reason details for the instance group.
--
-- /See:/ 'newInstanceGroupStateChangeReason' smart constructor.
data InstanceGroupStateChangeReason = InstanceGroupStateChangeReason'
  { -- | The programmable code for the state change reason.
    InstanceGroupStateChangeReason
-> Maybe InstanceGroupStateChangeReasonCode
code :: Prelude.Maybe InstanceGroupStateChangeReasonCode,
    -- | The status change reason description.
    InstanceGroupStateChangeReason -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (InstanceGroupStateChangeReason
-> InstanceGroupStateChangeReason -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceGroupStateChangeReason
-> InstanceGroupStateChangeReason -> Bool
$c/= :: InstanceGroupStateChangeReason
-> InstanceGroupStateChangeReason -> Bool
== :: InstanceGroupStateChangeReason
-> InstanceGroupStateChangeReason -> Bool
$c== :: InstanceGroupStateChangeReason
-> InstanceGroupStateChangeReason -> Bool
Prelude.Eq, ReadPrec [InstanceGroupStateChangeReason]
ReadPrec InstanceGroupStateChangeReason
Int -> ReadS InstanceGroupStateChangeReason
ReadS [InstanceGroupStateChangeReason]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceGroupStateChangeReason]
$creadListPrec :: ReadPrec [InstanceGroupStateChangeReason]
readPrec :: ReadPrec InstanceGroupStateChangeReason
$creadPrec :: ReadPrec InstanceGroupStateChangeReason
readList :: ReadS [InstanceGroupStateChangeReason]
$creadList :: ReadS [InstanceGroupStateChangeReason]
readsPrec :: Int -> ReadS InstanceGroupStateChangeReason
$creadsPrec :: Int -> ReadS InstanceGroupStateChangeReason
Prelude.Read, Int -> InstanceGroupStateChangeReason -> ShowS
[InstanceGroupStateChangeReason] -> ShowS
InstanceGroupStateChangeReason -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceGroupStateChangeReason] -> ShowS
$cshowList :: [InstanceGroupStateChangeReason] -> ShowS
show :: InstanceGroupStateChangeReason -> String
$cshow :: InstanceGroupStateChangeReason -> String
showsPrec :: Int -> InstanceGroupStateChangeReason -> ShowS
$cshowsPrec :: Int -> InstanceGroupStateChangeReason -> ShowS
Prelude.Show, forall x.
Rep InstanceGroupStateChangeReason x
-> InstanceGroupStateChangeReason
forall x.
InstanceGroupStateChangeReason
-> Rep InstanceGroupStateChangeReason x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InstanceGroupStateChangeReason x
-> InstanceGroupStateChangeReason
$cfrom :: forall x.
InstanceGroupStateChangeReason
-> Rep InstanceGroupStateChangeReason x
Prelude.Generic)

-- |
-- Create a value of 'InstanceGroupStateChangeReason' 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', 'instanceGroupStateChangeReason_code' - The programmable code for the state change reason.
--
-- 'message', 'instanceGroupStateChangeReason_message' - The status change reason description.
newInstanceGroupStateChangeReason ::
  InstanceGroupStateChangeReason
newInstanceGroupStateChangeReason :: InstanceGroupStateChangeReason
newInstanceGroupStateChangeReason =
  InstanceGroupStateChangeReason'
    { $sel:code:InstanceGroupStateChangeReason' :: Maybe InstanceGroupStateChangeReasonCode
code =
        forall a. Maybe a
Prelude.Nothing,
      $sel:message:InstanceGroupStateChangeReason' :: Maybe Text
message = forall a. Maybe a
Prelude.Nothing
    }

-- | The programmable code for the state change reason.
instanceGroupStateChangeReason_code :: Lens.Lens' InstanceGroupStateChangeReason (Prelude.Maybe InstanceGroupStateChangeReasonCode)
instanceGroupStateChangeReason_code :: Lens'
  InstanceGroupStateChangeReason
  (Maybe InstanceGroupStateChangeReasonCode)
instanceGroupStateChangeReason_code = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceGroupStateChangeReason' {Maybe InstanceGroupStateChangeReasonCode
code :: Maybe InstanceGroupStateChangeReasonCode
$sel:code:InstanceGroupStateChangeReason' :: InstanceGroupStateChangeReason
-> Maybe InstanceGroupStateChangeReasonCode
code} -> Maybe InstanceGroupStateChangeReasonCode
code) (\s :: InstanceGroupStateChangeReason
s@InstanceGroupStateChangeReason' {} Maybe InstanceGroupStateChangeReasonCode
a -> InstanceGroupStateChangeReason
s {$sel:code:InstanceGroupStateChangeReason' :: Maybe InstanceGroupStateChangeReasonCode
code = Maybe InstanceGroupStateChangeReasonCode
a} :: InstanceGroupStateChangeReason)

-- | The status change reason description.
instanceGroupStateChangeReason_message :: Lens.Lens' InstanceGroupStateChangeReason (Prelude.Maybe Prelude.Text)
instanceGroupStateChangeReason_message :: Lens' InstanceGroupStateChangeReason (Maybe Text)
instanceGroupStateChangeReason_message = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceGroupStateChangeReason' {Maybe Text
message :: Maybe Text
$sel:message:InstanceGroupStateChangeReason' :: InstanceGroupStateChangeReason -> Maybe Text
message} -> Maybe Text
message) (\s :: InstanceGroupStateChangeReason
s@InstanceGroupStateChangeReason' {} Maybe Text
a -> InstanceGroupStateChangeReason
s {$sel:message:InstanceGroupStateChangeReason' :: Maybe Text
message = Maybe Text
a} :: InstanceGroupStateChangeReason)

instance Data.FromJSON InstanceGroupStateChangeReason where
  parseJSON :: Value -> Parser InstanceGroupStateChangeReason
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"InstanceGroupStateChangeReason"
      ( \Object
x ->
          Maybe InstanceGroupStateChangeReasonCode
-> Maybe Text -> InstanceGroupStateChangeReason
InstanceGroupStateChangeReason'
            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
    InstanceGroupStateChangeReason
  where
  hashWithSalt :: Int -> InstanceGroupStateChangeReason -> Int
hashWithSalt
    Int
_salt
    InstanceGroupStateChangeReason' {Maybe Text
Maybe InstanceGroupStateChangeReasonCode
message :: Maybe Text
code :: Maybe InstanceGroupStateChangeReasonCode
$sel:message:InstanceGroupStateChangeReason' :: InstanceGroupStateChangeReason -> Maybe Text
$sel:code:InstanceGroupStateChangeReason' :: InstanceGroupStateChangeReason
-> Maybe InstanceGroupStateChangeReasonCode
..} =
      Int
_salt
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe InstanceGroupStateChangeReasonCode
code
        forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
message

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