{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.FMS.Types.StatefulRuleGroup
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.FMS.Types.StatefulRuleGroup where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.FMS.Types.NetworkFirewallStatefulRuleGroupOverride
import qualified Amazonka.Prelude as Prelude

-- | Network Firewall stateful rule group, used in a
-- NetworkFirewallPolicyDescription.
--
-- /See:/ 'newStatefulRuleGroup' smart constructor.
data StatefulRuleGroup = StatefulRuleGroup'
  { -- | The action that allows the policy owner to override the behavior of the
    -- rule group within a policy.
    StatefulRuleGroup -> Maybe NetworkFirewallStatefulRuleGroupOverride
override :: Prelude.Maybe NetworkFirewallStatefulRuleGroupOverride,
    -- | An integer setting that indicates the order in which to run the stateful
    -- rule groups in a single Network Firewall firewall policy. This setting
    -- only applies to firewall policies that specify the @STRICT_ORDER@ rule
    -- order in the stateful engine options settings.
    --
    -- Network Firewall evalutes each stateful rule group against a packet
    -- starting with the group that has the lowest priority setting. You must
    -- ensure that the priority settings are unique within each policy. For
    -- information about
    --
    -- You can change the priority settings of your rule groups at any time. To
    -- make it easier to insert rule groups later, number them so there\'s a
    -- wide range in between, for example use 100, 200, and so on.
    StatefulRuleGroup -> Maybe Int
priority :: Prelude.Maybe Prelude.Int,
    -- | The resource ID of the rule group.
    StatefulRuleGroup -> Maybe Text
resourceId :: Prelude.Maybe Prelude.Text,
    -- | The name of the rule group.
    StatefulRuleGroup -> Maybe Text
ruleGroupName :: Prelude.Maybe Prelude.Text
  }
  deriving (StatefulRuleGroup -> StatefulRuleGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StatefulRuleGroup -> StatefulRuleGroup -> Bool
$c/= :: StatefulRuleGroup -> StatefulRuleGroup -> Bool
== :: StatefulRuleGroup -> StatefulRuleGroup -> Bool
$c== :: StatefulRuleGroup -> StatefulRuleGroup -> Bool
Prelude.Eq, ReadPrec [StatefulRuleGroup]
ReadPrec StatefulRuleGroup
Int -> ReadS StatefulRuleGroup
ReadS [StatefulRuleGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StatefulRuleGroup]
$creadListPrec :: ReadPrec [StatefulRuleGroup]
readPrec :: ReadPrec StatefulRuleGroup
$creadPrec :: ReadPrec StatefulRuleGroup
readList :: ReadS [StatefulRuleGroup]
$creadList :: ReadS [StatefulRuleGroup]
readsPrec :: Int -> ReadS StatefulRuleGroup
$creadsPrec :: Int -> ReadS StatefulRuleGroup
Prelude.Read, Int -> StatefulRuleGroup -> ShowS
[StatefulRuleGroup] -> ShowS
StatefulRuleGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StatefulRuleGroup] -> ShowS
$cshowList :: [StatefulRuleGroup] -> ShowS
show :: StatefulRuleGroup -> String
$cshow :: StatefulRuleGroup -> String
showsPrec :: Int -> StatefulRuleGroup -> ShowS
$cshowsPrec :: Int -> StatefulRuleGroup -> ShowS
Prelude.Show, forall x. Rep StatefulRuleGroup x -> StatefulRuleGroup
forall x. StatefulRuleGroup -> Rep StatefulRuleGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep StatefulRuleGroup x -> StatefulRuleGroup
$cfrom :: forall x. StatefulRuleGroup -> Rep StatefulRuleGroup x
Prelude.Generic)

-- |
-- Create a value of 'StatefulRuleGroup' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'override', 'statefulRuleGroup_override' - The action that allows the policy owner to override the behavior of the
-- rule group within a policy.
--
-- 'priority', 'statefulRuleGroup_priority' - An integer setting that indicates the order in which to run the stateful
-- rule groups in a single Network Firewall firewall policy. This setting
-- only applies to firewall policies that specify the @STRICT_ORDER@ rule
-- order in the stateful engine options settings.
--
-- Network Firewall evalutes each stateful rule group against a packet
-- starting with the group that has the lowest priority setting. You must
-- ensure that the priority settings are unique within each policy. For
-- information about
--
-- You can change the priority settings of your rule groups at any time. To
-- make it easier to insert rule groups later, number them so there\'s a
-- wide range in between, for example use 100, 200, and so on.
--
-- 'resourceId', 'statefulRuleGroup_resourceId' - The resource ID of the rule group.
--
-- 'ruleGroupName', 'statefulRuleGroup_ruleGroupName' - The name of the rule group.
newStatefulRuleGroup ::
  StatefulRuleGroup
newStatefulRuleGroup :: StatefulRuleGroup
newStatefulRuleGroup =
  StatefulRuleGroup'
    { $sel:override:StatefulRuleGroup' :: Maybe NetworkFirewallStatefulRuleGroupOverride
override = forall a. Maybe a
Prelude.Nothing,
      $sel:priority:StatefulRuleGroup' :: Maybe Int
priority = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceId:StatefulRuleGroup' :: Maybe Text
resourceId = forall a. Maybe a
Prelude.Nothing,
      $sel:ruleGroupName:StatefulRuleGroup' :: Maybe Text
ruleGroupName = forall a. Maybe a
Prelude.Nothing
    }

-- | The action that allows the policy owner to override the behavior of the
-- rule group within a policy.
statefulRuleGroup_override :: Lens.Lens' StatefulRuleGroup (Prelude.Maybe NetworkFirewallStatefulRuleGroupOverride)
statefulRuleGroup_override :: Lens'
  StatefulRuleGroup (Maybe NetworkFirewallStatefulRuleGroupOverride)
statefulRuleGroup_override = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatefulRuleGroup' {Maybe NetworkFirewallStatefulRuleGroupOverride
override :: Maybe NetworkFirewallStatefulRuleGroupOverride
$sel:override:StatefulRuleGroup' :: StatefulRuleGroup -> Maybe NetworkFirewallStatefulRuleGroupOverride
override} -> Maybe NetworkFirewallStatefulRuleGroupOverride
override) (\s :: StatefulRuleGroup
s@StatefulRuleGroup' {} Maybe NetworkFirewallStatefulRuleGroupOverride
a -> StatefulRuleGroup
s {$sel:override:StatefulRuleGroup' :: Maybe NetworkFirewallStatefulRuleGroupOverride
override = Maybe NetworkFirewallStatefulRuleGroupOverride
a} :: StatefulRuleGroup)

-- | An integer setting that indicates the order in which to run the stateful
-- rule groups in a single Network Firewall firewall policy. This setting
-- only applies to firewall policies that specify the @STRICT_ORDER@ rule
-- order in the stateful engine options settings.
--
-- Network Firewall evalutes each stateful rule group against a packet
-- starting with the group that has the lowest priority setting. You must
-- ensure that the priority settings are unique within each policy. For
-- information about
--
-- You can change the priority settings of your rule groups at any time. To
-- make it easier to insert rule groups later, number them so there\'s a
-- wide range in between, for example use 100, 200, and so on.
statefulRuleGroup_priority :: Lens.Lens' StatefulRuleGroup (Prelude.Maybe Prelude.Int)
statefulRuleGroup_priority :: Lens' StatefulRuleGroup (Maybe Int)
statefulRuleGroup_priority = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatefulRuleGroup' {Maybe Int
priority :: Maybe Int
$sel:priority:StatefulRuleGroup' :: StatefulRuleGroup -> Maybe Int
priority} -> Maybe Int
priority) (\s :: StatefulRuleGroup
s@StatefulRuleGroup' {} Maybe Int
a -> StatefulRuleGroup
s {$sel:priority:StatefulRuleGroup' :: Maybe Int
priority = Maybe Int
a} :: StatefulRuleGroup)

-- | The resource ID of the rule group.
statefulRuleGroup_resourceId :: Lens.Lens' StatefulRuleGroup (Prelude.Maybe Prelude.Text)
statefulRuleGroup_resourceId :: Lens' StatefulRuleGroup (Maybe Text)
statefulRuleGroup_resourceId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatefulRuleGroup' {Maybe Text
resourceId :: Maybe Text
$sel:resourceId:StatefulRuleGroup' :: StatefulRuleGroup -> Maybe Text
resourceId} -> Maybe Text
resourceId) (\s :: StatefulRuleGroup
s@StatefulRuleGroup' {} Maybe Text
a -> StatefulRuleGroup
s {$sel:resourceId:StatefulRuleGroup' :: Maybe Text
resourceId = Maybe Text
a} :: StatefulRuleGroup)

-- | The name of the rule group.
statefulRuleGroup_ruleGroupName :: Lens.Lens' StatefulRuleGroup (Prelude.Maybe Prelude.Text)
statefulRuleGroup_ruleGroupName :: Lens' StatefulRuleGroup (Maybe Text)
statefulRuleGroup_ruleGroupName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatefulRuleGroup' {Maybe Text
ruleGroupName :: Maybe Text
$sel:ruleGroupName:StatefulRuleGroup' :: StatefulRuleGroup -> Maybe Text
ruleGroupName} -> Maybe Text
ruleGroupName) (\s :: StatefulRuleGroup
s@StatefulRuleGroup' {} Maybe Text
a -> StatefulRuleGroup
s {$sel:ruleGroupName:StatefulRuleGroup' :: Maybe Text
ruleGroupName = Maybe Text
a} :: StatefulRuleGroup)

instance Data.FromJSON StatefulRuleGroup where
  parseJSON :: Value -> Parser StatefulRuleGroup
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"StatefulRuleGroup"
      ( \Object
x ->
          Maybe NetworkFirewallStatefulRuleGroupOverride
-> Maybe Int -> Maybe Text -> Maybe Text -> StatefulRuleGroup
StatefulRuleGroup'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Override")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Priority")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"ResourceId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"RuleGroupName")
      )

instance Prelude.Hashable StatefulRuleGroup where
  hashWithSalt :: Int -> StatefulRuleGroup -> Int
hashWithSalt Int
_salt StatefulRuleGroup' {Maybe Int
Maybe Text
Maybe NetworkFirewallStatefulRuleGroupOverride
ruleGroupName :: Maybe Text
resourceId :: Maybe Text
priority :: Maybe Int
override :: Maybe NetworkFirewallStatefulRuleGroupOverride
$sel:ruleGroupName:StatefulRuleGroup' :: StatefulRuleGroup -> Maybe Text
$sel:resourceId:StatefulRuleGroup' :: StatefulRuleGroup -> Maybe Text
$sel:priority:StatefulRuleGroup' :: StatefulRuleGroup -> Maybe Int
$sel:override:StatefulRuleGroup' :: StatefulRuleGroup -> Maybe NetworkFirewallStatefulRuleGroupOverride
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe NetworkFirewallStatefulRuleGroupOverride
override
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Int
priority
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
resourceId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
ruleGroupName

instance Prelude.NFData StatefulRuleGroup where
  rnf :: StatefulRuleGroup -> ()
rnf StatefulRuleGroup' {Maybe Int
Maybe Text
Maybe NetworkFirewallStatefulRuleGroupOverride
ruleGroupName :: Maybe Text
resourceId :: Maybe Text
priority :: Maybe Int
override :: Maybe NetworkFirewallStatefulRuleGroupOverride
$sel:ruleGroupName:StatefulRuleGroup' :: StatefulRuleGroup -> Maybe Text
$sel:resourceId:StatefulRuleGroup' :: StatefulRuleGroup -> Maybe Text
$sel:priority:StatefulRuleGroup' :: StatefulRuleGroup -> Maybe Int
$sel:override:StatefulRuleGroup' :: StatefulRuleGroup -> Maybe NetworkFirewallStatefulRuleGroupOverride
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe NetworkFirewallStatefulRuleGroupOverride
override
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Int
priority
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
ruleGroupName