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

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

-- | Provides status change reason details for the instance fleet.
--
-- The instance fleet configuration is available only in Amazon EMR
-- versions 4.8.0 and later, excluding 5.0.x versions.
--
-- /See:/ 'newInstanceFleetStateChangeReason' smart constructor.
data InstanceFleetStateChangeReason = InstanceFleetStateChangeReason'
  { -- | A code corresponding to the reason the state change occurred.
    InstanceFleetStateChangeReason
-> Maybe InstanceFleetStateChangeReasonCode
code :: Prelude.Maybe InstanceFleetStateChangeReasonCode,
    -- | An explanatory message.
    InstanceFleetStateChangeReason -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (InstanceFleetStateChangeReason
-> InstanceFleetStateChangeReason -> Bool
(InstanceFleetStateChangeReason
 -> InstanceFleetStateChangeReason -> Bool)
-> (InstanceFleetStateChangeReason
    -> InstanceFleetStateChangeReason -> Bool)
-> Eq InstanceFleetStateChangeReason
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: InstanceFleetStateChangeReason
-> InstanceFleetStateChangeReason -> Bool
$c/= :: InstanceFleetStateChangeReason
-> InstanceFleetStateChangeReason -> Bool
== :: InstanceFleetStateChangeReason
-> InstanceFleetStateChangeReason -> Bool
$c== :: InstanceFleetStateChangeReason
-> InstanceFleetStateChangeReason -> Bool
Prelude.Eq, ReadPrec [InstanceFleetStateChangeReason]
ReadPrec InstanceFleetStateChangeReason
Int -> ReadS InstanceFleetStateChangeReason
ReadS [InstanceFleetStateChangeReason]
(Int -> ReadS InstanceFleetStateChangeReason)
-> ReadS [InstanceFleetStateChangeReason]
-> ReadPrec InstanceFleetStateChangeReason
-> ReadPrec [InstanceFleetStateChangeReason]
-> Read InstanceFleetStateChangeReason
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [InstanceFleetStateChangeReason]
$creadListPrec :: ReadPrec [InstanceFleetStateChangeReason]
readPrec :: ReadPrec InstanceFleetStateChangeReason
$creadPrec :: ReadPrec InstanceFleetStateChangeReason
readList :: ReadS [InstanceFleetStateChangeReason]
$creadList :: ReadS [InstanceFleetStateChangeReason]
readsPrec :: Int -> ReadS InstanceFleetStateChangeReason
$creadsPrec :: Int -> ReadS InstanceFleetStateChangeReason
Prelude.Read, Int -> InstanceFleetStateChangeReason -> ShowS
[InstanceFleetStateChangeReason] -> ShowS
InstanceFleetStateChangeReason -> String
(Int -> InstanceFleetStateChangeReason -> ShowS)
-> (InstanceFleetStateChangeReason -> String)
-> ([InstanceFleetStateChangeReason] -> ShowS)
-> Show InstanceFleetStateChangeReason
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [InstanceFleetStateChangeReason] -> ShowS
$cshowList :: [InstanceFleetStateChangeReason] -> ShowS
show :: InstanceFleetStateChangeReason -> String
$cshow :: InstanceFleetStateChangeReason -> String
showsPrec :: Int -> InstanceFleetStateChangeReason -> ShowS
$cshowsPrec :: Int -> InstanceFleetStateChangeReason -> ShowS
Prelude.Show, (forall x.
 InstanceFleetStateChangeReason
 -> Rep InstanceFleetStateChangeReason x)
-> (forall x.
    Rep InstanceFleetStateChangeReason x
    -> InstanceFleetStateChangeReason)
-> Generic InstanceFleetStateChangeReason
forall x.
Rep InstanceFleetStateChangeReason x
-> InstanceFleetStateChangeReason
forall x.
InstanceFleetStateChangeReason
-> Rep InstanceFleetStateChangeReason x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep InstanceFleetStateChangeReason x
-> InstanceFleetStateChangeReason
$cfrom :: forall x.
InstanceFleetStateChangeReason
-> Rep InstanceFleetStateChangeReason x
Prelude.Generic)

-- |
-- Create a value of 'InstanceFleetStateChangeReason' 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', 'instanceFleetStateChangeReason_code' - A code corresponding to the reason the state change occurred.
--
-- 'message', 'instanceFleetStateChangeReason_message' - An explanatory message.
newInstanceFleetStateChangeReason ::
  InstanceFleetStateChangeReason
newInstanceFleetStateChangeReason :: InstanceFleetStateChangeReason
newInstanceFleetStateChangeReason =
  InstanceFleetStateChangeReason' :: Maybe InstanceFleetStateChangeReasonCode
-> Maybe Text -> InstanceFleetStateChangeReason
InstanceFleetStateChangeReason'
    { $sel:code:InstanceFleetStateChangeReason' :: Maybe InstanceFleetStateChangeReasonCode
code =
        Maybe InstanceFleetStateChangeReasonCode
forall a. Maybe a
Prelude.Nothing,
      $sel:message:InstanceFleetStateChangeReason' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | A code corresponding to the reason the state change occurred.
instanceFleetStateChangeReason_code :: Lens.Lens' InstanceFleetStateChangeReason (Prelude.Maybe InstanceFleetStateChangeReasonCode)
instanceFleetStateChangeReason_code :: (Maybe InstanceFleetStateChangeReasonCode
 -> f (Maybe InstanceFleetStateChangeReasonCode))
-> InstanceFleetStateChangeReason
-> f InstanceFleetStateChangeReason
instanceFleetStateChangeReason_code = (InstanceFleetStateChangeReason
 -> Maybe InstanceFleetStateChangeReasonCode)
-> (InstanceFleetStateChangeReason
    -> Maybe InstanceFleetStateChangeReasonCode
    -> InstanceFleetStateChangeReason)
-> Lens
     InstanceFleetStateChangeReason
     InstanceFleetStateChangeReason
     (Maybe InstanceFleetStateChangeReasonCode)
     (Maybe InstanceFleetStateChangeReasonCode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceFleetStateChangeReason' {Maybe InstanceFleetStateChangeReasonCode
code :: Maybe InstanceFleetStateChangeReasonCode
$sel:code:InstanceFleetStateChangeReason' :: InstanceFleetStateChangeReason
-> Maybe InstanceFleetStateChangeReasonCode
code} -> Maybe InstanceFleetStateChangeReasonCode
code) (\s :: InstanceFleetStateChangeReason
s@InstanceFleetStateChangeReason' {} Maybe InstanceFleetStateChangeReasonCode
a -> InstanceFleetStateChangeReason
s {$sel:code:InstanceFleetStateChangeReason' :: Maybe InstanceFleetStateChangeReasonCode
code = Maybe InstanceFleetStateChangeReasonCode
a} :: InstanceFleetStateChangeReason)

-- | An explanatory message.
instanceFleetStateChangeReason_message :: Lens.Lens' InstanceFleetStateChangeReason (Prelude.Maybe Prelude.Text)
instanceFleetStateChangeReason_message :: (Maybe Text -> f (Maybe Text))
-> InstanceFleetStateChangeReason
-> f InstanceFleetStateChangeReason
instanceFleetStateChangeReason_message = (InstanceFleetStateChangeReason -> Maybe Text)
-> (InstanceFleetStateChangeReason
    -> Maybe Text -> InstanceFleetStateChangeReason)
-> Lens
     InstanceFleetStateChangeReason
     InstanceFleetStateChangeReason
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\InstanceFleetStateChangeReason' {Maybe Text
message :: Maybe Text
$sel:message:InstanceFleetStateChangeReason' :: InstanceFleetStateChangeReason -> Maybe Text
message} -> Maybe Text
message) (\s :: InstanceFleetStateChangeReason
s@InstanceFleetStateChangeReason' {} Maybe Text
a -> InstanceFleetStateChangeReason
s {$sel:message:InstanceFleetStateChangeReason' :: Maybe Text
message = Maybe Text
a} :: InstanceFleetStateChangeReason)

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

instance
  Prelude.NFData
    InstanceFleetStateChangeReason