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

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

-- | The reason for an AutoScalingPolicyStatus change.
--
-- /See:/ 'newAutoScalingPolicyStateChangeReason' smart constructor.
data AutoScalingPolicyStateChangeReason = AutoScalingPolicyStateChangeReason'
  { -- | The code indicating the reason for the change in status.@USER_REQUEST@
    -- indicates that the scaling policy status was changed by a user.
    -- @PROVISION_FAILURE@ indicates that the status change was because the
    -- policy failed to provision. @CLEANUP_FAILURE@ indicates an error.
    AutoScalingPolicyStateChangeReason
-> Maybe AutoScalingPolicyStateChangeReasonCode
code :: Prelude.Maybe AutoScalingPolicyStateChangeReasonCode,
    -- | A friendly, more verbose message that accompanies an automatic scaling
    -- policy state change.
    AutoScalingPolicyStateChangeReason -> Maybe Text
message :: Prelude.Maybe Prelude.Text
  }
  deriving (AutoScalingPolicyStateChangeReason
-> AutoScalingPolicyStateChangeReason -> Bool
(AutoScalingPolicyStateChangeReason
 -> AutoScalingPolicyStateChangeReason -> Bool)
-> (AutoScalingPolicyStateChangeReason
    -> AutoScalingPolicyStateChangeReason -> Bool)
-> Eq AutoScalingPolicyStateChangeReason
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AutoScalingPolicyStateChangeReason
-> AutoScalingPolicyStateChangeReason -> Bool
$c/= :: AutoScalingPolicyStateChangeReason
-> AutoScalingPolicyStateChangeReason -> Bool
== :: AutoScalingPolicyStateChangeReason
-> AutoScalingPolicyStateChangeReason -> Bool
$c== :: AutoScalingPolicyStateChangeReason
-> AutoScalingPolicyStateChangeReason -> Bool
Prelude.Eq, ReadPrec [AutoScalingPolicyStateChangeReason]
ReadPrec AutoScalingPolicyStateChangeReason
Int -> ReadS AutoScalingPolicyStateChangeReason
ReadS [AutoScalingPolicyStateChangeReason]
(Int -> ReadS AutoScalingPolicyStateChangeReason)
-> ReadS [AutoScalingPolicyStateChangeReason]
-> ReadPrec AutoScalingPolicyStateChangeReason
-> ReadPrec [AutoScalingPolicyStateChangeReason]
-> Read AutoScalingPolicyStateChangeReason
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AutoScalingPolicyStateChangeReason]
$creadListPrec :: ReadPrec [AutoScalingPolicyStateChangeReason]
readPrec :: ReadPrec AutoScalingPolicyStateChangeReason
$creadPrec :: ReadPrec AutoScalingPolicyStateChangeReason
readList :: ReadS [AutoScalingPolicyStateChangeReason]
$creadList :: ReadS [AutoScalingPolicyStateChangeReason]
readsPrec :: Int -> ReadS AutoScalingPolicyStateChangeReason
$creadsPrec :: Int -> ReadS AutoScalingPolicyStateChangeReason
Prelude.Read, Int -> AutoScalingPolicyStateChangeReason -> ShowS
[AutoScalingPolicyStateChangeReason] -> ShowS
AutoScalingPolicyStateChangeReason -> String
(Int -> AutoScalingPolicyStateChangeReason -> ShowS)
-> (AutoScalingPolicyStateChangeReason -> String)
-> ([AutoScalingPolicyStateChangeReason] -> ShowS)
-> Show AutoScalingPolicyStateChangeReason
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AutoScalingPolicyStateChangeReason] -> ShowS
$cshowList :: [AutoScalingPolicyStateChangeReason] -> ShowS
show :: AutoScalingPolicyStateChangeReason -> String
$cshow :: AutoScalingPolicyStateChangeReason -> String
showsPrec :: Int -> AutoScalingPolicyStateChangeReason -> ShowS
$cshowsPrec :: Int -> AutoScalingPolicyStateChangeReason -> ShowS
Prelude.Show, (forall x.
 AutoScalingPolicyStateChangeReason
 -> Rep AutoScalingPolicyStateChangeReason x)
-> (forall x.
    Rep AutoScalingPolicyStateChangeReason x
    -> AutoScalingPolicyStateChangeReason)
-> Generic AutoScalingPolicyStateChangeReason
forall x.
Rep AutoScalingPolicyStateChangeReason x
-> AutoScalingPolicyStateChangeReason
forall x.
AutoScalingPolicyStateChangeReason
-> Rep AutoScalingPolicyStateChangeReason x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep AutoScalingPolicyStateChangeReason x
-> AutoScalingPolicyStateChangeReason
$cfrom :: forall x.
AutoScalingPolicyStateChangeReason
-> Rep AutoScalingPolicyStateChangeReason x
Prelude.Generic)

-- |
-- Create a value of 'AutoScalingPolicyStateChangeReason' 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', 'autoScalingPolicyStateChangeReason_code' - The code indicating the reason for the change in status.@USER_REQUEST@
-- indicates that the scaling policy status was changed by a user.
-- @PROVISION_FAILURE@ indicates that the status change was because the
-- policy failed to provision. @CLEANUP_FAILURE@ indicates an error.
--
-- 'message', 'autoScalingPolicyStateChangeReason_message' - A friendly, more verbose message that accompanies an automatic scaling
-- policy state change.
newAutoScalingPolicyStateChangeReason ::
  AutoScalingPolicyStateChangeReason
newAutoScalingPolicyStateChangeReason :: AutoScalingPolicyStateChangeReason
newAutoScalingPolicyStateChangeReason =
  AutoScalingPolicyStateChangeReason' :: Maybe AutoScalingPolicyStateChangeReasonCode
-> Maybe Text -> AutoScalingPolicyStateChangeReason
AutoScalingPolicyStateChangeReason'
    { $sel:code:AutoScalingPolicyStateChangeReason' :: Maybe AutoScalingPolicyStateChangeReasonCode
code =
        Maybe AutoScalingPolicyStateChangeReasonCode
forall a. Maybe a
Prelude.Nothing,
      $sel:message:AutoScalingPolicyStateChangeReason' :: Maybe Text
message = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The code indicating the reason for the change in status.@USER_REQUEST@
-- indicates that the scaling policy status was changed by a user.
-- @PROVISION_FAILURE@ indicates that the status change was because the
-- policy failed to provision. @CLEANUP_FAILURE@ indicates an error.
autoScalingPolicyStateChangeReason_code :: Lens.Lens' AutoScalingPolicyStateChangeReason (Prelude.Maybe AutoScalingPolicyStateChangeReasonCode)
autoScalingPolicyStateChangeReason_code :: (Maybe AutoScalingPolicyStateChangeReasonCode
 -> f (Maybe AutoScalingPolicyStateChangeReasonCode))
-> AutoScalingPolicyStateChangeReason
-> f AutoScalingPolicyStateChangeReason
autoScalingPolicyStateChangeReason_code = (AutoScalingPolicyStateChangeReason
 -> Maybe AutoScalingPolicyStateChangeReasonCode)
-> (AutoScalingPolicyStateChangeReason
    -> Maybe AutoScalingPolicyStateChangeReasonCode
    -> AutoScalingPolicyStateChangeReason)
-> Lens
     AutoScalingPolicyStateChangeReason
     AutoScalingPolicyStateChangeReason
     (Maybe AutoScalingPolicyStateChangeReasonCode)
     (Maybe AutoScalingPolicyStateChangeReasonCode)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingPolicyStateChangeReason' {Maybe AutoScalingPolicyStateChangeReasonCode
code :: Maybe AutoScalingPolicyStateChangeReasonCode
$sel:code:AutoScalingPolicyStateChangeReason' :: AutoScalingPolicyStateChangeReason
-> Maybe AutoScalingPolicyStateChangeReasonCode
code} -> Maybe AutoScalingPolicyStateChangeReasonCode
code) (\s :: AutoScalingPolicyStateChangeReason
s@AutoScalingPolicyStateChangeReason' {} Maybe AutoScalingPolicyStateChangeReasonCode
a -> AutoScalingPolicyStateChangeReason
s {$sel:code:AutoScalingPolicyStateChangeReason' :: Maybe AutoScalingPolicyStateChangeReasonCode
code = Maybe AutoScalingPolicyStateChangeReasonCode
a} :: AutoScalingPolicyStateChangeReason)

-- | A friendly, more verbose message that accompanies an automatic scaling
-- policy state change.
autoScalingPolicyStateChangeReason_message :: Lens.Lens' AutoScalingPolicyStateChangeReason (Prelude.Maybe Prelude.Text)
autoScalingPolicyStateChangeReason_message :: (Maybe Text -> f (Maybe Text))
-> AutoScalingPolicyStateChangeReason
-> f AutoScalingPolicyStateChangeReason
autoScalingPolicyStateChangeReason_message = (AutoScalingPolicyStateChangeReason -> Maybe Text)
-> (AutoScalingPolicyStateChangeReason
    -> Maybe Text -> AutoScalingPolicyStateChangeReason)
-> Lens
     AutoScalingPolicyStateChangeReason
     AutoScalingPolicyStateChangeReason
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AutoScalingPolicyStateChangeReason' {Maybe Text
message :: Maybe Text
$sel:message:AutoScalingPolicyStateChangeReason' :: AutoScalingPolicyStateChangeReason -> Maybe Text
message} -> Maybe Text
message) (\s :: AutoScalingPolicyStateChangeReason
s@AutoScalingPolicyStateChangeReason' {} Maybe Text
a -> AutoScalingPolicyStateChangeReason
s {$sel:message:AutoScalingPolicyStateChangeReason' :: Maybe Text
message = Maybe Text
a} :: AutoScalingPolicyStateChangeReason)

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

instance
  Prelude.NFData
    AutoScalingPolicyStateChangeReason