{-# 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.DescribeResourcePolicy
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets the resource policy and policy revision for a bot or bot alias.
module Amazonka.LexV2Models.DescribeResourcePolicy
  ( -- * Creating a Request
    DescribeResourcePolicy (..),
    newDescribeResourcePolicy,

    -- * Request Lenses
    describeResourcePolicy_resourceArn,

    -- * Destructuring the Response
    DescribeResourcePolicyResponse (..),
    newDescribeResourcePolicyResponse,

    -- * Response Lenses
    describeResourcePolicyResponse_policy,
    describeResourcePolicyResponse_resourceArn,
    describeResourcePolicyResponse_revisionId,
    describeResourcePolicyResponse_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:/ 'newDescribeResourcePolicy' smart constructor.
data DescribeResourcePolicy = DescribeResourcePolicy'
  { -- | The Amazon Resource Name (ARN) of the bot or bot alias that the resource
    -- policy is attached to.
    DescribeResourcePolicy -> Text
resourceArn :: Prelude.Text
  }
  deriving (DescribeResourcePolicy -> DescribeResourcePolicy -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeResourcePolicy -> DescribeResourcePolicy -> Bool
$c/= :: DescribeResourcePolicy -> DescribeResourcePolicy -> Bool
== :: DescribeResourcePolicy -> DescribeResourcePolicy -> Bool
$c== :: DescribeResourcePolicy -> DescribeResourcePolicy -> Bool
Prelude.Eq, ReadPrec [DescribeResourcePolicy]
ReadPrec DescribeResourcePolicy
Int -> ReadS DescribeResourcePolicy
ReadS [DescribeResourcePolicy]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeResourcePolicy]
$creadListPrec :: ReadPrec [DescribeResourcePolicy]
readPrec :: ReadPrec DescribeResourcePolicy
$creadPrec :: ReadPrec DescribeResourcePolicy
readList :: ReadS [DescribeResourcePolicy]
$creadList :: ReadS [DescribeResourcePolicy]
readsPrec :: Int -> ReadS DescribeResourcePolicy
$creadsPrec :: Int -> ReadS DescribeResourcePolicy
Prelude.Read, Int -> DescribeResourcePolicy -> ShowS
[DescribeResourcePolicy] -> ShowS
DescribeResourcePolicy -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeResourcePolicy] -> ShowS
$cshowList :: [DescribeResourcePolicy] -> ShowS
show :: DescribeResourcePolicy -> String
$cshow :: DescribeResourcePolicy -> String
showsPrec :: Int -> DescribeResourcePolicy -> ShowS
$cshowsPrec :: Int -> DescribeResourcePolicy -> ShowS
Prelude.Show, forall x. Rep DescribeResourcePolicy x -> DescribeResourcePolicy
forall x. DescribeResourcePolicy -> Rep DescribeResourcePolicy x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeResourcePolicy x -> DescribeResourcePolicy
$cfrom :: forall x. DescribeResourcePolicy -> Rep DescribeResourcePolicy x
Prelude.Generic)

-- |
-- Create a value of 'DescribeResourcePolicy' 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', 'describeResourcePolicy_resourceArn' - The Amazon Resource Name (ARN) of the bot or bot alias that the resource
-- policy is attached to.
newDescribeResourcePolicy ::
  -- | 'resourceArn'
  Prelude.Text ->
  DescribeResourcePolicy
newDescribeResourcePolicy :: Text -> DescribeResourcePolicy
newDescribeResourcePolicy Text
pResourceArn_ =
  DescribeResourcePolicy'
    { $sel:resourceArn:DescribeResourcePolicy' :: Text
resourceArn =
        Text
pResourceArn_
    }

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

instance Core.AWSRequest DescribeResourcePolicy where
  type
    AWSResponse DescribeResourcePolicy =
      DescribeResourcePolicyResponse
  request :: (Service -> Service)
-> DescribeResourcePolicy -> Request DescribeResourcePolicy
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy DescribeResourcePolicy
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse DescribeResourcePolicy)))
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
-> Maybe Text
-> Int
-> DescribeResourcePolicyResponse
DescribeResourcePolicyResponse'
            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
"policy")
            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
"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 DescribeResourcePolicy where
  hashWithSalt :: Int -> DescribeResourcePolicy -> Int
hashWithSalt Int
_salt DescribeResourcePolicy' {Text
resourceArn :: Text
$sel:resourceArn:DescribeResourcePolicy' :: DescribeResourcePolicy -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
resourceArn

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

instance Data.ToHeaders DescribeResourcePolicy where
  toHeaders :: DescribeResourcePolicy -> 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 DescribeResourcePolicy where
  toPath :: DescribeResourcePolicy -> ByteString
toPath DescribeResourcePolicy' {Text
resourceArn :: Text
$sel:resourceArn:DescribeResourcePolicy' :: DescribeResourcePolicy -> 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 DescribeResourcePolicy where
  toQuery :: DescribeResourcePolicy -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

-- | /See:/ 'newDescribeResourcePolicyResponse' smart constructor.
data DescribeResourcePolicyResponse = DescribeResourcePolicyResponse'
  { -- | The JSON structure that contains the resource policy. For more
    -- information about the contents of a JSON policy document, see
    -- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies.html IAM JSON policy reference>
    -- .
    DescribeResourcePolicyResponse -> Maybe Text
policy :: Prelude.Maybe Prelude.Text,
    -- | The Amazon Resource Name (ARN) of the bot or bot alias that the resource
    -- policy is attached to.
    DescribeResourcePolicyResponse -> 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.
    DescribeResourcePolicyResponse -> Maybe Text
revisionId :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    DescribeResourcePolicyResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeResourcePolicyResponse
-> DescribeResourcePolicyResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeResourcePolicyResponse
-> DescribeResourcePolicyResponse -> Bool
$c/= :: DescribeResourcePolicyResponse
-> DescribeResourcePolicyResponse -> Bool
== :: DescribeResourcePolicyResponse
-> DescribeResourcePolicyResponse -> Bool
$c== :: DescribeResourcePolicyResponse
-> DescribeResourcePolicyResponse -> Bool
Prelude.Eq, ReadPrec [DescribeResourcePolicyResponse]
ReadPrec DescribeResourcePolicyResponse
Int -> ReadS DescribeResourcePolicyResponse
ReadS [DescribeResourcePolicyResponse]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeResourcePolicyResponse]
$creadListPrec :: ReadPrec [DescribeResourcePolicyResponse]
readPrec :: ReadPrec DescribeResourcePolicyResponse
$creadPrec :: ReadPrec DescribeResourcePolicyResponse
readList :: ReadS [DescribeResourcePolicyResponse]
$creadList :: ReadS [DescribeResourcePolicyResponse]
readsPrec :: Int -> ReadS DescribeResourcePolicyResponse
$creadsPrec :: Int -> ReadS DescribeResourcePolicyResponse
Prelude.Read, Int -> DescribeResourcePolicyResponse -> ShowS
[DescribeResourcePolicyResponse] -> ShowS
DescribeResourcePolicyResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeResourcePolicyResponse] -> ShowS
$cshowList :: [DescribeResourcePolicyResponse] -> ShowS
show :: DescribeResourcePolicyResponse -> String
$cshow :: DescribeResourcePolicyResponse -> String
showsPrec :: Int -> DescribeResourcePolicyResponse -> ShowS
$cshowsPrec :: Int -> DescribeResourcePolicyResponse -> ShowS
Prelude.Show, forall x.
Rep DescribeResourcePolicyResponse x
-> DescribeResourcePolicyResponse
forall x.
DescribeResourcePolicyResponse
-> Rep DescribeResourcePolicyResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeResourcePolicyResponse x
-> DescribeResourcePolicyResponse
$cfrom :: forall x.
DescribeResourcePolicyResponse
-> Rep DescribeResourcePolicyResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeResourcePolicyResponse' 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:
--
-- 'policy', 'describeResourcePolicyResponse_policy' - The JSON structure that contains the resource policy. For more
-- information about the contents of a JSON policy document, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies.html IAM JSON policy reference>
-- .
--
-- 'resourceArn', 'describeResourcePolicyResponse_resourceArn' - The Amazon Resource Name (ARN) of the bot or bot alias that the resource
-- policy is attached to.
--
-- 'revisionId', 'describeResourcePolicyResponse_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', 'describeResourcePolicyResponse_httpStatus' - The response's http status code.
newDescribeResourcePolicyResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeResourcePolicyResponse
newDescribeResourcePolicyResponse :: Int -> DescribeResourcePolicyResponse
newDescribeResourcePolicyResponse Int
pHttpStatus_ =
  DescribeResourcePolicyResponse'
    { $sel:policy:DescribeResourcePolicyResponse' :: Maybe Text
policy =
        forall a. Maybe a
Prelude.Nothing,
      $sel:resourceArn:DescribeResourcePolicyResponse' :: Maybe Text
resourceArn = forall a. Maybe a
Prelude.Nothing,
      $sel:revisionId:DescribeResourcePolicyResponse' :: Maybe Text
revisionId = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeResourcePolicyResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | The JSON structure that contains the resource policy. For more
-- information about the contents of a JSON policy document, see
-- <https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies.html IAM JSON policy reference>
-- .
describeResourcePolicyResponse_policy :: Lens.Lens' DescribeResourcePolicyResponse (Prelude.Maybe Prelude.Text)
describeResourcePolicyResponse_policy :: Lens' DescribeResourcePolicyResponse (Maybe Text)
describeResourcePolicyResponse_policy = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeResourcePolicyResponse' {Maybe Text
policy :: Maybe Text
$sel:policy:DescribeResourcePolicyResponse' :: DescribeResourcePolicyResponse -> Maybe Text
policy} -> Maybe Text
policy) (\s :: DescribeResourcePolicyResponse
s@DescribeResourcePolicyResponse' {} Maybe Text
a -> DescribeResourcePolicyResponse
s {$sel:policy:DescribeResourcePolicyResponse' :: Maybe Text
policy = Maybe Text
a} :: DescribeResourcePolicyResponse)

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

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

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

instance
  Prelude.NFData
    DescribeResourcePolicyResponse
  where
  rnf :: DescribeResourcePolicyResponse -> ()
rnf DescribeResourcePolicyResponse' {Int
Maybe Text
httpStatus :: Int
revisionId :: Maybe Text
resourceArn :: Maybe Text
policy :: Maybe Text
$sel:httpStatus:DescribeResourcePolicyResponse' :: DescribeResourcePolicyResponse -> Int
$sel:revisionId:DescribeResourcePolicyResponse' :: DescribeResourcePolicyResponse -> Maybe Text
$sel:resourceArn:DescribeResourcePolicyResponse' :: DescribeResourcePolicyResponse -> Maybe Text
$sel:policy:DescribeResourcePolicyResponse' :: DescribeResourcePolicyResponse -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
policy
      seq :: forall a b. a -> b -> b
`Prelude.seq` 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