{-# 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.LakeFormation.DescribeResource
-- 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)
--
-- Retrieves the current data access role for the given resource registered
-- in AWS Lake Formation.
module Amazonka.LakeFormation.DescribeResource
  ( -- * Creating a Request
    DescribeResource (..),
    newDescribeResource,

    -- * Request Lenses
    describeResource_resourceArn,

    -- * Destructuring the Response
    DescribeResourceResponse (..),
    newDescribeResourceResponse,

    -- * Response Lenses
    describeResourceResponse_resourceInfo,
    describeResourceResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import Amazonka.LakeFormation.Types
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newDescribeResource' smart constructor.
data DescribeResource = DescribeResource'
  { -- | The resource ARN.
    DescribeResource -> Text
resourceArn :: Prelude.Text
  }
  deriving (DescribeResource -> DescribeResource -> Bool
(DescribeResource -> DescribeResource -> Bool)
-> (DescribeResource -> DescribeResource -> Bool)
-> Eq DescribeResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeResource -> DescribeResource -> Bool
$c/= :: DescribeResource -> DescribeResource -> Bool
== :: DescribeResource -> DescribeResource -> Bool
$c== :: DescribeResource -> DescribeResource -> Bool
Prelude.Eq, ReadPrec [DescribeResource]
ReadPrec DescribeResource
Int -> ReadS DescribeResource
ReadS [DescribeResource]
(Int -> ReadS DescribeResource)
-> ReadS [DescribeResource]
-> ReadPrec DescribeResource
-> ReadPrec [DescribeResource]
-> Read DescribeResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeResource]
$creadListPrec :: ReadPrec [DescribeResource]
readPrec :: ReadPrec DescribeResource
$creadPrec :: ReadPrec DescribeResource
readList :: ReadS [DescribeResource]
$creadList :: ReadS [DescribeResource]
readsPrec :: Int -> ReadS DescribeResource
$creadsPrec :: Int -> ReadS DescribeResource
Prelude.Read, Int -> DescribeResource -> ShowS
[DescribeResource] -> ShowS
DescribeResource -> String
(Int -> DescribeResource -> ShowS)
-> (DescribeResource -> String)
-> ([DescribeResource] -> ShowS)
-> Show DescribeResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeResource] -> ShowS
$cshowList :: [DescribeResource] -> ShowS
show :: DescribeResource -> String
$cshow :: DescribeResource -> String
showsPrec :: Int -> DescribeResource -> ShowS
$cshowsPrec :: Int -> DescribeResource -> ShowS
Prelude.Show, (forall x. DescribeResource -> Rep DescribeResource x)
-> (forall x. Rep DescribeResource x -> DescribeResource)
-> Generic DescribeResource
forall x. Rep DescribeResource x -> DescribeResource
forall x. DescribeResource -> Rep DescribeResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep DescribeResource x -> DescribeResource
$cfrom :: forall x. DescribeResource -> Rep DescribeResource x
Prelude.Generic)

-- |
-- Create a value of 'DescribeResource' 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', 'describeResource_resourceArn' - The resource ARN.
newDescribeResource ::
  -- | 'resourceArn'
  Prelude.Text ->
  DescribeResource
newDescribeResource :: Text -> DescribeResource
newDescribeResource Text
pResourceArn_ =
  DescribeResource' :: Text -> DescribeResource
DescribeResource' {$sel:resourceArn:DescribeResource' :: Text
resourceArn = Text
pResourceArn_}

-- | The resource ARN.
describeResource_resourceArn :: Lens.Lens' DescribeResource Prelude.Text
describeResource_resourceArn :: (Text -> f Text) -> DescribeResource -> f DescribeResource
describeResource_resourceArn = (DescribeResource -> Text)
-> (DescribeResource -> Text -> DescribeResource)
-> Lens DescribeResource DescribeResource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeResource' {Text
resourceArn :: Text
$sel:resourceArn:DescribeResource' :: DescribeResource -> Text
resourceArn} -> Text
resourceArn) (\s :: DescribeResource
s@DescribeResource' {} Text
a -> DescribeResource
s {$sel:resourceArn:DescribeResource' :: Text
resourceArn = Text
a} :: DescribeResource)

instance Core.AWSRequest DescribeResource where
  type
    AWSResponse DescribeResource =
      DescribeResourceResponse
  request :: DescribeResource -> Request DescribeResource
request = Service -> DescribeResource -> Request DescribeResource
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy DescribeResource
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeResource)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse DescribeResource))
-> Logger
-> Service
-> Proxy DescribeResource
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse DescribeResource)))
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 ResourceInfo -> Int -> DescribeResourceResponse
DescribeResourceResponse'
            (Maybe ResourceInfo -> Int -> DescribeResourceResponse)
-> Either String (Maybe ResourceInfo)
-> Either String (Int -> DescribeResourceResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Either String (Maybe ResourceInfo)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"ResourceInfo")
            Either String (Int -> DescribeResourceResponse)
-> Either String Int -> Either String DescribeResourceResponse
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 DescribeResource

instance Prelude.NFData DescribeResource

instance Core.ToHeaders DescribeResource where
  toHeaders :: DescribeResource -> ResponseHeaders
toHeaders =
    ResponseHeaders -> DescribeResource -> 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
"AWSLakeFormation.DescribeResource" ::
                          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 DescribeResource where
  toJSON :: DescribeResource -> Value
toJSON DescribeResource' {Text
resourceArn :: Text
$sel:resourceArn:DescribeResource' :: DescribeResource -> 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 DescribeResource where
  toPath :: DescribeResource -> ByteString
toPath = ByteString -> DescribeResource -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

-- | /See:/ 'newDescribeResourceResponse' smart constructor.
data DescribeResourceResponse = DescribeResourceResponse'
  { -- | A structure containing information about an AWS Lake Formation resource.
    DescribeResourceResponse -> Maybe ResourceInfo
resourceInfo :: Prelude.Maybe ResourceInfo,
    -- | The response's http status code.
    DescribeResourceResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (DescribeResourceResponse -> DescribeResourceResponse -> Bool
(DescribeResourceResponse -> DescribeResourceResponse -> Bool)
-> (DescribeResourceResponse -> DescribeResourceResponse -> Bool)
-> Eq DescribeResourceResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: DescribeResourceResponse -> DescribeResourceResponse -> Bool
$c/= :: DescribeResourceResponse -> DescribeResourceResponse -> Bool
== :: DescribeResourceResponse -> DescribeResourceResponse -> Bool
$c== :: DescribeResourceResponse -> DescribeResourceResponse -> Bool
Prelude.Eq, ReadPrec [DescribeResourceResponse]
ReadPrec DescribeResourceResponse
Int -> ReadS DescribeResourceResponse
ReadS [DescribeResourceResponse]
(Int -> ReadS DescribeResourceResponse)
-> ReadS [DescribeResourceResponse]
-> ReadPrec DescribeResourceResponse
-> ReadPrec [DescribeResourceResponse]
-> Read DescribeResourceResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [DescribeResourceResponse]
$creadListPrec :: ReadPrec [DescribeResourceResponse]
readPrec :: ReadPrec DescribeResourceResponse
$creadPrec :: ReadPrec DescribeResourceResponse
readList :: ReadS [DescribeResourceResponse]
$creadList :: ReadS [DescribeResourceResponse]
readsPrec :: Int -> ReadS DescribeResourceResponse
$creadsPrec :: Int -> ReadS DescribeResourceResponse
Prelude.Read, Int -> DescribeResourceResponse -> ShowS
[DescribeResourceResponse] -> ShowS
DescribeResourceResponse -> String
(Int -> DescribeResourceResponse -> ShowS)
-> (DescribeResourceResponse -> String)
-> ([DescribeResourceResponse] -> ShowS)
-> Show DescribeResourceResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [DescribeResourceResponse] -> ShowS
$cshowList :: [DescribeResourceResponse] -> ShowS
show :: DescribeResourceResponse -> String
$cshow :: DescribeResourceResponse -> String
showsPrec :: Int -> DescribeResourceResponse -> ShowS
$cshowsPrec :: Int -> DescribeResourceResponse -> ShowS
Prelude.Show, (forall x.
 DescribeResourceResponse -> Rep DescribeResourceResponse x)
-> (forall x.
    Rep DescribeResourceResponse x -> DescribeResourceResponse)
-> Generic DescribeResourceResponse
forall x.
Rep DescribeResourceResponse x -> DescribeResourceResponse
forall x.
DescribeResourceResponse -> Rep DescribeResourceResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep DescribeResourceResponse x -> DescribeResourceResponse
$cfrom :: forall x.
DescribeResourceResponse -> Rep DescribeResourceResponse x
Prelude.Generic)

-- |
-- Create a value of 'DescribeResourceResponse' 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:
--
-- 'resourceInfo', 'describeResourceResponse_resourceInfo' - A structure containing information about an AWS Lake Formation resource.
--
-- 'httpStatus', 'describeResourceResponse_httpStatus' - The response's http status code.
newDescribeResourceResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  DescribeResourceResponse
newDescribeResourceResponse :: Int -> DescribeResourceResponse
newDescribeResourceResponse Int
pHttpStatus_ =
  DescribeResourceResponse' :: Maybe ResourceInfo -> Int -> DescribeResourceResponse
DescribeResourceResponse'
    { $sel:resourceInfo:DescribeResourceResponse' :: Maybe ResourceInfo
resourceInfo =
        Maybe ResourceInfo
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:DescribeResourceResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | A structure containing information about an AWS Lake Formation resource.
describeResourceResponse_resourceInfo :: Lens.Lens' DescribeResourceResponse (Prelude.Maybe ResourceInfo)
describeResourceResponse_resourceInfo :: (Maybe ResourceInfo -> f (Maybe ResourceInfo))
-> DescribeResourceResponse -> f DescribeResourceResponse
describeResourceResponse_resourceInfo = (DescribeResourceResponse -> Maybe ResourceInfo)
-> (DescribeResourceResponse
    -> Maybe ResourceInfo -> DescribeResourceResponse)
-> Lens
     DescribeResourceResponse
     DescribeResourceResponse
     (Maybe ResourceInfo)
     (Maybe ResourceInfo)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\DescribeResourceResponse' {Maybe ResourceInfo
resourceInfo :: Maybe ResourceInfo
$sel:resourceInfo:DescribeResourceResponse' :: DescribeResourceResponse -> Maybe ResourceInfo
resourceInfo} -> Maybe ResourceInfo
resourceInfo) (\s :: DescribeResourceResponse
s@DescribeResourceResponse' {} Maybe ResourceInfo
a -> DescribeResourceResponse
s {$sel:resourceInfo:DescribeResourceResponse' :: Maybe ResourceInfo
resourceInfo = Maybe ResourceInfo
a} :: DescribeResourceResponse)

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

instance Prelude.NFData DescribeResourceResponse