{-# 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.AutoScalingPlans.Types.ScalingPolicy where
import Amazonka.AutoScalingPlans.Types.PolicyType
import Amazonka.AutoScalingPlans.Types.TargetTrackingConfiguration
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data ScalingPolicy = ScalingPolicy'
{
ScalingPolicy -> Maybe TargetTrackingConfiguration
targetTrackingConfiguration :: Prelude.Maybe TargetTrackingConfiguration,
ScalingPolicy -> Text
policyName :: Prelude.Text,
ScalingPolicy -> PolicyType
policyType :: PolicyType
}
deriving (ScalingPolicy -> ScalingPolicy -> Bool
(ScalingPolicy -> ScalingPolicy -> Bool)
-> (ScalingPolicy -> ScalingPolicy -> Bool) -> Eq ScalingPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ScalingPolicy -> ScalingPolicy -> Bool
$c/= :: ScalingPolicy -> ScalingPolicy -> Bool
== :: ScalingPolicy -> ScalingPolicy -> Bool
$c== :: ScalingPolicy -> ScalingPolicy -> Bool
Prelude.Eq, ReadPrec [ScalingPolicy]
ReadPrec ScalingPolicy
Int -> ReadS ScalingPolicy
ReadS [ScalingPolicy]
(Int -> ReadS ScalingPolicy)
-> ReadS [ScalingPolicy]
-> ReadPrec ScalingPolicy
-> ReadPrec [ScalingPolicy]
-> Read ScalingPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ScalingPolicy]
$creadListPrec :: ReadPrec [ScalingPolicy]
readPrec :: ReadPrec ScalingPolicy
$creadPrec :: ReadPrec ScalingPolicy
readList :: ReadS [ScalingPolicy]
$creadList :: ReadS [ScalingPolicy]
readsPrec :: Int -> ReadS ScalingPolicy
$creadsPrec :: Int -> ReadS ScalingPolicy
Prelude.Read, Int -> ScalingPolicy -> ShowS
[ScalingPolicy] -> ShowS
ScalingPolicy -> String
(Int -> ScalingPolicy -> ShowS)
-> (ScalingPolicy -> String)
-> ([ScalingPolicy] -> ShowS)
-> Show ScalingPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ScalingPolicy] -> ShowS
$cshowList :: [ScalingPolicy] -> ShowS
show :: ScalingPolicy -> String
$cshow :: ScalingPolicy -> String
showsPrec :: Int -> ScalingPolicy -> ShowS
$cshowsPrec :: Int -> ScalingPolicy -> ShowS
Prelude.Show, (forall x. ScalingPolicy -> Rep ScalingPolicy x)
-> (forall x. Rep ScalingPolicy x -> ScalingPolicy)
-> Generic ScalingPolicy
forall x. Rep ScalingPolicy x -> ScalingPolicy
forall x. ScalingPolicy -> Rep ScalingPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ScalingPolicy x -> ScalingPolicy
$cfrom :: forall x. ScalingPolicy -> Rep ScalingPolicy x
Prelude.Generic)
newScalingPolicy ::
Prelude.Text ->
PolicyType ->
ScalingPolicy
newScalingPolicy :: Text -> PolicyType -> ScalingPolicy
newScalingPolicy Text
pPolicyName_ PolicyType
pPolicyType_ =
ScalingPolicy' :: Maybe TargetTrackingConfiguration
-> Text -> PolicyType -> ScalingPolicy
ScalingPolicy'
{ $sel:targetTrackingConfiguration:ScalingPolicy' :: Maybe TargetTrackingConfiguration
targetTrackingConfiguration =
Maybe TargetTrackingConfiguration
forall a. Maybe a
Prelude.Nothing,
$sel:policyName:ScalingPolicy' :: Text
policyName = Text
pPolicyName_,
$sel:policyType:ScalingPolicy' :: PolicyType
policyType = PolicyType
pPolicyType_
}
scalingPolicy_targetTrackingConfiguration :: Lens.Lens' ScalingPolicy (Prelude.Maybe TargetTrackingConfiguration)
scalingPolicy_targetTrackingConfiguration :: (Maybe TargetTrackingConfiguration
-> f (Maybe TargetTrackingConfiguration))
-> ScalingPolicy -> f ScalingPolicy
scalingPolicy_targetTrackingConfiguration = (ScalingPolicy -> Maybe TargetTrackingConfiguration)
-> (ScalingPolicy
-> Maybe TargetTrackingConfiguration -> ScalingPolicy)
-> Lens
ScalingPolicy
ScalingPolicy
(Maybe TargetTrackingConfiguration)
(Maybe TargetTrackingConfiguration)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPolicy' {Maybe TargetTrackingConfiguration
targetTrackingConfiguration :: Maybe TargetTrackingConfiguration
$sel:targetTrackingConfiguration:ScalingPolicy' :: ScalingPolicy -> Maybe TargetTrackingConfiguration
targetTrackingConfiguration} -> Maybe TargetTrackingConfiguration
targetTrackingConfiguration) (\s :: ScalingPolicy
s@ScalingPolicy' {} Maybe TargetTrackingConfiguration
a -> ScalingPolicy
s {$sel:targetTrackingConfiguration:ScalingPolicy' :: Maybe TargetTrackingConfiguration
targetTrackingConfiguration = Maybe TargetTrackingConfiguration
a} :: ScalingPolicy)
scalingPolicy_policyName :: Lens.Lens' ScalingPolicy Prelude.Text
scalingPolicy_policyName :: (Text -> f Text) -> ScalingPolicy -> f ScalingPolicy
scalingPolicy_policyName = (ScalingPolicy -> Text)
-> (ScalingPolicy -> Text -> ScalingPolicy)
-> Lens ScalingPolicy ScalingPolicy Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPolicy' {Text
policyName :: Text
$sel:policyName:ScalingPolicy' :: ScalingPolicy -> Text
policyName} -> Text
policyName) (\s :: ScalingPolicy
s@ScalingPolicy' {} Text
a -> ScalingPolicy
s {$sel:policyName:ScalingPolicy' :: Text
policyName = Text
a} :: ScalingPolicy)
scalingPolicy_policyType :: Lens.Lens' ScalingPolicy PolicyType
scalingPolicy_policyType :: (PolicyType -> f PolicyType) -> ScalingPolicy -> f ScalingPolicy
scalingPolicy_policyType = (ScalingPolicy -> PolicyType)
-> (ScalingPolicy -> PolicyType -> ScalingPolicy)
-> Lens ScalingPolicy ScalingPolicy PolicyType PolicyType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ScalingPolicy' {PolicyType
policyType :: PolicyType
$sel:policyType:ScalingPolicy' :: ScalingPolicy -> PolicyType
policyType} -> PolicyType
policyType) (\s :: ScalingPolicy
s@ScalingPolicy' {} PolicyType
a -> ScalingPolicy
s {$sel:policyType:ScalingPolicy' :: PolicyType
policyType = PolicyType
a} :: ScalingPolicy)
instance Core.FromJSON ScalingPolicy where
parseJSON :: Value -> Parser ScalingPolicy
parseJSON =
String
-> (Object -> Parser ScalingPolicy)
-> Value
-> Parser ScalingPolicy
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"ScalingPolicy"
( \Object
x ->
Maybe TargetTrackingConfiguration
-> Text -> PolicyType -> ScalingPolicy
ScalingPolicy'
(Maybe TargetTrackingConfiguration
-> Text -> PolicyType -> ScalingPolicy)
-> Parser (Maybe TargetTrackingConfiguration)
-> Parser (Text -> PolicyType -> ScalingPolicy)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe TargetTrackingConfiguration)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TargetTrackingConfiguration")
Parser (Text -> PolicyType -> ScalingPolicy)
-> Parser Text -> Parser (PolicyType -> ScalingPolicy)
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
"PolicyName")
Parser (PolicyType -> ScalingPolicy)
-> Parser PolicyType -> Parser ScalingPolicy
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser PolicyType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"PolicyType")
)
instance Prelude.Hashable ScalingPolicy
instance Prelude.NFData ScalingPolicy