{-# 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.DeleteRegexPatternSet
-- 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 RegexPatternSet. You can\'t delete a
-- @RegexPatternSet@ if it\'s still used in any @RegexMatchSet@ or if the
-- @RegexPatternSet@ is not empty.
module Amazonka.WAF.DeleteRegexPatternSet
  ( -- * Creating a Request
    DeleteRegexPatternSet (..),
    newDeleteRegexPatternSet,

    -- * Request Lenses
    deleteRegexPatternSet_regexPatternSetId,
    deleteRegexPatternSet_changeToken,

    -- * Destructuring the Response
    DeleteRegexPatternSetResponse (..),
    newDeleteRegexPatternSetResponse,

    -- * Response Lenses
    deleteRegexPatternSetResponse_changeToken,
    deleteRegexPatternSetResponse_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:/ 'newDeleteRegexPatternSet' smart constructor.
data DeleteRegexPatternSet = DeleteRegexPatternSet'
  { -- | The @RegexPatternSetId@ of the RegexPatternSet that you want to delete.
    -- @RegexPatternSetId@ is returned by CreateRegexPatternSet and by
    -- ListRegexPatternSets.
    DeleteRegexPatternSet -> Text
regexPatternSetId :: Prelude.Text,
    -- | The value returned by the most recent call to GetChangeToken.
    DeleteRegexPatternSet -> Text
changeToken :: Prelude.Text
  }
  deriving (DeleteRegexPatternSet -> DeleteRegexPatternSet -> Bool
(DeleteRegexPatternSet -> DeleteRegexPatternSet -> Bool)
-> (DeleteRegexPatternSet -> DeleteRegexPatternSet -> Bool)
-> Eq DeleteRegexPatternSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteRegexPatternSet -> DeleteRegexPatternSet -> Bool
$c/= :: DeleteRegexPatternSet -> DeleteRegexPatternSet -> Bool
== :: DeleteRegexPatternSet -> DeleteRegexPatternSet -> Bool
$c== :: DeleteRegexPatternSet -> DeleteRegexPatternSet -> Bool
Prelude.Eq, ReadPrec [DeleteRegexPatternSet]
ReadPrec DeleteRegexPatternSet
Int -> ReadS DeleteRegexPatternSet
ReadS [DeleteRegexPatternSet]
(Int -> ReadS DeleteRegexPatternSet)
-> ReadS [DeleteRegexPatternSet]
-> ReadPrec DeleteRegexPatternSet
-> ReadPrec [DeleteRegexPatternSet]
-> Read DeleteRegexPatternSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteRegexPatternSet]
$creadListPrec :: ReadPrec [DeleteRegexPatternSet]
readPrec :: ReadPrec DeleteRegexPatternSet
$creadPrec :: ReadPrec DeleteRegexPatternSet
readList :: ReadS [DeleteRegexPatternSet]
$creadList :: ReadS [DeleteRegexPatternSet]
readsPrec :: Int -> ReadS DeleteRegexPatternSet
$creadsPrec :: Int -> ReadS DeleteRegexPatternSet
Prelude.Read, Int -> DeleteRegexPatternSet -> ShowS
[DeleteRegexPatternSet] -> ShowS
DeleteRegexPatternSet -> String
(Int -> DeleteRegexPatternSet -> ShowS)
-> (DeleteRegexPatternSet -> String)
-> ([DeleteRegexPatternSet] -> ShowS)
-> Show DeleteRegexPatternSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteRegexPatternSet] -> ShowS
$cshowList :: [DeleteRegexPatternSet] -> ShowS
show :: DeleteRegexPatternSet -> String
$cshow :: DeleteRegexPatternSet -> String
showsPrec :: Int -> DeleteRegexPatternSet -> ShowS
$cshowsPrec :: Int -> DeleteRegexPatternSet -> ShowS
Prelude.Show, (forall x. DeleteRegexPatternSet -> Rep DeleteRegexPatternSet x)
-> (forall x. Rep DeleteRegexPatternSet x -> DeleteRegexPatternSet)
-> Generic DeleteRegexPatternSet
forall x. Rep DeleteRegexPatternSet x -> DeleteRegexPatternSet
forall x. DeleteRegexPatternSet -> Rep DeleteRegexPatternSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteRegexPatternSet x -> DeleteRegexPatternSet
$cfrom :: forall x. DeleteRegexPatternSet -> Rep DeleteRegexPatternSet x
Prelude.Generic)

-- |
-- Create a value of 'DeleteRegexPatternSet' 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:
--
-- 'regexPatternSetId', 'deleteRegexPatternSet_regexPatternSetId' - The @RegexPatternSetId@ of the RegexPatternSet that you want to delete.
-- @RegexPatternSetId@ is returned by CreateRegexPatternSet and by
-- ListRegexPatternSets.
--
-- 'changeToken', 'deleteRegexPatternSet_changeToken' - The value returned by the most recent call to GetChangeToken.
newDeleteRegexPatternSet ::
  -- | 'regexPatternSetId'
  Prelude.Text ->
  -- | 'changeToken'
  Prelude.Text ->
  DeleteRegexPatternSet
newDeleteRegexPatternSet :: Text -> Text -> DeleteRegexPatternSet
newDeleteRegexPatternSet
  Text
pRegexPatternSetId_
  Text
pChangeToken_ =
    DeleteRegexPatternSet' :: Text -> Text -> DeleteRegexPatternSet
DeleteRegexPatternSet'
      { $sel:regexPatternSetId:DeleteRegexPatternSet' :: Text
regexPatternSetId =
          Text
pRegexPatternSetId_,
        $sel:changeToken:DeleteRegexPatternSet' :: Text
changeToken = Text
pChangeToken_
      }

-- | The @RegexPatternSetId@ of the RegexPatternSet that you want to delete.
-- @RegexPatternSetId@ is returned by CreateRegexPatternSet and by
-- ListRegexPatternSets.
deleteRegexPatternSet_regexPatternSetId :: Lens.Lens' DeleteRegexPatternSet Prelude.Text
deleteRegexPatternSet_regexPatternSetId :: (Text -> f Text)
-> DeleteRegexPatternSet -> f DeleteRegexPatternSet
deleteRegexPatternSet_regexPatternSetId = (DeleteRegexPatternSet -> Text)
-> (DeleteRegexPatternSet -> Text -> DeleteRegexPatternSet)
-> Lens DeleteRegexPatternSet DeleteRegexPatternSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteRegexPatternSet' {Text
regexPatternSetId :: Text
$sel:regexPatternSetId:DeleteRegexPatternSet' :: DeleteRegexPatternSet -> Text
regexPatternSetId} -> Text
regexPatternSetId) (\s :: DeleteRegexPatternSet
s@DeleteRegexPatternSet' {} Text
a -> DeleteRegexPatternSet
s {$sel:regexPatternSetId:DeleteRegexPatternSet' :: Text
regexPatternSetId = Text
a} :: DeleteRegexPatternSet)

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

instance Core.AWSRequest DeleteRegexPatternSet where
  type
    AWSResponse DeleteRegexPatternSet =
      DeleteRegexPatternSetResponse
  request :: DeleteRegexPatternSet -> Request DeleteRegexPatternSet
request = Service -> DeleteRegexPatternSet -> Request DeleteRegexPatternSet
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteRegexPatternSet
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteRegexPatternSet)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteRegexPatternSet))
-> Logger
-> Service
-> Proxy DeleteRegexPatternSet
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteRegexPatternSet)))
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 -> DeleteRegexPatternSetResponse
DeleteRegexPatternSetResponse'
            (Maybe Text -> Int -> DeleteRegexPatternSetResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DeleteRegexPatternSetResponse)
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 -> DeleteRegexPatternSetResponse)
-> Either String Int -> Either String DeleteRegexPatternSetResponse
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 DeleteRegexPatternSet

instance Prelude.NFData DeleteRegexPatternSet

instance Core.ToHeaders DeleteRegexPatternSet where
  toHeaders :: DeleteRegexPatternSet -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeleteRegexPatternSet -> 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.DeleteRegexPatternSet" ::
                          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 DeleteRegexPatternSet where
  toJSON :: DeleteRegexPatternSet -> Value
toJSON DeleteRegexPatternSet' {Text
changeToken :: Text
regexPatternSetId :: Text
$sel:changeToken:DeleteRegexPatternSet' :: DeleteRegexPatternSet -> Text
$sel:regexPatternSetId:DeleteRegexPatternSet' :: DeleteRegexPatternSet -> 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
"RegexPatternSetId" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
regexPatternSetId),
            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 DeleteRegexPatternSet where
  toPath :: DeleteRegexPatternSet -> ByteString
toPath = ByteString -> DeleteRegexPatternSet -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

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

instance Prelude.NFData DeleteRegexPatternSetResponse