{-# 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.GetDocumentationVersion
-- 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)
--
-- -- | Undocumented operation.
module Amazonka.APIGateway.GetDocumentationVersion
  ( -- * Creating a Request
    GetDocumentationVersion (..),
    newGetDocumentationVersion,

    -- * Request Lenses
    getDocumentationVersion_restApiId,
    getDocumentationVersion_documentationVersion,

    -- * Destructuring the Response
    DocumentationVersion (..),
    newDocumentationVersion,

    -- * Response Lenses
    documentationVersion_createdDate,
    documentationVersion_version,
    documentationVersion_description,
  )
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

-- | Gets a documentation snapshot of an API.
--
-- /See:/ 'newGetDocumentationVersion' smart constructor.
data GetDocumentationVersion = GetDocumentationVersion'
  { -- | [Required] The string identifier of the associated RestApi.
    GetDocumentationVersion -> Text
restApiId :: Prelude.Text,
    -- | [Required] The version identifier of the to-be-retrieved documentation
    -- snapshot.
    GetDocumentationVersion -> Text
documentationVersion :: Prelude.Text
  }
  deriving (GetDocumentationVersion -> GetDocumentationVersion -> Bool
(GetDocumentationVersion -> GetDocumentationVersion -> Bool)
-> (GetDocumentationVersion -> GetDocumentationVersion -> Bool)
-> Eq GetDocumentationVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDocumentationVersion -> GetDocumentationVersion -> Bool
$c/= :: GetDocumentationVersion -> GetDocumentationVersion -> Bool
== :: GetDocumentationVersion -> GetDocumentationVersion -> Bool
$c== :: GetDocumentationVersion -> GetDocumentationVersion -> Bool
Prelude.Eq, ReadPrec [GetDocumentationVersion]
ReadPrec GetDocumentationVersion
Int -> ReadS GetDocumentationVersion
ReadS [GetDocumentationVersion]
(Int -> ReadS GetDocumentationVersion)
-> ReadS [GetDocumentationVersion]
-> ReadPrec GetDocumentationVersion
-> ReadPrec [GetDocumentationVersion]
-> Read GetDocumentationVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDocumentationVersion]
$creadListPrec :: ReadPrec [GetDocumentationVersion]
readPrec :: ReadPrec GetDocumentationVersion
$creadPrec :: ReadPrec GetDocumentationVersion
readList :: ReadS [GetDocumentationVersion]
$creadList :: ReadS [GetDocumentationVersion]
readsPrec :: Int -> ReadS GetDocumentationVersion
$creadsPrec :: Int -> ReadS GetDocumentationVersion
Prelude.Read, Int -> GetDocumentationVersion -> ShowS
[GetDocumentationVersion] -> ShowS
GetDocumentationVersion -> String
(Int -> GetDocumentationVersion -> ShowS)
-> (GetDocumentationVersion -> String)
-> ([GetDocumentationVersion] -> ShowS)
-> Show GetDocumentationVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDocumentationVersion] -> ShowS
$cshowList :: [GetDocumentationVersion] -> ShowS
show :: GetDocumentationVersion -> String
$cshow :: GetDocumentationVersion -> String
showsPrec :: Int -> GetDocumentationVersion -> ShowS
$cshowsPrec :: Int -> GetDocumentationVersion -> ShowS
Prelude.Show, (forall x.
 GetDocumentationVersion -> Rep GetDocumentationVersion x)
-> (forall x.
    Rep GetDocumentationVersion x -> GetDocumentationVersion)
-> Generic GetDocumentationVersion
forall x. Rep GetDocumentationVersion x -> GetDocumentationVersion
forall x. GetDocumentationVersion -> Rep GetDocumentationVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDocumentationVersion x -> GetDocumentationVersion
$cfrom :: forall x. GetDocumentationVersion -> Rep GetDocumentationVersion x
Prelude.Generic)

-- |
-- Create a value of 'GetDocumentationVersion' 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', 'getDocumentationVersion_restApiId' - [Required] The string identifier of the associated RestApi.
--
-- 'documentationVersion', 'getDocumentationVersion_documentationVersion' - [Required] The version identifier of the to-be-retrieved documentation
-- snapshot.
newGetDocumentationVersion ::
  -- | 'restApiId'
  Prelude.Text ->
  -- | 'documentationVersion'
  Prelude.Text ->
  GetDocumentationVersion
newGetDocumentationVersion :: Text -> Text -> GetDocumentationVersion
newGetDocumentationVersion
  Text
pRestApiId_
  Text
pDocumentationVersion_ =
    GetDocumentationVersion' :: Text -> Text -> GetDocumentationVersion
GetDocumentationVersion'
      { $sel:restApiId:GetDocumentationVersion' :: Text
restApiId = Text
pRestApiId_,
        $sel:documentationVersion:GetDocumentationVersion' :: Text
documentationVersion = Text
pDocumentationVersion_
      }

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

-- | [Required] The version identifier of the to-be-retrieved documentation
-- snapshot.
getDocumentationVersion_documentationVersion :: Lens.Lens' GetDocumentationVersion Prelude.Text
getDocumentationVersion_documentationVersion :: (Text -> f Text)
-> GetDocumentationVersion -> f GetDocumentationVersion
getDocumentationVersion_documentationVersion = (GetDocumentationVersion -> Text)
-> (GetDocumentationVersion -> Text -> GetDocumentationVersion)
-> Lens GetDocumentationVersion GetDocumentationVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetDocumentationVersion' {Text
documentationVersion :: Text
$sel:documentationVersion:GetDocumentationVersion' :: GetDocumentationVersion -> Text
documentationVersion} -> Text
documentationVersion) (\s :: GetDocumentationVersion
s@GetDocumentationVersion' {} Text
a -> GetDocumentationVersion
s {$sel:documentationVersion:GetDocumentationVersion' :: Text
documentationVersion = Text
a} :: GetDocumentationVersion)

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

instance Prelude.Hashable GetDocumentationVersion

instance Prelude.NFData GetDocumentationVersion

instance Core.ToHeaders GetDocumentationVersion where
  toHeaders :: GetDocumentationVersion -> ResponseHeaders
toHeaders =
    ResponseHeaders -> GetDocumentationVersion -> 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 GetDocumentationVersion where
  toPath :: GetDocumentationVersion -> ByteString
toPath GetDocumentationVersion' {Text
documentationVersion :: Text
restApiId :: Text
$sel:documentationVersion:GetDocumentationVersion' :: GetDocumentationVersion -> Text
$sel:restApiId:GetDocumentationVersion' :: GetDocumentationVersion -> 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
"/documentation/versions/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
documentationVersion
      ]

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