{-# 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.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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
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]
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
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. 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'
{ $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 :: Lens' RuleConfig RuleType
ruleConfig_type = 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 :: Lens' RuleConfig Bool
ruleConfig_inverted = 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 :: Lens' RuleConfig Int
ruleConfig_threshold = 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 Data.FromJSON RuleConfig where
parseJSON :: Value -> Parser RuleConfig
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"RuleConfig"
( \Object
x ->
RuleType -> Bool -> Int -> RuleConfig
RuleConfig'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Type")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Inverted")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Threshold")
)
instance Prelude.Hashable RuleConfig where
hashWithSalt :: Int -> RuleConfig -> Int
hashWithSalt Int
_salt 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
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` RuleType
type'
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Bool
inverted
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Int
threshold
instance Prelude.NFData RuleConfig where
rnf :: RuleConfig -> ()
rnf 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
..} =
forall a. NFData a => a -> ()
Prelude.rnf RuleType
type'
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Bool
inverted
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
threshold
instance Data.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
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ forall a. a -> Maybe a
Prelude.Just (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= RuleType
type'),
forall a. a -> Maybe a
Prelude.Just (Key
"Inverted" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Bool
inverted),
forall a. a -> Maybe a
Prelude.Just (Key
"Threshold" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Int
threshold)
]
)