{-# 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.DeleteByteMatchSet
-- 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 ByteMatchSet. You can\'t delete a @ByteMatchSet@
-- if it\'s still used in any @Rules@ or if it still includes any
-- ByteMatchTuple objects (any filters).
--
-- If you just want to remove a @ByteMatchSet@ from a @Rule@, use
-- UpdateRule.
--
-- To permanently delete a @ByteMatchSet@, perform the following steps:
--
-- 1.  Update the @ByteMatchSet@ to remove filters, if any. For more
--     information, see UpdateByteMatchSet.
--
-- 2.  Use GetChangeToken to get the change token that you provide in the
--     @ChangeToken@ parameter of a @DeleteByteMatchSet@ request.
--
-- 3.  Submit a @DeleteByteMatchSet@ request.
module Amazonka.WAFRegional.DeleteByteMatchSet
  ( -- * Creating a Request
    DeleteByteMatchSet (..),
    newDeleteByteMatchSet,

    -- * Request Lenses
    deleteByteMatchSet_byteMatchSetId,
    deleteByteMatchSet_changeToken,

    -- * Destructuring the Response
    DeleteByteMatchSetResponse (..),
    newDeleteByteMatchSetResponse,

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

-- |
-- Create a value of 'DeleteByteMatchSet' 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:
--
-- 'byteMatchSetId', 'deleteByteMatchSet_byteMatchSetId' - The @ByteMatchSetId@ of the ByteMatchSet that you want to delete.
-- @ByteMatchSetId@ is returned by CreateByteMatchSet and by
-- ListByteMatchSets.
--
-- 'changeToken', 'deleteByteMatchSet_changeToken' - The value returned by the most recent call to GetChangeToken.
newDeleteByteMatchSet ::
  -- | 'byteMatchSetId'
  Prelude.Text ->
  -- | 'changeToken'
  Prelude.Text ->
  DeleteByteMatchSet
newDeleteByteMatchSet :: Text -> Text -> DeleteByteMatchSet
newDeleteByteMatchSet Text
pByteMatchSetId_ Text
pChangeToken_ =
  DeleteByteMatchSet'
    { $sel:byteMatchSetId:DeleteByteMatchSet' :: Text
byteMatchSetId =
        Text
pByteMatchSetId_,
      $sel:changeToken:DeleteByteMatchSet' :: Text
changeToken = Text
pChangeToken_
    }

-- | The @ByteMatchSetId@ of the ByteMatchSet that you want to delete.
-- @ByteMatchSetId@ is returned by CreateByteMatchSet and by
-- ListByteMatchSets.
deleteByteMatchSet_byteMatchSetId :: Lens.Lens' DeleteByteMatchSet Prelude.Text
deleteByteMatchSet_byteMatchSetId :: Lens' DeleteByteMatchSet Text
deleteByteMatchSet_byteMatchSetId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteByteMatchSet' {Text
byteMatchSetId :: Text
$sel:byteMatchSetId:DeleteByteMatchSet' :: DeleteByteMatchSet -> Text
byteMatchSetId} -> Text
byteMatchSetId) (\s :: DeleteByteMatchSet
s@DeleteByteMatchSet' {} Text
a -> DeleteByteMatchSet
s {$sel:byteMatchSetId:DeleteByteMatchSet' :: Text
byteMatchSetId = Text
a} :: DeleteByteMatchSet)

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

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

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

instance Data.ToHeaders DeleteByteMatchSet where
  toHeaders :: DeleteByteMatchSet -> 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.DeleteByteMatchSet" ::
                          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 DeleteByteMatchSet where
  toJSON :: DeleteByteMatchSet -> Value
toJSON DeleteByteMatchSet' {Text
changeToken :: Text
byteMatchSetId :: Text
$sel:changeToken:DeleteByteMatchSet' :: DeleteByteMatchSet -> Text
$sel:byteMatchSetId:DeleteByteMatchSet' :: DeleteByteMatchSet -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              (Key
"ByteMatchSetId" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
byteMatchSetId),
            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 DeleteByteMatchSet where
  toPath :: DeleteByteMatchSet -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

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

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

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

instance Prelude.NFData DeleteByteMatchSetResponse where
  rnf :: DeleteByteMatchSetResponse -> ()
rnf DeleteByteMatchSetResponse' {Int
Maybe Text
httpStatus :: Int
changeToken :: Maybe Text
$sel:httpStatus:DeleteByteMatchSetResponse' :: DeleteByteMatchSetResponse -> Int
$sel:changeToken:DeleteByteMatchSetResponse' :: DeleteByteMatchSetResponse -> 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