{-# 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.LexV2Models.DeleteResourcePolicy
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Removes an existing policy from a bot or bot alias. If the resource
-- doesn\'t have a policy attached, Amazon Lex returns an exception.
module Amazonka.LexV2Models.DeleteResourcePolicy
  ( -- * Creating a Request
    DeleteResourcePolicy (..),
    newDeleteResourcePolicy,

    -- * Request Lenses
    deleteResourcePolicy_expectedRevisionId,
    deleteResourcePolicy_resourceArn,

    -- * Destructuring the Response
    DeleteResourcePolicyResponse (..),
    newDeleteResourcePolicyResponse,

    -- * Response Lenses
    deleteResourcePolicyResponse_resourceArn,
    deleteResourcePolicyResponse_revisionId,
    deleteResourcePolicyResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.LexV2Models.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDeleteResourcePolicy' smart constructor.
data DeleteResourcePolicy = DeleteResourcePolicy'
  { -- | The identifier of the revision to edit. If this ID doesn\'t match the
    -- current revision number, Amazon Lex returns an exception
    --
    -- If you don\'t specify a revision ID, Amazon Lex will delete the current
    -- policy.
    DeleteResourcePolicy -> Maybe Text
expectedRevisionId :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the bot or bot alias that has the
    -- resource policy attached.
    DeleteResourcePolicy -> Text
resourceArn :: Prelude.Text
  }
  deriving (DeleteResourcePolicy -> DeleteResourcePolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteResourcePolicy -> DeleteResourcePolicy -> Bool
$c/= :: DeleteResourcePolicy -> DeleteResourcePolicy -> Bool
== :: DeleteResourcePolicy -> DeleteResourcePolicy -> Bool
$c== :: DeleteResourcePolicy -> DeleteResourcePolicy -> Bool
Prelude.Eq, ReadPrec [DeleteResourcePolicy]
ReadPrec DeleteResourcePolicy
Int -> ReadS DeleteResourcePolicy
ReadS [DeleteResourcePolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteResourcePolicy]
$creadListPrec :: ReadPrec [DeleteResourcePolicy]
readPrec :: ReadPrec DeleteResourcePolicy
$creadPrec :: ReadPrec DeleteResourcePolicy
readList :: ReadS [DeleteResourcePolicy]
$creadList :: ReadS [DeleteResourcePolicy]
readsPrec :: Int -> ReadS DeleteResourcePolicy
$creadsPrec :: Int -> ReadS DeleteResourcePolicy
Prelude.Read, Int -> DeleteResourcePolicy -> ShowS
[DeleteResourcePolicy] -> ShowS
DeleteResourcePolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteResourcePolicy] -> ShowS
$cshowList :: [DeleteResourcePolicy] -> ShowS
show :: DeleteResourcePolicy -> String
$cshow :: DeleteResourcePolicy -> String
showsPrec :: Int -> DeleteResourcePolicy -> ShowS
$cshowsPrec :: Int -> DeleteResourcePolicy -> ShowS
Prelude.Show, forall x. Rep DeleteResourcePolicy x -> DeleteResourcePolicy
forall x. DeleteResourcePolicy -> Rep DeleteResourcePolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DeleteResourcePolicy x -> DeleteResourcePolicy
$cfrom :: forall x. DeleteResourcePolicy -> Rep DeleteResourcePolicy x
Prelude.Generic)

-- |
-- Create a value of 'DeleteResourcePolicy' 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:
--
-- 'expectedRevisionId', 'deleteResourcePolicy_expectedRevisionId' - The identifier of the revision to edit. If this ID doesn\'t match the
-- current revision number, Amazon Lex returns an exception
--
-- If you don\'t specify a revision ID, Amazon Lex will delete the current
-- policy.
--
-- 'resourceArn', 'deleteResourcePolicy_resourceArn' - The Amazon Resource Name (ARN) of the bot or bot alias that has the
-- resource policy attached.
newDeleteResourcePolicy ::
  -- | 'resourceArn'
  Prelude.Text ->
  DeleteResourcePolicy
newDeleteResourcePolicy :: Text -> DeleteResourcePolicy
newDeleteResourcePolicy Text
pResourceArn_ =
  DeleteResourcePolicy'
    { $sel:expectedRevisionId:DeleteResourcePolicy' :: Maybe Text
expectedRevisionId =
        forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:DeleteResourcePolicy' :: Text
resourceArn = Text
pResourceArn_
    }

-- | The identifier of the revision to edit. If this ID doesn\'t match the
-- current revision number, Amazon Lex returns an exception
--
-- If you don\'t specify a revision ID, Amazon Lex will delete the current
-- policy.
deleteResourcePolicy_expectedRevisionId :: Lens.Lens' DeleteResourcePolicy (Prelude.Maybe Prelude.Text)
deleteResourcePolicy_expectedRevisionId :: Lens' DeleteResourcePolicy (Maybe Text)
deleteResourcePolicy_expectedRevisionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteResourcePolicy' {Maybe Text
expectedRevisionId :: Maybe Text
$sel:expectedRevisionId:DeleteResourcePolicy' :: DeleteResourcePolicy -> Maybe Text
expectedRevisionId} -> Maybe Text
expectedRevisionId) (\s :: DeleteResourcePolicy
s@DeleteResourcePolicy' {} Maybe Text
a -> DeleteResourcePolicy
s {$sel:expectedRevisionId:DeleteResourcePolicy' :: Maybe Text
expectedRevisionId = Maybe Text
a} :: DeleteResourcePolicy)

-- | The Amazon Resource Name (ARN) of the bot or bot alias that has the
-- resource policy attached.
deleteResourcePolicy_resourceArn :: Lens.Lens' DeleteResourcePolicy Prelude.Text
deleteResourcePolicy_resourceArn :: Lens' DeleteResourcePolicy Text
deleteResourcePolicy_resourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteResourcePolicy' {Text
resourceArn :: Text
$sel:resourceArn:DeleteResourcePolicy' :: DeleteResourcePolicy -> Text
resourceArn} -> Text
resourceArn) (\s :: DeleteResourcePolicy
s@DeleteResourcePolicy' {} Text
a -> DeleteResourcePolicy
s {$sel:resourceArn:DeleteResourcePolicy' :: Text
resourceArn = Text
a} :: DeleteResourcePolicy)

instance Core.AWSRequest DeleteResourcePolicy where
  type
    AWSResponse DeleteResourcePolicy =
      DeleteResourcePolicyResponse
  request :: (Service -> Service)
-> DeleteResourcePolicy -> Request DeleteResourcePolicy
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.delete (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DeleteResourcePolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DeleteResourcePolicy)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Maybe Text -> Maybe Text -> Int -> DeleteResourcePolicyResponse
DeleteResourcePolicyResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"resourceArn")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"revisionId")
            forall (f :: * -> *) a b. Applicative f => 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 DeleteResourcePolicy where
  hashWithSalt :: Int -> DeleteResourcePolicy -> Int
hashWithSalt Int
_salt DeleteResourcePolicy' {Maybe Text
Text
resourceArn :: Text
expectedRevisionId :: Maybe Text
$sel:resourceArn:DeleteResourcePolicy' :: DeleteResourcePolicy -> Text
$sel:expectedRevisionId:DeleteResourcePolicy' :: DeleteResourcePolicy -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
expectedRevisionId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceArn

instance Prelude.NFData DeleteResourcePolicy where
  rnf :: DeleteResourcePolicy -> ()
rnf DeleteResourcePolicy' {Maybe Text
Text
resourceArn :: Text
expectedRevisionId :: Maybe Text
$sel:resourceArn:DeleteResourcePolicy' :: DeleteResourcePolicy -> Text
$sel:expectedRevisionId:DeleteResourcePolicy' :: DeleteResourcePolicy -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
expectedRevisionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
resourceArn

instance Data.ToHeaders DeleteResourcePolicy where
  toHeaders :: DeleteResourcePolicy -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToPath DeleteResourcePolicy where
  toPath :: DeleteResourcePolicy -> ByteString
toPath DeleteResourcePolicy' {Maybe Text
Text
resourceArn :: Text
expectedRevisionId :: Maybe Text
$sel:resourceArn:DeleteResourcePolicy' :: DeleteResourcePolicy -> Text
$sel:expectedRevisionId:DeleteResourcePolicy' :: DeleteResourcePolicy -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"/policy/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
resourceArn, ByteString
"/"]

instance Data.ToQuery DeleteResourcePolicy where
  toQuery :: DeleteResourcePolicy -> QueryString
toQuery DeleteResourcePolicy' {Maybe Text
Text
resourceArn :: Text
expectedRevisionId :: Maybe Text
$sel:resourceArn:DeleteResourcePolicy' :: DeleteResourcePolicy -> Text
$sel:expectedRevisionId:DeleteResourcePolicy' :: DeleteResourcePolicy -> Maybe Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ByteString
"expectedRevisionId" forall a. ToQuery a => ByteString -> a -> QueryString
Data.=: Maybe Text
expectedRevisionId]

-- | /See:/ 'newDeleteResourcePolicyResponse' smart constructor.
data DeleteResourcePolicyResponse = DeleteResourcePolicyResponse'
  { -- | The Amazon Resource Name (ARN) of the bot or bot alias that the resource
    -- policy was deleted from.
    DeleteResourcePolicyResponse -> Maybe Text
resourceArn :: Prelude.Maybe Prelude.Text,
    -- | The current revision of the resource policy. Use the revision ID to make
    -- sure that you are updating the most current version of a resource policy
    -- when you add a policy statement to a resource, delete a resource, or
    -- update a resource.
    DeleteResourcePolicyResponse -> Maybe Text
revisionId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DeleteResourcePolicyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DeleteResourcePolicyResponse
-> DeleteResourcePolicyResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DeleteResourcePolicyResponse
-> DeleteResourcePolicyResponse -> Bool
$c/= :: DeleteResourcePolicyResponse
-> DeleteResourcePolicyResponse -> Bool
== :: DeleteResourcePolicyResponse
-> DeleteResourcePolicyResponse -> Bool
$c== :: DeleteResourcePolicyResponse
-> DeleteResourcePolicyResponse -> Bool
Prelude.Eq, ReadPrec [DeleteResourcePolicyResponse]
ReadPrec DeleteResourcePolicyResponse
Int -> ReadS DeleteResourcePolicyResponse
ReadS [DeleteResourcePolicyResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DeleteResourcePolicyResponse]
$creadListPrec :: ReadPrec [DeleteResourcePolicyResponse]
readPrec :: ReadPrec DeleteResourcePolicyResponse
$creadPrec :: ReadPrec DeleteResourcePolicyResponse
readList :: ReadS [DeleteResourcePolicyResponse]
$creadList :: ReadS [DeleteResourcePolicyResponse]
readsPrec :: Int -> ReadS DeleteResourcePolicyResponse
$creadsPrec :: Int -> ReadS DeleteResourcePolicyResponse
Prelude.Read, Int -> DeleteResourcePolicyResponse -> ShowS
[DeleteResourcePolicyResponse] -> ShowS
DeleteResourcePolicyResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DeleteResourcePolicyResponse] -> ShowS
$cshowList :: [DeleteResourcePolicyResponse] -> ShowS
show :: DeleteResourcePolicyResponse -> String
$cshow :: DeleteResourcePolicyResponse -> String
showsPrec :: Int -> DeleteResourcePolicyResponse -> ShowS
$cshowsPrec :: Int -> DeleteResourcePolicyResponse -> ShowS
Prelude.Show, forall x.
Rep DeleteResourcePolicyResponse x -> DeleteResourcePolicyResponse
forall x.
DeleteResourcePolicyResponse -> Rep DeleteResourcePolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DeleteResourcePolicyResponse x -> DeleteResourcePolicyResponse
$cfrom :: forall x.
DeleteResourcePolicyResponse -> Rep DeleteResourcePolicyResponse x
Prelude.Generic)

-- |
-- Create a value of 'DeleteResourcePolicyResponse' 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', 'deleteResourcePolicyResponse_resourceArn' - The Amazon Resource Name (ARN) of the bot or bot alias that the resource
-- policy was deleted from.
--
-- 'revisionId', 'deleteResourcePolicyResponse_revisionId' - The current revision of the resource policy. Use the revision ID to make
-- sure that you are updating the most current version of a resource policy
-- when you add a policy statement to a resource, delete a resource, or
-- update a resource.
--
-- 'httpStatus', 'deleteResourcePolicyResponse_httpStatus' - The response's http status code.
newDeleteResourcePolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DeleteResourcePolicyResponse
newDeleteResourcePolicyResponse :: Int -> DeleteResourcePolicyResponse
newDeleteResourcePolicyResponse Int
pHttpStatus_ =
  DeleteResourcePolicyResponse'
    { $sel:resourceArn:DeleteResourcePolicyResponse' :: Maybe Text
resourceArn =
        forall a. Maybe a
Prelude.Nothing,
      $sel:revisionId:DeleteResourcePolicyResponse' :: Maybe Text
revisionId = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DeleteResourcePolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The Amazon Resource Name (ARN) of the bot or bot alias that the resource
-- policy was deleted from.
deleteResourcePolicyResponse_resourceArn :: Lens.Lens' DeleteResourcePolicyResponse (Prelude.Maybe Prelude.Text)
deleteResourcePolicyResponse_resourceArn :: Lens' DeleteResourcePolicyResponse (Maybe Text)
deleteResourcePolicyResponse_resourceArn = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteResourcePolicyResponse' {Maybe Text
resourceArn :: Maybe Text
$sel:resourceArn:DeleteResourcePolicyResponse' :: DeleteResourcePolicyResponse -> Maybe Text
resourceArn} -> Maybe Text
resourceArn) (\s :: DeleteResourcePolicyResponse
s@DeleteResourcePolicyResponse' {} Maybe Text
a -> DeleteResourcePolicyResponse
s {$sel:resourceArn:DeleteResourcePolicyResponse' :: Maybe Text
resourceArn = Maybe Text
a} :: DeleteResourcePolicyResponse)

-- | The current revision of the resource policy. Use the revision ID to make
-- sure that you are updating the most current version of a resource policy
-- when you add a policy statement to a resource, delete a resource, or
-- update a resource.
deleteResourcePolicyResponse_revisionId :: Lens.Lens' DeleteResourcePolicyResponse (Prelude.Maybe Prelude.Text)
deleteResourcePolicyResponse_revisionId :: Lens' DeleteResourcePolicyResponse (Maybe Text)
deleteResourcePolicyResponse_revisionId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DeleteResourcePolicyResponse' {Maybe Text
revisionId :: Maybe Text
$sel:revisionId:DeleteResourcePolicyResponse' :: DeleteResourcePolicyResponse -> Maybe Text
revisionId} -> Maybe Text
revisionId) (\s :: DeleteResourcePolicyResponse
s@DeleteResourcePolicyResponse' {} Maybe Text
a -> DeleteResourcePolicyResponse
s {$sel:revisionId:DeleteResourcePolicyResponse' :: Maybe Text
revisionId = Maybe Text
a} :: DeleteResourcePolicyResponse)

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

instance Prelude.NFData DeleteResourcePolicyResponse where
  rnf :: DeleteResourcePolicyResponse -> ()
rnf DeleteResourcePolicyResponse' {Int
Maybe Text
httpStatus :: Int
revisionId :: Maybe Text
resourceArn :: Maybe Text
$sel:httpStatus:DeleteResourcePolicyResponse' :: DeleteResourcePolicyResponse -> Int
$sel:revisionId:DeleteResourcePolicyResponse' :: DeleteResourcePolicyResponse -> Maybe Text
$sel:resourceArn:DeleteResourcePolicyResponse' :: DeleteResourcePolicyResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
resourceArn
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
revisionId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus