{-# 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.GetDocumentationPart
-- 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.GetDocumentationPart
  ( -- * Creating a Request
    GetDocumentationPart (..),
    newGetDocumentationPart,

    -- * Request Lenses
    getDocumentationPart_restApiId,
    getDocumentationPart_documentationPartId,

    -- * Destructuring the Response
    DocumentationPart (..),
    newDocumentationPart,

    -- * Response Lenses
    documentationPart_location,
    documentationPart_id,
    documentationPart_properties,
  )
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 specified documentation part of a given API.
--
-- /See:/ 'newGetDocumentationPart' smart constructor.
data GetDocumentationPart = GetDocumentationPart'
  { -- | [Required] The string identifier of the associated RestApi.
    GetDocumentationPart -> Text
restApiId :: Prelude.Text,
    -- | [Required] The string identifier of the associated RestApi.
    GetDocumentationPart -> Text
documentationPartId :: Prelude.Text
  }
  deriving (GetDocumentationPart -> GetDocumentationPart -> Bool
(GetDocumentationPart -> GetDocumentationPart -> Bool)
-> (GetDocumentationPart -> GetDocumentationPart -> Bool)
-> Eq GetDocumentationPart
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetDocumentationPart -> GetDocumentationPart -> Bool
$c/= :: GetDocumentationPart -> GetDocumentationPart -> Bool
== :: GetDocumentationPart -> GetDocumentationPart -> Bool
$c== :: GetDocumentationPart -> GetDocumentationPart -> Bool
Prelude.Eq, ReadPrec [GetDocumentationPart]
ReadPrec GetDocumentationPart
Int -> ReadS GetDocumentationPart
ReadS [GetDocumentationPart]
(Int -> ReadS GetDocumentationPart)
-> ReadS [GetDocumentationPart]
-> ReadPrec GetDocumentationPart
-> ReadPrec [GetDocumentationPart]
-> Read GetDocumentationPart
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetDocumentationPart]
$creadListPrec :: ReadPrec [GetDocumentationPart]
readPrec :: ReadPrec GetDocumentationPart
$creadPrec :: ReadPrec GetDocumentationPart
readList :: ReadS [GetDocumentationPart]
$creadList :: ReadS [GetDocumentationPart]
readsPrec :: Int -> ReadS GetDocumentationPart
$creadsPrec :: Int -> ReadS GetDocumentationPart
Prelude.Read, Int -> GetDocumentationPart -> ShowS
[GetDocumentationPart] -> ShowS
GetDocumentationPart -> String
(Int -> GetDocumentationPart -> ShowS)
-> (GetDocumentationPart -> String)
-> ([GetDocumentationPart] -> ShowS)
-> Show GetDocumentationPart
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetDocumentationPart] -> ShowS
$cshowList :: [GetDocumentationPart] -> ShowS
show :: GetDocumentationPart -> String
$cshow :: GetDocumentationPart -> String
showsPrec :: Int -> GetDocumentationPart -> ShowS
$cshowsPrec :: Int -> GetDocumentationPart -> ShowS
Prelude.Show, (forall x. GetDocumentationPart -> Rep GetDocumentationPart x)
-> (forall x. Rep GetDocumentationPart x -> GetDocumentationPart)
-> Generic GetDocumentationPart
forall x. Rep GetDocumentationPart x -> GetDocumentationPart
forall x. GetDocumentationPart -> Rep GetDocumentationPart x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetDocumentationPart x -> GetDocumentationPart
$cfrom :: forall x. GetDocumentationPart -> Rep GetDocumentationPart x
Prelude.Generic)

-- |
-- Create a value of 'GetDocumentationPart' 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', 'getDocumentationPart_restApiId' - [Required] The string identifier of the associated RestApi.
--
-- 'documentationPartId', 'getDocumentationPart_documentationPartId' - [Required] The string identifier of the associated RestApi.
newGetDocumentationPart ::
  -- | 'restApiId'
  Prelude.Text ->
  -- | 'documentationPartId'
  Prelude.Text ->
  GetDocumentationPart
newGetDocumentationPart :: Text -> Text -> GetDocumentationPart
newGetDocumentationPart
  Text
pRestApiId_
  Text
pDocumentationPartId_ =
    GetDocumentationPart' :: Text -> Text -> GetDocumentationPart
GetDocumentationPart'
      { $sel:restApiId:GetDocumentationPart' :: Text
restApiId = Text
pRestApiId_,
        $sel:documentationPartId:GetDocumentationPart' :: Text
documentationPartId = Text
pDocumentationPartId_
      }

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

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

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

instance Prelude.Hashable GetDocumentationPart

instance Prelude.NFData GetDocumentationPart

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

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