{-# 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.NetworkFirewall.Types.StatelessRule where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.NetworkFirewall.Types.RuleDefinition
import qualified Amazonka.Prelude as Prelude
data StatelessRule = StatelessRule'
{
StatelessRule -> RuleDefinition
ruleDefinition :: RuleDefinition,
StatelessRule -> Natural
priority :: Prelude.Natural
}
deriving (StatelessRule -> StatelessRule -> Bool
(StatelessRule -> StatelessRule -> Bool)
-> (StatelessRule -> StatelessRule -> Bool) -> Eq StatelessRule
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StatelessRule -> StatelessRule -> Bool
$c/= :: StatelessRule -> StatelessRule -> Bool
== :: StatelessRule -> StatelessRule -> Bool
$c== :: StatelessRule -> StatelessRule -> Bool
Prelude.Eq, ReadPrec [StatelessRule]
ReadPrec StatelessRule
Int -> ReadS StatelessRule
ReadS [StatelessRule]
(Int -> ReadS StatelessRule)
-> ReadS [StatelessRule]
-> ReadPrec StatelessRule
-> ReadPrec [StatelessRule]
-> Read StatelessRule
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StatelessRule]
$creadListPrec :: ReadPrec [StatelessRule]
readPrec :: ReadPrec StatelessRule
$creadPrec :: ReadPrec StatelessRule
readList :: ReadS [StatelessRule]
$creadList :: ReadS [StatelessRule]
readsPrec :: Int -> ReadS StatelessRule
$creadsPrec :: Int -> ReadS StatelessRule
Prelude.Read, Int -> StatelessRule -> ShowS
[StatelessRule] -> ShowS
StatelessRule -> String
(Int -> StatelessRule -> ShowS)
-> (StatelessRule -> String)
-> ([StatelessRule] -> ShowS)
-> Show StatelessRule
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StatelessRule] -> ShowS
$cshowList :: [StatelessRule] -> ShowS
show :: StatelessRule -> String
$cshow :: StatelessRule -> String
showsPrec :: Int -> StatelessRule -> ShowS
$cshowsPrec :: Int -> StatelessRule -> ShowS
Prelude.Show, (forall x. StatelessRule -> Rep StatelessRule x)
-> (forall x. Rep StatelessRule x -> StatelessRule)
-> Generic StatelessRule
forall x. Rep StatelessRule x -> StatelessRule
forall x. StatelessRule -> Rep StatelessRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StatelessRule x -> StatelessRule
$cfrom :: forall x. StatelessRule -> Rep StatelessRule x
Prelude.Generic)
newStatelessRule ::
RuleDefinition ->
Prelude.Natural ->
StatelessRule
newStatelessRule :: RuleDefinition -> Natural -> StatelessRule
newStatelessRule RuleDefinition
pRuleDefinition_ Natural
pPriority_ =
StatelessRule' :: RuleDefinition -> Natural -> StatelessRule
StatelessRule'
{ $sel:ruleDefinition:StatelessRule' :: RuleDefinition
ruleDefinition = RuleDefinition
pRuleDefinition_,
$sel:priority:StatelessRule' :: Natural
priority = Natural
pPriority_
}
statelessRule_ruleDefinition :: Lens.Lens' StatelessRule RuleDefinition
statelessRule_ruleDefinition :: (RuleDefinition -> f RuleDefinition)
-> StatelessRule -> f StatelessRule
statelessRule_ruleDefinition = (StatelessRule -> RuleDefinition)
-> (StatelessRule -> RuleDefinition -> StatelessRule)
-> Lens StatelessRule StatelessRule RuleDefinition RuleDefinition
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatelessRule' {RuleDefinition
ruleDefinition :: RuleDefinition
$sel:ruleDefinition:StatelessRule' :: StatelessRule -> RuleDefinition
ruleDefinition} -> RuleDefinition
ruleDefinition) (\s :: StatelessRule
s@StatelessRule' {} RuleDefinition
a -> StatelessRule
s {$sel:ruleDefinition:StatelessRule' :: RuleDefinition
ruleDefinition = RuleDefinition
a} :: StatelessRule)
statelessRule_priority :: Lens.Lens' StatelessRule Prelude.Natural
statelessRule_priority :: (Natural -> f Natural) -> StatelessRule -> f StatelessRule
statelessRule_priority = (StatelessRule -> Natural)
-> (StatelessRule -> Natural -> StatelessRule)
-> Lens StatelessRule StatelessRule Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatelessRule' {Natural
priority :: Natural
$sel:priority:StatelessRule' :: StatelessRule -> Natural
priority} -> Natural
priority) (\s :: StatelessRule
s@StatelessRule' {} Natural
a -> StatelessRule
s {$sel:priority:StatelessRule' :: Natural
priority = Natural
a} :: StatelessRule)
instance Core.FromJSON StatelessRule where
parseJSON :: Value -> Parser StatelessRule
parseJSON =
String
-> (Object -> Parser StatelessRule)
-> Value
-> Parser StatelessRule
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"StatelessRule"
( \Object
x ->
RuleDefinition -> Natural -> StatelessRule
StatelessRule'
(RuleDefinition -> Natural -> StatelessRule)
-> Parser RuleDefinition -> Parser (Natural -> StatelessRule)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser RuleDefinition
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"RuleDefinition")
Parser (Natural -> StatelessRule)
-> Parser Natural -> Parser StatelessRule
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Priority")
)
instance Prelude.Hashable StatelessRule
instance Prelude.NFData StatelessRule
instance Core.ToJSON StatelessRule where
toJSON :: StatelessRule -> Value
toJSON StatelessRule' {Natural
RuleDefinition
priority :: Natural
ruleDefinition :: RuleDefinition
$sel:priority:StatelessRule' :: StatelessRule -> Natural
$sel:ruleDefinition:StatelessRule' :: StatelessRule -> RuleDefinition
..} =
[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
"RuleDefinition" Text -> RuleDefinition -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RuleDefinition
ruleDefinition),
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Priority" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
priority)
]
)