{-# 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.APIGateway.GetRestApi
-- 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)
--
-- Lists the RestApi resource in the collection.
module Amazonka.APIGateway.GetRestApi
  ( -- * Creating a Request
    GetRestApi (..),
    newGetRestApi,

    -- * Request Lenses
    getRestApi_restApiId,

    -- * Destructuring the Response
    RestApi (..),
    newRestApi,

    -- * Response Lenses
    restApi_minimumCompressionSize,
    restApi_disableExecuteApiEndpoint,
    restApi_binaryMediaTypes,
    restApi_warnings,
    restApi_createdDate,
    restApi_name,
    restApi_version,
    restApi_apiKeySource,
    restApi_id,
    restApi_policy,
    restApi_endpointConfiguration,
    restApi_description,
    restApi_tags,
  )
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

-- | The GET request to list an existing RestApi defined for your collection.
--
-- /See:/ 'newGetRestApi' smart constructor.
data GetRestApi = GetRestApi'
  { -- | [Required] The string identifier of the associated RestApi.
    GetRestApi -> Text
restApiId :: Prelude.Text
  }
  deriving (GetRestApi -> GetRestApi -> Bool
(GetRestApi -> GetRestApi -> Bool)
-> (GetRestApi -> GetRestApi -> Bool) -> Eq GetRestApi
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetRestApi -> GetRestApi -> Bool
$c/= :: GetRestApi -> GetRestApi -> Bool
== :: GetRestApi -> GetRestApi -> Bool
$c== :: GetRestApi -> GetRestApi -> Bool
Prelude.Eq, ReadPrec [GetRestApi]
ReadPrec GetRestApi
Int -> ReadS GetRestApi
ReadS [GetRestApi]
(Int -> ReadS GetRestApi)
-> ReadS [GetRestApi]
-> ReadPrec GetRestApi
-> ReadPrec [GetRestApi]
-> Read GetRestApi
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetRestApi]
$creadListPrec :: ReadPrec [GetRestApi]
readPrec :: ReadPrec GetRestApi
$creadPrec :: ReadPrec GetRestApi
readList :: ReadS [GetRestApi]
$creadList :: ReadS [GetRestApi]
readsPrec :: Int -> ReadS GetRestApi
$creadsPrec :: Int -> ReadS GetRestApi
Prelude.Read, Int -> GetRestApi -> ShowS
[GetRestApi] -> ShowS
GetRestApi -> String
(Int -> GetRestApi -> ShowS)
-> (GetRestApi -> String)
-> ([GetRestApi] -> ShowS)
-> Show GetRestApi
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetRestApi] -> ShowS
$cshowList :: [GetRestApi] -> ShowS
show :: GetRestApi -> String
$cshow :: GetRestApi -> String
showsPrec :: Int -> GetRestApi -> ShowS
$cshowsPrec :: Int -> GetRestApi -> ShowS
Prelude.Show, (forall x. GetRestApi -> Rep GetRestApi x)
-> (forall x. Rep GetRestApi x -> GetRestApi) -> Generic GetRestApi
forall x. Rep GetRestApi x -> GetRestApi
forall x. GetRestApi -> Rep GetRestApi x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetRestApi x -> GetRestApi
$cfrom :: forall x. GetRestApi -> Rep GetRestApi x
Prelude.Generic)

-- |
-- Create a value of 'GetRestApi' 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:
--
-- 'restApiId', 'getRestApi_restApiId' - [Required] The string identifier of the associated RestApi.
newGetRestApi ::
  -- | 'restApiId'
  Prelude.Text ->
  GetRestApi
newGetRestApi :: Text -> GetRestApi
newGetRestApi Text
pRestApiId_ =
  GetRestApi' :: Text -> GetRestApi
GetRestApi' {$sel:restApiId:GetRestApi' :: Text
restApiId = Text
pRestApiId_}

-- | [Required] The string identifier of the associated RestApi.
getRestApi_restApiId :: Lens.Lens' GetRestApi Prelude.Text
getRestApi_restApiId :: (Text -> f Text) -> GetRestApi -> f GetRestApi
getRestApi_restApiId = (GetRestApi -> Text)
-> (GetRestApi -> Text -> GetRestApi)
-> Lens GetRestApi GetRestApi Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetRestApi' {Text
restApiId :: Text
$sel:restApiId:GetRestApi' :: GetRestApi -> Text
restApiId} -> Text
restApiId) (\s :: GetRestApi
s@GetRestApi' {} Text
a -> GetRestApi
s {$sel:restApiId:GetRestApi' :: Text
restApiId = Text
a} :: GetRestApi)

instance Core.AWSRequest GetRestApi where
  type AWSResponse GetRestApi = RestApi
  request :: GetRestApi -> Request GetRestApi
request = Service -> GetRestApi -> Request GetRestApi
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy GetRestApi
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetRestApi)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse GetRestApi))
-> Logger
-> Service
-> Proxy GetRestApi
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetRestApi)))
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 RestApi
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)

instance Prelude.Hashable GetRestApi

instance Prelude.NFData GetRestApi

instance Core.ToHeaders GetRestApi where
  toHeaders :: GetRestApi -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetRestApi -> 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 GetRestApi where
  toPath :: GetRestApi -> ByteString
toPath GetRestApi' {Text
restApiId :: Text
$sel:restApiId:GetRestApi' :: GetRestApi -> 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]

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