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

import qualified Amazonka.Core as Core
import Amazonka.EMR.Types.InstanceGroupStateChangeReasonCode
import qualified Amazonka.Lens as Lens
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
(InstanceGroupStateChangeReason
 -> InstanceGroupStateChangeReason -> Bool)
-> (InstanceGroupStateChangeReason
    -> InstanceGroupStateChangeReason -> Bool)
-> Eq InstanceGroupStateChangeReason
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]
(Int -> ReadS InstanceGroupStateChangeReason)
-> ReadS [InstanceGroupStateChangeReason]
-> ReadPrec InstanceGroupStateChangeReason
-> ReadPrec [InstanceGroupStateChangeReason]
-> Read 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
(Int -> InstanceGroupStateChangeReason -> ShowS)
-> (InstanceGroupStateChangeReason -> String)
-> ([InstanceGroupStateChangeReason] -> ShowS)
-> Show InstanceGroupStateChangeReason
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.
 InstanceGroupStateChangeReason
 -> Rep InstanceGroupStateChangeReason x)
-> (forall x.
    Rep InstanceGroupStateChangeReason x
    -> InstanceGroupStateChangeReason)
-> Generic InstanceGroupStateChangeReason
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' :: Maybe InstanceGroupStateChangeReasonCode
-> Maybe Text -> InstanceGroupStateChangeReason
InstanceGroupStateChangeReason'
    { $sel:code:InstanceGroupStateChangeReason' :: Maybe InstanceGroupStateChangeReasonCode
code =
        Maybe InstanceGroupStateChangeReasonCode
forall a. Maybe a
Prelude.Nothing,
      $sel:message:InstanceGroupStateChangeReason' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The programmable code for the state change reason.
instanceGroupStateChangeReason_code :: Lens.Lens' InstanceGroupStateChangeReason (Prelude.Maybe InstanceGroupStateChangeReasonCode)
instanceGroupStateChangeReason_code :: (Maybe InstanceGroupStateChangeReasonCode
 -> f (Maybe InstanceGroupStateChangeReasonCode))
-> InstanceGroupStateChangeReason
-> f InstanceGroupStateChangeReason
instanceGroupStateChangeReason_code = (InstanceGroupStateChangeReason
 -> Maybe InstanceGroupStateChangeReasonCode)
-> (InstanceGroupStateChangeReason
    -> Maybe InstanceGroupStateChangeReasonCode
    -> InstanceGroupStateChangeReason)
-> Lens
     InstanceGroupStateChangeReason
     InstanceGroupStateChangeReason
     (Maybe InstanceGroupStateChangeReasonCode)
     (Maybe InstanceGroupStateChangeReasonCode)
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 :: (Maybe Text -> f (Maybe Text))
-> InstanceGroupStateChangeReason
-> f InstanceGroupStateChangeReason
instanceGroupStateChangeReason_message = (InstanceGroupStateChangeReason -> Maybe Text)
-> (InstanceGroupStateChangeReason
    -> Maybe Text -> InstanceGroupStateChangeReason)
-> Lens
     InstanceGroupStateChangeReason
     InstanceGroupStateChangeReason
     (Maybe Text)
     (Maybe Text)
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 Core.FromJSON InstanceGroupStateChangeReason where
  parseJSON :: Value -> Parser InstanceGroupStateChangeReason
parseJSON =
    String
-> (Object -> Parser InstanceGroupStateChangeReason)
-> Value
-> Parser InstanceGroupStateChangeReason
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"InstanceGroupStateChangeReason"
      ( \Object
x ->
          Maybe InstanceGroupStateChangeReasonCode
-> Maybe Text -> InstanceGroupStateChangeReason
InstanceGroupStateChangeReason'
            (Maybe InstanceGroupStateChangeReasonCode
 -> Maybe Text -> InstanceGroupStateChangeReason)
-> Parser (Maybe InstanceGroupStateChangeReasonCode)
-> Parser (Maybe Text -> InstanceGroupStateChangeReason)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe InstanceGroupStateChangeReasonCode)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Code")
            Parser (Maybe Text -> InstanceGroupStateChangeReason)
-> Parser (Maybe Text) -> Parser InstanceGroupStateChangeReason
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
    InstanceGroupStateChangeReason

instance
  Prelude.NFData
    InstanceGroupStateChangeReason