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

    -- * Request Lenses
    deleteIPSet_iPSetId,
    deleteIPSet_changeToken,

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

    -- * Response Lenses
    deleteIPSetResponse_changeToken,
    deleteIPSetResponse_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:/ 'newDeleteIPSet' smart constructor.
data DeleteIPSet = DeleteIPSet'
  { -- | The @IPSetId@ of the IPSet that you want to delete. @IPSetId@ is
    -- returned by CreateIPSet and by ListIPSets.
    DeleteIPSet -> Text
iPSetId :: Prelude.Text,
    -- | The value returned by the most recent call to GetChangeToken.
    DeleteIPSet -> Text
changeToken :: Prelude.Text
  }
  deriving (DeleteIPSet -> DeleteIPSet -> Bool
(DeleteIPSet -> DeleteIPSet -> Bool)
-> (DeleteIPSet -> DeleteIPSet -> Bool) -> Eq DeleteIPSet
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]
(Int -> ReadS DeleteIPSet)
-> ReadS [DeleteIPSet]
-> ReadPrec DeleteIPSet
-> ReadPrec [DeleteIPSet]
-> Read 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
(Int -> DeleteIPSet -> ShowS)
-> (DeleteIPSet -> String)
-> ([DeleteIPSet] -> ShowS)
-> Show DeleteIPSet
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. DeleteIPSet -> Rep DeleteIPSet x)
-> (forall x. Rep DeleteIPSet x -> DeleteIPSet)
-> Generic DeleteIPSet
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:
--
-- 'iPSetId', 'deleteIPSet_iPSetId' - The @IPSetId@ of the IPSet that you want to delete. @IPSetId@ is
-- returned by CreateIPSet and by ListIPSets.
--
-- 'changeToken', 'deleteIPSet_changeToken' - The value returned by the most recent call to GetChangeToken.
newDeleteIPSet ::
  -- | 'iPSetId'
  Prelude.Text ->
  -- | 'changeToken'
  Prelude.Text ->
  DeleteIPSet
newDeleteIPSet :: Text -> Text -> DeleteIPSet
newDeleteIPSet Text
pIPSetId_ Text
pChangeToken_ =
  DeleteIPSet' :: Text -> Text -> DeleteIPSet
DeleteIPSet'
    { $sel:iPSetId:DeleteIPSet' :: Text
iPSetId = Text
pIPSetId_,
      $sel:changeToken:DeleteIPSet' :: Text
changeToken = Text
pChangeToken_
    }

-- | The @IPSetId@ of the IPSet that you want to delete. @IPSetId@ is
-- returned by CreateIPSet and by ListIPSets.
deleteIPSet_iPSetId :: Lens.Lens' DeleteIPSet Prelude.Text
deleteIPSet_iPSetId :: (Text -> f Text) -> DeleteIPSet -> f DeleteIPSet
deleteIPSet_iPSetId = (DeleteIPSet -> Text)
-> (DeleteIPSet -> Text -> DeleteIPSet)
-> Lens DeleteIPSet DeleteIPSet Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteIPSet' {Text
iPSetId :: Text
$sel:iPSetId:DeleteIPSet' :: DeleteIPSet -> Text
iPSetId} -> Text
iPSetId) (\s :: DeleteIPSet
s@DeleteIPSet' {} Text
a -> DeleteIPSet
s {$sel:iPSetId:DeleteIPSet' :: Text
iPSetId = Text
a} :: DeleteIPSet)

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

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

instance Prelude.NFData DeleteIPSet

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

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

-- | /See:/ 'newDeleteIPSetResponse' smart constructor.
data DeleteIPSetResponse = DeleteIPSetResponse'
  { -- | The @ChangeToken@ that you used to submit the @DeleteIPSet@ request. You
    -- can also use this value to query the status of the request. For more
    -- information, see GetChangeTokenStatus.
    DeleteIPSetResponse -> Maybe Text
changeToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DeleteIPSetResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteIPSetResponse -> DeleteIPSetResponse -> Bool
(DeleteIPSetResponse -> DeleteIPSetResponse -> Bool)
-> (DeleteIPSetResponse -> DeleteIPSetResponse -> Bool)
-> Eq DeleteIPSetResponse
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]
(Int -> ReadS DeleteIPSetResponse)
-> ReadS [DeleteIPSetResponse]
-> ReadPrec DeleteIPSetResponse
-> ReadPrec [DeleteIPSetResponse]
-> Read 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
(Int -> DeleteIPSetResponse -> ShowS)
-> (DeleteIPSetResponse -> String)
-> ([DeleteIPSetResponse] -> ShowS)
-> Show DeleteIPSetResponse
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. DeleteIPSetResponse -> Rep DeleteIPSetResponse x)
-> (forall x. Rep DeleteIPSetResponse x -> DeleteIPSetResponse)
-> Generic DeleteIPSetResponse
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:
--
-- 'changeToken', 'deleteIPSetResponse_changeToken' - The @ChangeToken@ that you used to submit the @DeleteIPSet@ request. You
-- can also use this value to query the status of the request. For more
-- information, see GetChangeTokenStatus.
--
-- 'httpStatus', 'deleteIPSetResponse_httpStatus' - The response's http status code.
newDeleteIPSetResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteIPSetResponse
newDeleteIPSetResponse :: Int -> DeleteIPSetResponse
newDeleteIPSetResponse Int
pHttpStatus_ =
  DeleteIPSetResponse' :: Maybe Text -> Int -> DeleteIPSetResponse
DeleteIPSetResponse'
    { $sel:changeToken:DeleteIPSetResponse' :: Maybe Text
changeToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteIPSetResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

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

-- | The response's http status code.
deleteIPSetResponse_httpStatus :: Lens.Lens' DeleteIPSetResponse Prelude.Int
deleteIPSetResponse_httpStatus :: (Int -> f Int) -> DeleteIPSetResponse -> f DeleteIPSetResponse
deleteIPSetResponse_httpStatus = (DeleteIPSetResponse -> Int)
-> (DeleteIPSetResponse -> Int -> DeleteIPSetResponse)
-> Lens DeleteIPSetResponse DeleteIPSetResponse Int Int
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