{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# 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.CreateRuleGroup
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Creates a RuleGroup per the specifications provided.
--
-- A rule group defines a collection of rules to inspect and control web
-- requests that you can use in a WebACL. When you create a rule group, you
-- define an immutable capacity limit. If you update a rule group, you must
-- stay within the capacity. This allows others to reuse the rule group
-- with confidence in its capacity requirements.
module Amazonka.WAFV2.CreateRuleGroup
  ( -- * Creating a Request
    CreateRuleGroup (..),
    newCreateRuleGroup,

    -- * Request Lenses
    createRuleGroup_customResponseBodies,
    createRuleGroup_description,
    createRuleGroup_rules,
    createRuleGroup_tags,
    createRuleGroup_name,
    createRuleGroup_scope,
    createRuleGroup_capacity,
    createRuleGroup_visibilityConfig,

    -- * Destructuring the Response
    CreateRuleGroupResponse (..),
    newCreateRuleGroupResponse,

    -- * Response Lenses
    createRuleGroupResponse_summary,
    createRuleGroupResponse_httpStatus,
  )
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 qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.WAFV2.Types

-- | /See:/ 'newCreateRuleGroup' smart constructor.
data CreateRuleGroup = CreateRuleGroup'
  { -- | A map of custom response keys and content bodies. When you create a rule
    -- with a block action, you can send a custom response to the web request.
    -- You define these for the rule group, and then use them in the rules that
    -- you define in the rule group.
    --
    -- For information about customizing web requests and responses, see
    -- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-custom-request-response.html Customizing web requests and responses in WAF>
    -- in the
    -- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html WAF Developer Guide>.
    --
    -- For information about the limits on count and size for custom request
    -- and response settings, see
    -- <https://docs.aws.amazon.com/waf/latest/developerguide/limits.html WAF quotas>
    -- in the
    -- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html WAF Developer Guide>.
    CreateRuleGroup -> Maybe (HashMap Text CustomResponseBody)
customResponseBodies :: Prelude.Maybe (Prelude.HashMap Prelude.Text CustomResponseBody),
    -- | A description of the rule group that helps with identification.
    CreateRuleGroup -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | The Rule statements used to identify the web requests that you want to
    -- allow, block, or count. Each rule includes one top-level statement that
    -- WAF uses to identify matching web requests, and parameters that govern
    -- how WAF handles them.
    CreateRuleGroup -> Maybe [Rule]
rules :: Prelude.Maybe [Rule],
    -- | An array of key:value pairs to associate with the resource.
    CreateRuleGroup -> Maybe (NonEmpty Tag)
tags :: Prelude.Maybe (Prelude.NonEmpty Tag),
    -- | The name of the rule group. You cannot change the name of a rule group
    -- after you create it.
    CreateRuleGroup -> Text
name :: Prelude.Text,
    -- | Specifies whether this is for an Amazon CloudFront distribution or for a
    -- regional application. A regional application can be an Application Load
    -- Balancer (ALB), an Amazon API Gateway REST API, an AppSync GraphQL API,
    -- or an Amazon Cognito user pool.
    --
    -- To work with CloudFront, you must also specify the Region US East (N.
    -- Virginia) as follows:
    --
    -- -   CLI - Specify the Region when you use the CloudFront scope:
    --     @--scope=CLOUDFRONT --region=us-east-1@.
    --
    -- -   API and SDKs - For all calls, use the Region endpoint us-east-1.
    CreateRuleGroup -> Scope
scope :: Scope,
    -- | The web ACL capacity units (WCUs) required for this rule group.
    --
    -- When you create your own rule group, you define this, and you cannot
    -- change it after creation. When you add or modify the rules in a rule
    -- group, WAF enforces this limit. You can check the capacity for a set of
    -- rules using CheckCapacity.
    --
    -- WAF uses WCUs to calculate and control the operating resources that are
    -- used to run your rules, rule groups, and web ACLs. WAF calculates
    -- capacity differently for each rule type, to reflect the relative cost of
    -- each rule. Simple rules that cost little to run use fewer WCUs than more
    -- complex rules that use more processing power. Rule group capacity is
    -- fixed at creation, which helps users plan their web ACL WCU usage when
    -- they use a rule group. The WCU limit for web ACLs is 1,500.
    CreateRuleGroup -> Natural
capacity :: Prelude.Natural,
    -- | Defines and enables Amazon CloudWatch metrics and web request sample
    -- collection.
    CreateRuleGroup -> VisibilityConfig
visibilityConfig :: VisibilityConfig
  }
  deriving (CreateRuleGroup -> CreateRuleGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateRuleGroup -> CreateRuleGroup -> Bool
$c/= :: CreateRuleGroup -> CreateRuleGroup -> Bool
== :: CreateRuleGroup -> CreateRuleGroup -> Bool
$c== :: CreateRuleGroup -> CreateRuleGroup -> Bool
Prelude.Eq, ReadPrec [CreateRuleGroup]
ReadPrec CreateRuleGroup
Int -> ReadS CreateRuleGroup
ReadS [CreateRuleGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateRuleGroup]
$creadListPrec :: ReadPrec [CreateRuleGroup]
readPrec :: ReadPrec CreateRuleGroup
$creadPrec :: ReadPrec CreateRuleGroup
readList :: ReadS [CreateRuleGroup]
$creadList :: ReadS [CreateRuleGroup]
readsPrec :: Int -> ReadS CreateRuleGroup
$creadsPrec :: Int -> ReadS CreateRuleGroup
Prelude.Read, Int -> CreateRuleGroup -> ShowS
[CreateRuleGroup] -> ShowS
CreateRuleGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateRuleGroup] -> ShowS
$cshowList :: [CreateRuleGroup] -> ShowS
show :: CreateRuleGroup -> String
$cshow :: CreateRuleGroup -> String
showsPrec :: Int -> CreateRuleGroup -> ShowS
$cshowsPrec :: Int -> CreateRuleGroup -> ShowS
Prelude.Show, forall x. Rep CreateRuleGroup x -> CreateRuleGroup
forall x. CreateRuleGroup -> Rep CreateRuleGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateRuleGroup x -> CreateRuleGroup
$cfrom :: forall x. CreateRuleGroup -> Rep CreateRuleGroup x
Prelude.Generic)

-- |
-- Create a value of 'CreateRuleGroup' 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:
--
-- 'customResponseBodies', 'createRuleGroup_customResponseBodies' - A map of custom response keys and content bodies. When you create a rule
-- with a block action, you can send a custom response to the web request.
-- You define these for the rule group, and then use them in the rules that
-- you define in the rule group.
--
-- For information about customizing web requests and responses, see
-- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-custom-request-response.html Customizing web requests and responses in WAF>
-- in the
-- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html WAF Developer Guide>.
--
-- For information about the limits on count and size for custom request
-- and response settings, see
-- <https://docs.aws.amazon.com/waf/latest/developerguide/limits.html WAF quotas>
-- in the
-- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html WAF Developer Guide>.
--
-- 'description', 'createRuleGroup_description' - A description of the rule group that helps with identification.
--
-- 'rules', 'createRuleGroup_rules' - The Rule statements used to identify the web requests that you want to
-- allow, block, or count. Each rule includes one top-level statement that
-- WAF uses to identify matching web requests, and parameters that govern
-- how WAF handles them.
--
-- 'tags', 'createRuleGroup_tags' - An array of key:value pairs to associate with the resource.
--
-- 'name', 'createRuleGroup_name' - The name of the rule group. You cannot change the name of a rule group
-- after you create it.
--
-- 'scope', 'createRuleGroup_scope' - Specifies whether this is for an Amazon CloudFront distribution or for a
-- regional application. A regional application can be an Application Load
-- Balancer (ALB), an Amazon API Gateway REST API, an AppSync GraphQL API,
-- or an Amazon Cognito user pool.
--
-- To work with CloudFront, you must also specify the Region US East (N.
-- Virginia) as follows:
--
-- -   CLI - Specify the Region when you use the CloudFront scope:
--     @--scope=CLOUDFRONT --region=us-east-1@.
--
-- -   API and SDKs - For all calls, use the Region endpoint us-east-1.
--
-- 'capacity', 'createRuleGroup_capacity' - The web ACL capacity units (WCUs) required for this rule group.
--
-- When you create your own rule group, you define this, and you cannot
-- change it after creation. When you add or modify the rules in a rule
-- group, WAF enforces this limit. You can check the capacity for a set of
-- rules using CheckCapacity.
--
-- WAF uses WCUs to calculate and control the operating resources that are
-- used to run your rules, rule groups, and web ACLs. WAF calculates
-- capacity differently for each rule type, to reflect the relative cost of
-- each rule. Simple rules that cost little to run use fewer WCUs than more
-- complex rules that use more processing power. Rule group capacity is
-- fixed at creation, which helps users plan their web ACL WCU usage when
-- they use a rule group. The WCU limit for web ACLs is 1,500.
--
-- 'visibilityConfig', 'createRuleGroup_visibilityConfig' - Defines and enables Amazon CloudWatch metrics and web request sample
-- collection.
newCreateRuleGroup ::
  -- | 'name'
  Prelude.Text ->
  -- | 'scope'
  Scope ->
  -- | 'capacity'
  Prelude.Natural ->
  -- | 'visibilityConfig'
  VisibilityConfig ->
  CreateRuleGroup
newCreateRuleGroup :: Text -> Scope -> Natural -> VisibilityConfig -> CreateRuleGroup
newCreateRuleGroup
  Text
pName_
  Scope
pScope_
  Natural
pCapacity_
  VisibilityConfig
pVisibilityConfig_ =
    CreateRuleGroup'
      { $sel:customResponseBodies:CreateRuleGroup' :: Maybe (HashMap Text CustomResponseBody)
customResponseBodies =
          forall a. Maybe a
Prelude.Nothing,
        $sel:description:CreateRuleGroup' :: Maybe Text
description = forall a. Maybe a
Prelude.Nothing,
        $sel:rules:CreateRuleGroup' :: Maybe [Rule]
rules = forall a. Maybe a
Prelude.Nothing,
        $sel:tags:CreateRuleGroup' :: Maybe (NonEmpty Tag)
tags = forall a. Maybe a
Prelude.Nothing,
        $sel:name:CreateRuleGroup' :: Text
name = Text
pName_,
        $sel:scope:CreateRuleGroup' :: Scope
scope = Scope
pScope_,
        $sel:capacity:CreateRuleGroup' :: Natural
capacity = Natural
pCapacity_,
        $sel:visibilityConfig:CreateRuleGroup' :: VisibilityConfig
visibilityConfig = VisibilityConfig
pVisibilityConfig_
      }

-- | A map of custom response keys and content bodies. When you create a rule
-- with a block action, you can send a custom response to the web request.
-- You define these for the rule group, and then use them in the rules that
-- you define in the rule group.
--
-- For information about customizing web requests and responses, see
-- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-custom-request-response.html Customizing web requests and responses in WAF>
-- in the
-- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html WAF Developer Guide>.
--
-- For information about the limits on count and size for custom request
-- and response settings, see
-- <https://docs.aws.amazon.com/waf/latest/developerguide/limits.html WAF quotas>
-- in the
-- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html WAF Developer Guide>.
createRuleGroup_customResponseBodies :: Lens.Lens' CreateRuleGroup (Prelude.Maybe (Prelude.HashMap Prelude.Text CustomResponseBody))
createRuleGroup_customResponseBodies :: Lens' CreateRuleGroup (Maybe (HashMap Text CustomResponseBody))
createRuleGroup_customResponseBodies = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRuleGroup' {Maybe (HashMap Text CustomResponseBody)
customResponseBodies :: Maybe (HashMap Text CustomResponseBody)
$sel:customResponseBodies:CreateRuleGroup' :: CreateRuleGroup -> Maybe (HashMap Text CustomResponseBody)
customResponseBodies} -> Maybe (HashMap Text CustomResponseBody)
customResponseBodies) (\s :: CreateRuleGroup
s@CreateRuleGroup' {} Maybe (HashMap Text CustomResponseBody)
a -> CreateRuleGroup
s {$sel:customResponseBodies:CreateRuleGroup' :: Maybe (HashMap Text CustomResponseBody)
customResponseBodies = Maybe (HashMap Text CustomResponseBody)
a} :: CreateRuleGroup) 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

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

-- | The Rule statements used to identify the web requests that you want to
-- allow, block, or count. Each rule includes one top-level statement that
-- WAF uses to identify matching web requests, and parameters that govern
-- how WAF handles them.
createRuleGroup_rules :: Lens.Lens' CreateRuleGroup (Prelude.Maybe [Rule])
createRuleGroup_rules :: Lens' CreateRuleGroup (Maybe [Rule])
createRuleGroup_rules = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRuleGroup' {Maybe [Rule]
rules :: Maybe [Rule]
$sel:rules:CreateRuleGroup' :: CreateRuleGroup -> Maybe [Rule]
rules} -> Maybe [Rule]
rules) (\s :: CreateRuleGroup
s@CreateRuleGroup' {} Maybe [Rule]
a -> CreateRuleGroup
s {$sel:rules:CreateRuleGroup' :: Maybe [Rule]
rules = Maybe [Rule]
a} :: CreateRuleGroup) 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

-- | An array of key:value pairs to associate with the resource.
createRuleGroup_tags :: Lens.Lens' CreateRuleGroup (Prelude.Maybe (Prelude.NonEmpty Tag))
createRuleGroup_tags :: Lens' CreateRuleGroup (Maybe (NonEmpty Tag))
createRuleGroup_tags = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRuleGroup' {Maybe (NonEmpty Tag)
tags :: Maybe (NonEmpty Tag)
$sel:tags:CreateRuleGroup' :: CreateRuleGroup -> Maybe (NonEmpty Tag)
tags} -> Maybe (NonEmpty Tag)
tags) (\s :: CreateRuleGroup
s@CreateRuleGroup' {} Maybe (NonEmpty Tag)
a -> CreateRuleGroup
s {$sel:tags:CreateRuleGroup' :: Maybe (NonEmpty Tag)
tags = Maybe (NonEmpty Tag)
a} :: CreateRuleGroup) 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 name of the rule group. You cannot change the name of a rule group
-- after you create it.
createRuleGroup_name :: Lens.Lens' CreateRuleGroup Prelude.Text
createRuleGroup_name :: Lens' CreateRuleGroup Text
createRuleGroup_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRuleGroup' {Text
name :: Text
$sel:name:CreateRuleGroup' :: CreateRuleGroup -> Text
name} -> Text
name) (\s :: CreateRuleGroup
s@CreateRuleGroup' {} Text
a -> CreateRuleGroup
s {$sel:name:CreateRuleGroup' :: Text
name = Text
a} :: CreateRuleGroup)

-- | Specifies whether this is for an Amazon CloudFront distribution or for a
-- regional application. A regional application can be an Application Load
-- Balancer (ALB), an Amazon API Gateway REST API, an AppSync GraphQL API,
-- or an Amazon Cognito user pool.
--
-- To work with CloudFront, you must also specify the Region US East (N.
-- Virginia) as follows:
--
-- -   CLI - Specify the Region when you use the CloudFront scope:
--     @--scope=CLOUDFRONT --region=us-east-1@.
--
-- -   API and SDKs - For all calls, use the Region endpoint us-east-1.
createRuleGroup_scope :: Lens.Lens' CreateRuleGroup Scope
createRuleGroup_scope :: Lens' CreateRuleGroup Scope
createRuleGroup_scope = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRuleGroup' {Scope
scope :: Scope
$sel:scope:CreateRuleGroup' :: CreateRuleGroup -> Scope
scope} -> Scope
scope) (\s :: CreateRuleGroup
s@CreateRuleGroup' {} Scope
a -> CreateRuleGroup
s {$sel:scope:CreateRuleGroup' :: Scope
scope = Scope
a} :: CreateRuleGroup)

-- | The web ACL capacity units (WCUs) required for this rule group.
--
-- When you create your own rule group, you define this, and you cannot
-- change it after creation. When you add or modify the rules in a rule
-- group, WAF enforces this limit. You can check the capacity for a set of
-- rules using CheckCapacity.
--
-- WAF uses WCUs to calculate and control the operating resources that are
-- used to run your rules, rule groups, and web ACLs. WAF calculates
-- capacity differently for each rule type, to reflect the relative cost of
-- each rule. Simple rules that cost little to run use fewer WCUs than more
-- complex rules that use more processing power. Rule group capacity is
-- fixed at creation, which helps users plan their web ACL WCU usage when
-- they use a rule group. The WCU limit for web ACLs is 1,500.
createRuleGroup_capacity :: Lens.Lens' CreateRuleGroup Prelude.Natural
createRuleGroup_capacity :: Lens' CreateRuleGroup Natural
createRuleGroup_capacity = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRuleGroup' {Natural
capacity :: Natural
$sel:capacity:CreateRuleGroup' :: CreateRuleGroup -> Natural
capacity} -> Natural
capacity) (\s :: CreateRuleGroup
s@CreateRuleGroup' {} Natural
a -> CreateRuleGroup
s {$sel:capacity:CreateRuleGroup' :: Natural
capacity = Natural
a} :: CreateRuleGroup)

-- | Defines and enables Amazon CloudWatch metrics and web request sample
-- collection.
createRuleGroup_visibilityConfig :: Lens.Lens' CreateRuleGroup VisibilityConfig
createRuleGroup_visibilityConfig :: Lens' CreateRuleGroup VisibilityConfig
createRuleGroup_visibilityConfig = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRuleGroup' {VisibilityConfig
visibilityConfig :: VisibilityConfig
$sel:visibilityConfig:CreateRuleGroup' :: CreateRuleGroup -> VisibilityConfig
visibilityConfig} -> VisibilityConfig
visibilityConfig) (\s :: CreateRuleGroup
s@CreateRuleGroup' {} VisibilityConfig
a -> CreateRuleGroup
s {$sel:visibilityConfig:CreateRuleGroup' :: VisibilityConfig
visibilityConfig = VisibilityConfig
a} :: CreateRuleGroup)

instance Core.AWSRequest CreateRuleGroup where
  type
    AWSResponse CreateRuleGroup =
      CreateRuleGroupResponse
  request :: (Service -> Service) -> CreateRuleGroup -> Request CreateRuleGroup
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy CreateRuleGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse CreateRuleGroup)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe RuleGroupSummary -> Int -> CreateRuleGroupResponse
CreateRuleGroupResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"Summary")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable CreateRuleGroup where
  hashWithSalt :: Int -> CreateRuleGroup -> Int
hashWithSalt Int
_salt CreateRuleGroup' {Natural
Maybe [Rule]
Maybe (NonEmpty Tag)
Maybe Text
Maybe (HashMap Text CustomResponseBody)
Text
Scope
VisibilityConfig
visibilityConfig :: VisibilityConfig
capacity :: Natural
scope :: Scope
name :: Text
tags :: Maybe (NonEmpty Tag)
rules :: Maybe [Rule]
description :: Maybe Text
customResponseBodies :: Maybe (HashMap Text CustomResponseBody)
$sel:visibilityConfig:CreateRuleGroup' :: CreateRuleGroup -> VisibilityConfig
$sel:capacity:CreateRuleGroup' :: CreateRuleGroup -> Natural
$sel:scope:CreateRuleGroup' :: CreateRuleGroup -> Scope
$sel:name:CreateRuleGroup' :: CreateRuleGroup -> Text
$sel:tags:CreateRuleGroup' :: CreateRuleGroup -> Maybe (NonEmpty Tag)
$sel:rules:CreateRuleGroup' :: CreateRuleGroup -> Maybe [Rule]
$sel:description:CreateRuleGroup' :: CreateRuleGroup -> Maybe Text
$sel:customResponseBodies:CreateRuleGroup' :: CreateRuleGroup -> Maybe (HashMap Text CustomResponseBody)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (HashMap Text CustomResponseBody)
customResponseBodies
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
description
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [Rule]
rules
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (NonEmpty Tag)
tags
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Scope
scope
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
capacity
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` VisibilityConfig
visibilityConfig

instance Prelude.NFData CreateRuleGroup where
  rnf :: CreateRuleGroup -> ()
rnf CreateRuleGroup' {Natural
Maybe [Rule]
Maybe (NonEmpty Tag)
Maybe Text
Maybe (HashMap Text CustomResponseBody)
Text
Scope
VisibilityConfig
visibilityConfig :: VisibilityConfig
capacity :: Natural
scope :: Scope
name :: Text
tags :: Maybe (NonEmpty Tag)
rules :: Maybe [Rule]
description :: Maybe Text
customResponseBodies :: Maybe (HashMap Text CustomResponseBody)
$sel:visibilityConfig:CreateRuleGroup' :: CreateRuleGroup -> VisibilityConfig
$sel:capacity:CreateRuleGroup' :: CreateRuleGroup -> Natural
$sel:scope:CreateRuleGroup' :: CreateRuleGroup -> Scope
$sel:name:CreateRuleGroup' :: CreateRuleGroup -> Text
$sel:tags:CreateRuleGroup' :: CreateRuleGroup -> Maybe (NonEmpty Tag)
$sel:rules:CreateRuleGroup' :: CreateRuleGroup -> Maybe [Rule]
$sel:description:CreateRuleGroup' :: CreateRuleGroup -> Maybe Text
$sel:customResponseBodies:CreateRuleGroup' :: CreateRuleGroup -> Maybe (HashMap Text CustomResponseBody)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (HashMap Text CustomResponseBody)
customResponseBodies
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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 [Rule]
rules
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe (NonEmpty Tag)
tags
      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 Scope
scope
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
capacity
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf VisibilityConfig
visibilityConfig

instance Data.ToHeaders CreateRuleGroup where
  toHeaders :: CreateRuleGroup -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AWSWAF_20190729.CreateRuleGroup" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON CreateRuleGroup where
  toJSON :: CreateRuleGroup -> Value
toJSON CreateRuleGroup' {Natural
Maybe [Rule]
Maybe (NonEmpty Tag)
Maybe Text
Maybe (HashMap Text CustomResponseBody)
Text
Scope
VisibilityConfig
visibilityConfig :: VisibilityConfig
capacity :: Natural
scope :: Scope
name :: Text
tags :: Maybe (NonEmpty Tag)
rules :: Maybe [Rule]
description :: Maybe Text
customResponseBodies :: Maybe (HashMap Text CustomResponseBody)
$sel:visibilityConfig:CreateRuleGroup' :: CreateRuleGroup -> VisibilityConfig
$sel:capacity:CreateRuleGroup' :: CreateRuleGroup -> Natural
$sel:scope:CreateRuleGroup' :: CreateRuleGroup -> Scope
$sel:name:CreateRuleGroup' :: CreateRuleGroup -> Text
$sel:tags:CreateRuleGroup' :: CreateRuleGroup -> Maybe (NonEmpty Tag)
$sel:rules:CreateRuleGroup' :: CreateRuleGroup -> Maybe [Rule]
$sel:description:CreateRuleGroup' :: CreateRuleGroup -> Maybe Text
$sel:customResponseBodies:CreateRuleGroup' :: CreateRuleGroup -> Maybe (HashMap Text CustomResponseBody)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"CustomResponseBodies" 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 (HashMap Text CustomResponseBody)
customResponseBodies,
            (Key
"Description" 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 Text
description,
            (Key
"Rules" 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 [Rule]
rules,
            (Key
"Tags" 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 (NonEmpty Tag)
tags,
            forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Scope" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Scope
scope),
            forall a. a -> Maybe a
Prelude.Just (Key
"Capacity" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
capacity),
            forall a. a -> Maybe a
Prelude.Just
              (Key
"VisibilityConfig" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= VisibilityConfig
visibilityConfig)
          ]
      )

instance Data.ToPath CreateRuleGroup where
  toPath :: CreateRuleGroup -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Data.ToQuery CreateRuleGroup where
  toQuery :: CreateRuleGroup -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newCreateRuleGroupResponse' smart constructor.
data CreateRuleGroupResponse = CreateRuleGroupResponse'
  { -- | High-level information about a RuleGroup, returned by operations like
    -- create and list. This provides information like the ID, that you can use
    -- to retrieve and manage a @RuleGroup@, and the ARN, that you provide to
    -- the RuleGroupReferenceStatement to use the rule group in a Rule.
    CreateRuleGroupResponse -> Maybe RuleGroupSummary
summary :: Prelude.Maybe RuleGroupSummary,
    -- | The response's http status code.
    CreateRuleGroupResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (CreateRuleGroupResponse -> CreateRuleGroupResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateRuleGroupResponse -> CreateRuleGroupResponse -> Bool
$c/= :: CreateRuleGroupResponse -> CreateRuleGroupResponse -> Bool
== :: CreateRuleGroupResponse -> CreateRuleGroupResponse -> Bool
$c== :: CreateRuleGroupResponse -> CreateRuleGroupResponse -> Bool
Prelude.Eq, ReadPrec [CreateRuleGroupResponse]
ReadPrec CreateRuleGroupResponse
Int -> ReadS CreateRuleGroupResponse
ReadS [CreateRuleGroupResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateRuleGroupResponse]
$creadListPrec :: ReadPrec [CreateRuleGroupResponse]
readPrec :: ReadPrec CreateRuleGroupResponse
$creadPrec :: ReadPrec CreateRuleGroupResponse
readList :: ReadS [CreateRuleGroupResponse]
$creadList :: ReadS [CreateRuleGroupResponse]
readsPrec :: Int -> ReadS CreateRuleGroupResponse
$creadsPrec :: Int -> ReadS CreateRuleGroupResponse
Prelude.Read, Int -> CreateRuleGroupResponse -> ShowS
[CreateRuleGroupResponse] -> ShowS
CreateRuleGroupResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateRuleGroupResponse] -> ShowS
$cshowList :: [CreateRuleGroupResponse] -> ShowS
show :: CreateRuleGroupResponse -> String
$cshow :: CreateRuleGroupResponse -> String
showsPrec :: Int -> CreateRuleGroupResponse -> ShowS
$cshowsPrec :: Int -> CreateRuleGroupResponse -> ShowS
Prelude.Show, forall x. Rep CreateRuleGroupResponse x -> CreateRuleGroupResponse
forall x. CreateRuleGroupResponse -> Rep CreateRuleGroupResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CreateRuleGroupResponse x -> CreateRuleGroupResponse
$cfrom :: forall x. CreateRuleGroupResponse -> Rep CreateRuleGroupResponse x
Prelude.Generic)

-- |
-- Create a value of 'CreateRuleGroupResponse' 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:
--
-- 'summary', 'createRuleGroupResponse_summary' - High-level information about a RuleGroup, returned by operations like
-- create and list. This provides information like the ID, that you can use
-- to retrieve and manage a @RuleGroup@, and the ARN, that you provide to
-- the RuleGroupReferenceStatement to use the rule group in a Rule.
--
-- 'httpStatus', 'createRuleGroupResponse_httpStatus' - The response's http status code.
newCreateRuleGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  CreateRuleGroupResponse
newCreateRuleGroupResponse :: Int -> CreateRuleGroupResponse
newCreateRuleGroupResponse Int
pHttpStatus_ =
  CreateRuleGroupResponse'
    { $sel:summary:CreateRuleGroupResponse' :: Maybe RuleGroupSummary
summary = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:CreateRuleGroupResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | High-level information about a RuleGroup, returned by operations like
-- create and list. This provides information like the ID, that you can use
-- to retrieve and manage a @RuleGroup@, and the ARN, that you provide to
-- the RuleGroupReferenceStatement to use the rule group in a Rule.
createRuleGroupResponse_summary :: Lens.Lens' CreateRuleGroupResponse (Prelude.Maybe RuleGroupSummary)
createRuleGroupResponse_summary :: Lens' CreateRuleGroupResponse (Maybe RuleGroupSummary)
createRuleGroupResponse_summary = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRuleGroupResponse' {Maybe RuleGroupSummary
summary :: Maybe RuleGroupSummary
$sel:summary:CreateRuleGroupResponse' :: CreateRuleGroupResponse -> Maybe RuleGroupSummary
summary} -> Maybe RuleGroupSummary
summary) (\s :: CreateRuleGroupResponse
s@CreateRuleGroupResponse' {} Maybe RuleGroupSummary
a -> CreateRuleGroupResponse
s {$sel:summary:CreateRuleGroupResponse' :: Maybe RuleGroupSummary
summary = Maybe RuleGroupSummary
a} :: CreateRuleGroupResponse)

-- | The response's http status code.
createRuleGroupResponse_httpStatus :: Lens.Lens' CreateRuleGroupResponse Prelude.Int
createRuleGroupResponse_httpStatus :: Lens' CreateRuleGroupResponse Int
createRuleGroupResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateRuleGroupResponse' {Int
httpStatus :: Int
$sel:httpStatus:CreateRuleGroupResponse' :: CreateRuleGroupResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: CreateRuleGroupResponse
s@CreateRuleGroupResponse' {} Int
a -> CreateRuleGroupResponse
s {$sel:httpStatus:CreateRuleGroupResponse' :: Int
httpStatus = Int
a} :: CreateRuleGroupResponse)

instance Prelude.NFData CreateRuleGroupResponse where
  rnf :: CreateRuleGroupResponse -> ()
rnf CreateRuleGroupResponse' {Int
Maybe RuleGroupSummary
httpStatus :: Int
summary :: Maybe RuleGroupSummary
$sel:httpStatus:CreateRuleGroupResponse' :: CreateRuleGroupResponse -> Int
$sel:summary:CreateRuleGroupResponse' :: CreateRuleGroupResponse -> Maybe RuleGroupSummary
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe RuleGroupSummary
summary
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus