{-# 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.DeletePermissionPolicy
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Permanently deletes an IAM policy from the specified rule group.
--
-- You must be the owner of the rule group to perform this operation.
module Amazonka.WAFV2.DeletePermissionPolicy
  ( -- * Creating a Request
    DeletePermissionPolicy (..),
    newDeletePermissionPolicy,

    -- * Request Lenses
    deletePermissionPolicy_resourceArn,

    -- * Destructuring the Response
    DeletePermissionPolicyResponse (..),
    newDeletePermissionPolicyResponse,

    -- * Response Lenses
    deletePermissionPolicyResponse_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:/ 'newDeletePermissionPolicy' smart constructor.
data DeletePermissionPolicy = DeletePermissionPolicy'
  { -- | The Amazon Resource Name (ARN) of the rule group from which you want to
    -- delete the policy.
    --
    -- You must be the owner of the rule group to perform this operation.
    DeletePermissionPolicy -> Text
resourceArn :: Prelude.Text
  }
  deriving (DeletePermissionPolicy -> DeletePermissionPolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeletePermissionPolicy -> DeletePermissionPolicy -> Bool
$c/= :: DeletePermissionPolicy -> DeletePermissionPolicy -> Bool
== :: DeletePermissionPolicy -> DeletePermissionPolicy -> Bool
$c== :: DeletePermissionPolicy -> DeletePermissionPolicy -> Bool
Prelude.Eq, ReadPrec [DeletePermissionPolicy]
ReadPrec DeletePermissionPolicy
Int -> ReadS DeletePermissionPolicy
ReadS [DeletePermissionPolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeletePermissionPolicy]
$creadListPrec :: ReadPrec [DeletePermissionPolicy]
readPrec :: ReadPrec DeletePermissionPolicy
$creadPrec :: ReadPrec DeletePermissionPolicy
readList :: ReadS [DeletePermissionPolicy]
$creadList :: ReadS [DeletePermissionPolicy]
readsPrec :: Int -> ReadS DeletePermissionPolicy
$creadsPrec :: Int -> ReadS DeletePermissionPolicy
Prelude.Read, Int -> DeletePermissionPolicy -> ShowS
[DeletePermissionPolicy] -> ShowS
DeletePermissionPolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeletePermissionPolicy] -> ShowS
$cshowList :: [DeletePermissionPolicy] -> ShowS
show :: DeletePermissionPolicy -> String
$cshow :: DeletePermissionPolicy -> String
showsPrec :: Int -> DeletePermissionPolicy -> ShowS
$cshowsPrec :: Int -> DeletePermissionPolicy -> ShowS
Prelude.Show, forall x. Rep DeletePermissionPolicy x -> DeletePermissionPolicy
forall x. DeletePermissionPolicy -> Rep DeletePermissionPolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeletePermissionPolicy x -> DeletePermissionPolicy
$cfrom :: forall x. DeletePermissionPolicy -> Rep DeletePermissionPolicy x
Prelude.Generic)

-- |
-- Create a value of 'DeletePermissionPolicy' 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:
--
-- 'resourceArn', 'deletePermissionPolicy_resourceArn' - The Amazon Resource Name (ARN) of the rule group from which you want to
-- delete the policy.
--
-- You must be the owner of the rule group to perform this operation.
newDeletePermissionPolicy ::
  -- | 'resourceArn'
  Prelude.Text ->
  DeletePermissionPolicy
newDeletePermissionPolicy :: Text -> DeletePermissionPolicy
newDeletePermissionPolicy Text
pResourceArn_ =
  DeletePermissionPolicy'
    { $sel:resourceArn:DeletePermissionPolicy' :: Text
resourceArn =
        Text
pResourceArn_
    }

-- | The Amazon Resource Name (ARN) of the rule group from which you want to
-- delete the policy.
--
-- You must be the owner of the rule group to perform this operation.
deletePermissionPolicy_resourceArn :: Lens.Lens' DeletePermissionPolicy Prelude.Text
deletePermissionPolicy_resourceArn :: Lens' DeletePermissionPolicy Text
deletePermissionPolicy_resourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeletePermissionPolicy' {Text
resourceArn :: Text
$sel:resourceArn:DeletePermissionPolicy' :: DeletePermissionPolicy -> Text
resourceArn} -> Text
resourceArn) (\s :: DeletePermissionPolicy
s@DeletePermissionPolicy' {} Text
a -> DeletePermissionPolicy
s {$sel:resourceArn:DeletePermissionPolicy' :: Text
resourceArn = Text
a} :: DeletePermissionPolicy)

instance Core.AWSRequest DeletePermissionPolicy where
  type
    AWSResponse DeletePermissionPolicy =
      DeletePermissionPolicyResponse
  request :: (Service -> Service)
-> DeletePermissionPolicy -> Request DeletePermissionPolicy
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 DeletePermissionPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeletePermissionPolicy)))
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 -> DeletePermissionPolicyResponse
DeletePermissionPolicyResponse'
            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 DeletePermissionPolicy where
  hashWithSalt :: Int -> DeletePermissionPolicy -> Int
hashWithSalt Int
_salt DeletePermissionPolicy' {Text
resourceArn :: Text
$sel:resourceArn:DeletePermissionPolicy' :: DeletePermissionPolicy -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceArn

instance Prelude.NFData DeletePermissionPolicy where
  rnf :: DeletePermissionPolicy -> ()
rnf DeletePermissionPolicy' {Text
resourceArn :: Text
$sel:resourceArn:DeletePermissionPolicy' :: DeletePermissionPolicy -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
resourceArn

instance Data.ToHeaders DeletePermissionPolicy where
  toHeaders :: DeletePermissionPolicy -> 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.DeletePermissionPolicy" ::
                          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 DeletePermissionPolicy where
  toJSON :: DeletePermissionPolicy -> Value
toJSON DeletePermissionPolicy' {Text
resourceArn :: Text
$sel:resourceArn:DeletePermissionPolicy' :: DeletePermissionPolicy -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"ResourceArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
resourceArn)]
      )

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

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

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

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

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

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