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

    -- * Request Lenses
    updateDocumentationVersion_patchOperations,
    updateDocumentationVersion_restApiId,
    updateDocumentationVersion_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

-- | Updates an existing documentation version of an API.
--
-- /See:/ 'newUpdateDocumentationVersion' smart constructor.
data UpdateDocumentationVersion = UpdateDocumentationVersion'
  { -- | A list of update operations to be applied to the specified resource and
    -- in the order specified in this list.
    UpdateDocumentationVersion -> Maybe [PatchOperation]
patchOperations :: Prelude.Maybe [PatchOperation],
    -- | [Required] The string identifier of the associated RestApi..
    UpdateDocumentationVersion -> Text
restApiId :: Prelude.Text,
    -- | [Required] The version identifier of the to-be-updated documentation
    -- version.
    UpdateDocumentationVersion -> Text
documentationVersion :: Prelude.Text
  }
  deriving (UpdateDocumentationVersion -> UpdateDocumentationVersion -> Bool
(UpdateDocumentationVersion -> UpdateDocumentationVersion -> Bool)
-> (UpdateDocumentationVersion
    -> UpdateDocumentationVersion -> Bool)
-> Eq UpdateDocumentationVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDocumentationVersion -> UpdateDocumentationVersion -> Bool
$c/= :: UpdateDocumentationVersion -> UpdateDocumentationVersion -> Bool
== :: UpdateDocumentationVersion -> UpdateDocumentationVersion -> Bool
$c== :: UpdateDocumentationVersion -> UpdateDocumentationVersion -> Bool
Prelude.Eq, ReadPrec [UpdateDocumentationVersion]
ReadPrec UpdateDocumentationVersion
Int -> ReadS UpdateDocumentationVersion
ReadS [UpdateDocumentationVersion]
(Int -> ReadS UpdateDocumentationVersion)
-> ReadS [UpdateDocumentationVersion]
-> ReadPrec UpdateDocumentationVersion
-> ReadPrec [UpdateDocumentationVersion]
-> Read UpdateDocumentationVersion
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDocumentationVersion]
$creadListPrec :: ReadPrec [UpdateDocumentationVersion]
readPrec :: ReadPrec UpdateDocumentationVersion
$creadPrec :: ReadPrec UpdateDocumentationVersion
readList :: ReadS [UpdateDocumentationVersion]
$creadList :: ReadS [UpdateDocumentationVersion]
readsPrec :: Int -> ReadS UpdateDocumentationVersion
$creadsPrec :: Int -> ReadS UpdateDocumentationVersion
Prelude.Read, Int -> UpdateDocumentationVersion -> ShowS
[UpdateDocumentationVersion] -> ShowS
UpdateDocumentationVersion -> String
(Int -> UpdateDocumentationVersion -> ShowS)
-> (UpdateDocumentationVersion -> String)
-> ([UpdateDocumentationVersion] -> ShowS)
-> Show UpdateDocumentationVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDocumentationVersion] -> ShowS
$cshowList :: [UpdateDocumentationVersion] -> ShowS
show :: UpdateDocumentationVersion -> String
$cshow :: UpdateDocumentationVersion -> String
showsPrec :: Int -> UpdateDocumentationVersion -> ShowS
$cshowsPrec :: Int -> UpdateDocumentationVersion -> ShowS
Prelude.Show, (forall x.
 UpdateDocumentationVersion -> Rep UpdateDocumentationVersion x)
-> (forall x.
    Rep UpdateDocumentationVersion x -> UpdateDocumentationVersion)
-> Generic UpdateDocumentationVersion
forall x.
Rep UpdateDocumentationVersion x -> UpdateDocumentationVersion
forall x.
UpdateDocumentationVersion -> Rep UpdateDocumentationVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateDocumentationVersion x -> UpdateDocumentationVersion
$cfrom :: forall x.
UpdateDocumentationVersion -> Rep UpdateDocumentationVersion x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDocumentationVersion' 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:
--
-- 'patchOperations', 'updateDocumentationVersion_patchOperations' - A list of update operations to be applied to the specified resource and
-- in the order specified in this list.
--
-- 'restApiId', 'updateDocumentationVersion_restApiId' - [Required] The string identifier of the associated RestApi..
--
-- 'documentationVersion', 'updateDocumentationVersion_documentationVersion' - [Required] The version identifier of the to-be-updated documentation
-- version.
newUpdateDocumentationVersion ::
  -- | 'restApiId'
  Prelude.Text ->
  -- | 'documentationVersion'
  Prelude.Text ->
  UpdateDocumentationVersion
newUpdateDocumentationVersion :: Text -> Text -> UpdateDocumentationVersion
newUpdateDocumentationVersion
  Text
pRestApiId_
  Text
pDocumentationVersion_ =
    UpdateDocumentationVersion' :: Maybe [PatchOperation]
-> Text -> Text -> UpdateDocumentationVersion
UpdateDocumentationVersion'
      { $sel:patchOperations:UpdateDocumentationVersion' :: Maybe [PatchOperation]
patchOperations =
          Maybe [PatchOperation]
forall a. Maybe a
Prelude.Nothing,
        $sel:restApiId:UpdateDocumentationVersion' :: Text
restApiId = Text
pRestApiId_,
        $sel:documentationVersion:UpdateDocumentationVersion' :: Text
documentationVersion = Text
pDocumentationVersion_
      }

-- | A list of update operations to be applied to the specified resource and
-- in the order specified in this list.
updateDocumentationVersion_patchOperations :: Lens.Lens' UpdateDocumentationVersion (Prelude.Maybe [PatchOperation])
updateDocumentationVersion_patchOperations :: (Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> UpdateDocumentationVersion -> f UpdateDocumentationVersion
updateDocumentationVersion_patchOperations = (UpdateDocumentationVersion -> Maybe [PatchOperation])
-> (UpdateDocumentationVersion
    -> Maybe [PatchOperation] -> UpdateDocumentationVersion)
-> Lens
     UpdateDocumentationVersion
     UpdateDocumentationVersion
     (Maybe [PatchOperation])
     (Maybe [PatchOperation])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDocumentationVersion' {Maybe [PatchOperation]
patchOperations :: Maybe [PatchOperation]
$sel:patchOperations:UpdateDocumentationVersion' :: UpdateDocumentationVersion -> Maybe [PatchOperation]
patchOperations} -> Maybe [PatchOperation]
patchOperations) (\s :: UpdateDocumentationVersion
s@UpdateDocumentationVersion' {} Maybe [PatchOperation]
a -> UpdateDocumentationVersion
s {$sel:patchOperations:UpdateDocumentationVersion' :: Maybe [PatchOperation]
patchOperations = Maybe [PatchOperation]
a} :: UpdateDocumentationVersion) ((Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
 -> UpdateDocumentationVersion -> f UpdateDocumentationVersion)
-> ((Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
    -> Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> (Maybe [PatchOperation] -> f (Maybe [PatchOperation]))
-> UpdateDocumentationVersion
-> f UpdateDocumentationVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [PatchOperation] [PatchOperation] [PatchOperation] [PatchOperation]
-> Iso
     (Maybe [PatchOperation])
     (Maybe [PatchOperation])
     (Maybe [PatchOperation])
     (Maybe [PatchOperation])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [PatchOperation] [PatchOperation] [PatchOperation] [PatchOperation]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

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

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

instance Prelude.NFData UpdateDocumentationVersion

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

instance Core.ToPath UpdateDocumentationVersion where
  toPath :: UpdateDocumentationVersion -> ByteString
toPath UpdateDocumentationVersion' {Maybe [PatchOperation]
Text
documentationVersion :: Text
restApiId :: Text
patchOperations :: Maybe [PatchOperation]
$sel:documentationVersion:UpdateDocumentationVersion' :: UpdateDocumentationVersion -> Text
$sel:restApiId:UpdateDocumentationVersion' :: UpdateDocumentationVersion -> Text
$sel:patchOperations:UpdateDocumentationVersion' :: UpdateDocumentationVersion -> Maybe [PatchOperation]
..} =
    [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 UpdateDocumentationVersion where
  toQuery :: UpdateDocumentationVersion -> QueryString
toQuery = QueryString -> UpdateDocumentationVersion -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
forall a. Monoid a => a
Prelude.mempty