{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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_apiKeySource,
    restApi_binaryMediaTypes,
    restApi_createdDate,
    restApi_description,
    restApi_disableExecuteApiEndpoint,
    restApi_endpointConfiguration,
    restApi_id,
    restApi_minimumCompressionSize,
    restApi_name,
    restApi_policy,
    restApi_tags,
    restApi_version,
    restApi_warnings,
  )
where

import Amazonka.APIGateway.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
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'
  { -- | The string identifier of the associated RestApi.
    GetRestApi -> Text
restApiId :: Prelude.Text
  }
  deriving (GetRestApi -> GetRestApi -> Bool
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]
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
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. 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' - The string identifier of the associated RestApi.
newGetRestApi ::
  -- | 'restApiId'
  Prelude.Text ->
  GetRestApi
newGetRestApi :: Text -> GetRestApi
newGetRestApi Text
pRestApiId_ =
  GetRestApi' {$sel:restApiId:GetRestApi' :: Text
restApiId = Text
pRestApiId_}

-- | The string identifier of the associated RestApi.
getRestApi_restApiId :: Lens.Lens' GetRestApi Prelude.Text
getRestApi_restApiId :: Lens' GetRestApi Text
getRestApi_restApiId = 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 :: (Service -> Service) -> GetRestApi -> Request GetRestApi
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 GetRestApi
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetRestApi)))
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 -> forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)

instance Prelude.Hashable GetRestApi where
  hashWithSalt :: Int -> GetRestApi -> Int
hashWithSalt Int
_salt GetRestApi' {Text
restApiId :: Text
$sel:restApiId:GetRestApi' :: GetRestApi -> Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
restApiId

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

instance Data.ToHeaders GetRestApi where
  toHeaders :: GetRestApi -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Accept"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# (ByteString
"application/json" :: Prelude.ByteString)
          ]
      )

instance Data.ToPath GetRestApi where
  toPath :: GetRestApi -> ByteString
toPath GetRestApi' {Text
restApiId :: Text
$sel:restApiId:GetRestApi' :: GetRestApi -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat [ByteString
"/restapis/", forall a. ToByteString a => a -> ByteString
Data.toBS Text
restApiId]

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