{-# 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.WAFV2.DeleteWebACL
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Deletes the specified WebACL.
--
-- You can only use this if @ManagedByFirewallManager@ is false in the
-- specified WebACL.
--
-- Before deleting any web ACL, first disassociate it from all resources.
--
-- -   To retrieve a list of the resources that are associated with a web
--     ACL, use the following calls:
--
--     -   For regional resources, call ListResourcesForWebACL.
--
--     -   For Amazon CloudFront distributions, use the CloudFront call
--         @ListDistributionsByWebACLId@. For information, see
--         <https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_ListDistributionsByWebACLId.html ListDistributionsByWebACLId>.
--
-- -   To disassociate a resource from a web ACL, use the following calls:
--
--     -   For regional resources, call DisassociateWebACL.
--
--     -   For Amazon CloudFront distributions, provide an empty web ACL ID
--         in the CloudFront call @UpdateDistribution@. For information,
--         see
--         <https://docs.aws.amazon.com/cloudfront/latest/APIReference/API_UpdateDistribution.html UpdateDistribution>.
module Amazonka.WAFV2.DeleteWebACL
  ( -- * Creating a Request
    DeleteWebACL (..),
    newDeleteWebACL,

    -- * Request Lenses
    deleteWebACL_name,
    deleteWebACL_scope,
    deleteWebACL_id,
    deleteWebACL_lockToken,

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

    -- * Response Lenses
    deleteWebACLResponse_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.WAFV2.Types

-- | /See:/ 'newDeleteWebACL' smart constructor.
data DeleteWebACL = DeleteWebACL'
  { -- | The name of the web ACL. You cannot change the name of a web ACL after
    -- you create it.
    DeleteWebACL -> Text
name :: Prelude.Text,
    -- | Specifies whether this is for an Amazon CloudFront distribution or for a
    -- regional application. A regional application can be an Application Load
    -- Balancer (ALB), an Amazon API Gateway REST API, an AppSync GraphQL API,
    -- or an Amazon Cognito user pool.
    --
    -- To work with CloudFront, you must also specify the Region US East (N.
    -- Virginia) as follows:
    --
    -- -   CLI - Specify the Region when you use the CloudFront scope:
    --     @--scope=CLOUDFRONT --region=us-east-1@.
    --
    -- -   API and SDKs - For all calls, use the Region endpoint us-east-1.
    DeleteWebACL -> Scope
scope :: Scope,
    -- | The unique identifier for the web ACL. This ID is returned in the
    -- responses to create and list commands. You provide it to operations like
    -- update and delete.
    DeleteWebACL -> Text
id :: Prelude.Text,
    -- | A token used for optimistic locking. WAF returns a token to your @get@
    -- and @list@ requests, to mark the state of the entity at the time of the
    -- request. To make changes to the entity associated with the token, you
    -- provide the token to operations like @update@ and @delete@. WAF uses the
    -- token to ensure that no changes have been made to the entity since you
    -- last retrieved it. If a change has been made, the update fails with a
    -- @WAFOptimisticLockException@. If this happens, perform another @get@,
    -- and use the new token returned by that operation.
    DeleteWebACL -> Text
lockToken :: Prelude.Text
  }
  deriving (DeleteWebACL -> DeleteWebACL -> Bool
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]
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
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. 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:
--
-- 'name', 'deleteWebACL_name' - The name of the web ACL. You cannot change the name of a web ACL after
-- you create it.
--
-- 'scope', 'deleteWebACL_scope' - Specifies whether this is for an Amazon CloudFront distribution or for a
-- regional application. A regional application can be an Application Load
-- Balancer (ALB), an Amazon API Gateway REST API, an AppSync GraphQL API,
-- or an Amazon Cognito user pool.
--
-- To work with CloudFront, you must also specify the Region US East (N.
-- Virginia) as follows:
--
-- -   CLI - Specify the Region when you use the CloudFront scope:
--     @--scope=CLOUDFRONT --region=us-east-1@.
--
-- -   API and SDKs - For all calls, use the Region endpoint us-east-1.
--
-- 'id', 'deleteWebACL_id' - The unique identifier for the web ACL. This ID is returned in the
-- responses to create and list commands. You provide it to operations like
-- update and delete.
--
-- 'lockToken', 'deleteWebACL_lockToken' - A token used for optimistic locking. WAF returns a token to your @get@
-- and @list@ requests, to mark the state of the entity at the time of the
-- request. To make changes to the entity associated with the token, you
-- provide the token to operations like @update@ and @delete@. WAF uses the
-- token to ensure that no changes have been made to the entity since you
-- last retrieved it. If a change has been made, the update fails with a
-- @WAFOptimisticLockException@. If this happens, perform another @get@,
-- and use the new token returned by that operation.
newDeleteWebACL ::
  -- | 'name'
  Prelude.Text ->
  -- | 'scope'
  Scope ->
  -- | 'id'
  Prelude.Text ->
  -- | 'lockToken'
  Prelude.Text ->
  DeleteWebACL
newDeleteWebACL :: Text -> Scope -> Text -> Text -> DeleteWebACL
newDeleteWebACL Text
pName_ Scope
pScope_ Text
pId_ Text
pLockToken_ =
  DeleteWebACL'
    { $sel:name:DeleteWebACL' :: Text
name = Text
pName_,
      $sel:scope:DeleteWebACL' :: Scope
scope = Scope
pScope_,
      $sel:id:DeleteWebACL' :: Text
id = Text
pId_,
      $sel:lockToken:DeleteWebACL' :: Text
lockToken = Text
pLockToken_
    }

-- | The name of the web ACL. You cannot change the name of a web ACL after
-- you create it.
deleteWebACL_name :: Lens.Lens' DeleteWebACL Prelude.Text
deleteWebACL_name :: Lens' DeleteWebACL Text
deleteWebACL_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteWebACL' {Text
name :: Text
$sel:name:DeleteWebACL' :: DeleteWebACL -> Text
name} -> Text
name) (\s :: DeleteWebACL
s@DeleteWebACL' {} Text
a -> DeleteWebACL
s {$sel:name:DeleteWebACL' :: Text
name = Text
a} :: DeleteWebACL)

-- | Specifies whether this is for an Amazon CloudFront distribution or for a
-- regional application. A regional application can be an Application Load
-- Balancer (ALB), an Amazon API Gateway REST API, an AppSync GraphQL API,
-- or an Amazon Cognito user pool.
--
-- To work with CloudFront, you must also specify the Region US East (N.
-- Virginia) as follows:
--
-- -   CLI - Specify the Region when you use the CloudFront scope:
--     @--scope=CLOUDFRONT --region=us-east-1@.
--
-- -   API and SDKs - For all calls, use the Region endpoint us-east-1.
deleteWebACL_scope :: Lens.Lens' DeleteWebACL Scope
deleteWebACL_scope :: Lens' DeleteWebACL Scope
deleteWebACL_scope = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteWebACL' {Scope
scope :: Scope
$sel:scope:DeleteWebACL' :: DeleteWebACL -> Scope
scope} -> Scope
scope) (\s :: DeleteWebACL
s@DeleteWebACL' {} Scope
a -> DeleteWebACL
s {$sel:scope:DeleteWebACL' :: Scope
scope = Scope
a} :: DeleteWebACL)

-- | The unique identifier for the web ACL. This ID is returned in the
-- responses to create and list commands. You provide it to operations like
-- update and delete.
deleteWebACL_id :: Lens.Lens' DeleteWebACL Prelude.Text
deleteWebACL_id :: Lens' DeleteWebACL Text
deleteWebACL_id = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteWebACL' {Text
id :: Text
$sel:id:DeleteWebACL' :: DeleteWebACL -> Text
id} -> Text
id) (\s :: DeleteWebACL
s@DeleteWebACL' {} Text
a -> DeleteWebACL
s {$sel:id:DeleteWebACL' :: Text
id = Text
a} :: DeleteWebACL)

-- | A token used for optimistic locking. WAF returns a token to your @get@
-- and @list@ requests, to mark the state of the entity at the time of the
-- request. To make changes to the entity associated with the token, you
-- provide the token to operations like @update@ and @delete@. WAF uses the
-- token to ensure that no changes have been made to the entity since you
-- last retrieved it. If a change has been made, the update fails with a
-- @WAFOptimisticLockException@. If this happens, perform another @get@,
-- and use the new token returned by that operation.
deleteWebACL_lockToken :: Lens.Lens' DeleteWebACL Prelude.Text
deleteWebACL_lockToken :: Lens' DeleteWebACL Text
deleteWebACL_lockToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteWebACL' {Text
lockToken :: Text
$sel:lockToken:DeleteWebACL' :: DeleteWebACL -> Text
lockToken} -> Text
lockToken) (\s :: DeleteWebACL
s@DeleteWebACL' {} Text
a -> DeleteWebACL
s {$sel:lockToken:DeleteWebACL' :: Text
lockToken = Text
a} :: DeleteWebACL)

instance Core.AWSRequest DeleteWebACL where
  type AWSResponse DeleteWebACL = DeleteWebACLResponse
  request :: (Service -> Service) -> DeleteWebACL -> Request DeleteWebACL
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 DeleteWebACL
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteWebACL)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeleteWebACLResponse
DeleteWebACLResponse'
            forall (f :: * -> *) a b. Functor 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 DeleteWebACL where
  hashWithSalt :: Int -> DeleteWebACL -> Int
hashWithSalt Int
_salt DeleteWebACL' {Text
Scope
lockToken :: Text
id :: Text
scope :: Scope
name :: Text
$sel:lockToken:DeleteWebACL' :: DeleteWebACL -> Text
$sel:id:DeleteWebACL' :: DeleteWebACL -> Text
$sel:scope:DeleteWebACL' :: DeleteWebACL -> Scope
$sel:name:DeleteWebACL' :: DeleteWebACL -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Scope
scope
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
id
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
lockToken

instance Prelude.NFData DeleteWebACL where
  rnf :: DeleteWebACL -> ()
rnf DeleteWebACL' {Text
Scope
lockToken :: Text
id :: Text
scope :: Scope
name :: Text
$sel:lockToken:DeleteWebACL' :: DeleteWebACL -> Text
$sel:id:DeleteWebACL' :: DeleteWebACL -> Text
$sel:scope:DeleteWebACL' :: DeleteWebACL -> Scope
$sel:name:DeleteWebACL' :: DeleteWebACL -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Scope
scope
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
id
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
lockToken

instance Data.ToHeaders DeleteWebACL where
  toHeaders :: DeleteWebACL -> 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_20190729.DeleteWebACL" ::
                          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 DeleteWebACL where
  toJSON :: DeleteWebACL -> Value
toJSON DeleteWebACL' {Text
Scope
lockToken :: Text
id :: Text
scope :: Scope
name :: Text
$sel:lockToken:DeleteWebACL' :: DeleteWebACL -> Text
$sel:id:DeleteWebACL' :: DeleteWebACL -> Text
$sel:scope:DeleteWebACL' :: DeleteWebACL -> Scope
$sel:name:DeleteWebACL' :: DeleteWebACL -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Scope" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Scope
scope),
            forall a. a -> Maybe a
Prelude.Just (Key
"Id" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
id),
            forall a. a -> Maybe a
Prelude.Just (Key
"LockToken" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
lockToken)
          ]
      )

instance Data.ToPath DeleteWebACL where
  toPath :: DeleteWebACL -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newDeleteWebACLResponse' smart constructor.
data DeleteWebACLResponse = DeleteWebACLResponse'
  { -- | The response's http status code.
    DeleteWebACLResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteWebACLResponse -> DeleteWebACLResponse -> Bool
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]
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
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. 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:
--
-- 'httpStatus', 'deleteWebACLResponse_httpStatus' - The response's http status code.
newDeleteWebACLResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteWebACLResponse
newDeleteWebACLResponse :: Int -> DeleteWebACLResponse
newDeleteWebACLResponse Int
pHttpStatus_ =
  DeleteWebACLResponse' {$sel:httpStatus:DeleteWebACLResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
deleteWebACLResponse_httpStatus :: Lens.Lens' DeleteWebACLResponse Prelude.Int
deleteWebACLResponse_httpStatus :: Lens' DeleteWebACLResponse Int
deleteWebACLResponse_httpStatus = 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 where
  rnf :: DeleteWebACLResponse -> ()
rnf DeleteWebACLResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteWebACLResponse' :: DeleteWebACLResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus