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

    -- * Request Lenses
    deleteXssMatchSet_xssMatchSetId,
    deleteXssMatchSet_changeToken,

    -- * Destructuring the Response
    DeleteXssMatchSetResponse (..),
    newDeleteXssMatchSetResponse,

    -- * Response Lenses
    deleteXssMatchSetResponse_changeToken,
    deleteXssMatchSetResponse_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

-- | A request to delete an XssMatchSet from AWS WAF.
--
-- /See:/ 'newDeleteXssMatchSet' smart constructor.
data DeleteXssMatchSet = DeleteXssMatchSet'
  { -- | The @XssMatchSetId@ of the XssMatchSet that you want to delete.
    -- @XssMatchSetId@ is returned by CreateXssMatchSet and by
    -- ListXssMatchSets.
    DeleteXssMatchSet -> Text
xssMatchSetId :: Prelude.Text,
    -- | The value returned by the most recent call to GetChangeToken.
    DeleteXssMatchSet -> Text
changeToken :: Prelude.Text
  }
  deriving (DeleteXssMatchSet -> DeleteXssMatchSet -> Bool
(DeleteXssMatchSet -> DeleteXssMatchSet -> Bool)
-> (DeleteXssMatchSet -> DeleteXssMatchSet -> Bool)
-> Eq DeleteXssMatchSet
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteXssMatchSet -> DeleteXssMatchSet -> Bool
$c/= :: DeleteXssMatchSet -> DeleteXssMatchSet -> Bool
== :: DeleteXssMatchSet -> DeleteXssMatchSet -> Bool
$c== :: DeleteXssMatchSet -> DeleteXssMatchSet -> Bool
Prelude.Eq, ReadPrec [DeleteXssMatchSet]
ReadPrec DeleteXssMatchSet
Int -> ReadS DeleteXssMatchSet
ReadS [DeleteXssMatchSet]
(Int -> ReadS DeleteXssMatchSet)
-> ReadS [DeleteXssMatchSet]
-> ReadPrec DeleteXssMatchSet
-> ReadPrec [DeleteXssMatchSet]
-> Read DeleteXssMatchSet
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteXssMatchSet]
$creadListPrec :: ReadPrec [DeleteXssMatchSet]
readPrec :: ReadPrec DeleteXssMatchSet
$creadPrec :: ReadPrec DeleteXssMatchSet
readList :: ReadS [DeleteXssMatchSet]
$creadList :: ReadS [DeleteXssMatchSet]
readsPrec :: Int -> ReadS DeleteXssMatchSet
$creadsPrec :: Int -> ReadS DeleteXssMatchSet
Prelude.Read, Int -> DeleteXssMatchSet -> ShowS
[DeleteXssMatchSet] -> ShowS
DeleteXssMatchSet -> String
(Int -> DeleteXssMatchSet -> ShowS)
-> (DeleteXssMatchSet -> String)
-> ([DeleteXssMatchSet] -> ShowS)
-> Show DeleteXssMatchSet
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteXssMatchSet] -> ShowS
$cshowList :: [DeleteXssMatchSet] -> ShowS
show :: DeleteXssMatchSet -> String
$cshow :: DeleteXssMatchSet -> String
showsPrec :: Int -> DeleteXssMatchSet -> ShowS
$cshowsPrec :: Int -> DeleteXssMatchSet -> ShowS
Prelude.Show, (forall x. DeleteXssMatchSet -> Rep DeleteXssMatchSet x)
-> (forall x. Rep DeleteXssMatchSet x -> DeleteXssMatchSet)
-> Generic DeleteXssMatchSet
forall x. Rep DeleteXssMatchSet x -> DeleteXssMatchSet
forall x. DeleteXssMatchSet -> Rep DeleteXssMatchSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteXssMatchSet x -> DeleteXssMatchSet
$cfrom :: forall x. DeleteXssMatchSet -> Rep DeleteXssMatchSet x
Prelude.Generic)

-- |
-- Create a value of 'DeleteXssMatchSet' 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:
--
-- 'xssMatchSetId', 'deleteXssMatchSet_xssMatchSetId' - The @XssMatchSetId@ of the XssMatchSet that you want to delete.
-- @XssMatchSetId@ is returned by CreateXssMatchSet and by
-- ListXssMatchSets.
--
-- 'changeToken', 'deleteXssMatchSet_changeToken' - The value returned by the most recent call to GetChangeToken.
newDeleteXssMatchSet ::
  -- | 'xssMatchSetId'
  Prelude.Text ->
  -- | 'changeToken'
  Prelude.Text ->
  DeleteXssMatchSet
newDeleteXssMatchSet :: Text -> Text -> DeleteXssMatchSet
newDeleteXssMatchSet Text
pXssMatchSetId_ Text
pChangeToken_ =
  DeleteXssMatchSet' :: Text -> Text -> DeleteXssMatchSet
DeleteXssMatchSet'
    { $sel:xssMatchSetId:DeleteXssMatchSet' :: Text
xssMatchSetId = Text
pXssMatchSetId_,
      $sel:changeToken:DeleteXssMatchSet' :: Text
changeToken = Text
pChangeToken_
    }

-- | The @XssMatchSetId@ of the XssMatchSet that you want to delete.
-- @XssMatchSetId@ is returned by CreateXssMatchSet and by
-- ListXssMatchSets.
deleteXssMatchSet_xssMatchSetId :: Lens.Lens' DeleteXssMatchSet Prelude.Text
deleteXssMatchSet_xssMatchSetId :: (Text -> f Text) -> DeleteXssMatchSet -> f DeleteXssMatchSet
deleteXssMatchSet_xssMatchSetId = (DeleteXssMatchSet -> Text)
-> (DeleteXssMatchSet -> Text -> DeleteXssMatchSet)
-> Lens DeleteXssMatchSet DeleteXssMatchSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteXssMatchSet' {Text
xssMatchSetId :: Text
$sel:xssMatchSetId:DeleteXssMatchSet' :: DeleteXssMatchSet -> Text
xssMatchSetId} -> Text
xssMatchSetId) (\s :: DeleteXssMatchSet
s@DeleteXssMatchSet' {} Text
a -> DeleteXssMatchSet
s {$sel:xssMatchSetId:DeleteXssMatchSet' :: Text
xssMatchSetId = Text
a} :: DeleteXssMatchSet)

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

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

instance Prelude.NFData DeleteXssMatchSet

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

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

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

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

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

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

instance Prelude.NFData DeleteXssMatchSetResponse