{-# 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.UpdateDocument
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Updates the specified attributes of a document. The user must have
-- access to both the document and its parent folder, if applicable.
module Amazonka.WorkDocs.UpdateDocument
  ( -- * Creating a Request
    UpdateDocument (..),
    newUpdateDocument,

    -- * Request Lenses
    updateDocument_authenticationToken,
    updateDocument_name,
    updateDocument_parentFolderId,
    updateDocument_resourceState,
    updateDocument_documentId,

    -- * Destructuring the Response
    UpdateDocumentResponse (..),
    newUpdateDocumentResponse,
  )
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:/ 'newUpdateDocument' smart constructor.
data UpdateDocument = UpdateDocument'
  { -- | Amazon WorkDocs authentication token. Not required when using AWS
    -- administrator credentials to access the API.
    UpdateDocument -> Maybe (Sensitive Text)
authenticationToken :: Prelude.Maybe (Data.Sensitive Prelude.Text),
    -- | The name of the document.
    UpdateDocument -> Maybe Text
name :: Prelude.Maybe Prelude.Text,
    -- | The ID of the parent folder.
    UpdateDocument -> Maybe Text
parentFolderId :: Prelude.Maybe Prelude.Text,
    -- | The resource state of the document. Only ACTIVE and RECYCLED are
    -- supported.
    UpdateDocument -> Maybe ResourceStateType
resourceState :: Prelude.Maybe ResourceStateType,
    -- | The ID of the document.
    UpdateDocument -> Text
documentId :: Prelude.Text
  }
  deriving (UpdateDocument -> UpdateDocument -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: UpdateDocument -> UpdateDocument -> Bool
$c/= :: UpdateDocument -> UpdateDocument -> Bool
== :: UpdateDocument -> UpdateDocument -> Bool
$c== :: UpdateDocument -> UpdateDocument -> Bool
Prelude.Eq, Int -> UpdateDocument -> ShowS
[UpdateDocument] -> ShowS
UpdateDocument -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [UpdateDocument] -> ShowS
$cshowList :: [UpdateDocument] -> ShowS
show :: UpdateDocument -> String
$cshow :: UpdateDocument -> String
showsPrec :: Int -> UpdateDocument -> ShowS
$cshowsPrec :: Int -> UpdateDocument -> ShowS
Prelude.Show, forall x. Rep UpdateDocument x -> UpdateDocument
forall x. UpdateDocument -> Rep UpdateDocument x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep UpdateDocument x -> UpdateDocument
$cfrom :: forall x. UpdateDocument -> Rep UpdateDocument x
Prelude.Generic)

-- |
-- Create a value of 'UpdateDocument' 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', 'updateDocument_authenticationToken' - Amazon WorkDocs authentication token. Not required when using AWS
-- administrator credentials to access the API.
--
-- 'name', 'updateDocument_name' - The name of the document.
--
-- 'parentFolderId', 'updateDocument_parentFolderId' - The ID of the parent folder.
--
-- 'resourceState', 'updateDocument_resourceState' - The resource state of the document. Only ACTIVE and RECYCLED are
-- supported.
--
-- 'documentId', 'updateDocument_documentId' - The ID of the document.
newUpdateDocument ::
  -- | 'documentId'
  Prelude.Text ->
  UpdateDocument
newUpdateDocument :: Text -> UpdateDocument
newUpdateDocument Text
pDocumentId_ =
  UpdateDocument'
    { $sel:authenticationToken:UpdateDocument' :: Maybe (Sensitive Text)
authenticationToken =
        forall a. Maybe a
Prelude.Nothing,
      $sel:name:UpdateDocument' :: Maybe Text
name = forall a. Maybe a
Prelude.Nothing,
      $sel:parentFolderId:UpdateDocument' :: Maybe Text
parentFolderId = forall a. Maybe a
Prelude.Nothing,
      $sel:resourceState:UpdateDocument' :: Maybe ResourceStateType
resourceState = forall a. Maybe a
Prelude.Nothing,
      $sel:documentId:UpdateDocument' :: Text
documentId = Text
pDocumentId_
    }

-- | Amazon WorkDocs authentication token. Not required when using AWS
-- administrator credentials to access the API.
updateDocument_authenticationToken :: Lens.Lens' UpdateDocument (Prelude.Maybe Prelude.Text)
updateDocument_authenticationToken :: Lens' UpdateDocument (Maybe Text)
updateDocument_authenticationToken = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDocument' {Maybe (Sensitive Text)
authenticationToken :: Maybe (Sensitive Text)
$sel:authenticationToken:UpdateDocument' :: UpdateDocument -> Maybe (Sensitive Text)
authenticationToken} -> Maybe (Sensitive Text)
authenticationToken) (\s :: UpdateDocument
s@UpdateDocument' {} Maybe (Sensitive Text)
a -> UpdateDocument
s {$sel:authenticationToken:UpdateDocument' :: Maybe (Sensitive Text)
authenticationToken = Maybe (Sensitive Text)
a} :: UpdateDocument) 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 name of the document.
updateDocument_name :: Lens.Lens' UpdateDocument (Prelude.Maybe Prelude.Text)
updateDocument_name :: Lens' UpdateDocument (Maybe Text)
updateDocument_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDocument' {Maybe Text
name :: Maybe Text
$sel:name:UpdateDocument' :: UpdateDocument -> Maybe Text
name} -> Maybe Text
name) (\s :: UpdateDocument
s@UpdateDocument' {} Maybe Text
a -> UpdateDocument
s {$sel:name:UpdateDocument' :: Maybe Text
name = Maybe Text
a} :: UpdateDocument)

-- | The ID of the parent folder.
updateDocument_parentFolderId :: Lens.Lens' UpdateDocument (Prelude.Maybe Prelude.Text)
updateDocument_parentFolderId :: Lens' UpdateDocument (Maybe Text)
updateDocument_parentFolderId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDocument' {Maybe Text
parentFolderId :: Maybe Text
$sel:parentFolderId:UpdateDocument' :: UpdateDocument -> Maybe Text
parentFolderId} -> Maybe Text
parentFolderId) (\s :: UpdateDocument
s@UpdateDocument' {} Maybe Text
a -> UpdateDocument
s {$sel:parentFolderId:UpdateDocument' :: Maybe Text
parentFolderId = Maybe Text
a} :: UpdateDocument)

-- | The resource state of the document. Only ACTIVE and RECYCLED are
-- supported.
updateDocument_resourceState :: Lens.Lens' UpdateDocument (Prelude.Maybe ResourceStateType)
updateDocument_resourceState :: Lens' UpdateDocument (Maybe ResourceStateType)
updateDocument_resourceState = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\UpdateDocument' {Maybe ResourceStateType
resourceState :: Maybe ResourceStateType
$sel:resourceState:UpdateDocument' :: UpdateDocument -> Maybe ResourceStateType
resourceState} -> Maybe ResourceStateType
resourceState) (\s :: UpdateDocument
s@UpdateDocument' {} Maybe ResourceStateType
a -> UpdateDocument
s {$sel:resourceState:UpdateDocument' :: Maybe ResourceStateType
resourceState = Maybe ResourceStateType
a} :: UpdateDocument)

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

instance Core.AWSRequest UpdateDocument where
  type
    AWSResponse UpdateDocument =
      UpdateDocumentResponse
  request :: (Service -> Service) -> UpdateDocument -> Request UpdateDocument
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 UpdateDocument
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateDocument)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull UpdateDocumentResponse
UpdateDocumentResponse'

instance Prelude.Hashable UpdateDocument where
  hashWithSalt :: Int -> UpdateDocument -> Int
hashWithSalt Int
_salt UpdateDocument' {Maybe Text
Maybe (Sensitive Text)
Maybe ResourceStateType
Text
documentId :: Text
resourceState :: Maybe ResourceStateType
parentFolderId :: Maybe Text
name :: Maybe Text
authenticationToken :: Maybe (Sensitive Text)
$sel:documentId:UpdateDocument' :: UpdateDocument -> Text
$sel:resourceState:UpdateDocument' :: UpdateDocument -> Maybe ResourceStateType
$sel:parentFolderId:UpdateDocument' :: UpdateDocument -> Maybe Text
$sel:name:UpdateDocument' :: UpdateDocument -> Maybe Text
$sel:authenticationToken:UpdateDocument' :: UpdateDocument -> 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 Text
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
parentFolderId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe ResourceStateType
resourceState
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
documentId

instance Prelude.NFData UpdateDocument where
  rnf :: UpdateDocument -> ()
rnf UpdateDocument' {Maybe Text
Maybe (Sensitive Text)
Maybe ResourceStateType
Text
documentId :: Text
resourceState :: Maybe ResourceStateType
parentFolderId :: Maybe Text
name :: Maybe Text
authenticationToken :: Maybe (Sensitive Text)
$sel:documentId:UpdateDocument' :: UpdateDocument -> Text
$sel:resourceState:UpdateDocument' :: UpdateDocument -> Maybe ResourceStateType
$sel:parentFolderId:UpdateDocument' :: UpdateDocument -> Maybe Text
$sel:name:UpdateDocument' :: UpdateDocument -> Maybe Text
$sel:authenticationToken:UpdateDocument' :: UpdateDocument -> 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 Text
name
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
parentFolderId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe ResourceStateType
resourceState
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
documentId

instance Data.ToHeaders UpdateDocument where
  toHeaders :: UpdateDocument -> [Header]
toHeaders UpdateDocument' {Maybe Text
Maybe (Sensitive Text)
Maybe ResourceStateType
Text
documentId :: Text
resourceState :: Maybe ResourceStateType
parentFolderId :: Maybe Text
name :: Maybe Text
authenticationToken :: Maybe (Sensitive Text)
$sel:documentId:UpdateDocument' :: UpdateDocument -> Text
$sel:resourceState:UpdateDocument' :: UpdateDocument -> Maybe ResourceStateType
$sel:parentFolderId:UpdateDocument' :: UpdateDocument -> Maybe Text
$sel:name:UpdateDocument' :: UpdateDocument -> Maybe Text
$sel:authenticationToken:UpdateDocument' :: UpdateDocument -> 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 UpdateDocument where
  toJSON :: UpdateDocument -> Value
toJSON UpdateDocument' {Maybe Text
Maybe (Sensitive Text)
Maybe ResourceStateType
Text
documentId :: Text
resourceState :: Maybe ResourceStateType
parentFolderId :: Maybe Text
name :: Maybe Text
authenticationToken :: Maybe (Sensitive Text)
$sel:documentId:UpdateDocument' :: UpdateDocument -> Text
$sel:resourceState:UpdateDocument' :: UpdateDocument -> Maybe ResourceStateType
$sel:parentFolderId:UpdateDocument' :: UpdateDocument -> Maybe Text
$sel:name:UpdateDocument' :: UpdateDocument -> Maybe Text
$sel:authenticationToken:UpdateDocument' :: UpdateDocument -> Maybe (Sensitive Text)
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Name" 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 Text
name,
            (Key
"ParentFolderId" 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 Text
parentFolderId,
            (Key
"ResourceState" 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 ResourceStateType
resourceState
          ]
      )

instance Data.ToPath UpdateDocument where
  toPath :: UpdateDocument -> ByteString
toPath UpdateDocument' {Maybe Text
Maybe (Sensitive Text)
Maybe ResourceStateType
Text
documentId :: Text
resourceState :: Maybe ResourceStateType
parentFolderId :: Maybe Text
name :: Maybe Text
authenticationToken :: Maybe (Sensitive Text)
$sel:documentId:UpdateDocument' :: UpdateDocument -> Text
$sel:resourceState:UpdateDocument' :: UpdateDocument -> Maybe ResourceStateType
$sel:parentFolderId:UpdateDocument' :: UpdateDocument -> Maybe Text
$sel:name:UpdateDocument' :: UpdateDocument -> Maybe Text
$sel:authenticationToken:UpdateDocument' :: UpdateDocument -> 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]

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

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

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

instance Prelude.NFData UpdateDocumentResponse where
  rnf :: UpdateDocumentResponse -> ()
rnf UpdateDocumentResponse
_ = ()