{-# 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.WAFRegional.DeleteRateBasedRule
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- This is __AWS WAF Classic__ documentation. For more information, see
-- <https://docs.aws.amazon.com/waf/latest/developerguide/classic-waf-chapter.html AWS WAF Classic>
-- in the developer guide.
--
-- __For the latest version of AWS WAF__, use the AWS WAFV2 API and see the
-- <https://docs.aws.amazon.com/waf/latest/developerguide/waf-chapter.html AWS WAF Developer Guide>.
-- With the latest version, AWS WAF has a single set of endpoints for
-- regional and global use.
--
-- Permanently deletes a RateBasedRule. You can\'t delete a rule if it\'s
-- still used in any @WebACL@ objects or if it still includes any
-- predicates, such as @ByteMatchSet@ objects.
--
-- If you just want to remove a rule from a @WebACL@, use UpdateWebACL.
--
-- To permanently delete a @RateBasedRule@ from AWS WAF, perform the
-- following steps:
--
-- 1.  Update the @RateBasedRule@ to remove predicates, if any. For more
--     information, see UpdateRateBasedRule.
--
-- 2.  Use GetChangeToken to get the change token that you provide in the
--     @ChangeToken@ parameter of a @DeleteRateBasedRule@ request.
--
-- 3.  Submit a @DeleteRateBasedRule@ request.
module Amazonka.WAFRegional.DeleteRateBasedRule
  ( -- * Creating a Request
    DeleteRateBasedRule (..),
    newDeleteRateBasedRule,

    -- * Request Lenses
    deleteRateBasedRule_ruleId,
    deleteRateBasedRule_changeToken,

    -- * Destructuring the Response
    DeleteRateBasedRuleResponse (..),
    newDeleteRateBasedRuleResponse,

    -- * Response Lenses
    deleteRateBasedRuleResponse_changeToken,
    deleteRateBasedRuleResponse_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.WAFRegional.Types

-- | /See:/ 'newDeleteRateBasedRule' smart constructor.
data DeleteRateBasedRule = DeleteRateBasedRule'
  { -- | The @RuleId@ of the RateBasedRule that you want to delete. @RuleId@ is
    -- returned by CreateRateBasedRule and by ListRateBasedRules.
    DeleteRateBasedRule -> Text
ruleId :: Prelude.Text,
    -- | The value returned by the most recent call to GetChangeToken.
    DeleteRateBasedRule -> Text
changeToken :: Prelude.Text
  }
  deriving (DeleteRateBasedRule -> DeleteRateBasedRule -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteRateBasedRule -> DeleteRateBasedRule -> Bool
$c/= :: DeleteRateBasedRule -> DeleteRateBasedRule -> Bool
== :: DeleteRateBasedRule -> DeleteRateBasedRule -> Bool
$c== :: DeleteRateBasedRule -> DeleteRateBasedRule -> Bool
Prelude.Eq, ReadPrec [DeleteRateBasedRule]
ReadPrec DeleteRateBasedRule
Int -> ReadS DeleteRateBasedRule
ReadS [DeleteRateBasedRule]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteRateBasedRule]
$creadListPrec :: ReadPrec [DeleteRateBasedRule]
readPrec :: ReadPrec DeleteRateBasedRule
$creadPrec :: ReadPrec DeleteRateBasedRule
readList :: ReadS [DeleteRateBasedRule]
$creadList :: ReadS [DeleteRateBasedRule]
readsPrec :: Int -> ReadS DeleteRateBasedRule
$creadsPrec :: Int -> ReadS DeleteRateBasedRule
Prelude.Read, Int -> DeleteRateBasedRule -> ShowS
[DeleteRateBasedRule] -> ShowS
DeleteRateBasedRule -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteRateBasedRule] -> ShowS
$cshowList :: [DeleteRateBasedRule] -> ShowS
show :: DeleteRateBasedRule -> String
$cshow :: DeleteRateBasedRule -> String
showsPrec :: Int -> DeleteRateBasedRule -> ShowS
$cshowsPrec :: Int -> DeleteRateBasedRule -> ShowS
Prelude.Show, forall x. Rep DeleteRateBasedRule x -> DeleteRateBasedRule
forall x. DeleteRateBasedRule -> Rep DeleteRateBasedRule x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteRateBasedRule x -> DeleteRateBasedRule
$cfrom :: forall x. DeleteRateBasedRule -> Rep DeleteRateBasedRule x
Prelude.Generic)

-- |
-- Create a value of 'DeleteRateBasedRule' 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:
--
-- 'ruleId', 'deleteRateBasedRule_ruleId' - The @RuleId@ of the RateBasedRule that you want to delete. @RuleId@ is
-- returned by CreateRateBasedRule and by ListRateBasedRules.
--
-- 'changeToken', 'deleteRateBasedRule_changeToken' - The value returned by the most recent call to GetChangeToken.
newDeleteRateBasedRule ::
  -- | 'ruleId'
  Prelude.Text ->
  -- | 'changeToken'
  Prelude.Text ->
  DeleteRateBasedRule
newDeleteRateBasedRule :: Text -> Text -> DeleteRateBasedRule
newDeleteRateBasedRule Text
pRuleId_ Text
pChangeToken_ =
  DeleteRateBasedRule'
    { $sel:ruleId:DeleteRateBasedRule' :: Text
ruleId = Text
pRuleId_,
      $sel:changeToken:DeleteRateBasedRule' :: Text
changeToken = Text
pChangeToken_
    }

-- | The @RuleId@ of the RateBasedRule that you want to delete. @RuleId@ is
-- returned by CreateRateBasedRule and by ListRateBasedRules.
deleteRateBasedRule_ruleId :: Lens.Lens' DeleteRateBasedRule Prelude.Text
deleteRateBasedRule_ruleId :: Lens' DeleteRateBasedRule Text
deleteRateBasedRule_ruleId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteRateBasedRule' {Text
ruleId :: Text
$sel:ruleId:DeleteRateBasedRule' :: DeleteRateBasedRule -> Text
ruleId} -> Text
ruleId) (\s :: DeleteRateBasedRule
s@DeleteRateBasedRule' {} Text
a -> DeleteRateBasedRule
s {$sel:ruleId:DeleteRateBasedRule' :: Text
ruleId = Text
a} :: DeleteRateBasedRule)

-- | The value returned by the most recent call to GetChangeToken.
deleteRateBasedRule_changeToken :: Lens.Lens' DeleteRateBasedRule Prelude.Text
deleteRateBasedRule_changeToken :: Lens' DeleteRateBasedRule Text
deleteRateBasedRule_changeToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteRateBasedRule' {Text
changeToken :: Text
$sel:changeToken:DeleteRateBasedRule' :: DeleteRateBasedRule -> Text
changeToken} -> Text
changeToken) (\s :: DeleteRateBasedRule
s@DeleteRateBasedRule' {} Text
a -> DeleteRateBasedRule
s {$sel:changeToken:DeleteRateBasedRule' :: Text
changeToken = Text
a} :: DeleteRateBasedRule)

instance Core.AWSRequest DeleteRateBasedRule where
  type
    AWSResponse DeleteRateBasedRule =
      DeleteRateBasedRuleResponse
  request :: (Service -> Service)
-> DeleteRateBasedRule -> Request DeleteRateBasedRule
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 DeleteRateBasedRule
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteRateBasedRule)))
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 Text -> Int -> DeleteRateBasedRuleResponse
DeleteRateBasedRuleResponse'
            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
"ChangeToken")
            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 DeleteRateBasedRule where
  hashWithSalt :: Int -> DeleteRateBasedRule -> Int
hashWithSalt Int
_salt DeleteRateBasedRule' {Text
changeToken :: Text
ruleId :: Text
$sel:changeToken:DeleteRateBasedRule' :: DeleteRateBasedRule -> Text
$sel:ruleId:DeleteRateBasedRule' :: DeleteRateBasedRule -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
ruleId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
changeToken

instance Prelude.NFData DeleteRateBasedRule where
  rnf :: DeleteRateBasedRule -> ()
rnf DeleteRateBasedRule' {Text
changeToken :: Text
ruleId :: Text
$sel:changeToken:DeleteRateBasedRule' :: DeleteRateBasedRule -> Text
$sel:ruleId:DeleteRateBasedRule' :: DeleteRateBasedRule -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
ruleId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
changeToken

instance Data.ToHeaders DeleteRateBasedRule where
  toHeaders :: DeleteRateBasedRule -> 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_Regional_20161128.DeleteRateBasedRule" ::
                          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 DeleteRateBasedRule where
  toJSON :: DeleteRateBasedRule -> Value
toJSON DeleteRateBasedRule' {Text
changeToken :: Text
ruleId :: Text
$sel:changeToken:DeleteRateBasedRule' :: DeleteRateBasedRule -> Text
$sel:ruleId:DeleteRateBasedRule' :: DeleteRateBasedRule -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"RuleId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
ruleId),
            forall a. a -> Maybe a
Prelude.Just (Key
"ChangeToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
changeToken)
          ]
      )

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

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

-- | /See:/ 'newDeleteRateBasedRuleResponse' smart constructor.
data DeleteRateBasedRuleResponse = DeleteRateBasedRuleResponse'
  { -- | The @ChangeToken@ that you used to submit the @DeleteRateBasedRule@
    -- request. You can also use this value to query the status of the request.
    -- For more information, see GetChangeTokenStatus.
    DeleteRateBasedRuleResponse -> Maybe Text
changeToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DeleteRateBasedRuleResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteRateBasedRuleResponse -> DeleteRateBasedRuleResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteRateBasedRuleResponse -> DeleteRateBasedRuleResponse -> Bool
$c/= :: DeleteRateBasedRuleResponse -> DeleteRateBasedRuleResponse -> Bool
== :: DeleteRateBasedRuleResponse -> DeleteRateBasedRuleResponse -> Bool
$c== :: DeleteRateBasedRuleResponse -> DeleteRateBasedRuleResponse -> Bool
Prelude.Eq, ReadPrec [DeleteRateBasedRuleResponse]
ReadPrec DeleteRateBasedRuleResponse
Int -> ReadS DeleteRateBasedRuleResponse
ReadS [DeleteRateBasedRuleResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteRateBasedRuleResponse]
$creadListPrec :: ReadPrec [DeleteRateBasedRuleResponse]
readPrec :: ReadPrec DeleteRateBasedRuleResponse
$creadPrec :: ReadPrec DeleteRateBasedRuleResponse
readList :: ReadS [DeleteRateBasedRuleResponse]
$creadList :: ReadS [DeleteRateBasedRuleResponse]
readsPrec :: Int -> ReadS DeleteRateBasedRuleResponse
$creadsPrec :: Int -> ReadS DeleteRateBasedRuleResponse
Prelude.Read, Int -> DeleteRateBasedRuleResponse -> ShowS
[DeleteRateBasedRuleResponse] -> ShowS
DeleteRateBasedRuleResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteRateBasedRuleResponse] -> ShowS
$cshowList :: [DeleteRateBasedRuleResponse] -> ShowS
show :: DeleteRateBasedRuleResponse -> String
$cshow :: DeleteRateBasedRuleResponse -> String
showsPrec :: Int -> DeleteRateBasedRuleResponse -> ShowS
$cshowsPrec :: Int -> DeleteRateBasedRuleResponse -> ShowS
Prelude.Show, forall x.
Rep DeleteRateBasedRuleResponse x -> DeleteRateBasedRuleResponse
forall x.
DeleteRateBasedRuleResponse -> Rep DeleteRateBasedRuleResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteRateBasedRuleResponse x -> DeleteRateBasedRuleResponse
$cfrom :: forall x.
DeleteRateBasedRuleResponse -> Rep DeleteRateBasedRuleResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteRateBasedRuleResponse' 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:
--
-- 'changeToken', 'deleteRateBasedRuleResponse_changeToken' - The @ChangeToken@ that you used to submit the @DeleteRateBasedRule@
-- request. You can also use this value to query the status of the request.
-- For more information, see GetChangeTokenStatus.
--
-- 'httpStatus', 'deleteRateBasedRuleResponse_httpStatus' - The response's http status code.
newDeleteRateBasedRuleResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteRateBasedRuleResponse
newDeleteRateBasedRuleResponse :: Int -> DeleteRateBasedRuleResponse
newDeleteRateBasedRuleResponse Int
pHttpStatus_ =
  DeleteRateBasedRuleResponse'
    { $sel:changeToken:DeleteRateBasedRuleResponse' :: Maybe Text
changeToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteRateBasedRuleResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The @ChangeToken@ that you used to submit the @DeleteRateBasedRule@
-- request. You can also use this value to query the status of the request.
-- For more information, see GetChangeTokenStatus.
deleteRateBasedRuleResponse_changeToken :: Lens.Lens' DeleteRateBasedRuleResponse (Prelude.Maybe Prelude.Text)
deleteRateBasedRuleResponse_changeToken :: Lens' DeleteRateBasedRuleResponse (Maybe Text)
deleteRateBasedRuleResponse_changeToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteRateBasedRuleResponse' {Maybe Text
changeToken :: Maybe Text
$sel:changeToken:DeleteRateBasedRuleResponse' :: DeleteRateBasedRuleResponse -> Maybe Text
changeToken} -> Maybe Text
changeToken) (\s :: DeleteRateBasedRuleResponse
s@DeleteRateBasedRuleResponse' {} Maybe Text
a -> DeleteRateBasedRuleResponse
s {$sel:changeToken:DeleteRateBasedRuleResponse' :: Maybe Text
changeToken = Maybe Text
a} :: DeleteRateBasedRuleResponse)

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

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