{-# 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.WAFV2.Types.ManagedRuleSet
-- 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.WAFV2.Types.ManagedRuleSet where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.WAFV2.Types.ManagedRuleSetVersion

-- | A set of rules that is managed by Amazon Web Services and Amazon Web
-- Services Marketplace sellers to provide versioned managed rule groups
-- for customers of WAF.
--
-- This is intended for use only by vendors of managed rule sets. Vendors
-- are Amazon Web Services and Amazon Web Services Marketplace sellers.
--
-- Vendors, you can use the managed rule set APIs to provide controlled
-- rollout of your versioned managed rule group offerings for your
-- customers. The APIs are @ListManagedRuleSets@, @GetManagedRuleSet@,
-- @PutManagedRuleSetVersions@, and
-- @UpdateManagedRuleSetVersionExpiryDate@.
--
-- /See:/ 'newManagedRuleSet' smart constructor.
data ManagedRuleSet = ManagedRuleSet'
  { -- | A description of the set that helps with identification.
    ManagedRuleSet -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The label namespace prefix for the managed rule groups that are offered
    -- to customers from this managed rule set. All labels that are added by
    -- rules in the managed rule group have this prefix.
    --
    -- -   The syntax for the label namespace prefix for a managed rule group
    --     is the following:
    --
    --     @awswaf:managed:\<vendor>:\<rule group name>@:
    --
    -- -   When a rule with a label matches a web request, WAF adds the fully
    --     qualified label to the request. A fully qualified label is made up
    --     of the label namespace from the rule group or web ACL where the rule
    --     is defined and the label from the rule, separated by a colon:
    --
    --     @\<label namespace>:\<label from rule>@
    ManagedRuleSet -> Maybe Text
labelNamespace :: Prelude.Maybe Prelude.Text,
    -- | The versions of this managed rule set that are available for use by
    -- customers.
    ManagedRuleSet -> Maybe (HashMap Text ManagedRuleSetVersion)
publishedVersions :: Prelude.Maybe (Prelude.HashMap Prelude.Text ManagedRuleSetVersion),
    -- | The version that you would like your customers to use.
    ManagedRuleSet -> Maybe Text
recommendedVersion :: Prelude.Maybe Prelude.Text,
    -- | The name of the managed rule set. You use this, along with the rule set
    -- ID, to identify the rule set.
    --
    -- This name is assigned to the corresponding managed rule group, which
    -- your customers can access and use.
    ManagedRuleSet -> Text
name :: Prelude.Text,
    -- | A unique identifier for the managed rule set. The ID is returned in the
    -- responses to commands like @list@. You provide it to operations like
    -- @get@ and @update@.
    ManagedRuleSet -> Text
id :: Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the entity.
    ManagedRuleSet -> Text
arn :: Prelude.Text
  }
  deriving (ManagedRuleSet -> ManagedRuleSet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ManagedRuleSet -> ManagedRuleSet -> Bool
$c/= :: ManagedRuleSet -> ManagedRuleSet -> Bool
== :: ManagedRuleSet -> ManagedRuleSet -> Bool
$c== :: ManagedRuleSet -> ManagedRuleSet -> Bool
Prelude.Eq, ReadPrec [ManagedRuleSet]
ReadPrec ManagedRuleSet
Int -> ReadS ManagedRuleSet
ReadS [ManagedRuleSet]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ManagedRuleSet]
$creadListPrec :: ReadPrec [ManagedRuleSet]
readPrec :: ReadPrec ManagedRuleSet
$creadPrec :: ReadPrec ManagedRuleSet
readList :: ReadS [ManagedRuleSet]
$creadList :: ReadS [ManagedRuleSet]
readsPrec :: Int -> ReadS ManagedRuleSet
$creadsPrec :: Int -> ReadS ManagedRuleSet
Prelude.Read, Int -> ManagedRuleSet -> ShowS
[ManagedRuleSet] -> ShowS
ManagedRuleSet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ManagedRuleSet] -> ShowS
$cshowList :: [ManagedRuleSet] -> ShowS
show :: ManagedRuleSet -> String
$cshow :: ManagedRuleSet -> String
showsPrec :: Int -> ManagedRuleSet -> ShowS
$cshowsPrec :: Int -> ManagedRuleSet -> ShowS
Prelude.Show, forall x. Rep ManagedRuleSet x -> ManagedRuleSet
forall x. ManagedRuleSet -> Rep ManagedRuleSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ManagedRuleSet x -> ManagedRuleSet
$cfrom :: forall x. ManagedRuleSet -> Rep ManagedRuleSet x
Prelude.Generic)

-- |
-- Create a value of 'ManagedRuleSet' 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:
--
-- 'description', 'managedRuleSet_description' - A description of the set that helps with identification.
--
-- 'labelNamespace', 'managedRuleSet_labelNamespace' - The label namespace prefix for the managed rule groups that are offered
-- to customers from this managed rule set. All labels that are added by
-- rules in the managed rule group have this prefix.
--
-- -   The syntax for the label namespace prefix for a managed rule group
--     is the following:
--
--     @awswaf:managed:\<vendor>:\<rule group name>@:
--
-- -   When a rule with a label matches a web request, WAF adds the fully
--     qualified label to the request. A fully qualified label is made up
--     of the label namespace from the rule group or web ACL where the rule
--     is defined and the label from the rule, separated by a colon:
--
--     @\<label namespace>:\<label from rule>@
--
-- 'publishedVersions', 'managedRuleSet_publishedVersions' - The versions of this managed rule set that are available for use by
-- customers.
--
-- 'recommendedVersion', 'managedRuleSet_recommendedVersion' - The version that you would like your customers to use.
--
-- 'name', 'managedRuleSet_name' - The name of the managed rule set. You use this, along with the rule set
-- ID, to identify the rule set.
--
-- This name is assigned to the corresponding managed rule group, which
-- your customers can access and use.
--
-- 'id', 'managedRuleSet_id' - A unique identifier for the managed rule set. The ID is returned in the
-- responses to commands like @list@. You provide it to operations like
-- @get@ and @update@.
--
-- 'arn', 'managedRuleSet_arn' - The Amazon Resource Name (ARN) of the entity.
newManagedRuleSet ::
  -- | 'name'
  Prelude.Text ->
  -- | 'id'
  Prelude.Text ->
  -- | 'arn'
  Prelude.Text ->
  ManagedRuleSet
newManagedRuleSet :: Text -> Text -> Text -> ManagedRuleSet
newManagedRuleSet Text
pName_ Text
pId_ Text
pARN_ =
  ManagedRuleSet'
    { $sel:description:ManagedRuleSet' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
      $sel:labelNamespace:ManagedRuleSet' :: Maybe Text
labelNamespace = forall a. Maybe a
Prelude.Nothing,
      $sel:publishedVersions:ManagedRuleSet' :: Maybe (HashMap Text ManagedRuleSetVersion)
publishedVersions = forall a. Maybe a
Prelude.Nothing,
      $sel:recommendedVersion:ManagedRuleSet' :: Maybe Text
recommendedVersion = forall a. Maybe a
Prelude.Nothing,
      $sel:name:ManagedRuleSet' :: Text
name = Text
pName_,
      $sel:id:ManagedRuleSet' :: Text
id = Text
pId_,
      $sel:arn:ManagedRuleSet' :: Text
arn = Text
pARN_
    }

-- | A description of the set that helps with identification.
managedRuleSet_description :: Lens.Lens' ManagedRuleSet (Prelude.Maybe Prelude.Text)
managedRuleSet_description :: Lens' ManagedRuleSet (Maybe Text)
managedRuleSet_description = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleSet' {Maybe Text
description :: Maybe Text
$sel:description:ManagedRuleSet' :: ManagedRuleSet -> Maybe Text
description} -> Maybe Text
description) (\s :: ManagedRuleSet
s@ManagedRuleSet' {} Maybe Text
a -> ManagedRuleSet
s {$sel:description:ManagedRuleSet' :: Maybe Text
description = Maybe Text
a} :: ManagedRuleSet)

-- | The label namespace prefix for the managed rule groups that are offered
-- to customers from this managed rule set. All labels that are added by
-- rules in the managed rule group have this prefix.
--
-- -   The syntax for the label namespace prefix for a managed rule group
--     is the following:
--
--     @awswaf:managed:\<vendor>:\<rule group name>@:
--
-- -   When a rule with a label matches a web request, WAF adds the fully
--     qualified label to the request. A fully qualified label is made up
--     of the label namespace from the rule group or web ACL where the rule
--     is defined and the label from the rule, separated by a colon:
--
--     @\<label namespace>:\<label from rule>@
managedRuleSet_labelNamespace :: Lens.Lens' ManagedRuleSet (Prelude.Maybe Prelude.Text)
managedRuleSet_labelNamespace :: Lens' ManagedRuleSet (Maybe Text)
managedRuleSet_labelNamespace = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleSet' {Maybe Text
labelNamespace :: Maybe Text
$sel:labelNamespace:ManagedRuleSet' :: ManagedRuleSet -> Maybe Text
labelNamespace} -> Maybe Text
labelNamespace) (\s :: ManagedRuleSet
s@ManagedRuleSet' {} Maybe Text
a -> ManagedRuleSet
s {$sel:labelNamespace:ManagedRuleSet' :: Maybe Text
labelNamespace = Maybe Text
a} :: ManagedRuleSet)

-- | The versions of this managed rule set that are available for use by
-- customers.
managedRuleSet_publishedVersions :: Lens.Lens' ManagedRuleSet (Prelude.Maybe (Prelude.HashMap Prelude.Text ManagedRuleSetVersion))
managedRuleSet_publishedVersions :: Lens' ManagedRuleSet (Maybe (HashMap Text ManagedRuleSetVersion))
managedRuleSet_publishedVersions = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleSet' {Maybe (HashMap Text ManagedRuleSetVersion)
publishedVersions :: Maybe (HashMap Text ManagedRuleSetVersion)
$sel:publishedVersions:ManagedRuleSet' :: ManagedRuleSet -> Maybe (HashMap Text ManagedRuleSetVersion)
publishedVersions} -> Maybe (HashMap Text ManagedRuleSetVersion)
publishedVersions) (\s :: ManagedRuleSet
s@ManagedRuleSet' {} Maybe (HashMap Text ManagedRuleSetVersion)
a -> ManagedRuleSet
s {$sel:publishedVersions:ManagedRuleSet' :: Maybe (HashMap Text ManagedRuleSetVersion)
publishedVersions = Maybe (HashMap Text ManagedRuleSetVersion)
a} :: ManagedRuleSet) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The version that you would like your customers to use.
managedRuleSet_recommendedVersion :: Lens.Lens' ManagedRuleSet (Prelude.Maybe Prelude.Text)
managedRuleSet_recommendedVersion :: Lens' ManagedRuleSet (Maybe Text)
managedRuleSet_recommendedVersion = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleSet' {Maybe Text
recommendedVersion :: Maybe Text
$sel:recommendedVersion:ManagedRuleSet' :: ManagedRuleSet -> Maybe Text
recommendedVersion} -> Maybe Text
recommendedVersion) (\s :: ManagedRuleSet
s@ManagedRuleSet' {} Maybe Text
a -> ManagedRuleSet
s {$sel:recommendedVersion:ManagedRuleSet' :: Maybe Text
recommendedVersion = Maybe Text
a} :: ManagedRuleSet)

-- | The name of the managed rule set. You use this, along with the rule set
-- ID, to identify the rule set.
--
-- This name is assigned to the corresponding managed rule group, which
-- your customers can access and use.
managedRuleSet_name :: Lens.Lens' ManagedRuleSet Prelude.Text
managedRuleSet_name :: Lens' ManagedRuleSet Text
managedRuleSet_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleSet' {Text
name :: Text
$sel:name:ManagedRuleSet' :: ManagedRuleSet -> Text
name} -> Text
name) (\s :: ManagedRuleSet
s@ManagedRuleSet' {} Text
a -> ManagedRuleSet
s {$sel:name:ManagedRuleSet' :: Text
name = Text
a} :: ManagedRuleSet)

-- | A unique identifier for the managed rule set. The ID is returned in the
-- responses to commands like @list@. You provide it to operations like
-- @get@ and @update@.
managedRuleSet_id :: Lens.Lens' ManagedRuleSet Prelude.Text
managedRuleSet_id :: Lens' ManagedRuleSet Text
managedRuleSet_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleSet' {Text
id :: Text
$sel:id:ManagedRuleSet' :: ManagedRuleSet -> Text
id} -> Text
id) (\s :: ManagedRuleSet
s@ManagedRuleSet' {} Text
a -> ManagedRuleSet
s {$sel:id:ManagedRuleSet' :: Text
id = Text
a} :: ManagedRuleSet)

-- | The Amazon Resource Name (ARN) of the entity.
managedRuleSet_arn :: Lens.Lens' ManagedRuleSet Prelude.Text
managedRuleSet_arn :: Lens' ManagedRuleSet Text
managedRuleSet_arn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ManagedRuleSet' {Text
arn :: Text
$sel:arn:ManagedRuleSet' :: ManagedRuleSet -> Text
arn} -> Text
arn) (\s :: ManagedRuleSet
s@ManagedRuleSet' {} Text
a -> ManagedRuleSet
s {$sel:arn:ManagedRuleSet' :: Text
arn = Text
a} :: ManagedRuleSet)

instance Data.FromJSON ManagedRuleSet where
  parseJSON :: Value -> Parser ManagedRuleSet
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ManagedRuleSet"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe (HashMap Text ManagedRuleSetVersion)
-> Maybe Text
-> Text
-> Text
-> Text
-> ManagedRuleSet
ManagedRuleSet'
            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
"Description")
            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
"LabelNamespace")
            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
"PublishedVersions"
                            forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty
                        )
            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
"RecommendedVersion")
            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
"Name")
            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
"Id")
            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
"ARN")
      )

instance Prelude.Hashable ManagedRuleSet where
  hashWithSalt :: Int -> ManagedRuleSet -> Int
hashWithSalt Int
_salt ManagedRuleSet' {Maybe Text
Maybe (HashMap Text ManagedRuleSetVersion)
Text
arn :: Text
id :: Text
name :: Text
recommendedVersion :: Maybe Text
publishedVersions :: Maybe (HashMap Text ManagedRuleSetVersion)
labelNamespace :: Maybe Text
description :: Maybe Text
$sel:arn:ManagedRuleSet' :: ManagedRuleSet -> Text
$sel:id:ManagedRuleSet' :: ManagedRuleSet -> Text
$sel:name:ManagedRuleSet' :: ManagedRuleSet -> Text
$sel:recommendedVersion:ManagedRuleSet' :: ManagedRuleSet -> Maybe Text
$sel:publishedVersions:ManagedRuleSet' :: ManagedRuleSet -> Maybe (HashMap Text ManagedRuleSetVersion)
$sel:labelNamespace:ManagedRuleSet' :: ManagedRuleSet -> Maybe Text
$sel:description:ManagedRuleSet' :: ManagedRuleSet -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
labelNamespace
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text ManagedRuleSetVersion)
publishedVersions
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
recommendedVersion
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
arn

instance Prelude.NFData ManagedRuleSet where
  rnf :: ManagedRuleSet -> ()
rnf ManagedRuleSet' {Maybe Text
Maybe (HashMap Text ManagedRuleSetVersion)
Text
arn :: Text
id :: Text
name :: Text
recommendedVersion :: Maybe Text
publishedVersions :: Maybe (HashMap Text ManagedRuleSetVersion)
labelNamespace :: Maybe Text
description :: Maybe Text
$sel:arn:ManagedRuleSet' :: ManagedRuleSet -> Text
$sel:id:ManagedRuleSet' :: ManagedRuleSet -> Text
$sel:name:ManagedRuleSet' :: ManagedRuleSet -> Text
$sel:recommendedVersion:ManagedRuleSet' :: ManagedRuleSet -> Maybe Text
$sel:publishedVersions:ManagedRuleSet' :: ManagedRuleSet -> Maybe (HashMap Text ManagedRuleSetVersion)
$sel:labelNamespace:ManagedRuleSet' :: ManagedRuleSet -> Maybe Text
$sel:description:ManagedRuleSet' :: ManagedRuleSet -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
description
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
labelNamespace
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text ManagedRuleSetVersion)
publishedVersions
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
recommendedVersion
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
arn