{-# 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.SecurityHub.Types.AwsWafWebAclDetails
-- 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.SecurityHub.Types.AwsWafWebAclDetails where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SecurityHub.Types.AwsWafWebAclRule

-- | Details about an WAF WebACL.
--
-- /See:/ 'newAwsWafWebAclDetails' smart constructor.
data AwsWafWebAclDetails = AwsWafWebAclDetails'
  { -- | An array that contains the action for each rule in a WebACL, the
    -- priority of the rule, and the ID of the rule.
    AwsWafWebAclDetails -> Maybe [AwsWafWebAclRule]
rules :: Prelude.Maybe [AwsWafWebAclRule],
    -- | A unique identifier for a WebACL.
    AwsWafWebAclDetails -> Maybe Text
webAclId :: Prelude.Maybe Prelude.Text,
    -- | A friendly name or description of the WebACL. You can\'t change the name
    -- of a WebACL after you create it.
    AwsWafWebAclDetails -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The action to perform if none of the rules contained in the WebACL
    -- match.
    AwsWafWebAclDetails -> Maybe Text
defaultAction :: Prelude.Maybe Prelude.Text
  }
  deriving (AwsWafWebAclDetails -> AwsWafWebAclDetails -> Bool
(AwsWafWebAclDetails -> AwsWafWebAclDetails -> Bool)
-> (AwsWafWebAclDetails -> AwsWafWebAclDetails -> Bool)
-> Eq AwsWafWebAclDetails
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: AwsWafWebAclDetails -> AwsWafWebAclDetails -> Bool
$c/= :: AwsWafWebAclDetails -> AwsWafWebAclDetails -> Bool
== :: AwsWafWebAclDetails -> AwsWafWebAclDetails -> Bool
$c== :: AwsWafWebAclDetails -> AwsWafWebAclDetails -> Bool
Prelude.Eq, ReadPrec [AwsWafWebAclDetails]
ReadPrec AwsWafWebAclDetails
Int -> ReadS AwsWafWebAclDetails
ReadS [AwsWafWebAclDetails]
(Int -> ReadS AwsWafWebAclDetails)
-> ReadS [AwsWafWebAclDetails]
-> ReadPrec AwsWafWebAclDetails
-> ReadPrec [AwsWafWebAclDetails]
-> Read AwsWafWebAclDetails
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [AwsWafWebAclDetails]
$creadListPrec :: ReadPrec [AwsWafWebAclDetails]
readPrec :: ReadPrec AwsWafWebAclDetails
$creadPrec :: ReadPrec AwsWafWebAclDetails
readList :: ReadS [AwsWafWebAclDetails]
$creadList :: ReadS [AwsWafWebAclDetails]
readsPrec :: Int -> ReadS AwsWafWebAclDetails
$creadsPrec :: Int -> ReadS AwsWafWebAclDetails
Prelude.Read, Int -> AwsWafWebAclDetails -> ShowS
[AwsWafWebAclDetails] -> ShowS
AwsWafWebAclDetails -> String
(Int -> AwsWafWebAclDetails -> ShowS)
-> (AwsWafWebAclDetails -> String)
-> ([AwsWafWebAclDetails] -> ShowS)
-> Show AwsWafWebAclDetails
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [AwsWafWebAclDetails] -> ShowS
$cshowList :: [AwsWafWebAclDetails] -> ShowS
show :: AwsWafWebAclDetails -> String
$cshow :: AwsWafWebAclDetails -> String
showsPrec :: Int -> AwsWafWebAclDetails -> ShowS
$cshowsPrec :: Int -> AwsWafWebAclDetails -> ShowS
Prelude.Show, (forall x. AwsWafWebAclDetails -> Rep AwsWafWebAclDetails x)
-> (forall x. Rep AwsWafWebAclDetails x -> AwsWafWebAclDetails)
-> Generic AwsWafWebAclDetails
forall x. Rep AwsWafWebAclDetails x -> AwsWafWebAclDetails
forall x. AwsWafWebAclDetails -> Rep AwsWafWebAclDetails x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep AwsWafWebAclDetails x -> AwsWafWebAclDetails
$cfrom :: forall x. AwsWafWebAclDetails -> Rep AwsWafWebAclDetails x
Prelude.Generic)

-- |
-- Create a value of 'AwsWafWebAclDetails' 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:
--
-- 'rules', 'awsWafWebAclDetails_rules' - An array that contains the action for each rule in a WebACL, the
-- priority of the rule, and the ID of the rule.
--
-- 'webAclId', 'awsWafWebAclDetails_webAclId' - A unique identifier for a WebACL.
--
-- 'name', 'awsWafWebAclDetails_name' - A friendly name or description of the WebACL. You can\'t change the name
-- of a WebACL after you create it.
--
-- 'defaultAction', 'awsWafWebAclDetails_defaultAction' - The action to perform if none of the rules contained in the WebACL
-- match.
newAwsWafWebAclDetails ::
  AwsWafWebAclDetails
newAwsWafWebAclDetails :: AwsWafWebAclDetails
newAwsWafWebAclDetails =
  AwsWafWebAclDetails' :: Maybe [AwsWafWebAclRule]
-> Maybe Text -> Maybe Text -> Maybe Text -> AwsWafWebAclDetails
AwsWafWebAclDetails'
    { $sel:rules:AwsWafWebAclDetails' :: Maybe [AwsWafWebAclRule]
rules = Maybe [AwsWafWebAclRule]
forall a. Maybe a
Prelude.Nothing,
      $sel:webAclId:AwsWafWebAclDetails' :: Maybe Text
webAclId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:name:AwsWafWebAclDetails' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:defaultAction:AwsWafWebAclDetails' :: Maybe Text
defaultAction = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | An array that contains the action for each rule in a WebACL, the
-- priority of the rule, and the ID of the rule.
awsWafWebAclDetails_rules :: Lens.Lens' AwsWafWebAclDetails (Prelude.Maybe [AwsWafWebAclRule])
awsWafWebAclDetails_rules :: (Maybe [AwsWafWebAclRule] -> f (Maybe [AwsWafWebAclRule]))
-> AwsWafWebAclDetails -> f AwsWafWebAclDetails
awsWafWebAclDetails_rules = (AwsWafWebAclDetails -> Maybe [AwsWafWebAclRule])
-> (AwsWafWebAclDetails
    -> Maybe [AwsWafWebAclRule] -> AwsWafWebAclDetails)
-> Lens
     AwsWafWebAclDetails
     AwsWafWebAclDetails
     (Maybe [AwsWafWebAclRule])
     (Maybe [AwsWafWebAclRule])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsWafWebAclDetails' {Maybe [AwsWafWebAclRule]
rules :: Maybe [AwsWafWebAclRule]
$sel:rules:AwsWafWebAclDetails' :: AwsWafWebAclDetails -> Maybe [AwsWafWebAclRule]
rules} -> Maybe [AwsWafWebAclRule]
rules) (\s :: AwsWafWebAclDetails
s@AwsWafWebAclDetails' {} Maybe [AwsWafWebAclRule]
a -> AwsWafWebAclDetails
s {$sel:rules:AwsWafWebAclDetails' :: Maybe [AwsWafWebAclRule]
rules = Maybe [AwsWafWebAclRule]
a} :: AwsWafWebAclDetails) ((Maybe [AwsWafWebAclRule] -> f (Maybe [AwsWafWebAclRule]))
 -> AwsWafWebAclDetails -> f AwsWafWebAclDetails)
-> ((Maybe [AwsWafWebAclRule] -> f (Maybe [AwsWafWebAclRule]))
    -> Maybe [AwsWafWebAclRule] -> f (Maybe [AwsWafWebAclRule]))
-> (Maybe [AwsWafWebAclRule] -> f (Maybe [AwsWafWebAclRule]))
-> AwsWafWebAclDetails
-> f AwsWafWebAclDetails
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [AwsWafWebAclRule]
  [AwsWafWebAclRule]
  [AwsWafWebAclRule]
  [AwsWafWebAclRule]
-> Iso
     (Maybe [AwsWafWebAclRule])
     (Maybe [AwsWafWebAclRule])
     (Maybe [AwsWafWebAclRule])
     (Maybe [AwsWafWebAclRule])
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
  [AwsWafWebAclRule]
  [AwsWafWebAclRule]
  [AwsWafWebAclRule]
  [AwsWafWebAclRule]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | A unique identifier for a WebACL.
awsWafWebAclDetails_webAclId :: Lens.Lens' AwsWafWebAclDetails (Prelude.Maybe Prelude.Text)
awsWafWebAclDetails_webAclId :: (Maybe Text -> f (Maybe Text))
-> AwsWafWebAclDetails -> f AwsWafWebAclDetails
awsWafWebAclDetails_webAclId = (AwsWafWebAclDetails -> Maybe Text)
-> (AwsWafWebAclDetails -> Maybe Text -> AwsWafWebAclDetails)
-> Lens
     AwsWafWebAclDetails AwsWafWebAclDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsWafWebAclDetails' {Maybe Text
webAclId :: Maybe Text
$sel:webAclId:AwsWafWebAclDetails' :: AwsWafWebAclDetails -> Maybe Text
webAclId} -> Maybe Text
webAclId) (\s :: AwsWafWebAclDetails
s@AwsWafWebAclDetails' {} Maybe Text
a -> AwsWafWebAclDetails
s {$sel:webAclId:AwsWafWebAclDetails' :: Maybe Text
webAclId = Maybe Text
a} :: AwsWafWebAclDetails)

-- | A friendly name or description of the WebACL. You can\'t change the name
-- of a WebACL after you create it.
awsWafWebAclDetails_name :: Lens.Lens' AwsWafWebAclDetails (Prelude.Maybe Prelude.Text)
awsWafWebAclDetails_name :: (Maybe Text -> f (Maybe Text))
-> AwsWafWebAclDetails -> f AwsWafWebAclDetails
awsWafWebAclDetails_name = (AwsWafWebAclDetails -> Maybe Text)
-> (AwsWafWebAclDetails -> Maybe Text -> AwsWafWebAclDetails)
-> Lens
     AwsWafWebAclDetails AwsWafWebAclDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsWafWebAclDetails' {Maybe Text
name :: Maybe Text
$sel:name:AwsWafWebAclDetails' :: AwsWafWebAclDetails -> Maybe Text
name} -> Maybe Text
name) (\s :: AwsWafWebAclDetails
s@AwsWafWebAclDetails' {} Maybe Text
a -> AwsWafWebAclDetails
s {$sel:name:AwsWafWebAclDetails' :: Maybe Text
name = Maybe Text
a} :: AwsWafWebAclDetails)

-- | The action to perform if none of the rules contained in the WebACL
-- match.
awsWafWebAclDetails_defaultAction :: Lens.Lens' AwsWafWebAclDetails (Prelude.Maybe Prelude.Text)
awsWafWebAclDetails_defaultAction :: (Maybe Text -> f (Maybe Text))
-> AwsWafWebAclDetails -> f AwsWafWebAclDetails
awsWafWebAclDetails_defaultAction = (AwsWafWebAclDetails -> Maybe Text)
-> (AwsWafWebAclDetails -> Maybe Text -> AwsWafWebAclDetails)
-> Lens
     AwsWafWebAclDetails AwsWafWebAclDetails (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\AwsWafWebAclDetails' {Maybe Text
defaultAction :: Maybe Text
$sel:defaultAction:AwsWafWebAclDetails' :: AwsWafWebAclDetails -> Maybe Text
defaultAction} -> Maybe Text
defaultAction) (\s :: AwsWafWebAclDetails
s@AwsWafWebAclDetails' {} Maybe Text
a -> AwsWafWebAclDetails
s {$sel:defaultAction:AwsWafWebAclDetails' :: Maybe Text
defaultAction = Maybe Text
a} :: AwsWafWebAclDetails)

instance Core.FromJSON AwsWafWebAclDetails where
  parseJSON :: Value -> Parser AwsWafWebAclDetails
parseJSON =
    String
-> (Object -> Parser AwsWafWebAclDetails)
-> Value
-> Parser AwsWafWebAclDetails
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"AwsWafWebAclDetails"
      ( \Object
x ->
          Maybe [AwsWafWebAclRule]
-> Maybe Text -> Maybe Text -> Maybe Text -> AwsWafWebAclDetails
AwsWafWebAclDetails'
            (Maybe [AwsWafWebAclRule]
 -> Maybe Text -> Maybe Text -> Maybe Text -> AwsWafWebAclDetails)
-> Parser (Maybe [AwsWafWebAclRule])
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> AwsWafWebAclDetails)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe (Maybe [AwsWafWebAclRule]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Rules" Parser (Maybe (Maybe [AwsWafWebAclRule]))
-> Maybe [AwsWafWebAclRule] -> Parser (Maybe [AwsWafWebAclRule])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [AwsWafWebAclRule]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe Text -> Maybe Text -> Maybe Text -> AwsWafWebAclDetails)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> AwsWafWebAclDetails)
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
"WebAclId")
            Parser (Maybe Text -> Maybe Text -> AwsWafWebAclDetails)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> AwsWafWebAclDetails)
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
"Name")
            Parser (Maybe Text -> AwsWafWebAclDetails)
-> Parser (Maybe Text) -> Parser AwsWafWebAclDetails
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
"DefaultAction")
      )

instance Prelude.Hashable AwsWafWebAclDetails

instance Prelude.NFData AwsWafWebAclDetails

instance Core.ToJSON AwsWafWebAclDetails where
  toJSON :: AwsWafWebAclDetails -> Value
toJSON AwsWafWebAclDetails' {Maybe [AwsWafWebAclRule]
Maybe Text
defaultAction :: Maybe Text
name :: Maybe Text
webAclId :: Maybe Text
rules :: Maybe [AwsWafWebAclRule]
$sel:defaultAction:AwsWafWebAclDetails' :: AwsWafWebAclDetails -> Maybe Text
$sel:name:AwsWafWebAclDetails' :: AwsWafWebAclDetails -> Maybe Text
$sel:webAclId:AwsWafWebAclDetails' :: AwsWafWebAclDetails -> Maybe Text
$sel:rules:AwsWafWebAclDetails' :: AwsWafWebAclDetails -> Maybe [AwsWafWebAclRule]
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Rules" Text -> [AwsWafWebAclRule] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) ([AwsWafWebAclRule] -> Pair)
-> Maybe [AwsWafWebAclRule] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [AwsWafWebAclRule]
rules,
            (Text
"WebAclId" 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
webAclId,
            (Text
"Name" 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
name,
            (Text
"DefaultAction" 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
defaultAction
          ]
      )