{-# 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.Rule where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.Route53RecoveryControlConfig.Types.AssertionRule
import Amazonka.Route53RecoveryControlConfig.Types.GatingRule
data Rule = Rule'
{
Rule -> Maybe GatingRule
gating :: Prelude.Maybe GatingRule,
Rule -> Maybe AssertionRule
assertion :: Prelude.Maybe AssertionRule
}
deriving (Rule -> Rule -> Bool
(Rule -> Rule -> Bool) -> (Rule -> Rule -> Bool) -> Eq Rule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Rule -> Rule -> Bool
$c/= :: Rule -> Rule -> Bool
== :: Rule -> Rule -> Bool
$c== :: Rule -> Rule -> Bool
Prelude.Eq, ReadPrec [Rule]
ReadPrec Rule
Int -> ReadS Rule
ReadS [Rule]
(Int -> ReadS Rule)
-> ReadS [Rule] -> ReadPrec Rule -> ReadPrec [Rule] -> Read Rule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Rule]
$creadListPrec :: ReadPrec [Rule]
readPrec :: ReadPrec Rule
$creadPrec :: ReadPrec Rule
readList :: ReadS [Rule]
$creadList :: ReadS [Rule]
readsPrec :: Int -> ReadS Rule
$creadsPrec :: Int -> ReadS Rule
Prelude.Read, Int -> Rule -> ShowS
[Rule] -> ShowS
Rule -> String
(Int -> Rule -> ShowS)
-> (Rule -> String) -> ([Rule] -> ShowS) -> Show Rule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Rule] -> ShowS
$cshowList :: [Rule] -> ShowS
show :: Rule -> String
$cshow :: Rule -> String
showsPrec :: Int -> Rule -> ShowS
$cshowsPrec :: Int -> Rule -> ShowS
Prelude.Show, (forall x. Rule -> Rep Rule x)
-> (forall x. Rep Rule x -> Rule) -> Generic Rule
forall x. Rep Rule x -> Rule
forall x. Rule -> Rep Rule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Rule x -> Rule
$cfrom :: forall x. Rule -> Rep Rule x
Prelude.Generic)
newRule ::
Rule
newRule :: Rule
newRule =
Rule' :: Maybe GatingRule -> Maybe AssertionRule -> Rule
Rule'
{ $sel:gating:Rule' :: Maybe GatingRule
gating = Maybe GatingRule
forall a. Maybe a
Prelude.Nothing,
$sel:assertion:Rule' :: Maybe AssertionRule
assertion = Maybe AssertionRule
forall a. Maybe a
Prelude.Nothing
}
rule_gating :: Lens.Lens' Rule (Prelude.Maybe GatingRule)
rule_gating :: (Maybe GatingRule -> f (Maybe GatingRule)) -> Rule -> f Rule
rule_gating = (Rule -> Maybe GatingRule)
-> (Rule -> Maybe GatingRule -> Rule)
-> Lens Rule Rule (Maybe GatingRule) (Maybe GatingRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {Maybe GatingRule
gating :: Maybe GatingRule
$sel:gating:Rule' :: Rule -> Maybe GatingRule
gating} -> Maybe GatingRule
gating) (\s :: Rule
s@Rule' {} Maybe GatingRule
a -> Rule
s {$sel:gating:Rule' :: Maybe GatingRule
gating = Maybe GatingRule
a} :: Rule)
rule_assertion :: Lens.Lens' Rule (Prelude.Maybe AssertionRule)
rule_assertion :: (Maybe AssertionRule -> f (Maybe AssertionRule)) -> Rule -> f Rule
rule_assertion = (Rule -> Maybe AssertionRule)
-> (Rule -> Maybe AssertionRule -> Rule)
-> Lens Rule Rule (Maybe AssertionRule) (Maybe AssertionRule)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Rule' {Maybe AssertionRule
assertion :: Maybe AssertionRule
$sel:assertion:Rule' :: Rule -> Maybe AssertionRule
assertion} -> Maybe AssertionRule
assertion) (\s :: Rule
s@Rule' {} Maybe AssertionRule
a -> Rule
s {$sel:assertion:Rule' :: Maybe AssertionRule
assertion = Maybe AssertionRule
a} :: Rule)
instance Core.FromJSON Rule where
parseJSON :: Value -> Parser Rule
parseJSON =
String -> (Object -> Parser Rule) -> Value -> Parser Rule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Rule"
( \Object
x ->
Maybe GatingRule -> Maybe AssertionRule -> Rule
Rule'
(Maybe GatingRule -> Maybe AssertionRule -> Rule)
-> Parser (Maybe GatingRule)
-> Parser (Maybe AssertionRule -> Rule)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe GatingRule)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"GATING")
Parser (Maybe AssertionRule -> Rule)
-> Parser (Maybe AssertionRule) -> Parser Rule
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe AssertionRule)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"ASSERTION")
)
instance Prelude.Hashable Rule
instance Prelude.NFData Rule