{-# 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.Route53RecoveryControlConfig.Types.RuleConfig where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Route53RecoveryControlConfig.Types.RuleType
data RuleConfig = RuleConfig'
{
RuleConfig -> RuleType
type' :: RuleType,
RuleConfig -> Bool
inverted :: Prelude.Bool,
RuleConfig -> Int
threshold :: Prelude.Int
}
deriving (RuleConfig -> RuleConfig -> Bool
(RuleConfig -> RuleConfig -> Bool)
-> (RuleConfig -> RuleConfig -> Bool) -> Eq RuleConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RuleConfig -> RuleConfig -> Bool
$c/= :: RuleConfig -> RuleConfig -> Bool
== :: RuleConfig -> RuleConfig -> Bool
$c== :: RuleConfig -> RuleConfig -> Bool
Prelude.Eq, ReadPrec [RuleConfig]
ReadPrec RuleConfig
Int -> ReadS RuleConfig
ReadS [RuleConfig]
(Int -> ReadS RuleConfig)
-> ReadS [RuleConfig]
-> ReadPrec RuleConfig
-> ReadPrec [RuleConfig]
-> Read RuleConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RuleConfig]
$creadListPrec :: ReadPrec [RuleConfig]
readPrec :: ReadPrec RuleConfig
$creadPrec :: ReadPrec RuleConfig
readList :: ReadS [RuleConfig]
$creadList :: ReadS [RuleConfig]
readsPrec :: Int -> ReadS RuleConfig
$creadsPrec :: Int -> ReadS RuleConfig
Prelude.Read, Int -> RuleConfig -> ShowS
[RuleConfig] -> ShowS
RuleConfig -> String
(Int -> RuleConfig -> ShowS)
-> (RuleConfig -> String)
-> ([RuleConfig] -> ShowS)
-> Show RuleConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RuleConfig] -> ShowS
$cshowList :: [RuleConfig] -> ShowS
show :: RuleConfig -> String
$cshow :: RuleConfig -> String
showsPrec :: Int -> RuleConfig -> ShowS
$cshowsPrec :: Int -> RuleConfig -> ShowS
Prelude.Show, (forall x. RuleConfig -> Rep RuleConfig x)
-> (forall x. Rep RuleConfig x -> RuleConfig) -> Generic RuleConfig
forall x. Rep RuleConfig x -> RuleConfig
forall x. RuleConfig -> Rep RuleConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RuleConfig x -> RuleConfig
$cfrom :: forall x. RuleConfig -> Rep RuleConfig x
Prelude.Generic)
newRuleConfig ::
RuleType ->
Prelude.Bool ->
Prelude.Int ->
RuleConfig
newRuleConfig :: RuleType -> Bool -> Int -> RuleConfig
newRuleConfig RuleType
pType_ Bool
pInverted_ Int
pThreshold_ =
RuleConfig' :: RuleType -> Bool -> Int -> RuleConfig
RuleConfig'
{ $sel:type':RuleConfig' :: RuleType
type' = RuleType
pType_,
$sel:inverted:RuleConfig' :: Bool
inverted = Bool
pInverted_,
$sel:threshold:RuleConfig' :: Int
threshold = Int
pThreshold_
}
ruleConfig_type :: Lens.Lens' RuleConfig RuleType
ruleConfig_type :: (RuleType -> f RuleType) -> RuleConfig -> f RuleConfig
ruleConfig_type = (RuleConfig -> RuleType)
-> (RuleConfig -> RuleType -> RuleConfig)
-> Lens RuleConfig RuleConfig RuleType RuleType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleConfig' {RuleType
type' :: RuleType
$sel:type':RuleConfig' :: RuleConfig -> RuleType
type'} -> RuleType
type') (\s :: RuleConfig
s@RuleConfig' {} RuleType
a -> RuleConfig
s {$sel:type':RuleConfig' :: RuleType
type' = RuleType
a} :: RuleConfig)
ruleConfig_inverted :: Lens.Lens' RuleConfig Prelude.Bool
ruleConfig_inverted :: (Bool -> f Bool) -> RuleConfig -> f RuleConfig
ruleConfig_inverted = (RuleConfig -> Bool)
-> (RuleConfig -> Bool -> RuleConfig)
-> Lens RuleConfig RuleConfig Bool Bool
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleConfig' {Bool
inverted :: Bool
$sel:inverted:RuleConfig' :: RuleConfig -> Bool
inverted} -> Bool
inverted) (\s :: RuleConfig
s@RuleConfig' {} Bool
a -> RuleConfig
s {$sel:inverted:RuleConfig' :: Bool
inverted = Bool
a} :: RuleConfig)
ruleConfig_threshold :: Lens.Lens' RuleConfig Prelude.Int
ruleConfig_threshold :: (Int -> f Int) -> RuleConfig -> f RuleConfig
ruleConfig_threshold = (RuleConfig -> Int)
-> (RuleConfig -> Int -> RuleConfig)
-> Lens RuleConfig RuleConfig Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleConfig' {Int
threshold :: Int
$sel:threshold:RuleConfig' :: RuleConfig -> Int
threshold} -> Int
threshold) (\s :: RuleConfig
s@RuleConfig' {} Int
a -> RuleConfig
s {$sel:threshold:RuleConfig' :: Int
threshold = Int
a} :: RuleConfig)
instance Core.FromJSON RuleConfig where
parseJSON :: Value -> Parser RuleConfig
parseJSON =
String
-> (Object -> Parser RuleConfig) -> Value -> Parser RuleConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"RuleConfig"
( \Object
x ->
RuleType -> Bool -> Int -> RuleConfig
RuleConfig'
(RuleType -> Bool -> Int -> RuleConfig)
-> Parser RuleType -> Parser (Bool -> Int -> RuleConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser RuleType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Type")
Parser (Bool -> Int -> RuleConfig)
-> Parser Bool -> Parser (Int -> RuleConfig)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Bool
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Inverted")
Parser (Int -> RuleConfig) -> Parser Int -> Parser RuleConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Int
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Threshold")
)
instance Prelude.Hashable RuleConfig
instance Prelude.NFData RuleConfig
instance Core.ToJSON RuleConfig where
toJSON :: RuleConfig -> Value
toJSON RuleConfig' {Bool
Int
RuleType
threshold :: Int
inverted :: Bool
type' :: RuleType
$sel:threshold:RuleConfig' :: RuleConfig -> Int
$sel:inverted:RuleConfig' :: RuleConfig -> Bool
$sel:type':RuleConfig' :: RuleConfig -> RuleType
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Type" Text -> RuleType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RuleType
type'),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Inverted" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Bool
inverted),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Threshold" Text -> Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Int
threshold)
]
)