{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.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
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 (Data.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
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
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. 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'
    { $sel:authenticationToken:UpdateDocumentVersion' :: Maybe (Sensitive Text)
authenticationToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:versionStatus:UpdateDocumentVersion' :: Maybe DocumentVersionStatus
versionStatus = 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 :: Lens' UpdateDocumentVersion (Maybe Text)
updateDocumentVersion_authenticationToken = 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) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | The status of the version.
updateDocumentVersion_versionStatus :: Lens.Lens' UpdateDocumentVersion (Prelude.Maybe DocumentVersionStatus)
updateDocumentVersion_versionStatus :: Lens' UpdateDocumentVersion (Maybe DocumentVersionStatus)
updateDocumentVersion_versionStatus = 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 :: Lens' UpdateDocumentVersion Text
updateDocumentVersion_documentId = 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 :: Lens' UpdateDocumentVersion Text
updateDocumentVersion_versionId = 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 :: (Service -> Service)
-> UpdateDocumentVersion -> Request UpdateDocumentVersion
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy UpdateDocumentVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse UpdateDocumentVersion)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull UpdateDocumentVersionResponse
UpdateDocumentVersionResponse'

instance Prelude.Hashable UpdateDocumentVersion where
  hashWithSalt :: Int -> UpdateDocumentVersion -> Int
hashWithSalt Int
_salt 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)
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe (Sensitive Text)
authenticationToken
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe DocumentVersionStatus
versionStatus
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
documentId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
versionId

instance Prelude.NFData UpdateDocumentVersion where
  rnf :: UpdateDocumentVersion -> ()
rnf 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)
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe (Sensitive Text)
authenticationToken
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe DocumentVersionStatus
versionStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
documentId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
versionId

instance Data.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)
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ HeaderName
"Authentication" forall a. ToHeader a => HeaderName -> a -> [Header]
Data.=# Maybe (Sensitive Text)
authenticationToken,
        HeaderName
"Content-Type"
          forall a. ToHeader a => HeaderName -> a -> [Header]
Data.=# (ByteString
"application/x-amz-json-1.1" :: Prelude.ByteString)
      ]

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"VersionStatus" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=)
              forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe DocumentVersionStatus
versionStatus
          ]
      )

instance Data.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)
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/api/v1/documents/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
documentId,
        ByteString
"/versions/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
versionId
      ]

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

-- | /See:/ 'newUpdateDocumentVersionResponse' smart constructor.
data UpdateDocumentVersionResponse = UpdateDocumentVersionResponse'
  {
  }
  deriving (UpdateDocumentVersionResponse
-> UpdateDocumentVersionResponse -> Bool
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]
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
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.
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 where
  rnf :: UpdateDocumentVersionResponse -> ()
rnf UpdateDocumentVersionResponse
_ = ()