{-# 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 #-}
module Amazonka.APIGateway.GetResource
(
GetResource (..),
newGetResource,
getResource_embed,
getResource_restApiId,
getResource_resourceId,
Resource (..),
newResource,
resource_pathPart,
resource_path,
resource_id,
resource_resourceMethods,
resource_parentId,
)
where
import Amazonka.APIGateway.Types
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
data GetResource = GetResource'
{
GetResource -> Maybe [Text]
embed :: Prelude.Maybe [Prelude.Text],
GetResource -> Text
restApiId :: Prelude.Text,
GetResource -> Text
resourceId :: Prelude.Text
}
deriving (GetResource -> GetResource -> Bool
(GetResource -> GetResource -> Bool)
-> (GetResource -> GetResource -> Bool) -> Eq GetResource
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetResource -> GetResource -> Bool
$c/= :: GetResource -> GetResource -> Bool
== :: GetResource -> GetResource -> Bool
$c== :: GetResource -> GetResource -> Bool
Prelude.Eq, ReadPrec [GetResource]
ReadPrec GetResource
Int -> ReadS GetResource
ReadS [GetResource]
(Int -> ReadS GetResource)
-> ReadS [GetResource]
-> ReadPrec GetResource
-> ReadPrec [GetResource]
-> Read GetResource
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetResource]
$creadListPrec :: ReadPrec [GetResource]
readPrec :: ReadPrec GetResource
$creadPrec :: ReadPrec GetResource
readList :: ReadS [GetResource]
$creadList :: ReadS [GetResource]
readsPrec :: Int -> ReadS GetResource
$creadsPrec :: Int -> ReadS GetResource
Prelude.Read, Int -> GetResource -> ShowS
[GetResource] -> ShowS
GetResource -> String
(Int -> GetResource -> ShowS)
-> (GetResource -> String)
-> ([GetResource] -> ShowS)
-> Show GetResource
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetResource] -> ShowS
$cshowList :: [GetResource] -> ShowS
show :: GetResource -> String
$cshow :: GetResource -> String
showsPrec :: Int -> GetResource -> ShowS
$cshowsPrec :: Int -> GetResource -> ShowS
Prelude.Show, (forall x. GetResource -> Rep GetResource x)
-> (forall x. Rep GetResource x -> GetResource)
-> Generic GetResource
forall x. Rep GetResource x -> GetResource
forall x. GetResource -> Rep GetResource x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetResource x -> GetResource
$cfrom :: forall x. GetResource -> Rep GetResource x
Prelude.Generic)
newGetResource ::
Prelude.Text ->
Prelude.Text ->
GetResource
newGetResource :: Text -> Text -> GetResource
newGetResource Text
pRestApiId_ Text
pResourceId_ =
GetResource' :: Maybe [Text] -> Text -> Text -> GetResource
GetResource'
{ $sel:embed:GetResource' :: Maybe [Text]
embed = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
$sel:restApiId:GetResource' :: Text
restApiId = Text
pRestApiId_,
$sel:resourceId:GetResource' :: Text
resourceId = Text
pResourceId_
}
getResource_embed :: Lens.Lens' GetResource (Prelude.Maybe [Prelude.Text])
getResource_embed :: (Maybe [Text] -> f (Maybe [Text])) -> GetResource -> f GetResource
getResource_embed = (GetResource -> Maybe [Text])
-> (GetResource -> Maybe [Text] -> GetResource)
-> Lens GetResource GetResource (Maybe [Text]) (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResource' {Maybe [Text]
embed :: Maybe [Text]
$sel:embed:GetResource' :: GetResource -> Maybe [Text]
embed} -> Maybe [Text]
embed) (\s :: GetResource
s@GetResource' {} Maybe [Text]
a -> GetResource
s {$sel:embed:GetResource' :: Maybe [Text]
embed = Maybe [Text]
a} :: GetResource) ((Maybe [Text] -> f (Maybe [Text]))
-> GetResource -> f GetResource)
-> ((Maybe [Text] -> f (Maybe [Text]))
-> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> GetResource
-> f GetResource
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
getResource_restApiId :: Lens.Lens' GetResource Prelude.Text
getResource_restApiId :: (Text -> f Text) -> GetResource -> f GetResource
getResource_restApiId = (GetResource -> Text)
-> (GetResource -> Text -> GetResource)
-> Lens GetResource GetResource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResource' {Text
restApiId :: Text
$sel:restApiId:GetResource' :: GetResource -> Text
restApiId} -> Text
restApiId) (\s :: GetResource
s@GetResource' {} Text
a -> GetResource
s {$sel:restApiId:GetResource' :: Text
restApiId = Text
a} :: GetResource)
getResource_resourceId :: Lens.Lens' GetResource Prelude.Text
getResource_resourceId :: (Text -> f Text) -> GetResource -> f GetResource
getResource_resourceId = (GetResource -> Text)
-> (GetResource -> Text -> GetResource)
-> Lens GetResource GetResource Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetResource' {Text
resourceId :: Text
$sel:resourceId:GetResource' :: GetResource -> Text
resourceId} -> Text
resourceId) (\s :: GetResource
s@GetResource' {} Text
a -> GetResource
s {$sel:resourceId:GetResource' :: Text
resourceId = Text
a} :: GetResource)
instance Core.AWSRequest GetResource where
type AWSResponse GetResource = Resource
request :: GetResource -> Request GetResource
request = Service -> GetResource -> Request GetResource
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
response :: Logger
-> Service
-> Proxy GetResource
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetResource)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetResource))
-> Logger
-> Service
-> Proxy GetResource
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetResource)))
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 -> Object -> Either String Resource
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
instance Prelude.Hashable GetResource
instance Prelude.NFData GetResource
instance Core.ToHeaders GetResource where
toHeaders :: GetResource -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetResource -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ HeaderName
"Accept"
HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# (ByteString
"application/json" :: Prelude.ByteString)
]
)
instance Core.ToPath GetResource where
toPath :: GetResource -> ByteString
toPath GetResource' {Maybe [Text]
Text
resourceId :: Text
restApiId :: Text
embed :: Maybe [Text]
$sel:resourceId:GetResource' :: GetResource -> Text
$sel:restApiId:GetResource' :: GetResource -> Text
$sel:embed:GetResource' :: GetResource -> Maybe [Text]
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"/restapis/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
restApiId,
ByteString
"/resources/",
Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
resourceId
]
instance Core.ToQuery GetResource where
toQuery :: GetResource -> QueryString
toQuery GetResource' {Maybe [Text]
Text
resourceId :: Text
restApiId :: Text
embed :: Maybe [Text]
$sel:resourceId:GetResource' :: GetResource -> Text
$sel:restApiId:GetResource' :: GetResource -> Text
$sel:embed:GetResource' :: GetResource -> Maybe [Text]
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ ByteString
"embed"
ByteString -> QueryString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe QueryString -> QueryString
forall a. ToQuery a => a -> QueryString
Core.toQuery
(ByteString -> [Text] -> QueryString
forall a.
(IsList a, ToQuery (Item a)) =>
ByteString -> a -> QueryString
Core.toQueryList ByteString
"member" ([Text] -> QueryString) -> Maybe [Text] -> Maybe QueryString
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [Text]
embed)
]