{-# 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-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)
--
-- 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_parentFolderId,
    updateDocument_authenticationToken,
    updateDocument_name,
    updateDocument_resourceState,
    updateDocument_documentId,

    -- * Destructuring the Response
    UpdateDocumentResponse (..),
    newUpdateDocumentResponse,
  )
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:/ 'newUpdateDocument' smart constructor.
data UpdateDocument = UpdateDocument'
  { -- | The ID of the parent folder.
    UpdateDocument -> Maybe Text
parentFolderId :: Prelude.Maybe Prelude.Text,
    -- | Amazon WorkDocs authentication token. Not required when using AWS
    -- administrator credentials to access the API.
    UpdateDocument -> Maybe (Sensitive Text)
authenticationToken :: Prelude.Maybe (Core.Sensitive Prelude.Text),
    -- | The name of the document.
    UpdateDocument -> Maybe Text
name :: 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
(UpdateDocument -> UpdateDocument -> Bool)
-> (UpdateDocument -> UpdateDocument -> Bool) -> Eq UpdateDocument
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
(Int -> UpdateDocument -> ShowS)
-> (UpdateDocument -> String)
-> ([UpdateDocument] -> ShowS)
-> Show UpdateDocument
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. UpdateDocument -> Rep UpdateDocument x)
-> (forall x. Rep UpdateDocument x -> UpdateDocument)
-> Generic UpdateDocument
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:
--
-- 'parentFolderId', 'updateDocument_parentFolderId' - The ID of the parent folder.
--
-- '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.
--
-- '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' :: Maybe Text
-> Maybe (Sensitive Text)
-> Maybe Text
-> Maybe ResourceStateType
-> Text
-> UpdateDocument
UpdateDocument'
    { $sel:parentFolderId:UpdateDocument' :: Maybe Text
parentFolderId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:authenticationToken:UpdateDocument' :: Maybe (Sensitive Text)
authenticationToken = Maybe (Sensitive Text)
forall a. Maybe a
Prelude.Nothing,
      $sel:name:UpdateDocument' :: Maybe Text
name = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:resourceState:UpdateDocument' :: Maybe ResourceStateType
resourceState = Maybe ResourceStateType
forall a. Maybe a
Prelude.Nothing,
      $sel:documentId:UpdateDocument' :: Text
documentId = Text
pDocumentId_
    }

-- | The ID of the parent folder.
updateDocument_parentFolderId :: Lens.Lens' UpdateDocument (Prelude.Maybe Prelude.Text)
updateDocument_parentFolderId :: (Maybe Text -> f (Maybe Text))
-> UpdateDocument -> f UpdateDocument
updateDocument_parentFolderId = (UpdateDocument -> Maybe Text)
-> (UpdateDocument -> Maybe Text -> UpdateDocument)
-> Lens UpdateDocument UpdateDocument (Maybe Text) (Maybe Text)
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)

-- | 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 :: (Maybe Text -> f (Maybe Text))
-> UpdateDocument -> f UpdateDocument
updateDocument_authenticationToken = (UpdateDocument -> Maybe (Sensitive Text))
-> (UpdateDocument -> Maybe (Sensitive Text) -> UpdateDocument)
-> Lens
     UpdateDocument
     UpdateDocument
     (Maybe (Sensitive Text))
     (Maybe (Sensitive Text))
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) ((Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
 -> UpdateDocument -> f UpdateDocument)
-> ((Maybe Text -> f (Maybe Text))
    -> Maybe (Sensitive Text) -> f (Maybe (Sensitive Text)))
-> (Maybe Text -> f (Maybe Text))
-> UpdateDocument
-> f UpdateDocument
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 name of the document.
updateDocument_name :: Lens.Lens' UpdateDocument (Prelude.Maybe Prelude.Text)
updateDocument_name :: (Maybe Text -> f (Maybe Text))
-> UpdateDocument -> f UpdateDocument
updateDocument_name = (UpdateDocument -> Maybe Text)
-> (UpdateDocument -> Maybe Text -> UpdateDocument)
-> Lens UpdateDocument UpdateDocument (Maybe Text) (Maybe Text)
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 resource state of the document. Only ACTIVE and RECYCLED are
-- supported.
updateDocument_resourceState :: Lens.Lens' UpdateDocument (Prelude.Maybe ResourceStateType)
updateDocument_resourceState :: (Maybe ResourceStateType -> f (Maybe ResourceStateType))
-> UpdateDocument -> f UpdateDocument
updateDocument_resourceState = (UpdateDocument -> Maybe ResourceStateType)
-> (UpdateDocument -> Maybe ResourceStateType -> UpdateDocument)
-> Lens
     UpdateDocument
     UpdateDocument
     (Maybe ResourceStateType)
     (Maybe ResourceStateType)
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 :: (Text -> f Text) -> UpdateDocument -> f UpdateDocument
updateDocument_documentId = (UpdateDocument -> Text)
-> (UpdateDocument -> Text -> UpdateDocument)
-> Lens UpdateDocument UpdateDocument Text Text
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 :: UpdateDocument -> Request UpdateDocument
request = Service -> UpdateDocument -> Request UpdateDocument
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.patchJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy UpdateDocument
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateDocument)))
response =
    AWSResponse UpdateDocument
-> Logger
-> Service
-> Proxy UpdateDocument
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse UpdateDocument)))
forall (m :: * -> *) a.
MonadResource m =>
AWSResponse a
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveNull AWSResponse UpdateDocument
UpdateDocumentResponse
UpdateDocumentResponse'

instance Prelude.Hashable UpdateDocument

instance Prelude.NFData UpdateDocument

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

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

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

-- | /See:/ 'newUpdateDocumentResponse' smart constructor.
data UpdateDocumentResponse = UpdateDocumentResponse'
  {
  }
  deriving (UpdateDocumentResponse -> UpdateDocumentResponse -> Bool
(UpdateDocumentResponse -> UpdateDocumentResponse -> Bool)
-> (UpdateDocumentResponse -> UpdateDocumentResponse -> Bool)
-> Eq UpdateDocumentResponse
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]
(Int -> ReadS UpdateDocumentResponse)
-> ReadS [UpdateDocumentResponse]
-> ReadPrec UpdateDocumentResponse
-> ReadPrec [UpdateDocumentResponse]
-> Read 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
(Int -> UpdateDocumentResponse -> ShowS)
-> (UpdateDocumentResponse -> String)
-> ([UpdateDocumentResponse] -> ShowS)
-> Show UpdateDocumentResponse
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. UpdateDocumentResponse -> Rep UpdateDocumentResponse x)
-> (forall x.
    Rep UpdateDocumentResponse x -> UpdateDocumentResponse)
-> Generic UpdateDocumentResponse
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