{-# 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.FirewallPolicy
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.NetworkFirewall.Types.FirewallPolicy where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.NetworkFirewall.Types.CustomAction
import Amazonka.NetworkFirewall.Types.StatefulEngineOptions
import Amazonka.NetworkFirewall.Types.StatefulRuleGroupReference
import Amazonka.NetworkFirewall.Types.StatelessRuleGroupReference
import qualified Amazonka.Prelude as Prelude

-- | The firewall policy defines the behavior of a firewall using a
-- collection of stateless and stateful rule groups and other settings. You
-- can use one firewall policy for multiple firewalls.
--
-- This, along with FirewallPolicyResponse, define the policy. You can
-- retrieve all objects for a firewall policy by calling
-- DescribeFirewallPolicy.
--
-- /See:/ 'newFirewallPolicy' smart constructor.
data FirewallPolicy = FirewallPolicy'
  { -- | Additional options governing how Network Firewall handles stateful
    -- rules. The stateful rule groups that you use in your policy must have
    -- stateful rule options settings that are compatible with these settings.
    FirewallPolicy -> Maybe StatefulEngineOptions
statefulEngineOptions :: Prelude.Maybe StatefulEngineOptions,
    -- | References to the stateful rule groups that are used in the policy.
    -- These define the inspection criteria in stateful rules.
    FirewallPolicy -> Maybe [StatefulRuleGroupReference]
statefulRuleGroupReferences :: Prelude.Maybe [StatefulRuleGroupReference],
    -- | References to the stateless rule groups that are used in the policy.
    -- These define the matching criteria in stateless rules.
    FirewallPolicy -> Maybe [StatelessRuleGroupReference]
statelessRuleGroupReferences :: Prelude.Maybe [StatelessRuleGroupReference],
    -- | The custom action definitions that are available for use in the firewall
    -- policy\'s @StatelessDefaultActions@ setting. You name each custom action
    -- that you define, and then you can use it by name in your default actions
    -- specifications.
    FirewallPolicy -> Maybe [CustomAction]
statelessCustomActions :: Prelude.Maybe [CustomAction],
    -- | The default actions to take on a packet that doesn\'t match any stateful
    -- rules.
    FirewallPolicy -> Maybe [Text]
statefulDefaultActions :: Prelude.Maybe [Prelude.Text],
    -- | The actions to take on a packet if it doesn\'t match any of the
    -- stateless rules in the policy. If you want non-matching packets to be
    -- forwarded for stateful inspection, specify @aws:forward_to_sfe@.
    --
    -- You must specify one of the standard actions: @aws:pass@, @aws:drop@, or
    -- @aws:forward_to_sfe@. In addition, you can specify custom actions that
    -- are compatible with your standard section choice.
    --
    -- For example, you could specify @[\"aws:pass\"]@ or you could specify
    -- @[\"aws:pass\", “customActionName”]@. For information about
    -- compatibility, see the custom action descriptions under CustomAction.
    FirewallPolicy -> [Text]
statelessDefaultActions :: [Prelude.Text],
    -- | The actions to take on a fragmented UDP packet if it doesn\'t match any
    -- of the stateless rules in the policy. Network Firewall only manages UDP
    -- packet fragments and silently drops packet fragments for other
    -- protocols. If you want non-matching fragmented UDP packets to be
    -- forwarded for stateful inspection, specify @aws:forward_to_sfe@.
    --
    -- You must specify one of the standard actions: @aws:pass@, @aws:drop@, or
    -- @aws:forward_to_sfe@. In addition, you can specify custom actions that
    -- are compatible with your standard section choice.
    --
    -- For example, you could specify @[\"aws:pass\"]@ or you could specify
    -- @[\"aws:pass\", “customActionName”]@. For information about
    -- compatibility, see the custom action descriptions under CustomAction.
    FirewallPolicy -> [Text]
statelessFragmentDefaultActions :: [Prelude.Text]
  }
  deriving (FirewallPolicy -> FirewallPolicy -> Bool
(FirewallPolicy -> FirewallPolicy -> Bool)
-> (FirewallPolicy -> FirewallPolicy -> Bool) -> Eq FirewallPolicy
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FirewallPolicy -> FirewallPolicy -> Bool
$c/= :: FirewallPolicy -> FirewallPolicy -> Bool
== :: FirewallPolicy -> FirewallPolicy -> Bool
$c== :: FirewallPolicy -> FirewallPolicy -> Bool
Prelude.Eq, ReadPrec [FirewallPolicy]
ReadPrec FirewallPolicy
Int -> ReadS FirewallPolicy
ReadS [FirewallPolicy]
(Int -> ReadS FirewallPolicy)
-> ReadS [FirewallPolicy]
-> ReadPrec FirewallPolicy
-> ReadPrec [FirewallPolicy]
-> Read FirewallPolicy
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FirewallPolicy]
$creadListPrec :: ReadPrec [FirewallPolicy]
readPrec :: ReadPrec FirewallPolicy
$creadPrec :: ReadPrec FirewallPolicy
readList :: ReadS [FirewallPolicy]
$creadList :: ReadS [FirewallPolicy]
readsPrec :: Int -> ReadS FirewallPolicy
$creadsPrec :: Int -> ReadS FirewallPolicy
Prelude.Read, Int -> FirewallPolicy -> ShowS
[FirewallPolicy] -> ShowS
FirewallPolicy -> String
(Int -> FirewallPolicy -> ShowS)
-> (FirewallPolicy -> String)
-> ([FirewallPolicy] -> ShowS)
-> Show FirewallPolicy
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FirewallPolicy] -> ShowS
$cshowList :: [FirewallPolicy] -> ShowS
show :: FirewallPolicy -> String
$cshow :: FirewallPolicy -> String
showsPrec :: Int -> FirewallPolicy -> ShowS
$cshowsPrec :: Int -> FirewallPolicy -> ShowS
Prelude.Show, (forall x. FirewallPolicy -> Rep FirewallPolicy x)
-> (forall x. Rep FirewallPolicy x -> FirewallPolicy)
-> Generic FirewallPolicy
forall x. Rep FirewallPolicy x -> FirewallPolicy
forall x. FirewallPolicy -> Rep FirewallPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FirewallPolicy x -> FirewallPolicy
$cfrom :: forall x. FirewallPolicy -> Rep FirewallPolicy x
Prelude.Generic)

-- |
-- Create a value of 'FirewallPolicy' 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:
--
-- 'statefulEngineOptions', 'firewallPolicy_statefulEngineOptions' - Additional options governing how Network Firewall handles stateful
-- rules. The stateful rule groups that you use in your policy must have
-- stateful rule options settings that are compatible with these settings.
--
-- 'statefulRuleGroupReferences', 'firewallPolicy_statefulRuleGroupReferences' - References to the stateful rule groups that are used in the policy.
-- These define the inspection criteria in stateful rules.
--
-- 'statelessRuleGroupReferences', 'firewallPolicy_statelessRuleGroupReferences' - References to the stateless rule groups that are used in the policy.
-- These define the matching criteria in stateless rules.
--
-- 'statelessCustomActions', 'firewallPolicy_statelessCustomActions' - The custom action definitions that are available for use in the firewall
-- policy\'s @StatelessDefaultActions@ setting. You name each custom action
-- that you define, and then you can use it by name in your default actions
-- specifications.
--
-- 'statefulDefaultActions', 'firewallPolicy_statefulDefaultActions' - The default actions to take on a packet that doesn\'t match any stateful
-- rules.
--
-- 'statelessDefaultActions', 'firewallPolicy_statelessDefaultActions' - The actions to take on a packet if it doesn\'t match any of the
-- stateless rules in the policy. If you want non-matching packets to be
-- forwarded for stateful inspection, specify @aws:forward_to_sfe@.
--
-- You must specify one of the standard actions: @aws:pass@, @aws:drop@, or
-- @aws:forward_to_sfe@. In addition, you can specify custom actions that
-- are compatible with your standard section choice.
--
-- For example, you could specify @[\"aws:pass\"]@ or you could specify
-- @[\"aws:pass\", “customActionName”]@. For information about
-- compatibility, see the custom action descriptions under CustomAction.
--
-- 'statelessFragmentDefaultActions', 'firewallPolicy_statelessFragmentDefaultActions' - The actions to take on a fragmented UDP packet if it doesn\'t match any
-- of the stateless rules in the policy. Network Firewall only manages UDP
-- packet fragments and silently drops packet fragments for other
-- protocols. If you want non-matching fragmented UDP packets to be
-- forwarded for stateful inspection, specify @aws:forward_to_sfe@.
--
-- You must specify one of the standard actions: @aws:pass@, @aws:drop@, or
-- @aws:forward_to_sfe@. In addition, you can specify custom actions that
-- are compatible with your standard section choice.
--
-- For example, you could specify @[\"aws:pass\"]@ or you could specify
-- @[\"aws:pass\", “customActionName”]@. For information about
-- compatibility, see the custom action descriptions under CustomAction.
newFirewallPolicy ::
  FirewallPolicy
newFirewallPolicy :: FirewallPolicy
newFirewallPolicy =
  FirewallPolicy' :: Maybe StatefulEngineOptions
-> Maybe [StatefulRuleGroupReference]
-> Maybe [StatelessRuleGroupReference]
-> Maybe [CustomAction]
-> Maybe [Text]
-> [Text]
-> [Text]
-> FirewallPolicy
FirewallPolicy'
    { $sel:statefulEngineOptions:FirewallPolicy' :: Maybe StatefulEngineOptions
statefulEngineOptions =
        Maybe StatefulEngineOptions
forall a. Maybe a
Prelude.Nothing,
      $sel:statefulRuleGroupReferences:FirewallPolicy' :: Maybe [StatefulRuleGroupReference]
statefulRuleGroupReferences = Maybe [StatefulRuleGroupReference]
forall a. Maybe a
Prelude.Nothing,
      $sel:statelessRuleGroupReferences:FirewallPolicy' :: Maybe [StatelessRuleGroupReference]
statelessRuleGroupReferences = Maybe [StatelessRuleGroupReference]
forall a. Maybe a
Prelude.Nothing,
      $sel:statelessCustomActions:FirewallPolicy' :: Maybe [CustomAction]
statelessCustomActions = Maybe [CustomAction]
forall a. Maybe a
Prelude.Nothing,
      $sel:statefulDefaultActions:FirewallPolicy' :: Maybe [Text]
statefulDefaultActions = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:statelessDefaultActions:FirewallPolicy' :: [Text]
statelessDefaultActions = [Text]
forall a. Monoid a => a
Prelude.mempty,
      $sel:statelessFragmentDefaultActions:FirewallPolicy' :: [Text]
statelessFragmentDefaultActions = [Text]
forall a. Monoid a => a
Prelude.mempty
    }

-- | Additional options governing how Network Firewall handles stateful
-- rules. The stateful rule groups that you use in your policy must have
-- stateful rule options settings that are compatible with these settings.
firewallPolicy_statefulEngineOptions :: Lens.Lens' FirewallPolicy (Prelude.Maybe StatefulEngineOptions)
firewallPolicy_statefulEngineOptions :: (Maybe StatefulEngineOptions -> f (Maybe StatefulEngineOptions))
-> FirewallPolicy -> f FirewallPolicy
firewallPolicy_statefulEngineOptions = (FirewallPolicy -> Maybe StatefulEngineOptions)
-> (FirewallPolicy
    -> Maybe StatefulEngineOptions -> FirewallPolicy)
-> Lens
     FirewallPolicy
     FirewallPolicy
     (Maybe StatefulEngineOptions)
     (Maybe StatefulEngineOptions)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FirewallPolicy' {Maybe StatefulEngineOptions
statefulEngineOptions :: Maybe StatefulEngineOptions
$sel:statefulEngineOptions:FirewallPolicy' :: FirewallPolicy -> Maybe StatefulEngineOptions
statefulEngineOptions} -> Maybe StatefulEngineOptions
statefulEngineOptions) (\s :: FirewallPolicy
s@FirewallPolicy' {} Maybe StatefulEngineOptions
a -> FirewallPolicy
s {$sel:statefulEngineOptions:FirewallPolicy' :: Maybe StatefulEngineOptions
statefulEngineOptions = Maybe StatefulEngineOptions
a} :: FirewallPolicy)

-- | References to the stateful rule groups that are used in the policy.
-- These define the inspection criteria in stateful rules.
firewallPolicy_statefulRuleGroupReferences :: Lens.Lens' FirewallPolicy (Prelude.Maybe [StatefulRuleGroupReference])
firewallPolicy_statefulRuleGroupReferences :: (Maybe [StatefulRuleGroupReference]
 -> f (Maybe [StatefulRuleGroupReference]))
-> FirewallPolicy -> f FirewallPolicy
firewallPolicy_statefulRuleGroupReferences = (FirewallPolicy -> Maybe [StatefulRuleGroupReference])
-> (FirewallPolicy
    -> Maybe [StatefulRuleGroupReference] -> FirewallPolicy)
-> Lens
     FirewallPolicy
     FirewallPolicy
     (Maybe [StatefulRuleGroupReference])
     (Maybe [StatefulRuleGroupReference])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FirewallPolicy' {Maybe [StatefulRuleGroupReference]
statefulRuleGroupReferences :: Maybe [StatefulRuleGroupReference]
$sel:statefulRuleGroupReferences:FirewallPolicy' :: FirewallPolicy -> Maybe [StatefulRuleGroupReference]
statefulRuleGroupReferences} -> Maybe [StatefulRuleGroupReference]
statefulRuleGroupReferences) (\s :: FirewallPolicy
s@FirewallPolicy' {} Maybe [StatefulRuleGroupReference]
a -> FirewallPolicy
s {$sel:statefulRuleGroupReferences:FirewallPolicy' :: Maybe [StatefulRuleGroupReference]
statefulRuleGroupReferences = Maybe [StatefulRuleGroupReference]
a} :: FirewallPolicy) ((Maybe [StatefulRuleGroupReference]
  -> f (Maybe [StatefulRuleGroupReference]))
 -> FirewallPolicy -> f FirewallPolicy)
-> ((Maybe [StatefulRuleGroupReference]
     -> f (Maybe [StatefulRuleGroupReference]))
    -> Maybe [StatefulRuleGroupReference]
    -> f (Maybe [StatefulRuleGroupReference]))
-> (Maybe [StatefulRuleGroupReference]
    -> f (Maybe [StatefulRuleGroupReference]))
-> FirewallPolicy
-> f FirewallPolicy
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [StatefulRuleGroupReference]
  [StatefulRuleGroupReference]
  [StatefulRuleGroupReference]
  [StatefulRuleGroupReference]
-> Iso
     (Maybe [StatefulRuleGroupReference])
     (Maybe [StatefulRuleGroupReference])
     (Maybe [StatefulRuleGroupReference])
     (Maybe [StatefulRuleGroupReference])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [StatefulRuleGroupReference]
  [StatefulRuleGroupReference]
  [StatefulRuleGroupReference]
  [StatefulRuleGroupReference]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | References to the stateless rule groups that are used in the policy.
-- These define the matching criteria in stateless rules.
firewallPolicy_statelessRuleGroupReferences :: Lens.Lens' FirewallPolicy (Prelude.Maybe [StatelessRuleGroupReference])
firewallPolicy_statelessRuleGroupReferences :: (Maybe [StatelessRuleGroupReference]
 -> f (Maybe [StatelessRuleGroupReference]))
-> FirewallPolicy -> f FirewallPolicy
firewallPolicy_statelessRuleGroupReferences = (FirewallPolicy -> Maybe [StatelessRuleGroupReference])
-> (FirewallPolicy
    -> Maybe [StatelessRuleGroupReference] -> FirewallPolicy)
-> Lens
     FirewallPolicy
     FirewallPolicy
     (Maybe [StatelessRuleGroupReference])
     (Maybe [StatelessRuleGroupReference])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FirewallPolicy' {Maybe [StatelessRuleGroupReference]
statelessRuleGroupReferences :: Maybe [StatelessRuleGroupReference]
$sel:statelessRuleGroupReferences:FirewallPolicy' :: FirewallPolicy -> Maybe [StatelessRuleGroupReference]
statelessRuleGroupReferences} -> Maybe [StatelessRuleGroupReference]
statelessRuleGroupReferences) (\s :: FirewallPolicy
s@FirewallPolicy' {} Maybe [StatelessRuleGroupReference]
a -> FirewallPolicy
s {$sel:statelessRuleGroupReferences:FirewallPolicy' :: Maybe [StatelessRuleGroupReference]
statelessRuleGroupReferences = Maybe [StatelessRuleGroupReference]
a} :: FirewallPolicy) ((Maybe [StatelessRuleGroupReference]
  -> f (Maybe [StatelessRuleGroupReference]))
 -> FirewallPolicy -> f FirewallPolicy)
-> ((Maybe [StatelessRuleGroupReference]
     -> f (Maybe [StatelessRuleGroupReference]))
    -> Maybe [StatelessRuleGroupReference]
    -> f (Maybe [StatelessRuleGroupReference]))
-> (Maybe [StatelessRuleGroupReference]
    -> f (Maybe [StatelessRuleGroupReference]))
-> FirewallPolicy
-> f FirewallPolicy
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [StatelessRuleGroupReference]
  [StatelessRuleGroupReference]
  [StatelessRuleGroupReference]
  [StatelessRuleGroupReference]
-> Iso
     (Maybe [StatelessRuleGroupReference])
     (Maybe [StatelessRuleGroupReference])
     (Maybe [StatelessRuleGroupReference])
     (Maybe [StatelessRuleGroupReference])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [StatelessRuleGroupReference]
  [StatelessRuleGroupReference]
  [StatelessRuleGroupReference]
  [StatelessRuleGroupReference]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The custom action definitions that are available for use in the firewall
-- policy\'s @StatelessDefaultActions@ setting. You name each custom action
-- that you define, and then you can use it by name in your default actions
-- specifications.
firewallPolicy_statelessCustomActions :: Lens.Lens' FirewallPolicy (Prelude.Maybe [CustomAction])
firewallPolicy_statelessCustomActions :: (Maybe [CustomAction] -> f (Maybe [CustomAction]))
-> FirewallPolicy -> f FirewallPolicy
firewallPolicy_statelessCustomActions = (FirewallPolicy -> Maybe [CustomAction])
-> (FirewallPolicy -> Maybe [CustomAction] -> FirewallPolicy)
-> Lens
     FirewallPolicy
     FirewallPolicy
     (Maybe [CustomAction])
     (Maybe [CustomAction])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FirewallPolicy' {Maybe [CustomAction]
statelessCustomActions :: Maybe [CustomAction]
$sel:statelessCustomActions:FirewallPolicy' :: FirewallPolicy -> Maybe [CustomAction]
statelessCustomActions} -> Maybe [CustomAction]
statelessCustomActions) (\s :: FirewallPolicy
s@FirewallPolicy' {} Maybe [CustomAction]
a -> FirewallPolicy
s {$sel:statelessCustomActions:FirewallPolicy' :: Maybe [CustomAction]
statelessCustomActions = Maybe [CustomAction]
a} :: FirewallPolicy) ((Maybe [CustomAction] -> f (Maybe [CustomAction]))
 -> FirewallPolicy -> f FirewallPolicy)
-> ((Maybe [CustomAction] -> f (Maybe [CustomAction]))
    -> Maybe [CustomAction] -> f (Maybe [CustomAction]))
-> (Maybe [CustomAction] -> f (Maybe [CustomAction]))
-> FirewallPolicy
-> f FirewallPolicy
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [CustomAction] [CustomAction] [CustomAction] [CustomAction]
-> Iso
     (Maybe [CustomAction])
     (Maybe [CustomAction])
     (Maybe [CustomAction])
     (Maybe [CustomAction])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [CustomAction] [CustomAction] [CustomAction] [CustomAction]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The default actions to take on a packet that doesn\'t match any stateful
-- rules.
firewallPolicy_statefulDefaultActions :: Lens.Lens' FirewallPolicy (Prelude.Maybe [Prelude.Text])
firewallPolicy_statefulDefaultActions :: (Maybe [Text] -> f (Maybe [Text]))
-> FirewallPolicy -> f FirewallPolicy
firewallPolicy_statefulDefaultActions = (FirewallPolicy -> Maybe [Text])
-> (FirewallPolicy -> Maybe [Text] -> FirewallPolicy)
-> Lens FirewallPolicy FirewallPolicy (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FirewallPolicy' {Maybe [Text]
statefulDefaultActions :: Maybe [Text]
$sel:statefulDefaultActions:FirewallPolicy' :: FirewallPolicy -> Maybe [Text]
statefulDefaultActions} -> Maybe [Text]
statefulDefaultActions) (\s :: FirewallPolicy
s@FirewallPolicy' {} Maybe [Text]
a -> FirewallPolicy
s {$sel:statefulDefaultActions:FirewallPolicy' :: Maybe [Text]
statefulDefaultActions = Maybe [Text]
a} :: FirewallPolicy) ((Maybe [Text] -> f (Maybe [Text]))
 -> FirewallPolicy -> f FirewallPolicy)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> FirewallPolicy
-> f FirewallPolicy
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The actions to take on a packet if it doesn\'t match any of the
-- stateless rules in the policy. If you want non-matching packets to be
-- forwarded for stateful inspection, specify @aws:forward_to_sfe@.
--
-- You must specify one of the standard actions: @aws:pass@, @aws:drop@, or
-- @aws:forward_to_sfe@. In addition, you can specify custom actions that
-- are compatible with your standard section choice.
--
-- For example, you could specify @[\"aws:pass\"]@ or you could specify
-- @[\"aws:pass\", “customActionName”]@. For information about
-- compatibility, see the custom action descriptions under CustomAction.
firewallPolicy_statelessDefaultActions :: Lens.Lens' FirewallPolicy [Prelude.Text]
firewallPolicy_statelessDefaultActions :: ([Text] -> f [Text]) -> FirewallPolicy -> f FirewallPolicy
firewallPolicy_statelessDefaultActions = (FirewallPolicy -> [Text])
-> (FirewallPolicy -> [Text] -> FirewallPolicy)
-> Lens FirewallPolicy FirewallPolicy [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FirewallPolicy' {[Text]
statelessDefaultActions :: [Text]
$sel:statelessDefaultActions:FirewallPolicy' :: FirewallPolicy -> [Text]
statelessDefaultActions} -> [Text]
statelessDefaultActions) (\s :: FirewallPolicy
s@FirewallPolicy' {} [Text]
a -> FirewallPolicy
s {$sel:statelessDefaultActions:FirewallPolicy' :: [Text]
statelessDefaultActions = [Text]
a} :: FirewallPolicy) (([Text] -> f [Text]) -> FirewallPolicy -> f FirewallPolicy)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> FirewallPolicy
-> f FirewallPolicy
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The actions to take on a fragmented UDP packet if it doesn\'t match any
-- of the stateless rules in the policy. Network Firewall only manages UDP
-- packet fragments and silently drops packet fragments for other
-- protocols. If you want non-matching fragmented UDP packets to be
-- forwarded for stateful inspection, specify @aws:forward_to_sfe@.
--
-- You must specify one of the standard actions: @aws:pass@, @aws:drop@, or
-- @aws:forward_to_sfe@. In addition, you can specify custom actions that
-- are compatible with your standard section choice.
--
-- For example, you could specify @[\"aws:pass\"]@ or you could specify
-- @[\"aws:pass\", “customActionName”]@. For information about
-- compatibility, see the custom action descriptions under CustomAction.
firewallPolicy_statelessFragmentDefaultActions :: Lens.Lens' FirewallPolicy [Prelude.Text]
firewallPolicy_statelessFragmentDefaultActions :: ([Text] -> f [Text]) -> FirewallPolicy -> f FirewallPolicy
firewallPolicy_statelessFragmentDefaultActions = (FirewallPolicy -> [Text])
-> (FirewallPolicy -> [Text] -> FirewallPolicy)
-> Lens FirewallPolicy FirewallPolicy [Text] [Text]
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FirewallPolicy' {[Text]
statelessFragmentDefaultActions :: [Text]
$sel:statelessFragmentDefaultActions:FirewallPolicy' :: FirewallPolicy -> [Text]
statelessFragmentDefaultActions} -> [Text]
statelessFragmentDefaultActions) (\s :: FirewallPolicy
s@FirewallPolicy' {} [Text]
a -> FirewallPolicy
s {$sel:statelessFragmentDefaultActions:FirewallPolicy' :: [Text]
statelessFragmentDefaultActions = [Text]
a} :: FirewallPolicy) (([Text] -> f [Text]) -> FirewallPolicy -> f FirewallPolicy)
-> (([Text] -> f [Text]) -> [Text] -> f [Text])
-> ([Text] -> f [Text])
-> FirewallPolicy
-> f FirewallPolicy
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. ([Text] -> f [Text]) -> [Text] -> f [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON FirewallPolicy where
  parseJSON :: Value -> Parser FirewallPolicy
parseJSON =
    String
-> (Object -> Parser FirewallPolicy)
-> Value
-> Parser FirewallPolicy
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"FirewallPolicy"
      ( \Object
x ->
          Maybe StatefulEngineOptions
-> Maybe [StatefulRuleGroupReference]
-> Maybe [StatelessRuleGroupReference]
-> Maybe [CustomAction]
-> Maybe [Text]
-> [Text]
-> [Text]
-> FirewallPolicy
FirewallPolicy'
            (Maybe StatefulEngineOptions
 -> Maybe [StatefulRuleGroupReference]
 -> Maybe [StatelessRuleGroupReference]
 -> Maybe [CustomAction]
 -> Maybe [Text]
 -> [Text]
 -> [Text]
 -> FirewallPolicy)
-> Parser (Maybe StatefulEngineOptions)
-> Parser
     (Maybe [StatefulRuleGroupReference]
      -> Maybe [StatelessRuleGroupReference]
      -> Maybe [CustomAction]
      -> Maybe [Text]
      -> [Text]
      -> [Text]
      -> FirewallPolicy)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe StatefulEngineOptions)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StatefulEngineOptions")
            Parser
  (Maybe [StatefulRuleGroupReference]
   -> Maybe [StatelessRuleGroupReference]
   -> Maybe [CustomAction]
   -> Maybe [Text]
   -> [Text]
   -> [Text]
   -> FirewallPolicy)
-> Parser (Maybe [StatefulRuleGroupReference])
-> Parser
     (Maybe [StatelessRuleGroupReference]
      -> Maybe [CustomAction]
      -> Maybe [Text]
      -> [Text]
      -> [Text]
      -> FirewallPolicy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text -> Parser (Maybe (Maybe [StatefulRuleGroupReference]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StatefulRuleGroupReferences"
                            Parser (Maybe (Maybe [StatefulRuleGroupReference]))
-> Maybe [StatefulRuleGroupReference]
-> Parser (Maybe [StatefulRuleGroupReference])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [StatefulRuleGroupReference]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe [StatelessRuleGroupReference]
   -> Maybe [CustomAction]
   -> Maybe [Text]
   -> [Text]
   -> [Text]
   -> FirewallPolicy)
-> Parser (Maybe [StatelessRuleGroupReference])
-> Parser
     (Maybe [CustomAction]
      -> Maybe [Text] -> [Text] -> [Text] -> FirewallPolicy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object
-> Text -> Parser (Maybe (Maybe [StatelessRuleGroupReference]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StatelessRuleGroupReferences"
                            Parser (Maybe (Maybe [StatelessRuleGroupReference]))
-> Maybe [StatelessRuleGroupReference]
-> Parser (Maybe [StatelessRuleGroupReference])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [StatelessRuleGroupReference]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser
  (Maybe [CustomAction]
   -> Maybe [Text] -> [Text] -> [Text] -> FirewallPolicy)
-> Parser (Maybe [CustomAction])
-> Parser (Maybe [Text] -> [Text] -> [Text] -> FirewallPolicy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [CustomAction]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StatelessCustomActions"
                            Parser (Maybe (Maybe [CustomAction]))
-> Maybe [CustomAction] -> Parser (Maybe [CustomAction])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [CustomAction]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (Maybe [Text] -> [Text] -> [Text] -> FirewallPolicy)
-> Parser (Maybe [Text])
-> Parser ([Text] -> [Text] -> FirewallPolicy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StatefulDefaultActions"
                            Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser ([Text] -> [Text] -> FirewallPolicy)
-> Parser [Text] -> Parser ([Text] -> FirewallPolicy)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe [Text])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StatelessDefaultActions"
                            Parser (Maybe [Text]) -> [Text] -> Parser [Text]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser ([Text] -> FirewallPolicy)
-> Parser [Text] -> Parser FirewallPolicy
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe [Text])
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"StatelessFragmentDefaultActions"
                            Parser (Maybe [Text]) -> [Text] -> Parser [Text]
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= [Text]
forall a. Monoid a => a
Prelude.mempty
                        )
      )

instance Prelude.Hashable FirewallPolicy

instance Prelude.NFData FirewallPolicy

instance Core.ToJSON FirewallPolicy where
  toJSON :: FirewallPolicy -> Value
toJSON FirewallPolicy' {[Text]
Maybe [Text]
Maybe [CustomAction]
Maybe [StatefulRuleGroupReference]
Maybe [StatelessRuleGroupReference]
Maybe StatefulEngineOptions
statelessFragmentDefaultActions :: [Text]
statelessDefaultActions :: [Text]
statefulDefaultActions :: Maybe [Text]
statelessCustomActions :: Maybe [CustomAction]
statelessRuleGroupReferences :: Maybe [StatelessRuleGroupReference]
statefulRuleGroupReferences :: Maybe [StatefulRuleGroupReference]
statefulEngineOptions :: Maybe StatefulEngineOptions
$sel:statelessFragmentDefaultActions:FirewallPolicy' :: FirewallPolicy -> [Text]
$sel:statelessDefaultActions:FirewallPolicy' :: FirewallPolicy -> [Text]
$sel:statefulDefaultActions:FirewallPolicy' :: FirewallPolicy -> Maybe [Text]
$sel:statelessCustomActions:FirewallPolicy' :: FirewallPolicy -> Maybe [CustomAction]
$sel:statelessRuleGroupReferences:FirewallPolicy' :: FirewallPolicy -> Maybe [StatelessRuleGroupReference]
$sel:statefulRuleGroupReferences:FirewallPolicy' :: FirewallPolicy -> Maybe [StatefulRuleGroupReference]
$sel:statefulEngineOptions:FirewallPolicy' :: FirewallPolicy -> Maybe StatefulEngineOptions
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"StatefulEngineOptions" Text -> StatefulEngineOptions -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (StatefulEngineOptions -> Pair)
-> Maybe StatefulEngineOptions -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe StatefulEngineOptions
statefulEngineOptions,
            (Text
"StatefulRuleGroupReferences" Text -> [StatefulRuleGroupReference] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([StatefulRuleGroupReference] -> Pair)
-> Maybe [StatefulRuleGroupReference] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [StatefulRuleGroupReference]
statefulRuleGroupReferences,
            (Text
"StatelessRuleGroupReferences" Text -> [StatelessRuleGroupReference] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([StatelessRuleGroupReference] -> Pair)
-> Maybe [StatelessRuleGroupReference] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [StatelessRuleGroupReference]
statelessRuleGroupReferences,
            (Text
"StatelessCustomActions" Text -> [CustomAction] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([CustomAction] -> Pair) -> Maybe [CustomAction] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [CustomAction]
statelessCustomActions,
            (Text
"StatefulDefaultActions" Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([Text] -> Pair) -> Maybe [Text] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
statefulDefaultActions,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"StatelessDefaultActions"
                  Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
statelessDefaultActions
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"StatelessFragmentDefaultActions"
                  Text -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= [Text]
statelessFragmentDefaultActions
              )
          ]
      )