{-# 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.WorkDocs.UpdateDocumentVersion
-- 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)
--
-- Changes the status of the document version to ACTIVE.
--
-- Amazon WorkDocs also sets its document container to ACTIVE. This is the
-- last step in a document upload, after the client uploads the document to
-- an S3-presigned URL returned by InitiateDocumentVersionUpload.
module Amazonka.WorkDocs.UpdateDocumentVersion
  ( -- * Creating a Request
    UpdateDocumentVersion (..),
    newUpdateDocumentVersion,

    -- * Request Lenses
    updateDocumentVersion_authenticationToken,
    updateDocumentVersion_versionStatus,
    updateDocumentVersion_documentId,
    updateDocumentVersion_versionId,

    -- * Destructuring the Response
    UpdateDocumentVersionResponse (..),
    newUpdateDocumentVersionResponse,
  )
where

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
import Amazonka.WorkDocs.Types

-- | /See:/ 'newUpdateDocumentVersion' smart constructor.
data UpdateDocumentVersion = UpdateDocumentVersion'
  { -- | Amazon WorkDocs authentication token. Not required when using AWS
    -- administrator credentials to access the API.
    UpdateDocumentVersion -> Maybe (Sensitive Text)
authenticationToken :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The status of the version.
    UpdateDocumentVersion -> Maybe DocumentVersionStatus
versionStatus :: Prelude.Maybe DocumentVersionStatus,
    -- | The ID of the document.
    UpdateDocumentVersion -> Text
documentId :: Prelude.Text,
    -- | The version ID of the document.
    UpdateDocumentVersion -> Text
versionId :: Prelude.Text
  }
  deriving (UpdateDocumentVersion -> UpdateDocumentVersion -> Bool
(UpdateDocumentVersion -> UpdateDocumentVersion -> Bool)
-> (UpdateDocumentVersion -> UpdateDocumentVersion -> Bool)
-> Eq UpdateDocumentVersion
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDocumentVersion -> UpdateDocumentVersion -> Bool
$c/= :: UpdateDocumentVersion -> UpdateDocumentVersion -> Bool
== :: UpdateDocumentVersion -> UpdateDocumentVersion -> Bool
$c== :: UpdateDocumentVersion -> UpdateDocumentVersion -> Bool
Prelude.Eq, Int -> UpdateDocumentVersion -> ShowS
[UpdateDocumentVersion] -> ShowS
UpdateDocumentVersion -> String
(Int -> UpdateDocumentVersion -> ShowS)
-> (UpdateDocumentVersion -> String)
-> ([UpdateDocumentVersion] -> ShowS)
-> Show UpdateDocumentVersion
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDocumentVersion] -> ShowS
$cshowList :: [UpdateDocumentVersion] -> ShowS
show :: UpdateDocumentVersion -> String
$cshow :: UpdateDocumentVersion -> String
showsPrec :: Int -> UpdateDocumentVersion -> ShowS
$cshowsPrec :: Int -> UpdateDocumentVersion -> ShowS
Prelude.Show, (forall x. UpdateDocumentVersion -> Rep UpdateDocumentVersion x)
-> (forall x. Rep UpdateDocumentVersion x -> UpdateDocumentVersion)
-> Generic UpdateDocumentVersion
forall x. Rep UpdateDocumentVersion x -> UpdateDocumentVersion
forall x. UpdateDocumentVersion -> Rep UpdateDocumentVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateDocumentVersion x -> UpdateDocumentVersion
$cfrom :: forall x. UpdateDocumentVersion -> Rep UpdateDocumentVersion x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDocumentVersion' 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:
--
-- 'authenticationToken', 'updateDocumentVersion_authenticationToken' - Amazon WorkDocs authentication token. Not required when using AWS
-- administrator credentials to access the API.
--
-- 'versionStatus', 'updateDocumentVersion_versionStatus' - The status of the version.
--
-- 'documentId', 'updateDocumentVersion_documentId' - The ID of the document.
--
-- 'versionId', 'updateDocumentVersion_versionId' - The version ID of the document.
newUpdateDocumentVersion ::
  -- | 'documentId'
  Prelude.Text ->
  -- | 'versionId'
  Prelude.Text ->
  UpdateDocumentVersion
newUpdateDocumentVersion :: Text -> Text -> UpdateDocumentVersion
newUpdateDocumentVersion Text
pDocumentId_ Text
pVersionId_ =
  UpdateDocumentVersion' :: Maybe (Sensitive Text)
-> Maybe DocumentVersionStatus
-> Text
-> Text
-> UpdateDocumentVersion
UpdateDocumentVersion'
    { $sel:authenticationToken:UpdateDocumentVersion' :: Maybe (Sensitive Text)
authenticationToken =
        Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:versionStatus:UpdateDocumentVersion' :: Maybe DocumentVersionStatus
versionStatus = Maybe DocumentVersionStatus
forall a. Maybe a
Prelude.Nothing,
      $sel:documentId:UpdateDocumentVersion' :: Text
documentId = Text
pDocumentId_,
      $sel:versionId:UpdateDocumentVersion' :: Text
versionId = Text
pVersionId_
    }

-- | Amazon WorkDocs authentication token. Not required when using AWS
-- administrator credentials to access the API.
updateDocumentVersion_authenticationToken :: Lens.Lens' UpdateDocumentVersion (Prelude.Maybe Prelude.Text)
updateDocumentVersion_authenticationToken :: (Maybe Text -> f (Maybe Text))
-> UpdateDocumentVersion -> f UpdateDocumentVersion
updateDocumentVersion_authenticationToken = (UpdateDocumentVersion -> Maybe (Sensitive Text))
-> (UpdateDocumentVersion
    -> Maybe (Sensitive Text) -> UpdateDocumentVersion)
-> Lens
     UpdateDocumentVersion
     UpdateDocumentVersion
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDocumentVersion' {Maybe (Sensitive Text)
authenticationToken :: Maybe (Sensitive Text)
$sel:authenticationToken:UpdateDocumentVersion' :: UpdateDocumentVersion -> Maybe (Sensitive Text)
authenticationToken} -> Maybe (Sensitive Text)
authenticationToken) (\s :: UpdateDocumentVersion
s@UpdateDocumentVersion' {} Maybe (Sensitive Text)
a -> UpdateDocumentVersion
s {$sel:authenticationToken:UpdateDocumentVersion' :: Maybe (Sensitive Text)
authenticationToken = Maybe (Sensitive Text)
a} :: UpdateDocumentVersion) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> UpdateDocumentVersion -> f UpdateDocumentVersion)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> UpdateDocumentVersion
-> f UpdateDocumentVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso (Sensitive Text) (Sensitive Text) Text Text
-> Iso
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
     (Maybe Text)
     (Maybe Text)
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 (Sensitive Text) (Sensitive Text) Text Text
forall a. Iso' (Sensitive a) a
Core._Sensitive

-- | The status of the version.
updateDocumentVersion_versionStatus :: Lens.Lens' UpdateDocumentVersion (Prelude.Maybe DocumentVersionStatus)
updateDocumentVersion_versionStatus :: (Maybe DocumentVersionStatus -> f (Maybe DocumentVersionStatus))
-> UpdateDocumentVersion -> f UpdateDocumentVersion
updateDocumentVersion_versionStatus = (UpdateDocumentVersion -> Maybe DocumentVersionStatus)
-> (UpdateDocumentVersion
    -> Maybe DocumentVersionStatus -> UpdateDocumentVersion)
-> Lens
     UpdateDocumentVersion
     UpdateDocumentVersion
     (Maybe DocumentVersionStatus)
     (Maybe DocumentVersionStatus)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDocumentVersion' {Maybe DocumentVersionStatus
versionStatus :: Maybe DocumentVersionStatus
$sel:versionStatus:UpdateDocumentVersion' :: UpdateDocumentVersion -> Maybe DocumentVersionStatus
versionStatus} -> Maybe DocumentVersionStatus
versionStatus) (\s :: UpdateDocumentVersion
s@UpdateDocumentVersion' {} Maybe DocumentVersionStatus
a -> UpdateDocumentVersion
s {$sel:versionStatus:UpdateDocumentVersion' :: Maybe DocumentVersionStatus
versionStatus = Maybe DocumentVersionStatus
a} :: UpdateDocumentVersion)

-- | The ID of the document.
updateDocumentVersion_documentId :: Lens.Lens' UpdateDocumentVersion Prelude.Text
updateDocumentVersion_documentId :: (Text -> f Text)
-> UpdateDocumentVersion -> f UpdateDocumentVersion
updateDocumentVersion_documentId = (UpdateDocumentVersion -> Text)
-> (UpdateDocumentVersion -> Text -> UpdateDocumentVersion)
-> Lens UpdateDocumentVersion UpdateDocumentVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDocumentVersion' {Text
documentId :: Text
$sel:documentId:UpdateDocumentVersion' :: UpdateDocumentVersion -> Text
documentId} -> Text
documentId) (\s :: UpdateDocumentVersion
s@UpdateDocumentVersion' {} Text
a -> UpdateDocumentVersion
s {$sel:documentId:UpdateDocumentVersion' :: Text
documentId = Text
a} :: UpdateDocumentVersion)

-- | The version ID of the document.
updateDocumentVersion_versionId :: Lens.Lens' UpdateDocumentVersion Prelude.Text
updateDocumentVersion_versionId :: (Text -> f Text)
-> UpdateDocumentVersion -> f UpdateDocumentVersion
updateDocumentVersion_versionId = (UpdateDocumentVersion -> Text)
-> (UpdateDocumentVersion -> Text -> UpdateDocumentVersion)
-> Lens UpdateDocumentVersion UpdateDocumentVersion Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDocumentVersion' {Text
versionId :: Text
$sel:versionId:UpdateDocumentVersion' :: UpdateDocumentVersion -> Text
versionId} -> Text
versionId) (\s :: UpdateDocumentVersion
s@UpdateDocumentVersion' {} Text
a -> UpdateDocumentVersion
s {$sel:versionId:UpdateDocumentVersion' :: Text
versionId = Text
a} :: UpdateDocumentVersion)

instance Core.AWSRequest UpdateDocumentVersion where
  type
    AWSResponse UpdateDocumentVersion =
      UpdateDocumentVersionResponse
  request :: UpdateDocumentVersion -> Request UpdateDocumentVersion
request = Service -> UpdateDocumentVersion -> Request UpdateDocumentVersion
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateDocumentVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateDocumentVersion)))
response =
    AWSResponse UpdateDocumentVersion
-> Logger
-> Service
-> Proxy UpdateDocumentVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateDocumentVersion)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse UpdateDocumentVersion
UpdateDocumentVersionResponse
UpdateDocumentVersionResponse'

instance Prelude.Hashable UpdateDocumentVersion

instance Prelude.NFData UpdateDocumentVersion

instance Core.ToHeaders UpdateDocumentVersion where
  toHeaders :: UpdateDocumentVersion -> [Header]
toHeaders UpdateDocumentVersion' {Maybe (Sensitive Text)
Maybe DocumentVersionStatus
Text
versionId :: Text
documentId :: Text
versionStatus :: Maybe DocumentVersionStatus
authenticationToken :: Maybe (Sensitive Text)
$sel:versionId:UpdateDocumentVersion' :: UpdateDocumentVersion -> Text
$sel:documentId:UpdateDocumentVersion' :: UpdateDocumentVersion -> Text
$sel:versionStatus:UpdateDocumentVersion' :: UpdateDocumentVersion -> Maybe DocumentVersionStatus
$sel:authenticationToken:UpdateDocumentVersion' :: UpdateDocumentVersion -> Maybe (Sensitive Text)
..} =
    [[Header]] -> [Header]
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"Authentication" HeaderName -> Maybe (Sensitive Text) -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# Maybe (Sensitive Text)
authenticationToken,
        HeaderName
"Content-Type"
          HeaderName -> ByteString -> [Header]
forall a. ToHeader a => HeaderName -> a -> [Header]
Core.=# (ByteString
"application/x-amz-json-1.1" :: Prelude.ByteString)
      ]

instance Core.ToJSON UpdateDocumentVersion where
  toJSON :: UpdateDocumentVersion -> Value
toJSON UpdateDocumentVersion' {Maybe (Sensitive Text)
Maybe DocumentVersionStatus
Text
versionId :: Text
documentId :: Text
versionStatus :: Maybe DocumentVersionStatus
authenticationToken :: Maybe (Sensitive Text)
$sel:versionId:UpdateDocumentVersion' :: UpdateDocumentVersion -> Text
$sel:documentId:UpdateDocumentVersion' :: UpdateDocumentVersion -> Text
$sel:versionStatus:UpdateDocumentVersion' :: UpdateDocumentVersion -> Maybe DocumentVersionStatus
$sel:authenticationToken:UpdateDocumentVersion' :: UpdateDocumentVersion -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"VersionStatus" Text -> DocumentVersionStatus -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (DocumentVersionStatus -> Pair)
-> Maybe DocumentVersionStatus -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DocumentVersionStatus
versionStatus
          ]
      )

instance Core.ToPath UpdateDocumentVersion where
  toPath :: UpdateDocumentVersion -> ByteString
toPath UpdateDocumentVersion' {Maybe (Sensitive Text)
Maybe DocumentVersionStatus
Text
versionId :: Text
documentId :: Text
versionStatus :: Maybe DocumentVersionStatus
authenticationToken :: Maybe (Sensitive Text)
$sel:versionId:UpdateDocumentVersion' :: UpdateDocumentVersion -> Text
$sel:documentId:UpdateDocumentVersion' :: UpdateDocumentVersion -> Text
$sel:versionStatus:UpdateDocumentVersion' :: UpdateDocumentVersion -> Maybe DocumentVersionStatus
$sel:authenticationToken:UpdateDocumentVersion' :: UpdateDocumentVersion -> Maybe (Sensitive Text)
..} =
    [ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/api/v1/documents/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
documentId,
        ByteString
"/versions/",
        Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
versionId
      ]

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

-- | /See:/ 'newUpdateDocumentVersionResponse' smart constructor.
data UpdateDocumentVersionResponse = UpdateDocumentVersionResponse'
  {
  }
  deriving (UpdateDocumentVersionResponse
-> UpdateDocumentVersionResponse -> Bool
(UpdateDocumentVersionResponse
 -> UpdateDocumentVersionResponse -> Bool)
-> (UpdateDocumentVersionResponse
    -> UpdateDocumentVersionResponse -> Bool)
-> Eq UpdateDocumentVersionResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDocumentVersionResponse
-> UpdateDocumentVersionResponse -> Bool
$c/= :: UpdateDocumentVersionResponse
-> UpdateDocumentVersionResponse -> Bool
== :: UpdateDocumentVersionResponse
-> UpdateDocumentVersionResponse -> Bool
$c== :: UpdateDocumentVersionResponse
-> UpdateDocumentVersionResponse -> Bool
Prelude.Eq, ReadPrec [UpdateDocumentVersionResponse]
ReadPrec UpdateDocumentVersionResponse
Int -> ReadS UpdateDocumentVersionResponse
ReadS [UpdateDocumentVersionResponse]
(Int -> ReadS UpdateDocumentVersionResponse)
-> ReadS [UpdateDocumentVersionResponse]
-> ReadPrec UpdateDocumentVersionResponse
-> ReadPrec [UpdateDocumentVersionResponse]
-> Read UpdateDocumentVersionResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [UpdateDocumentVersionResponse]
$creadListPrec :: ReadPrec [UpdateDocumentVersionResponse]
readPrec :: ReadPrec UpdateDocumentVersionResponse
$creadPrec :: ReadPrec UpdateDocumentVersionResponse
readList :: ReadS [UpdateDocumentVersionResponse]
$creadList :: ReadS [UpdateDocumentVersionResponse]
readsPrec :: Int -> ReadS UpdateDocumentVersionResponse
$creadsPrec :: Int -> ReadS UpdateDocumentVersionResponse
Prelude.Read, Int -> UpdateDocumentVersionResponse -> ShowS
[UpdateDocumentVersionResponse] -> ShowS
UpdateDocumentVersionResponse -> String
(Int -> UpdateDocumentVersionResponse -> ShowS)
-> (UpdateDocumentVersionResponse -> String)
-> ([UpdateDocumentVersionResponse] -> ShowS)
-> Show UpdateDocumentVersionResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDocumentVersionResponse] -> ShowS
$cshowList :: [UpdateDocumentVersionResponse] -> ShowS
show :: UpdateDocumentVersionResponse -> String
$cshow :: UpdateDocumentVersionResponse -> String
showsPrec :: Int -> UpdateDocumentVersionResponse -> ShowS
$cshowsPrec :: Int -> UpdateDocumentVersionResponse -> ShowS
Prelude.Show, (forall x.
 UpdateDocumentVersionResponse
 -> Rep UpdateDocumentVersionResponse x)
-> (forall x.
    Rep UpdateDocumentVersionResponse x
    -> UpdateDocumentVersionResponse)
-> Generic UpdateDocumentVersionResponse
forall x.
Rep UpdateDocumentVersionResponse x
-> UpdateDocumentVersionResponse
forall x.
UpdateDocumentVersionResponse
-> Rep UpdateDocumentVersionResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep UpdateDocumentVersionResponse x
-> UpdateDocumentVersionResponse
$cfrom :: forall x.
UpdateDocumentVersionResponse
-> Rep UpdateDocumentVersionResponse x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDocumentVersionResponse' 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.
newUpdateDocumentVersionResponse ::
  UpdateDocumentVersionResponse
newUpdateDocumentVersionResponse :: UpdateDocumentVersionResponse
newUpdateDocumentVersionResponse =
  UpdateDocumentVersionResponse
UpdateDocumentVersionResponse'

instance Prelude.NFData UpdateDocumentVersionResponse