{-# 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.DeleteByteMatchSet
-- 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 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.WAF.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.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:/ '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
(DeleteByteMatchSet -> DeleteByteMatchSet -> Bool)
-> (DeleteByteMatchSet -> DeleteByteMatchSet -> Bool)
-> Eq DeleteByteMatchSet
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]
(Int -> ReadS DeleteByteMatchSet)
-> ReadS [DeleteByteMatchSet]
-> ReadPrec DeleteByteMatchSet
-> ReadPrec [DeleteByteMatchSet]
-> Read 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
(Int -> DeleteByteMatchSet -> ShowS)
-> (DeleteByteMatchSet -> String)
-> ([DeleteByteMatchSet] -> ShowS)
-> Show DeleteByteMatchSet
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. DeleteByteMatchSet -> Rep DeleteByteMatchSet x)
-> (forall x. Rep DeleteByteMatchSet x -> DeleteByteMatchSet)
-> Generic DeleteByteMatchSet
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' :: Text -> Text -> DeleteByteMatchSet
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 :: (Text -> f Text) -> DeleteByteMatchSet -> f DeleteByteMatchSet
deleteByteMatchSet_byteMatchSetId = (DeleteByteMatchSet -> Text)
-> (DeleteByteMatchSet -> Text -> DeleteByteMatchSet)
-> Lens DeleteByteMatchSet DeleteByteMatchSet Text Text
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 :: (Text -> f Text) -> DeleteByteMatchSet -> f DeleteByteMatchSet
deleteByteMatchSet_changeToken = (DeleteByteMatchSet -> Text)
-> (DeleteByteMatchSet -> Text -> DeleteByteMatchSet)
-> Lens DeleteByteMatchSet DeleteByteMatchSet Text Text
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 :: DeleteByteMatchSet -> Request DeleteByteMatchSet
request = Service -> DeleteByteMatchSet -> Request DeleteByteMatchSet
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeleteByteMatchSet
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteByteMatchSet)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DeleteByteMatchSet))
-> Logger
-> Service
-> Proxy DeleteByteMatchSet
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteByteMatchSet)))
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 -> DeleteByteMatchSetResponse
DeleteByteMatchSetResponse'
            (Maybe Text -> Int -> DeleteByteMatchSetResponse)
-> Either String (Maybe Text)
-> Either String (Int -> DeleteByteMatchSetResponse)
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 -> DeleteByteMatchSetResponse)
-> Either String Int -> Either String DeleteByteMatchSetResponse
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 DeleteByteMatchSet

instance Prelude.NFData DeleteByteMatchSet

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

instance Core.ToQuery DeleteByteMatchSet where
  toQuery :: DeleteByteMatchSet -> QueryString
toQuery = QueryString -> DeleteByteMatchSet -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeleteByteMatchSetResponse -> DeleteByteMatchSetResponse -> Bool)
-> (DeleteByteMatchSetResponse
    -> DeleteByteMatchSetResponse -> Bool)
-> Eq DeleteByteMatchSetResponse
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]
(Int -> ReadS DeleteByteMatchSetResponse)
-> ReadS [DeleteByteMatchSetResponse]
-> ReadPrec DeleteByteMatchSetResponse
-> ReadPrec [DeleteByteMatchSetResponse]
-> Read 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
(Int -> DeleteByteMatchSetResponse -> ShowS)
-> (DeleteByteMatchSetResponse -> String)
-> ([DeleteByteMatchSetResponse] -> ShowS)
-> Show DeleteByteMatchSetResponse
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.
 DeleteByteMatchSetResponse -> Rep DeleteByteMatchSetResponse x)
-> (forall x.
    Rep DeleteByteMatchSetResponse x -> DeleteByteMatchSetResponse)
-> Generic DeleteByteMatchSetResponse
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' :: Maybe Text -> Int -> DeleteByteMatchSetResponse
DeleteByteMatchSetResponse'
    { $sel:changeToken:DeleteByteMatchSetResponse' :: Maybe Text
changeToken =
        Maybe Text
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 :: (Maybe Text -> f (Maybe Text))
-> DeleteByteMatchSetResponse -> f DeleteByteMatchSetResponse
deleteByteMatchSetResponse_changeToken = (DeleteByteMatchSetResponse -> Maybe Text)
-> (DeleteByteMatchSetResponse
    -> Maybe Text -> DeleteByteMatchSetResponse)
-> Lens
     DeleteByteMatchSetResponse
     DeleteByteMatchSetResponse
     (Maybe Text)
     (Maybe Text)
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 :: (Int -> f Int)
-> DeleteByteMatchSetResponse -> f DeleteByteMatchSetResponse
deleteByteMatchSetResponse_httpStatus = (DeleteByteMatchSetResponse -> Int)
-> (DeleteByteMatchSetResponse
    -> Int -> DeleteByteMatchSetResponse)
-> Lens
     DeleteByteMatchSetResponse DeleteByteMatchSetResponse Int Int
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