{-# 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 #-}
module Amazonka.EMR.Types.ScalingRule where
import qualified Amazonka.Core as Core
import Amazonka.EMR.Types.ScalingAction
import Amazonka.EMR.Types.ScalingTrigger
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data ScalingRule = ScalingRule'
{
ScalingRule -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
ScalingRule -> Text
name :: Prelude.Text,
ScalingRule -> ScalingAction
action :: ScalingAction,
ScalingRule -> ScalingTrigger
trigger :: ScalingTrigger
}
deriving (ScalingRule -> ScalingRule -> Bool
(ScalingRule -> ScalingRule -> Bool)
-> (ScalingRule -> ScalingRule -> Bool) -> Eq ScalingRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScalingRule -> ScalingRule -> Bool
$c/= :: ScalingRule -> ScalingRule -> Bool
== :: ScalingRule -> ScalingRule -> Bool
$c== :: ScalingRule -> ScalingRule -> Bool
Prelude.Eq, ReadPrec [ScalingRule]
ReadPrec ScalingRule
Int -> ReadS ScalingRule
ReadS [ScalingRule]
(Int -> ReadS ScalingRule)
-> ReadS [ScalingRule]
-> ReadPrec ScalingRule
-> ReadPrec [ScalingRule]
-> Read ScalingRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScalingRule]
$creadListPrec :: ReadPrec [ScalingRule]
readPrec :: ReadPrec ScalingRule
$creadPrec :: ReadPrec ScalingRule
readList :: ReadS [ScalingRule]
$creadList :: ReadS [ScalingRule]
readsPrec :: Int -> ReadS ScalingRule
$creadsPrec :: Int -> ReadS ScalingRule
Prelude.Read, Int -> ScalingRule -> ShowS
[ScalingRule] -> ShowS
ScalingRule -> String
(Int -> ScalingRule -> ShowS)
-> (ScalingRule -> String)
-> ([ScalingRule] -> ShowS)
-> Show ScalingRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScalingRule] -> ShowS
$cshowList :: [ScalingRule] -> ShowS
show :: ScalingRule -> String
$cshow :: ScalingRule -> String
showsPrec :: Int -> ScalingRule -> ShowS
$cshowsPrec :: Int -> ScalingRule -> ShowS
Prelude.Show, (forall x. ScalingRule -> Rep ScalingRule x)
-> (forall x. Rep ScalingRule x -> ScalingRule)
-> Generic ScalingRule
forall x. Rep ScalingRule x -> ScalingRule
forall x. ScalingRule -> Rep ScalingRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ScalingRule x -> ScalingRule
$cfrom :: forall x. ScalingRule -> Rep ScalingRule x
Prelude.Generic)
newScalingRule ::
Prelude.Text ->
ScalingAction ->
ScalingTrigger ->
ScalingRule
newScalingRule :: Text -> ScalingAction -> ScalingTrigger -> ScalingRule
newScalingRule Text
pName_ ScalingAction
pAction_ ScalingTrigger
pTrigger_ =
ScalingRule' :: Maybe Text
-> Text -> ScalingAction -> ScalingTrigger -> ScalingRule
ScalingRule'
{ $sel:description:ScalingRule' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:name:ScalingRule' :: Text
name = Text
pName_,
$sel:action:ScalingRule' :: ScalingAction
action = ScalingAction
pAction_,
$sel:trigger:ScalingRule' :: ScalingTrigger
trigger = ScalingTrigger
pTrigger_
}
scalingRule_description :: Lens.Lens' ScalingRule (Prelude.Maybe Prelude.Text)
scalingRule_description :: (Maybe Text -> f (Maybe Text)) -> ScalingRule -> f ScalingRule
scalingRule_description = (ScalingRule -> Maybe Text)
-> (ScalingRule -> Maybe Text -> ScalingRule)
-> Lens ScalingRule ScalingRule (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingRule' {Maybe Text
description :: Maybe Text
$sel:description:ScalingRule' :: ScalingRule -> Maybe Text
description} -> Maybe Text
description) (\s :: ScalingRule
s@ScalingRule' {} Maybe Text
a -> ScalingRule
s {$sel:description:ScalingRule' :: Maybe Text
description = Maybe Text
a} :: ScalingRule)
scalingRule_name :: Lens.Lens' ScalingRule Prelude.Text
scalingRule_name :: (Text -> f Text) -> ScalingRule -> f ScalingRule
scalingRule_name = (ScalingRule -> Text)
-> (ScalingRule -> Text -> ScalingRule)
-> Lens ScalingRule ScalingRule Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingRule' {Text
name :: Text
$sel:name:ScalingRule' :: ScalingRule -> Text
name} -> Text
name) (\s :: ScalingRule
s@ScalingRule' {} Text
a -> ScalingRule
s {$sel:name:ScalingRule' :: Text
name = Text
a} :: ScalingRule)
scalingRule_action :: Lens.Lens' ScalingRule ScalingAction
scalingRule_action :: (ScalingAction -> f ScalingAction) -> ScalingRule -> f ScalingRule
scalingRule_action = (ScalingRule -> ScalingAction)
-> (ScalingRule -> ScalingAction -> ScalingRule)
-> Lens ScalingRule ScalingRule ScalingAction ScalingAction
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingRule' {ScalingAction
action :: ScalingAction
$sel:action:ScalingRule' :: ScalingRule -> ScalingAction
action} -> ScalingAction
action) (\s :: ScalingRule
s@ScalingRule' {} ScalingAction
a -> ScalingRule
s {$sel:action:ScalingRule' :: ScalingAction
action = ScalingAction
a} :: ScalingRule)
scalingRule_trigger :: Lens.Lens' ScalingRule ScalingTrigger
scalingRule_trigger :: (ScalingTrigger -> f ScalingTrigger)
-> ScalingRule -> f ScalingRule
scalingRule_trigger = (ScalingRule -> ScalingTrigger)
-> (ScalingRule -> ScalingTrigger -> ScalingRule)
-> Lens ScalingRule ScalingRule ScalingTrigger ScalingTrigger
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingRule' {ScalingTrigger
trigger :: ScalingTrigger
$sel:trigger:ScalingRule' :: ScalingRule -> ScalingTrigger
trigger} -> ScalingTrigger
trigger) (\s :: ScalingRule
s@ScalingRule' {} ScalingTrigger
a -> ScalingRule
s {$sel:trigger:ScalingRule' :: ScalingTrigger
trigger = ScalingTrigger
a} :: ScalingRule)
instance Core.FromJSON ScalingRule where
parseJSON :: Value -> Parser ScalingRule
parseJSON =
String
-> (Object -> Parser ScalingRule) -> Value -> Parser ScalingRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"ScalingRule"
( \Object
x ->
Maybe Text
-> Text -> ScalingAction -> ScalingTrigger -> ScalingRule
ScalingRule'
(Maybe Text
-> Text -> ScalingAction -> ScalingTrigger -> ScalingRule)
-> Parser (Maybe Text)
-> Parser (Text -> ScalingAction -> ScalingTrigger -> ScalingRule)
forall (f :: * -> *) a b. Functor 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
"Description")
Parser (Text -> ScalingAction -> ScalingTrigger -> ScalingRule)
-> Parser Text
-> Parser (ScalingAction -> ScalingTrigger -> ScalingRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Name")
Parser (ScalingAction -> ScalingTrigger -> ScalingRule)
-> Parser ScalingAction -> Parser (ScalingTrigger -> ScalingRule)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ScalingAction
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Action")
Parser (ScalingTrigger -> ScalingRule)
-> Parser ScalingTrigger -> Parser ScalingRule
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser ScalingTrigger
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Trigger")
)
instance Prelude.Hashable ScalingRule
instance Prelude.NFData ScalingRule
instance Core.ToJSON ScalingRule where
toJSON :: ScalingRule -> Value
toJSON ScalingRule' {Maybe Text
Text
ScalingAction
ScalingTrigger
trigger :: ScalingTrigger
action :: ScalingAction
name :: Text
description :: Maybe Text
$sel:trigger:ScalingRule' :: ScalingRule -> ScalingTrigger
$sel:action:ScalingRule' :: ScalingRule -> ScalingAction
$sel:name:ScalingRule' :: ScalingRule -> Text
$sel:description:ScalingRule' :: ScalingRule -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Name" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
name),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Action" Text -> ScalingAction -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ScalingAction
action),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Trigger" Text -> ScalingTrigger -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= ScalingTrigger
trigger)
]
)