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

    -- * Request Lenses
    createDocumentationVersion_stageName,
    createDocumentationVersion_description,
    createDocumentationVersion_restApiId,
    createDocumentationVersion_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

-- | Creates a new documentation version of a given API.
--
-- /See:/ 'newCreateDocumentationVersion' smart constructor.
data CreateDocumentationVersion = CreateDocumentationVersion'
  { -- | The stage name to be associated with the new documentation snapshot.
    CreateDocumentationVersion -> Maybe Text
stageName :: Prelude.Maybe Prelude.Text,
    -- | A description about the new documentation snapshot.
    CreateDocumentationVersion -> Maybe Text
description :: Prelude.Maybe Prelude.Text,
    -- | [Required] The string identifier of the associated RestApi.
    CreateDocumentationVersion -> Text
restApiId :: Prelude.Text,
    -- | [Required] The version identifier of the new snapshot.
    CreateDocumentationVersion -> Text
documentationVersion :: Prelude.Text
  }
  deriving (CreateDocumentationVersion -> CreateDocumentationVersion -> Bool
(CreateDocumentationVersion -> CreateDocumentationVersion -> Bool)
-> (CreateDocumentationVersion
    -> CreateDocumentationVersion -> Bool)
-> Eq CreateDocumentationVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CreateDocumentationVersion -> CreateDocumentationVersion -> Bool
$c/= :: CreateDocumentationVersion -> CreateDocumentationVersion -> Bool
== :: CreateDocumentationVersion -> CreateDocumentationVersion -> Bool
$c== :: CreateDocumentationVersion -> CreateDocumentationVersion -> Bool
Prelude.Eq, ReadPrec [CreateDocumentationVersion]
ReadPrec CreateDocumentationVersion
Int -> ReadS CreateDocumentationVersion
ReadS [CreateDocumentationVersion]
(Int -> ReadS CreateDocumentationVersion)
-> ReadS [CreateDocumentationVersion]
-> ReadPrec CreateDocumentationVersion
-> ReadPrec [CreateDocumentationVersion]
-> Read CreateDocumentationVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CreateDocumentationVersion]
$creadListPrec :: ReadPrec [CreateDocumentationVersion]
readPrec :: ReadPrec CreateDocumentationVersion
$creadPrec :: ReadPrec CreateDocumentationVersion
readList :: ReadS [CreateDocumentationVersion]
$creadList :: ReadS [CreateDocumentationVersion]
readsPrec :: Int -> ReadS CreateDocumentationVersion
$creadsPrec :: Int -> ReadS CreateDocumentationVersion
Prelude.Read, Int -> CreateDocumentationVersion -> ShowS
[CreateDocumentationVersion] -> ShowS
CreateDocumentationVersion -> String
(Int -> CreateDocumentationVersion -> ShowS)
-> (CreateDocumentationVersion -> String)
-> ([CreateDocumentationVersion] -> ShowS)
-> Show CreateDocumentationVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CreateDocumentationVersion] -> ShowS
$cshowList :: [CreateDocumentationVersion] -> ShowS
show :: CreateDocumentationVersion -> String
$cshow :: CreateDocumentationVersion -> String
showsPrec :: Int -> CreateDocumentationVersion -> ShowS
$cshowsPrec :: Int -> CreateDocumentationVersion -> ShowS
Prelude.Show, (forall x.
 CreateDocumentationVersion -> Rep CreateDocumentationVersion x)
-> (forall x.
    Rep CreateDocumentationVersion x -> CreateDocumentationVersion)
-> Generic CreateDocumentationVersion
forall x.
Rep CreateDocumentationVersion x -> CreateDocumentationVersion
forall x.
CreateDocumentationVersion -> Rep CreateDocumentationVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep CreateDocumentationVersion x -> CreateDocumentationVersion
$cfrom :: forall x.
CreateDocumentationVersion -> Rep CreateDocumentationVersion x
Prelude.Generic)

-- |
-- Create a value of 'CreateDocumentationVersion' 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:
--
-- 'stageName', 'createDocumentationVersion_stageName' - The stage name to be associated with the new documentation snapshot.
--
-- 'description', 'createDocumentationVersion_description' - A description about the new documentation snapshot.
--
-- 'restApiId', 'createDocumentationVersion_restApiId' - [Required] The string identifier of the associated RestApi.
--
-- 'documentationVersion', 'createDocumentationVersion_documentationVersion' - [Required] The version identifier of the new snapshot.
newCreateDocumentationVersion ::
  -- | 'restApiId'
  Prelude.Text ->
  -- | 'documentationVersion'
  Prelude.Text ->
  CreateDocumentationVersion
newCreateDocumentationVersion :: Text -> Text -> CreateDocumentationVersion
newCreateDocumentationVersion
  Text
pRestApiId_
  Text
pDocumentationVersion_ =
    CreateDocumentationVersion' :: Maybe Text
-> Maybe Text -> Text -> Text -> CreateDocumentationVersion
CreateDocumentationVersion'
      { $sel:stageName:CreateDocumentationVersion' :: Maybe Text
stageName =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:description:CreateDocumentationVersion' :: Maybe Text
description = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:restApiId:CreateDocumentationVersion' :: Text
restApiId = Text
pRestApiId_,
        $sel:documentationVersion:CreateDocumentationVersion' :: Text
documentationVersion = Text
pDocumentationVersion_
      }

-- | The stage name to be associated with the new documentation snapshot.
createDocumentationVersion_stageName :: Lens.Lens' CreateDocumentationVersion (Prelude.Maybe Prelude.Text)
createDocumentationVersion_stageName :: (Maybe Text -> f (Maybe Text))
-> CreateDocumentationVersion -> f CreateDocumentationVersion
createDocumentationVersion_stageName = (CreateDocumentationVersion -> Maybe Text)
-> (CreateDocumentationVersion
    -> Maybe Text -> CreateDocumentationVersion)
-> Lens
     CreateDocumentationVersion
     CreateDocumentationVersion
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDocumentationVersion' {Maybe Text
stageName :: Maybe Text
$sel:stageName:CreateDocumentationVersion' :: CreateDocumentationVersion -> Maybe Text
stageName} -> Maybe Text
stageName) (\s :: CreateDocumentationVersion
s@CreateDocumentationVersion' {} Maybe Text
a -> CreateDocumentationVersion
s {$sel:stageName:CreateDocumentationVersion' :: Maybe Text
stageName = Maybe Text
a} :: CreateDocumentationVersion)

-- | A description about the new documentation snapshot.
createDocumentationVersion_description :: Lens.Lens' CreateDocumentationVersion (Prelude.Maybe Prelude.Text)
createDocumentationVersion_description :: (Maybe Text -> f (Maybe Text))
-> CreateDocumentationVersion -> f CreateDocumentationVersion
createDocumentationVersion_description = (CreateDocumentationVersion -> Maybe Text)
-> (CreateDocumentationVersion
    -> Maybe Text -> CreateDocumentationVersion)
-> Lens
     CreateDocumentationVersion
     CreateDocumentationVersion
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDocumentationVersion' {Maybe Text
description :: Maybe Text
$sel:description:CreateDocumentationVersion' :: CreateDocumentationVersion -> Maybe Text
description} -> Maybe Text
description) (\s :: CreateDocumentationVersion
s@CreateDocumentationVersion' {} Maybe Text
a -> CreateDocumentationVersion
s {$sel:description:CreateDocumentationVersion' :: Maybe Text
description = Maybe Text
a} :: CreateDocumentationVersion)

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

-- | [Required] The version identifier of the new snapshot.
createDocumentationVersion_documentationVersion :: Lens.Lens' CreateDocumentationVersion Prelude.Text
createDocumentationVersion_documentationVersion :: (Text -> f Text)
-> CreateDocumentationVersion -> f CreateDocumentationVersion
createDocumentationVersion_documentationVersion = (CreateDocumentationVersion -> Text)
-> (CreateDocumentationVersion
    -> Text -> CreateDocumentationVersion)
-> Lens
     CreateDocumentationVersion CreateDocumentationVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CreateDocumentationVersion' {Text
documentationVersion :: Text
$sel:documentationVersion:CreateDocumentationVersion' :: CreateDocumentationVersion -> Text
documentationVersion} -> Text
documentationVersion) (\s :: CreateDocumentationVersion
s@CreateDocumentationVersion' {} Text
a -> CreateDocumentationVersion
s {$sel:documentationVersion:CreateDocumentationVersion' :: Text
documentationVersion = Text
a} :: CreateDocumentationVersion)

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

instance Prelude.NFData CreateDocumentationVersion

instance Core.ToHeaders CreateDocumentationVersion where
  toHeaders :: CreateDocumentationVersion -> ResponseHeaders
toHeaders =
    ResponseHeaders -> CreateDocumentationVersion -> 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.ToJSON CreateDocumentationVersion where
  toJSON :: CreateDocumentationVersion -> Value
toJSON CreateDocumentationVersion' {Maybe Text
Text
documentationVersion :: Text
restApiId :: Text
description :: Maybe Text
stageName :: Maybe Text
$sel:documentationVersion:CreateDocumentationVersion' :: CreateDocumentationVersion -> Text
$sel:restApiId:CreateDocumentationVersion' :: CreateDocumentationVersion -> Text
$sel:description:CreateDocumentationVersion' :: CreateDocumentationVersion -> Maybe Text
$sel:stageName:CreateDocumentationVersion' :: CreateDocumentationVersion -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"stageName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
stageName,
            (Text
"description" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
description,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"documentationVersion"
                  Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
documentationVersion
              )
          ]
      )

instance Core.ToPath CreateDocumentationVersion where
  toPath :: CreateDocumentationVersion -> ByteString
toPath CreateDocumentationVersion' {Maybe Text
Text
documentationVersion :: Text
restApiId :: Text
description :: Maybe Text
stageName :: Maybe Text
$sel:documentationVersion:CreateDocumentationVersion' :: CreateDocumentationVersion -> Text
$sel:restApiId:CreateDocumentationVersion' :: CreateDocumentationVersion -> Text
$sel:description:CreateDocumentationVersion' :: CreateDocumentationVersion -> Maybe Text
$sel:stageName:CreateDocumentationVersion' :: CreateDocumentationVersion -> Maybe 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"
      ]

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