{-# 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.DeletePermissionPolicy
-- 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 IAM policy from the specified RuleGroup.
--
-- The user making the request must be the owner of the RuleGroup.
module Amazonka.WAFRegional.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.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:/ 'newDeletePermissionPolicy' smart constructor.
data DeletePermissionPolicy = DeletePermissionPolicy'
  { -- | The Amazon Resource Name (ARN) of the RuleGroup from which you want to
    -- delete the policy.
    --
    -- The user making the request must be the owner of the RuleGroup.
    DeletePermissionPolicy -> Text
resourceArn :: Prelude.Text
  }
  deriving (DeletePermissionPolicy -> DeletePermissionPolicy -> Bool
(DeletePermissionPolicy -> DeletePermissionPolicy -> Bool)
-> (DeletePermissionPolicy -> DeletePermissionPolicy -> Bool)
-> Eq DeletePermissionPolicy
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]
(Int -> ReadS DeletePermissionPolicy)
-> ReadS [DeletePermissionPolicy]
-> ReadPrec DeletePermissionPolicy
-> ReadPrec [DeletePermissionPolicy]
-> Read 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
(Int -> DeletePermissionPolicy -> ShowS)
-> (DeletePermissionPolicy -> String)
-> ([DeletePermissionPolicy] -> ShowS)
-> Show DeletePermissionPolicy
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. DeletePermissionPolicy -> Rep DeletePermissionPolicy x)
-> (forall x.
    Rep DeletePermissionPolicy x -> DeletePermissionPolicy)
-> Generic DeletePermissionPolicy
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 RuleGroup from which you want to
-- delete the policy.
--
-- The user making the request must be the owner of the RuleGroup.
newDeletePermissionPolicy ::
  -- | 'resourceArn'
  Prelude.Text ->
  DeletePermissionPolicy
newDeletePermissionPolicy :: Text -> DeletePermissionPolicy
newDeletePermissionPolicy Text
pResourceArn_ =
  DeletePermissionPolicy' :: Text -> DeletePermissionPolicy
DeletePermissionPolicy'
    { $sel:resourceArn:DeletePermissionPolicy' :: Text
resourceArn =
        Text
pResourceArn_
    }

-- | The Amazon Resource Name (ARN) of the RuleGroup from which you want to
-- delete the policy.
--
-- The user making the request must be the owner of the RuleGroup.
deletePermissionPolicy_resourceArn :: Lens.Lens' DeletePermissionPolicy Prelude.Text
deletePermissionPolicy_resourceArn :: (Text -> f Text)
-> DeletePermissionPolicy -> f DeletePermissionPolicy
deletePermissionPolicy_resourceArn = (DeletePermissionPolicy -> Text)
-> (DeletePermissionPolicy -> Text -> DeletePermissionPolicy)
-> Lens DeletePermissionPolicy DeletePermissionPolicy Text Text
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 :: DeletePermissionPolicy -> Request DeletePermissionPolicy
request = Service -> DeletePermissionPolicy -> Request DeletePermissionPolicy
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DeletePermissionPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeletePermissionPolicy)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse DeletePermissionPolicy))
-> Logger
-> Service
-> Proxy DeletePermissionPolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeletePermissionPolicy)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> DeletePermissionPolicyResponse
DeletePermissionPolicyResponse'
            (Int -> DeletePermissionPolicyResponse)
-> Either String Int
-> Either String DeletePermissionPolicyResponse
forall (f :: * -> *) a b. Functor 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 DeletePermissionPolicy

instance Prelude.NFData DeletePermissionPolicy

instance Core.ToHeaders DeletePermissionPolicy where
  toHeaders :: DeletePermissionPolicy -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DeletePermissionPolicy -> 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.DeletePermissionPolicy" ::
                          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 DeletePermissionPolicy where
  toJSON :: DeletePermissionPolicy -> Value
toJSON DeletePermissionPolicy' {Text
resourceArn :: Text
$sel:resourceArn:DeletePermissionPolicy' :: DeletePermissionPolicy -> 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
"ResourceArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
resourceArn)]
      )

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

instance Core.ToQuery DeletePermissionPolicy where
  toQuery :: DeletePermissionPolicy -> QueryString
toQuery = QueryString -> DeletePermissionPolicy -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(DeletePermissionPolicyResponse
 -> DeletePermissionPolicyResponse -> Bool)
-> (DeletePermissionPolicyResponse
    -> DeletePermissionPolicyResponse -> Bool)
-> Eq DeletePermissionPolicyResponse
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]
(Int -> ReadS DeletePermissionPolicyResponse)
-> ReadS [DeletePermissionPolicyResponse]
-> ReadPrec DeletePermissionPolicyResponse
-> ReadPrec [DeletePermissionPolicyResponse]
-> Read 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
(Int -> DeletePermissionPolicyResponse -> ShowS)
-> (DeletePermissionPolicyResponse -> String)
-> ([DeletePermissionPolicyResponse] -> ShowS)
-> Show DeletePermissionPolicyResponse
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.
 DeletePermissionPolicyResponse
 -> Rep DeletePermissionPolicyResponse x)
-> (forall x.
    Rep DeletePermissionPolicyResponse x
    -> DeletePermissionPolicyResponse)
-> Generic DeletePermissionPolicyResponse
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' :: Int -> DeletePermissionPolicyResponse
DeletePermissionPolicyResponse'
    { $sel:httpStatus:DeletePermissionPolicyResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

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