{-# 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.NetworkFirewall.Types.StatefulRuleGroupReference
-- 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.NetworkFirewall.Types.StatefulRuleGroupReference where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.NetworkFirewall.Types.StatefulRuleGroupOverride
import qualified Amazonka.Prelude as Prelude

-- | Identifier for a single stateful rule group, used in a firewall policy
-- to refer to a rule group.
--
-- /See:/ 'newStatefulRuleGroupReference' smart constructor.
data StatefulRuleGroupReference = StatefulRuleGroupReference'
  { -- | The action that allows the policy owner to override the behavior of the
    -- rule group within a policy.
    StatefulRuleGroupReference -> Maybe StatefulRuleGroupOverride
override :: Prelude.Maybe StatefulRuleGroupOverride,
    -- | An integer setting that indicates the order in which to run the stateful
    -- rule groups in a single FirewallPolicy. 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.
    --
    -- 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.
    StatefulRuleGroupReference -> Maybe Natural
priority :: Prelude.Maybe Prelude.Natural,
    -- | The Amazon Resource Name (ARN) of the stateful rule group.
    StatefulRuleGroupReference -> Text
resourceArn :: Prelude.Text
  }
  deriving (StatefulRuleGroupReference -> StatefulRuleGroupReference -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: StatefulRuleGroupReference -> StatefulRuleGroupReference -> Bool
$c/= :: StatefulRuleGroupReference -> StatefulRuleGroupReference -> Bool
== :: StatefulRuleGroupReference -> StatefulRuleGroupReference -> Bool
$c== :: StatefulRuleGroupReference -> StatefulRuleGroupReference -> Bool
Prelude.Eq, ReadPrec [StatefulRuleGroupReference]
ReadPrec StatefulRuleGroupReference
Int -> ReadS StatefulRuleGroupReference
ReadS [StatefulRuleGroupReference]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [StatefulRuleGroupReference]
$creadListPrec :: ReadPrec [StatefulRuleGroupReference]
readPrec :: ReadPrec StatefulRuleGroupReference
$creadPrec :: ReadPrec StatefulRuleGroupReference
readList :: ReadS [StatefulRuleGroupReference]
$creadList :: ReadS [StatefulRuleGroupReference]
readsPrec :: Int -> ReadS StatefulRuleGroupReference
$creadsPrec :: Int -> ReadS StatefulRuleGroupReference
Prelude.Read, Int -> StatefulRuleGroupReference -> ShowS
[StatefulRuleGroupReference] -> ShowS
StatefulRuleGroupReference -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [StatefulRuleGroupReference] -> ShowS
$cshowList :: [StatefulRuleGroupReference] -> ShowS
show :: StatefulRuleGroupReference -> String
$cshow :: StatefulRuleGroupReference -> String
showsPrec :: Int -> StatefulRuleGroupReference -> ShowS
$cshowsPrec :: Int -> StatefulRuleGroupReference -> ShowS
Prelude.Show, forall x.
Rep StatefulRuleGroupReference x -> StatefulRuleGroupReference
forall x.
StatefulRuleGroupReference -> Rep StatefulRuleGroupReference x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep StatefulRuleGroupReference x -> StatefulRuleGroupReference
$cfrom :: forall x.
StatefulRuleGroupReference -> Rep StatefulRuleGroupReference x
Prelude.Generic)

-- |
-- Create a value of 'StatefulRuleGroupReference' 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', 'statefulRuleGroupReference_override' - The action that allows the policy owner to override the behavior of the
-- rule group within a policy.
--
-- 'priority', 'statefulRuleGroupReference_priority' - An integer setting that indicates the order in which to run the stateful
-- rule groups in a single FirewallPolicy. 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.
--
-- 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.
--
-- 'resourceArn', 'statefulRuleGroupReference_resourceArn' - The Amazon Resource Name (ARN) of the stateful rule group.
newStatefulRuleGroupReference ::
  -- | 'resourceArn'
  Prelude.Text ->
  StatefulRuleGroupReference
newStatefulRuleGroupReference :: Text -> StatefulRuleGroupReference
newStatefulRuleGroupReference Text
pResourceArn_ =
  StatefulRuleGroupReference'
    { $sel:override:StatefulRuleGroupReference' :: Maybe StatefulRuleGroupOverride
override =
        forall a. Maybe a
Prelude.Nothing,
      $sel:priority:StatefulRuleGroupReference' :: Maybe Natural
priority = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:StatefulRuleGroupReference' :: Text
resourceArn = Text
pResourceArn_
    }

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

-- | An integer setting that indicates the order in which to run the stateful
-- rule groups in a single FirewallPolicy. 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.
--
-- 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.
statefulRuleGroupReference_priority :: Lens.Lens' StatefulRuleGroupReference (Prelude.Maybe Prelude.Natural)
statefulRuleGroupReference_priority :: Lens' StatefulRuleGroupReference (Maybe Natural)
statefulRuleGroupReference_priority = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatefulRuleGroupReference' {Maybe Natural
priority :: Maybe Natural
$sel:priority:StatefulRuleGroupReference' :: StatefulRuleGroupReference -> Maybe Natural
priority} -> Maybe Natural
priority) (\s :: StatefulRuleGroupReference
s@StatefulRuleGroupReference' {} Maybe Natural
a -> StatefulRuleGroupReference
s {$sel:priority:StatefulRuleGroupReference' :: Maybe Natural
priority = Maybe Natural
a} :: StatefulRuleGroupReference)

-- | The Amazon Resource Name (ARN) of the stateful rule group.
statefulRuleGroupReference_resourceArn :: Lens.Lens' StatefulRuleGroupReference Prelude.Text
statefulRuleGroupReference_resourceArn :: Lens' StatefulRuleGroupReference Text
statefulRuleGroupReference_resourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\StatefulRuleGroupReference' {Text
resourceArn :: Text
$sel:resourceArn:StatefulRuleGroupReference' :: StatefulRuleGroupReference -> Text
resourceArn} -> Text
resourceArn) (\s :: StatefulRuleGroupReference
s@StatefulRuleGroupReference' {} Text
a -> StatefulRuleGroupReference
s {$sel:resourceArn:StatefulRuleGroupReference' :: Text
resourceArn = Text
a} :: StatefulRuleGroupReference)

instance Data.FromJSON StatefulRuleGroupReference where
  parseJSON :: Value -> Parser StatefulRuleGroupReference
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"StatefulRuleGroupReference"
      ( \Object
x ->
          Maybe StatefulRuleGroupOverride
-> Maybe Natural -> Text -> StatefulRuleGroupReference
StatefulRuleGroupReference'
            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 a
Data..: Key
"ResourceArn")
      )

instance Prelude.Hashable StatefulRuleGroupReference where
  hashWithSalt :: Int -> StatefulRuleGroupReference -> Int
hashWithSalt Int
_salt StatefulRuleGroupReference' {Maybe Natural
Maybe StatefulRuleGroupOverride
Text
resourceArn :: Text
priority :: Maybe Natural
override :: Maybe StatefulRuleGroupOverride
$sel:resourceArn:StatefulRuleGroupReference' :: StatefulRuleGroupReference -> Text
$sel:priority:StatefulRuleGroupReference' :: StatefulRuleGroupReference -> Maybe Natural
$sel:override:StatefulRuleGroupReference' :: StatefulRuleGroupReference -> Maybe StatefulRuleGroupOverride
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe StatefulRuleGroupOverride
override
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Natural
priority
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceArn

instance Prelude.NFData StatefulRuleGroupReference where
  rnf :: StatefulRuleGroupReference -> ()
rnf StatefulRuleGroupReference' {Maybe Natural
Maybe StatefulRuleGroupOverride
Text
resourceArn :: Text
priority :: Maybe Natural
override :: Maybe StatefulRuleGroupOverride
$sel:resourceArn:StatefulRuleGroupReference' :: StatefulRuleGroupReference -> Text
$sel:priority:StatefulRuleGroupReference' :: StatefulRuleGroupReference -> Maybe Natural
$sel:override:StatefulRuleGroupReference' :: StatefulRuleGroupReference -> Maybe StatefulRuleGroupOverride
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe StatefulRuleGroupOverride
override
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Natural
priority
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resourceArn

instance Data.ToJSON StatefulRuleGroupReference where
  toJSON :: StatefulRuleGroupReference -> Value
toJSON StatefulRuleGroupReference' {Maybe Natural
Maybe StatefulRuleGroupOverride
Text
resourceArn :: Text
priority :: Maybe Natural
override :: Maybe StatefulRuleGroupOverride
$sel:resourceArn:StatefulRuleGroupReference' :: StatefulRuleGroupReference -> Text
$sel:priority:StatefulRuleGroupReference' :: StatefulRuleGroupReference -> Maybe Natural
$sel:override:StatefulRuleGroupReference' :: StatefulRuleGroupReference -> Maybe StatefulRuleGroupOverride
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Override" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StatefulRuleGroupOverride
override,
            (Key
"Priority" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Natural
priority,
            forall a. a -> Maybe a
Prelude.Just (Key
"ResourceArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
resourceArn)
          ]
      )