{-# 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.WAF.DeleteRuleGroup
-- 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)
--
-- 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 RuleGroup. You can\'t delete a @RuleGroup@ if
-- it\'s still used in any @WebACL@ objects or if it still includes any
-- rules.
--
-- If you just want to remove a @RuleGroup@ from a @WebACL@, use
-- UpdateWebACL.
--
-- To permanently delete a @RuleGroup@ from AWS WAF, perform the following
-- steps:
--
-- 1.  Update the @RuleGroup@ to remove rules, if any. For more
--     information, see UpdateRuleGroup.
--
-- 2.  Use GetChangeToken to get the change token that you provide in the
--     @ChangeToken@ parameter of a @DeleteRuleGroup@ request.
--
-- 3.  Submit a @DeleteRuleGroup@ request.
module Amazonka.WAF.DeleteRuleGroup
  ( -- * Creating a Request
    DeleteRuleGroup (..),
    newDeleteRuleGroup,

    -- * Request Lenses
    deleteRuleGroup_ruleGroupId,
    deleteRuleGroup_changeToken,

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

    -- * Response Lenses
    deleteRuleGroupResponse_changeToken,
    deleteRuleGroupResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.WAF.Types

-- | /See:/ 'newDeleteRuleGroup' smart constructor.
data DeleteRuleGroup = DeleteRuleGroup'
  { -- | The @RuleGroupId@ of the RuleGroup that you want to delete.
    -- @RuleGroupId@ is returned by CreateRuleGroup and by ListRuleGroups.
    DeleteRuleGroup -> Text
ruleGroupId :: Prelude.Text,
    -- | The value returned by the most recent call to GetChangeToken.
    DeleteRuleGroup -> Text
changeToken :: Prelude.Text
  }
  deriving (DeleteRuleGroup -> DeleteRuleGroup -> Bool
(DeleteRuleGroup -> DeleteRuleGroup -> Bool)
-> (DeleteRuleGroup -> DeleteRuleGroup -> Bool)
-> Eq DeleteRuleGroup
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]
(Int -> ReadS DeleteRuleGroup)
-> ReadS [DeleteRuleGroup]
-> ReadPrec DeleteRuleGroup
-> ReadPrec [DeleteRuleGroup]
-> Read 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
(Int -> DeleteRuleGroup -> ShowS)
-> (DeleteRuleGroup -> String)
-> ([DeleteRuleGroup] -> ShowS)
-> Show DeleteRuleGroup
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. DeleteRuleGroup -> Rep DeleteRuleGroup x)
-> (forall x. Rep DeleteRuleGroup x -> DeleteRuleGroup)
-> Generic DeleteRuleGroup
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:
--
-- 'ruleGroupId', 'deleteRuleGroup_ruleGroupId' - The @RuleGroupId@ of the RuleGroup that you want to delete.
-- @RuleGroupId@ is returned by CreateRuleGroup and by ListRuleGroups.
--
-- 'changeToken', 'deleteRuleGroup_changeToken' - The value returned by the most recent call to GetChangeToken.
newDeleteRuleGroup ::
  -- | 'ruleGroupId'
  Prelude.Text ->
  -- | 'changeToken'
  Prelude.Text ->
  DeleteRuleGroup
newDeleteRuleGroup :: Text -> Text -> DeleteRuleGroup
newDeleteRuleGroup Text
pRuleGroupId_ Text
pChangeToken_ =
  DeleteRuleGroup' :: Text -> Text -> DeleteRuleGroup
DeleteRuleGroup'
    { $sel:ruleGroupId:DeleteRuleGroup' :: Text
ruleGroupId = Text
pRuleGroupId_,
      $sel:changeToken:DeleteRuleGroup' :: Text
changeToken = Text
pChangeToken_
    }

-- | The @RuleGroupId@ of the RuleGroup that you want to delete.
-- @RuleGroupId@ is returned by CreateRuleGroup and by ListRuleGroups.
deleteRuleGroup_ruleGroupId :: Lens.Lens' DeleteRuleGroup Prelude.Text
deleteRuleGroup_ruleGroupId :: (Text -> f Text) -> DeleteRuleGroup -> f DeleteRuleGroup
deleteRuleGroup_ruleGroupId = (DeleteRuleGroup -> Text)
-> (DeleteRuleGroup -> Text -> DeleteRuleGroup)
-> Lens DeleteRuleGroup DeleteRuleGroup Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteRuleGroup' {Text
ruleGroupId :: Text
$sel:ruleGroupId:DeleteRuleGroup' :: DeleteRuleGroup -> Text
ruleGroupId} -> Text
ruleGroupId) (\s :: DeleteRuleGroup
s@DeleteRuleGroup' {} Text
a -> DeleteRuleGroup
s {$sel:ruleGroupId:DeleteRuleGroup' :: Text
ruleGroupId = Text
a} :: DeleteRuleGroup)

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

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

instance Prelude.Hashable DeleteRuleGroup

instance Prelude.NFData DeleteRuleGroup

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

instance Core.ToJSON DeleteRuleGroup where
  toJSON :: DeleteRuleGroup -> Value
toJSON DeleteRuleGroup' {Text
changeToken :: Text
ruleGroupId :: Text
$sel:changeToken:DeleteRuleGroup' :: DeleteRuleGroup -> Text
$sel:ruleGroupId:DeleteRuleGroup' :: DeleteRuleGroup -> Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"RuleGroupId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
ruleGroupId),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ChangeToken" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
changeToken)
          ]
      )

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

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

-- | /See:/ 'newDeleteRuleGroupResponse' smart constructor.
data DeleteRuleGroupResponse = DeleteRuleGroupResponse'
  { -- | The @ChangeToken@ that you used to submit the @DeleteRuleGroup@ request.
    -- You can also use this value to query the status of the request. For more
    -- information, see GetChangeTokenStatus.
    DeleteRuleGroupResponse -> Maybe Text
changeToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DeleteRuleGroupResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteRuleGroupResponse -> DeleteRuleGroupResponse -> Bool
(DeleteRuleGroupResponse -> DeleteRuleGroupResponse -> Bool)
-> (DeleteRuleGroupResponse -> DeleteRuleGroupResponse -> Bool)
-> Eq DeleteRuleGroupResponse
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]
(Int -> ReadS DeleteRuleGroupResponse)
-> ReadS [DeleteRuleGroupResponse]
-> ReadPrec DeleteRuleGroupResponse
-> ReadPrec [DeleteRuleGroupResponse]
-> Read 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
(Int -> DeleteRuleGroupResponse -> ShowS)
-> (DeleteRuleGroupResponse -> String)
-> ([DeleteRuleGroupResponse] -> ShowS)
-> Show DeleteRuleGroupResponse
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.
 DeleteRuleGroupResponse -> Rep DeleteRuleGroupResponse x)
-> (forall x.
    Rep DeleteRuleGroupResponse x -> DeleteRuleGroupResponse)
-> Generic DeleteRuleGroupResponse
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:
--
-- 'changeToken', 'deleteRuleGroupResponse_changeToken' - The @ChangeToken@ that you used to submit the @DeleteRuleGroup@ request.
-- You can also use this value to query the status of the request. For more
-- information, see GetChangeTokenStatus.
--
-- 'httpStatus', 'deleteRuleGroupResponse_httpStatus' - The response's http status code.
newDeleteRuleGroupResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteRuleGroupResponse
newDeleteRuleGroupResponse :: Int -> DeleteRuleGroupResponse
newDeleteRuleGroupResponse Int
pHttpStatus_ =
  DeleteRuleGroupResponse' :: Maybe Text -> Int -> DeleteRuleGroupResponse
DeleteRuleGroupResponse'
    { $sel:changeToken:DeleteRuleGroupResponse' :: Maybe Text
changeToken =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteRuleGroupResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

-- | The response's http status code.
deleteRuleGroupResponse_httpStatus :: Lens.Lens' DeleteRuleGroupResponse Prelude.Int
deleteRuleGroupResponse_httpStatus :: (Int -> f Int)
-> DeleteRuleGroupResponse -> f DeleteRuleGroupResponse
deleteRuleGroupResponse_httpStatus = (DeleteRuleGroupResponse -> Int)
-> (DeleteRuleGroupResponse -> Int -> DeleteRuleGroupResponse)
-> Lens DeleteRuleGroupResponse DeleteRuleGroupResponse Int Int
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