{-# 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.DeleteIPSet
-- 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 IPSet.
module Amazonka.WAFV2.DeleteIPSet
  ( -- * Creating a Request
    DeleteIPSet (..),
    newDeleteIPSet,

    -- * Request Lenses
    deleteIPSet_name,
    deleteIPSet_scope,
    deleteIPSet_id,
    deleteIPSet_lockToken,

    -- * Destructuring the Response
    DeleteIPSetResponse (..),
    newDeleteIPSetResponse,

    -- * Response Lenses
    deleteIPSetResponse_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:/ 'newDeleteIPSet' smart constructor.
data DeleteIPSet = DeleteIPSet'
  { -- | The name of the IP set. You cannot change the name of an @IPSet@ after
    -- you create it.
    DeleteIPSet -> 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.
    DeleteIPSet -> Scope
scope :: Scope,
    -- | A unique identifier for the set. This ID is returned in the responses to
    -- create and list commands. You provide it to operations like update and
    -- delete.
    DeleteIPSet -> 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.
    DeleteIPSet -> Text
lockToken :: Prelude.Text
  }
  deriving (DeleteIPSet -> DeleteIPSet -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteIPSet -> DeleteIPSet -> Bool
$c/= :: DeleteIPSet -> DeleteIPSet -> Bool
== :: DeleteIPSet -> DeleteIPSet -> Bool
$c== :: DeleteIPSet -> DeleteIPSet -> Bool
Prelude.Eq, ReadPrec [DeleteIPSet]
ReadPrec DeleteIPSet
Int -> ReadS DeleteIPSet
ReadS [DeleteIPSet]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteIPSet]
$creadListPrec :: ReadPrec [DeleteIPSet]
readPrec :: ReadPrec DeleteIPSet
$creadPrec :: ReadPrec DeleteIPSet
readList :: ReadS [DeleteIPSet]
$creadList :: ReadS [DeleteIPSet]
readsPrec :: Int -> ReadS DeleteIPSet
$creadsPrec :: Int -> ReadS DeleteIPSet
Prelude.Read, Int -> DeleteIPSet -> ShowS
[DeleteIPSet] -> ShowS
DeleteIPSet -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteIPSet] -> ShowS
$cshowList :: [DeleteIPSet] -> ShowS
show :: DeleteIPSet -> String
$cshow :: DeleteIPSet -> String
showsPrec :: Int -> DeleteIPSet -> ShowS
$cshowsPrec :: Int -> DeleteIPSet -> ShowS
Prelude.Show, forall x. Rep DeleteIPSet x -> DeleteIPSet
forall x. DeleteIPSet -> Rep DeleteIPSet x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteIPSet x -> DeleteIPSet
$cfrom :: forall x. DeleteIPSet -> Rep DeleteIPSet x
Prelude.Generic)

-- |
-- Create a value of 'DeleteIPSet' 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', 'deleteIPSet_name' - The name of the IP set. You cannot change the name of an @IPSet@ after
-- you create it.
--
-- 'scope', 'deleteIPSet_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', 'deleteIPSet_id' - A unique identifier for the set. This ID is returned in the responses to
-- create and list commands. You provide it to operations like update and
-- delete.
--
-- 'lockToken', 'deleteIPSet_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.
newDeleteIPSet ::
  -- | 'name'
  Prelude.Text ->
  -- | 'scope'
  Scope ->
  -- | 'id'
  Prelude.Text ->
  -- | 'lockToken'
  Prelude.Text ->
  DeleteIPSet
newDeleteIPSet :: Text -> Scope -> Text -> Text -> DeleteIPSet
newDeleteIPSet Text
pName_ Scope
pScope_ Text
pId_ Text
pLockToken_ =
  DeleteIPSet'
    { $sel:name:DeleteIPSet' :: Text
name = Text
pName_,
      $sel:scope:DeleteIPSet' :: Scope
scope = Scope
pScope_,
      $sel:id:DeleteIPSet' :: Text
id = Text
pId_,
      $sel:lockToken:DeleteIPSet' :: Text
lockToken = Text
pLockToken_
    }

-- | The name of the IP set. You cannot change the name of an @IPSet@ after
-- you create it.
deleteIPSet_name :: Lens.Lens' DeleteIPSet Prelude.Text
deleteIPSet_name :: Lens' DeleteIPSet Text
deleteIPSet_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteIPSet' {Text
name :: Text
$sel:name:DeleteIPSet' :: DeleteIPSet -> Text
name} -> Text
name) (\s :: DeleteIPSet
s@DeleteIPSet' {} Text
a -> DeleteIPSet
s {$sel:name:DeleteIPSet' :: Text
name = Text
a} :: DeleteIPSet)

-- | 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.
deleteIPSet_scope :: Lens.Lens' DeleteIPSet Scope
deleteIPSet_scope :: Lens' DeleteIPSet Scope
deleteIPSet_scope = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteIPSet' {Scope
scope :: Scope
$sel:scope:DeleteIPSet' :: DeleteIPSet -> Scope
scope} -> Scope
scope) (\s :: DeleteIPSet
s@DeleteIPSet' {} Scope
a -> DeleteIPSet
s {$sel:scope:DeleteIPSet' :: Scope
scope = Scope
a} :: DeleteIPSet)

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

-- | 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.
deleteIPSet_lockToken :: Lens.Lens' DeleteIPSet Prelude.Text
deleteIPSet_lockToken :: Lens' DeleteIPSet Text
deleteIPSet_lockToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteIPSet' {Text
lockToken :: Text
$sel:lockToken:DeleteIPSet' :: DeleteIPSet -> Text
lockToken} -> Text
lockToken) (\s :: DeleteIPSet
s@DeleteIPSet' {} Text
a -> DeleteIPSet
s {$sel:lockToken:DeleteIPSet' :: Text
lockToken = Text
a} :: DeleteIPSet)

instance Core.AWSRequest DeleteIPSet where
  type AWSResponse DeleteIPSet = DeleteIPSetResponse
  request :: (Service -> Service) -> DeleteIPSet -> Request DeleteIPSet
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 DeleteIPSet
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DeleteIPSet)))
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 -> DeleteIPSetResponse
DeleteIPSetResponse'
            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 DeleteIPSet where
  hashWithSalt :: Int -> DeleteIPSet -> Int
hashWithSalt Int
_salt DeleteIPSet' {Text
Scope
lockToken :: Text
id :: Text
scope :: Scope
name :: Text
$sel:lockToken:DeleteIPSet' :: DeleteIPSet -> Text
$sel:id:DeleteIPSet' :: DeleteIPSet -> Text
$sel:scope:DeleteIPSet' :: DeleteIPSet -> Scope
$sel:name:DeleteIPSet' :: DeleteIPSet -> 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 DeleteIPSet where
  rnf :: DeleteIPSet -> ()
rnf DeleteIPSet' {Text
Scope
lockToken :: Text
id :: Text
scope :: Scope
name :: Text
$sel:lockToken:DeleteIPSet' :: DeleteIPSet -> Text
$sel:id:DeleteIPSet' :: DeleteIPSet -> Text
$sel:scope:DeleteIPSet' :: DeleteIPSet -> Scope
$sel:name:DeleteIPSet' :: DeleteIPSet -> 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 DeleteIPSet where
  toHeaders :: DeleteIPSet -> 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.DeleteIPSet" ::
                          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 DeleteIPSet where
  toJSON :: DeleteIPSet -> Value
toJSON DeleteIPSet' {Text
Scope
lockToken :: Text
id :: Text
scope :: Scope
name :: Text
$sel:lockToken:DeleteIPSet' :: DeleteIPSet -> Text
$sel:id:DeleteIPSet' :: DeleteIPSet -> Text
$sel:scope:DeleteIPSet' :: DeleteIPSet -> Scope
$sel:name:DeleteIPSet' :: DeleteIPSet -> 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 DeleteIPSet where
  toPath :: DeleteIPSet -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newDeleteIPSetResponse' smart constructor.
data DeleteIPSetResponse = DeleteIPSetResponse'
  { -- | The response's http status code.
    DeleteIPSetResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteIPSetResponse -> DeleteIPSetResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteIPSetResponse -> DeleteIPSetResponse -> Bool
$c/= :: DeleteIPSetResponse -> DeleteIPSetResponse -> Bool
== :: DeleteIPSetResponse -> DeleteIPSetResponse -> Bool
$c== :: DeleteIPSetResponse -> DeleteIPSetResponse -> Bool
Prelude.Eq, ReadPrec [DeleteIPSetResponse]
ReadPrec DeleteIPSetResponse
Int -> ReadS DeleteIPSetResponse
ReadS [DeleteIPSetResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteIPSetResponse]
$creadListPrec :: ReadPrec [DeleteIPSetResponse]
readPrec :: ReadPrec DeleteIPSetResponse
$creadPrec :: ReadPrec DeleteIPSetResponse
readList :: ReadS [DeleteIPSetResponse]
$creadList :: ReadS [DeleteIPSetResponse]
readsPrec :: Int -> ReadS DeleteIPSetResponse
$creadsPrec :: Int -> ReadS DeleteIPSetResponse
Prelude.Read, Int -> DeleteIPSetResponse -> ShowS
[DeleteIPSetResponse] -> ShowS
DeleteIPSetResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteIPSetResponse] -> ShowS
$cshowList :: [DeleteIPSetResponse] -> ShowS
show :: DeleteIPSetResponse -> String
$cshow :: DeleteIPSetResponse -> String
showsPrec :: Int -> DeleteIPSetResponse -> ShowS
$cshowsPrec :: Int -> DeleteIPSetResponse -> ShowS
Prelude.Show, forall x. Rep DeleteIPSetResponse x -> DeleteIPSetResponse
forall x. DeleteIPSetResponse -> Rep DeleteIPSetResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteIPSetResponse x -> DeleteIPSetResponse
$cfrom :: forall x. DeleteIPSetResponse -> Rep DeleteIPSetResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteIPSetResponse' 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', 'deleteIPSetResponse_httpStatus' - The response's http status code.
newDeleteIPSetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteIPSetResponse
newDeleteIPSetResponse :: Int -> DeleteIPSetResponse
newDeleteIPSetResponse Int
pHttpStatus_ =
  DeleteIPSetResponse' {$sel:httpStatus:DeleteIPSetResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData DeleteIPSetResponse where
  rnf :: DeleteIPSetResponse -> ()
rnf DeleteIPSetResponse' {Int
httpStatus :: Int
$sel:httpStatus:DeleteIPSetResponse' :: DeleteIPSetResponse -> Int
..} = forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus