{-# 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.DeleteWebACL
-- 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 WebACL. You can\'t delete a @WebACL@ if it still
-- contains any @Rules@.
--
-- To delete a @WebACL@, perform the following steps:
--
-- 1.  Update the @WebACL@ to remove @Rules@, if any. For more information,
--     see UpdateWebACL.
--
-- 2.  Use GetChangeToken to get the change token that you provide in the
--     @ChangeToken@ parameter of a @DeleteWebACL@ request.
--
-- 3.  Submit a @DeleteWebACL@ request.
module Amazonka.WAFRegional.DeleteWebACL
  ( -- * Creating a Request
    DeleteWebACL (..),
    newDeleteWebACL,

    -- * Request Lenses
    deleteWebACL_webACLId,
    deleteWebACL_changeToken,

    -- * Destructuring the Response
    DeleteWebACLResponse (..),
    newDeleteWebACLResponse,

    -- * Response Lenses
    deleteWebACLResponse_changeToken,
    deleteWebACLResponse_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.WAFRegional.Types

-- | /See:/ 'newDeleteWebACL' smart constructor.
data DeleteWebACL = DeleteWebACL'
  { -- | The @WebACLId@ of the WebACL that you want to delete. @WebACLId@ is
    -- returned by CreateWebACL and by ListWebACLs.
    DeleteWebACL -> Text
webACLId :: Prelude.Text,
    -- | The value returned by the most recent call to GetChangeToken.
    DeleteWebACL -> Text
changeToken :: Prelude.Text
  }
  deriving (DeleteWebACL -> DeleteWebACL -> Bool
(DeleteWebACL -> DeleteWebACL -> Bool)
-> (DeleteWebACL -> DeleteWebACL -> Bool) -> Eq DeleteWebACL
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteWebACL -> DeleteWebACL -> Bool
$c/= :: DeleteWebACL -> DeleteWebACL -> Bool
== :: DeleteWebACL -> DeleteWebACL -> Bool
$c== :: DeleteWebACL -> DeleteWebACL -> Bool
Prelude.Eq, ReadPrec [DeleteWebACL]
ReadPrec DeleteWebACL
Int -> ReadS DeleteWebACL
ReadS [DeleteWebACL]
(Int -> ReadS DeleteWebACL)
-> ReadS [DeleteWebACL]
-> ReadPrec DeleteWebACL
-> ReadPrec [DeleteWebACL]
-> Read DeleteWebACL
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteWebACL]
$creadListPrec :: ReadPrec [DeleteWebACL]
readPrec :: ReadPrec DeleteWebACL
$creadPrec :: ReadPrec DeleteWebACL
readList :: ReadS [DeleteWebACL]
$creadList :: ReadS [DeleteWebACL]
readsPrec :: Int -> ReadS DeleteWebACL
$creadsPrec :: Int -> ReadS DeleteWebACL
Prelude.Read, Int -> DeleteWebACL -> ShowS
[DeleteWebACL] -> ShowS
DeleteWebACL -> String
(Int -> DeleteWebACL -> ShowS)
-> (DeleteWebACL -> String)
-> ([DeleteWebACL] -> ShowS)
-> Show DeleteWebACL
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteWebACL] -> ShowS
$cshowList :: [DeleteWebACL] -> ShowS
show :: DeleteWebACL -> String
$cshow :: DeleteWebACL -> String
showsPrec :: Int -> DeleteWebACL -> ShowS
$cshowsPrec :: Int -> DeleteWebACL -> ShowS
Prelude.Show, (forall x. DeleteWebACL -> Rep DeleteWebACL x)
-> (forall x. Rep DeleteWebACL x -> DeleteWebACL)
-> Generic DeleteWebACL
forall x. Rep DeleteWebACL x -> DeleteWebACL
forall x. DeleteWebACL -> Rep DeleteWebACL x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteWebACL x -> DeleteWebACL
$cfrom :: forall x. DeleteWebACL -> Rep DeleteWebACL x
Prelude.Generic)

-- |
-- Create a value of 'DeleteWebACL' 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:
--
-- 'webACLId', 'deleteWebACL_webACLId' - The @WebACLId@ of the WebACL that you want to delete. @WebACLId@ is
-- returned by CreateWebACL and by ListWebACLs.
--
-- 'changeToken', 'deleteWebACL_changeToken' - The value returned by the most recent call to GetChangeToken.
newDeleteWebACL ::
  -- | 'webACLId'
  Prelude.Text ->
  -- | 'changeToken'
  Prelude.Text ->
  DeleteWebACL
newDeleteWebACL :: Text -> Text -> DeleteWebACL
newDeleteWebACL Text
pWebACLId_ Text
pChangeToken_ =
  DeleteWebACL' :: Text -> Text -> DeleteWebACL
DeleteWebACL'
    { $sel:webACLId:DeleteWebACL' :: Text
webACLId = Text
pWebACLId_,
      $sel:changeToken:DeleteWebACL' :: Text
changeToken = Text
pChangeToken_
    }

-- | The @WebACLId@ of the WebACL that you want to delete. @WebACLId@ is
-- returned by CreateWebACL and by ListWebACLs.
deleteWebACL_webACLId :: Lens.Lens' DeleteWebACL Prelude.Text
deleteWebACL_webACLId :: (Text -> f Text) -> DeleteWebACL -> f DeleteWebACL
deleteWebACL_webACLId = (DeleteWebACL -> Text)
-> (DeleteWebACL -> Text -> DeleteWebACL)
-> Lens DeleteWebACL DeleteWebACL Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteWebACL' {Text
webACLId :: Text
$sel:webACLId:DeleteWebACL' :: DeleteWebACL -> Text
webACLId} -> Text
webACLId) (\s :: DeleteWebACL
s@DeleteWebACL' {} Text
a -> DeleteWebACL
s {$sel:webACLId:DeleteWebACL' :: Text
webACLId = Text
a} :: DeleteWebACL)

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

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

instance Prelude.NFData DeleteWebACL

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

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

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

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

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

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

instance Prelude.NFData DeleteWebACLResponse