{-# 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.DeleteRuleGroup
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes the specified RuleGroup.
module Amazonka.WAFV2.DeleteRuleGroup
  ( -- * Creating a Request
    DeleteRuleGroup (..),
    newDeleteRuleGroup,

    -- * Request Lenses
    deleteRuleGroup_name,
    deleteRuleGroup_scope,
    deleteRuleGroup_id,
    deleteRuleGroup_lockToken,

    -- * Destructuring the Response
    DeleteRuleGroupResponse (..),
    newDeleteRuleGroupResponse,

    -- * Response Lenses
    deleteRuleGroupResponse_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:/ 'newDeleteRuleGroup' smart constructor.
data DeleteRuleGroup = DeleteRuleGroup'
  { -- | The name of the rule group. You cannot change the name of a rule group
    -- after you create it.
    DeleteRuleGroup -> 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.
    DeleteRuleGroup -> Scope
scope :: Scope,
    -- | A unique identifier for the rule group. This ID is returned in the
    -- responses to create and list commands. You provide it to operations like
    -- update and delete.
    DeleteRuleGroup -> Text
id :: Prelude.Text,
    -- | A token used for optimistic locking. WAF returns a token to your @get@
    -- and @list@ requests, to mark the state of the entity at the time of the
    -- request. To make changes to the entity associated with the token, you
    -- provide the token to operations like @update@ and @delete@. WAF uses the
    -- token to ensure that no changes have been made to the entity since you
    -- last retrieved it. If a change has been made, the update fails with a
    -- @WAFOptimisticLockException@. If this happens, perform another @get@,
    -- and use the new token returned by that operation.
    DeleteRuleGroup -> Text
lockToken :: Prelude.Text
  }
  deriving (DeleteRuleGroup -> DeleteRuleGroup -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteRuleGroup -> DeleteRuleGroup -> Bool
$c/= :: DeleteRuleGroup -> DeleteRuleGroup -> Bool
== :: DeleteRuleGroup -> DeleteRuleGroup -> Bool
$c== :: DeleteRuleGroup -> DeleteRuleGroup -> Bool
Prelude.Eq, ReadPrec [DeleteRuleGroup]
ReadPrec DeleteRuleGroup
Int -> ReadS DeleteRuleGroup
ReadS [DeleteRuleGroup]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteRuleGroup]
$creadListPrec :: ReadPrec [DeleteRuleGroup]
readPrec :: ReadPrec DeleteRuleGroup
$creadPrec :: ReadPrec DeleteRuleGroup
readList :: ReadS [DeleteRuleGroup]
$creadList :: ReadS [DeleteRuleGroup]
readsPrec :: Int -> ReadS DeleteRuleGroup
$creadsPrec :: Int -> ReadS DeleteRuleGroup
Prelude.Read, Int -> DeleteRuleGroup -> ShowS
[DeleteRuleGroup] -> ShowS
DeleteRuleGroup -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteRuleGroup] -> ShowS
$cshowList :: [DeleteRuleGroup] -> ShowS
show :: DeleteRuleGroup -> String
$cshow :: DeleteRuleGroup -> String
showsPrec :: Int -> DeleteRuleGroup -> ShowS
$cshowsPrec :: Int -> DeleteRuleGroup -> ShowS
Prelude.Show, forall x. Rep DeleteRuleGroup x -> DeleteRuleGroup
forall x. DeleteRuleGroup -> Rep DeleteRuleGroup x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteRuleGroup x -> DeleteRuleGroup
$cfrom :: forall x. DeleteRuleGroup -> Rep DeleteRuleGroup x
Prelude.Generic)

-- |
-- Create a value of 'DeleteRuleGroup' 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:
--
-- 'name', 'deleteRuleGroup_name' - The name of the rule group. You cannot change the name of a rule group
-- after you create it.
--
-- 'scope', 'deleteRuleGroup_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.
--
-- 'id', 'deleteRuleGroup_id' - A unique identifier for the rule group. This ID is returned in the
-- responses to create and list commands. You provide it to operations like
-- update and delete.
--
-- 'lockToken', 'deleteRuleGroup_lockToken' - A token used for optimistic locking. WAF returns a token to your @get@
-- and @list@ requests, to mark the state of the entity at the time of the
-- request. To make changes to the entity associated with the token, you
-- provide the token to operations like @update@ and @delete@. WAF uses the
-- token to ensure that no changes have been made to the entity since you
-- last retrieved it. If a change has been made, the update fails with a
-- @WAFOptimisticLockException@. If this happens, perform another @get@,
-- and use the new token returned by that operation.
newDeleteRuleGroup ::
  -- | 'name'
  Prelude.Text ->
  -- | 'scope'
  Scope ->
  -- | 'id'
  Prelude.Text ->
  -- | 'lockToken'
  Prelude.Text ->
  DeleteRuleGroup
newDeleteRuleGroup :: Text -> Scope -> Text -> Text -> DeleteRuleGroup
newDeleteRuleGroup Text
pName_ Scope
pScope_ Text
pId_ Text
pLockToken_ =
  DeleteRuleGroup'
    { $sel:name:DeleteRuleGroup' :: Text
name = Text
pName_,
      $sel:scope:DeleteRuleGroup' :: Scope
scope = Scope
pScope_,
      $sel:id:DeleteRuleGroup' :: Text
id = Text
pId_,
      $sel:lockToken:DeleteRuleGroup' :: Text
lockToken = Text
pLockToken_
    }

-- | The name of the rule group. You cannot change the name of a rule group
-- after you create it.
deleteRuleGroup_name :: Lens.Lens' DeleteRuleGroup Prelude.Text
deleteRuleGroup_name :: Lens' DeleteRuleGroup Text
deleteRuleGroup_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteRuleGroup' {Text
name :: Text
$sel:name:DeleteRuleGroup' :: DeleteRuleGroup -> Text
name} -> Text
name) (\s :: DeleteRuleGroup
s@DeleteRuleGroup' {} Text
a -> DeleteRuleGroup
s {$sel:name:DeleteRuleGroup' :: Text
name = Text
a} :: DeleteRuleGroup)

-- | 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.
deleteRuleGroup_scope :: Lens.Lens' DeleteRuleGroup Scope
deleteRuleGroup_scope :: Lens' DeleteRuleGroup Scope
deleteRuleGroup_scope = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteRuleGroup' {Scope
scope :: Scope
$sel:scope:DeleteRuleGroup' :: DeleteRuleGroup -> Scope
scope} -> Scope
scope) (\s :: DeleteRuleGroup
s@DeleteRuleGroup' {} Scope
a -> DeleteRuleGroup
s {$sel:scope:DeleteRuleGroup' :: Scope
scope = Scope
a} :: DeleteRuleGroup)

-- | A unique identifier for the rule group. This ID is returned in the
-- responses to create and list commands. You provide it to operations like
-- update and delete.
deleteRuleGroup_id :: Lens.Lens' DeleteRuleGroup Prelude.Text
deleteRuleGroup_id :: Lens' DeleteRuleGroup Text
deleteRuleGroup_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteRuleGroup' {Text
id :: Text
$sel:id:DeleteRuleGroup' :: DeleteRuleGroup -> Text
id} -> Text
id) (\s :: DeleteRuleGroup
s@DeleteRuleGroup' {} Text
a -> DeleteRuleGroup
s {$sel:id:DeleteRuleGroup' :: Text
id = Text
a} :: DeleteRuleGroup)

-- | A token used for optimistic locking. WAF returns a token to your @get@
-- and @list@ requests, to mark the state of the entity at the time of the
-- request. To make changes to the entity associated with the token, you
-- provide the token to operations like @update@ and @delete@. WAF uses the
-- token to ensure that no changes have been made to the entity since you
-- last retrieved it. If a change has been made, the update fails with a
-- @WAFOptimisticLockException@. If this happens, perform another @get@,
-- and use the new token returned by that operation.
deleteRuleGroup_lockToken :: Lens.Lens' DeleteRuleGroup Prelude.Text
deleteRuleGroup_lockToken :: Lens' DeleteRuleGroup Text
deleteRuleGroup_lockToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteRuleGroup' {Text
lockToken :: Text
$sel:lockToken:DeleteRuleGroup' :: DeleteRuleGroup -> Text
lockToken} -> Text
lockToken) (\s :: DeleteRuleGroup
s@DeleteRuleGroup' {} Text
a -> DeleteRuleGroup
s {$sel:lockToken:DeleteRuleGroup' :: Text
lockToken = Text
a} :: DeleteRuleGroup)

instance Core.AWSRequest DeleteRuleGroup where
  type
    AWSResponse DeleteRuleGroup =
      DeleteRuleGroupResponse
  request :: (Service -> Service) -> DeleteRuleGroup -> Request DeleteRuleGroup
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 DeleteRuleGroup
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteRuleGroup)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteRuleGroupResponse
DeleteRuleGroupResponse'
            forall (f :: * -> *) a b. Functor 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 DeleteRuleGroup where
  hashWithSalt :: Int -> DeleteRuleGroup -> Int
hashWithSalt Int
_salt DeleteRuleGroup' {Text
Scope
lockToken :: Text
id :: Text
scope :: Scope
name :: Text
$sel:lockToken:DeleteRuleGroup' :: DeleteRuleGroup -> Text
$sel:id:DeleteRuleGroup' :: DeleteRuleGroup -> Text
$sel:scope:DeleteRuleGroup' :: DeleteRuleGroup -> Scope
$sel:name:DeleteRuleGroup' :: DeleteRuleGroup -> Text
..} =
    Int
_salt
      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` Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
lockToken

instance Prelude.NFData DeleteRuleGroup where
  rnf :: DeleteRuleGroup -> ()
rnf DeleteRuleGroup' {Text
Scope
lockToken :: Text
id :: Text
scope :: Scope
name :: Text
$sel:lockToken:DeleteRuleGroup' :: DeleteRuleGroup -> Text
$sel:id:DeleteRuleGroup' :: DeleteRuleGroup -> Text
$sel:scope:DeleteRuleGroup' :: DeleteRuleGroup -> Scope
$sel:name:DeleteRuleGroup' :: DeleteRuleGroup -> Text
..} =
    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 Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
lockToken

instance Data.ToHeaders DeleteRuleGroup where
  toHeaders :: DeleteRuleGroup -> 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.DeleteRuleGroup" ::
                          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 DeleteRuleGroup where
  toJSON :: DeleteRuleGroup -> Value
toJSON DeleteRuleGroup' {Text
Scope
lockToken :: Text
id :: Text
scope :: Scope
name :: Text
$sel:lockToken:DeleteRuleGroup' :: DeleteRuleGroup -> Text
$sel:id:DeleteRuleGroup' :: DeleteRuleGroup -> Text
$sel:scope:DeleteRuleGroup' :: DeleteRuleGroup -> Scope
$sel:name:DeleteRuleGroup' :: DeleteRuleGroup -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ 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
"Id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
id),
            forall a. a -> Maybe a
Prelude.Just (Key
"LockToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
lockToken)
          ]
      )

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

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

-- | /See:/ 'newDeleteRuleGroupResponse' smart constructor.
data DeleteRuleGroupResponse = DeleteRuleGroupResponse'
  { -- | The response's http status code.
    DeleteRuleGroupResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteRuleGroupResponse -> DeleteRuleGroupResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteRuleGroupResponse -> DeleteRuleGroupResponse -> Bool
$c/= :: DeleteRuleGroupResponse -> DeleteRuleGroupResponse -> Bool
== :: DeleteRuleGroupResponse -> DeleteRuleGroupResponse -> Bool
$c== :: DeleteRuleGroupResponse -> DeleteRuleGroupResponse -> Bool
Prelude.Eq, ReadPrec [DeleteRuleGroupResponse]
ReadPrec DeleteRuleGroupResponse
Int -> ReadS DeleteRuleGroupResponse
ReadS [DeleteRuleGroupResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteRuleGroupResponse]
$creadListPrec :: ReadPrec [DeleteRuleGroupResponse]
readPrec :: ReadPrec DeleteRuleGroupResponse
$creadPrec :: ReadPrec DeleteRuleGroupResponse
readList :: ReadS [DeleteRuleGroupResponse]
$creadList :: ReadS [DeleteRuleGroupResponse]
readsPrec :: Int -> ReadS DeleteRuleGroupResponse
$creadsPrec :: Int -> ReadS DeleteRuleGroupResponse
Prelude.Read, Int -> DeleteRuleGroupResponse -> ShowS
[DeleteRuleGroupResponse] -> ShowS
DeleteRuleGroupResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteRuleGroupResponse] -> ShowS
$cshowList :: [DeleteRuleGroupResponse] -> ShowS
show :: DeleteRuleGroupResponse -> String
$cshow :: DeleteRuleGroupResponse -> String
showsPrec :: Int -> DeleteRuleGroupResponse -> ShowS
$cshowsPrec :: Int -> DeleteRuleGroupResponse -> ShowS
Prelude.Show, forall x. Rep DeleteRuleGroupResponse x -> DeleteRuleGroupResponse
forall x. DeleteRuleGroupResponse -> Rep DeleteRuleGroupResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteRuleGroupResponse x -> DeleteRuleGroupResponse
$cfrom :: forall x. DeleteRuleGroupResponse -> Rep DeleteRuleGroupResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteRuleGroupResponse' 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:
--
-- 'httpStatus', 'deleteRuleGroupResponse_httpStatus' - The response's http status code.
newDeleteRuleGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteRuleGroupResponse
newDeleteRuleGroupResponse :: Int -> DeleteRuleGroupResponse
newDeleteRuleGroupResponse Int
pHttpStatus_ =
  DeleteRuleGroupResponse' {$sel:httpStatus:DeleteRuleGroupResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData DeleteRuleGroupResponse where
  rnf :: DeleteRuleGroupResponse -> ()
rnf DeleteRuleGroupResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteRuleGroupResponse' :: DeleteRuleGroupResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus