{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Gets a documentation version.
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_description,
    documentationVersion_version,
  )
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

-- | Gets a documentation snapshot of an API.
--
-- /See:/ 'newGetDocumentationVersion' smart constructor.
data GetDocumentationVersion = GetDocumentationVersion'
  { -- | The string identifier of the associated RestApi.
    GetDocumentationVersion -> Text
restApiId :: Prelude.Text,
    -- | The version identifier of the to-be-retrieved documentation snapshot.
    GetDocumentationVersion -> Text
documentationVersion :: Prelude.Text
  }
  deriving (GetDocumentationVersion -> GetDocumentationVersion -> Bool
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]
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
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. 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' - The string identifier of the associated RestApi.
--
-- 'documentationVersion', 'getDocumentationVersion_documentationVersion' - 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'
      { $sel:restApiId:GetDocumentationVersion' :: Text
restApiId = Text
pRestApiId_,
        $sel:documentationVersion:GetDocumentationVersion' :: Text
documentationVersion = Text
pDocumentationVersion_
      }

-- | The string identifier of the associated RestApi.
getDocumentationVersion_restApiId :: Lens.Lens' GetDocumentationVersion Prelude.Text
getDocumentationVersion_restApiId :: Lens' GetDocumentationVersion Text
getDocumentationVersion_restApiId = 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)

-- | The version identifier of the to-be-retrieved documentation snapshot.
getDocumentationVersion_documentationVersion :: Lens.Lens' GetDocumentationVersion Prelude.Text
getDocumentationVersion_documentationVersion :: Lens' GetDocumentationVersion Text
getDocumentationVersion_documentationVersion = 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 :: (Service -> Service)
-> GetDocumentationVersion -> Request GetDocumentationVersion
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 GetDocumentationVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetDocumentationVersion)))
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 GetDocumentationVersion where
  hashWithSalt :: Int -> GetDocumentationVersion -> Int
hashWithSalt Int
_salt GetDocumentationVersion' {Text
documentationVersion :: Text
restApiId :: Text
$sel:documentationVersion:GetDocumentationVersion' :: GetDocumentationVersion -> Text
$sel:restApiId:GetDocumentationVersion' :: GetDocumentationVersion -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
restApiId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
documentationVersion

instance Prelude.NFData GetDocumentationVersion where
  rnf :: GetDocumentationVersion -> ()
rnf GetDocumentationVersion' {Text
documentationVersion :: Text
restApiId :: Text
$sel:documentationVersion:GetDocumentationVersion' :: GetDocumentationVersion -> Text
$sel:restApiId:GetDocumentationVersion' :: GetDocumentationVersion -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
restApiId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
documentationVersion

instance Data.ToHeaders GetDocumentationVersion where
  toHeaders :: GetDocumentationVersion -> 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 GetDocumentationVersion where
  toPath :: GetDocumentationVersion -> ByteString
toPath GetDocumentationVersion' {Text
documentationVersion :: Text
restApiId :: Text
$sel:documentationVersion:GetDocumentationVersion' :: GetDocumentationVersion -> Text
$sel:restApiId:GetDocumentationVersion' :: GetDocumentationVersion -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/restapis/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
restApiId,
        ByteString
"/documentation/versions/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
documentationVersion
      ]

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