{-# 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.RuleGroup where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.NetworkFirewall.Types.RuleVariables
import Amazonka.NetworkFirewall.Types.RulesSource
import Amazonka.NetworkFirewall.Types.StatefulRuleOptions
import qualified Amazonka.Prelude as Prelude
data RuleGroup = RuleGroup'
{
RuleGroup -> Maybe StatefulRuleOptions
statefulRuleOptions :: Prelude.Maybe StatefulRuleOptions,
RuleGroup -> Maybe RuleVariables
ruleVariables :: Prelude.Maybe RuleVariables,
RuleGroup -> RulesSource
rulesSource :: RulesSource
}
deriving (RuleGroup -> RuleGroup -> Bool
(RuleGroup -> RuleGroup -> Bool)
-> (RuleGroup -> RuleGroup -> Bool) -> Eq RuleGroup
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: RuleGroup -> RuleGroup -> Bool
$c/= :: RuleGroup -> RuleGroup -> Bool
== :: RuleGroup -> RuleGroup -> Bool
$c== :: RuleGroup -> RuleGroup -> Bool
Prelude.Eq, ReadPrec [RuleGroup]
ReadPrec RuleGroup
Int -> ReadS RuleGroup
ReadS [RuleGroup]
(Int -> ReadS RuleGroup)
-> ReadS [RuleGroup]
-> ReadPrec RuleGroup
-> ReadPrec [RuleGroup]
-> Read RuleGroup
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [RuleGroup]
$creadListPrec :: ReadPrec [RuleGroup]
readPrec :: ReadPrec RuleGroup
$creadPrec :: ReadPrec RuleGroup
readList :: ReadS [RuleGroup]
$creadList :: ReadS [RuleGroup]
readsPrec :: Int -> ReadS RuleGroup
$creadsPrec :: Int -> ReadS RuleGroup
Prelude.Read, Int -> RuleGroup -> ShowS
[RuleGroup] -> ShowS
RuleGroup -> String
(Int -> RuleGroup -> ShowS)
-> (RuleGroup -> String)
-> ([RuleGroup] -> ShowS)
-> Show RuleGroup
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [RuleGroup] -> ShowS
$cshowList :: [RuleGroup] -> ShowS
show :: RuleGroup -> String
$cshow :: RuleGroup -> String
showsPrec :: Int -> RuleGroup -> ShowS
$cshowsPrec :: Int -> RuleGroup -> ShowS
Prelude.Show, (forall x. RuleGroup -> Rep RuleGroup x)
-> (forall x. Rep RuleGroup x -> RuleGroup) -> Generic RuleGroup
forall x. Rep RuleGroup x -> RuleGroup
forall x. RuleGroup -> Rep RuleGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep RuleGroup x -> RuleGroup
$cfrom :: forall x. RuleGroup -> Rep RuleGroup x
Prelude.Generic)
newRuleGroup ::
RulesSource ->
RuleGroup
newRuleGroup :: RulesSource -> RuleGroup
newRuleGroup RulesSource
pRulesSource_ =
RuleGroup' :: Maybe StatefulRuleOptions
-> Maybe RuleVariables -> RulesSource -> RuleGroup
RuleGroup'
{ $sel:statefulRuleOptions:RuleGroup' :: Maybe StatefulRuleOptions
statefulRuleOptions = Maybe StatefulRuleOptions
forall a. Maybe a
Prelude.Nothing,
$sel:ruleVariables:RuleGroup' :: Maybe RuleVariables
ruleVariables = Maybe RuleVariables
forall a. Maybe a
Prelude.Nothing,
$sel:rulesSource:RuleGroup' :: RulesSource
rulesSource = RulesSource
pRulesSource_
}
ruleGroup_statefulRuleOptions :: Lens.Lens' RuleGroup (Prelude.Maybe StatefulRuleOptions)
ruleGroup_statefulRuleOptions :: (Maybe StatefulRuleOptions -> f (Maybe StatefulRuleOptions))
-> RuleGroup -> f RuleGroup
ruleGroup_statefulRuleOptions = (RuleGroup -> Maybe StatefulRuleOptions)
-> (RuleGroup -> Maybe StatefulRuleOptions -> RuleGroup)
-> Lens
RuleGroup
RuleGroup
(Maybe StatefulRuleOptions)
(Maybe StatefulRuleOptions)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleGroup' {Maybe StatefulRuleOptions
statefulRuleOptions :: Maybe StatefulRuleOptions
$sel:statefulRuleOptions:RuleGroup' :: RuleGroup -> Maybe StatefulRuleOptions
statefulRuleOptions} -> Maybe StatefulRuleOptions
statefulRuleOptions) (\s :: RuleGroup
s@RuleGroup' {} Maybe StatefulRuleOptions
a -> RuleGroup
s {$sel:statefulRuleOptions:RuleGroup' :: Maybe StatefulRuleOptions
statefulRuleOptions = Maybe StatefulRuleOptions
a} :: RuleGroup)
ruleGroup_ruleVariables :: Lens.Lens' RuleGroup (Prelude.Maybe RuleVariables)
ruleGroup_ruleVariables :: (Maybe RuleVariables -> f (Maybe RuleVariables))
-> RuleGroup -> f RuleGroup
ruleGroup_ruleVariables = (RuleGroup -> Maybe RuleVariables)
-> (RuleGroup -> Maybe RuleVariables -> RuleGroup)
-> Lens
RuleGroup RuleGroup (Maybe RuleVariables) (Maybe RuleVariables)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleGroup' {Maybe RuleVariables
ruleVariables :: Maybe RuleVariables
$sel:ruleVariables:RuleGroup' :: RuleGroup -> Maybe RuleVariables
ruleVariables} -> Maybe RuleVariables
ruleVariables) (\s :: RuleGroup
s@RuleGroup' {} Maybe RuleVariables
a -> RuleGroup
s {$sel:ruleVariables:RuleGroup' :: Maybe RuleVariables
ruleVariables = Maybe RuleVariables
a} :: RuleGroup)
ruleGroup_rulesSource :: Lens.Lens' RuleGroup RulesSource
ruleGroup_rulesSource :: (RulesSource -> f RulesSource) -> RuleGroup -> f RuleGroup
ruleGroup_rulesSource = (RuleGroup -> RulesSource)
-> (RuleGroup -> RulesSource -> RuleGroup)
-> Lens RuleGroup RuleGroup RulesSource RulesSource
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\RuleGroup' {RulesSource
rulesSource :: RulesSource
$sel:rulesSource:RuleGroup' :: RuleGroup -> RulesSource
rulesSource} -> RulesSource
rulesSource) (\s :: RuleGroup
s@RuleGroup' {} RulesSource
a -> RuleGroup
s {$sel:rulesSource:RuleGroup' :: RulesSource
rulesSource = RulesSource
a} :: RuleGroup)
instance Core.FromJSON RuleGroup where
parseJSON :: Value -> Parser RuleGroup
parseJSON =
String -> (Object -> Parser RuleGroup) -> Value -> Parser RuleGroup
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"RuleGroup"
( \Object
x ->
Maybe StatefulRuleOptions
-> Maybe RuleVariables -> RulesSource -> RuleGroup
RuleGroup'
(Maybe StatefulRuleOptions
-> Maybe RuleVariables -> RulesSource -> RuleGroup)
-> Parser (Maybe StatefulRuleOptions)
-> Parser (Maybe RuleVariables -> RulesSource -> RuleGroup)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe StatefulRuleOptions)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StatefulRuleOptions")
Parser (Maybe RuleVariables -> RulesSource -> RuleGroup)
-> Parser (Maybe RuleVariables)
-> Parser (RulesSource -> RuleGroup)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe RuleVariables)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"RuleVariables")
Parser (RulesSource -> RuleGroup)
-> Parser RulesSource -> Parser RuleGroup
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser RulesSource
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"RulesSource")
)
instance Prelude.Hashable RuleGroup
instance Prelude.NFData RuleGroup
instance Core.ToJSON RuleGroup where
toJSON :: RuleGroup -> Value
toJSON RuleGroup' {Maybe RuleVariables
Maybe StatefulRuleOptions
RulesSource
rulesSource :: RulesSource
ruleVariables :: Maybe RuleVariables
statefulRuleOptions :: Maybe StatefulRuleOptions
$sel:rulesSource:RuleGroup' :: RuleGroup -> RulesSource
$sel:ruleVariables:RuleGroup' :: RuleGroup -> Maybe RuleVariables
$sel:statefulRuleOptions:RuleGroup' :: RuleGroup -> Maybe StatefulRuleOptions
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"StatefulRuleOptions" Text -> StatefulRuleOptions -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
(StatefulRuleOptions -> Pair)
-> Maybe StatefulRuleOptions -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StatefulRuleOptions
statefulRuleOptions,
(Text
"RuleVariables" Text -> RuleVariables -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (RuleVariables -> Pair) -> Maybe RuleVariables -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe RuleVariables
ruleVariables,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RulesSource" Text -> RulesSource -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= RulesSource
rulesSource)
]
)