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

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

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

-- |
-- Create a value of 'InstanceStateChangeReason' 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', 'instanceStateChangeReason_code' - The programmable code for the state change reason.
--
-- 'message', 'instanceStateChangeReason_message' - The status change reason description.
newInstanceStateChangeReason ::
  InstanceStateChangeReason
newInstanceStateChangeReason :: InstanceStateChangeReason
newInstanceStateChangeReason =
  InstanceStateChangeReason' :: Maybe InstanceStateChangeReasonCode
-> Maybe Text -> InstanceStateChangeReason
InstanceStateChangeReason'
    { $sel:code:InstanceStateChangeReason' :: Maybe InstanceStateChangeReasonCode
code = Maybe InstanceStateChangeReasonCode
forall a. Maybe a
Prelude.Nothing,
      $sel:message:InstanceStateChangeReason' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

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

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

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

instance Prelude.NFData InstanceStateChangeReason