使用亚马逊的 WorkDocs 示例 AWS CLI - AWS SDK代码示例

AWS 文档 AWS SDK示例 GitHub 存储库中还有更多SDK示例

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

使用亚马逊的 WorkDocs 示例 AWS CLI

以下代码示例向您展示如何在 Amazon 中使用来执行操作和实现常见场景 WorkDocs。 AWS Command Line Interface

操作是大型程序的代码摘录,必须在上下文中运行。您可以通过操作了解如何调用单个服务函数,还可以通过函数相关场景的上下文查看操作。

每个示例都包含一个指向完整源代码的链接,您可以在其中找到有关如何在上下文中设置和运行代码的说明。

主题

操作

以下代码示例演示如何使用 abort-document-version-upload

AWS CLI

停止上传文档版本

此示例停止先前启动的文档版本上传。

命令:

aws workdocs abort-document-version-upload --document-id feaba64d4efdf271c2521b60a2a44a8f057e84beaabbe22f01267313209835f2 --version-id 1536773972914-ddb67663e782e7ce8455ebc962217cf9f9e47b5a9a702e5c84dcccd417da9313

输出:

None

以下代码示例演示如何使用 activate-user

AWS CLI

激活用户

此示例激活了一个不活跃的用户。

命令:

aws workdocs activate-user --user-id "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c"

输出:

{ "User": { "Id": "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c", "Username": "exampleUser", "EmailAddress": "exampleUser@site.awsapps.com", "GivenName": "Example", "Surname": "User", "OrganizationId": "d-926726012c", "RootFolderId": "75f67c183aa1217409ac87576a45c03a5df5e6d8c51c35c01669970538e86cd0", "RecycleBinFolderId": "642b7dd3e60b14204534f3df7b1959e01b5d170f8c2707f410e40a8149120a57", "Status": "ACTIVE", "Type": "MINIMALUSER", "CreatedTimestamp": 1521226107.747, "ModifiedTimestamp": 1525297406.462, "Storage": { "StorageUtilizedInBytes": 0, "StorageRule": { "StorageAllocatedInBytes": 0, "StorageType": "QUOTA" } } } }

以下代码示例演示如何使用 add-resource-permissions

AWS CLI

为资源添加权限

此示例为指定委托人添加资源权限。

命令:

aws workdocs add-resource-permissions --resource-id d90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65 --principals Id=anonymous,Type=ANONYMOUS,Role=VIEWER

输出:

{ "ShareResults": [ { "PrincipalId": "anonymous", "Role": "VIEWER", "Status": "SUCCESS", "ShareId": "d90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65", "StatusMessage": "" } ] }

以下代码示例演示如何使用 create-comment

AWS CLI

添加新评论

此示例向指定的文档版本添加了新注释。

命令:

aws workdocs create-comment --document-id 15df51e0335cfcc6a2e4de9dd8be9f22ee40545ad9176f54758dcf903be982d3 --version-id 1521672507741-9f7df0ea5dd0b121c4f3564a0c7c0b4da95cd12c635d3c442af337a88e297920 --text "This is a comment."

输出:

{ "Comment": { "CommentId": "1534799058197-c7f5c84de9115875bbca93e0367bbebac609541d461636b760849b88b1609dd5", "ThreadId": "1534799058197-c7f5c84de9115875bbca93e0367bbebac609541d461636b760849b88b1609dd5", "Text": "This is a comment.", "Contributor": { "Id": "arn:aws:iam::123456789123:user/exampleUser", "Username": "exampleUser", "GivenName": "Example", "Surname": "User", "Status": "ACTIVE" }, "CreatedTimestamp": 1534799058.197, "Status": "PUBLISHED", "Visibility": "PUBLIC" } }

以下代码示例演示如何使用 create-custom-metadata

AWS CLI

创建自定义元数据

此示例为指定文档创建自定义元数据。

命令:

aws workdocs create-custom-metadata --resource-id d90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65 --custom-metadata KeyName1=example,KeyName2=example2

输出:

None

以下代码示例演示如何使用 create-folder

AWS CLI

创建文件夹

此示例创建了一个文件夹。

命令:

aws workdocs create-folder --name documents --parent-folder-id 1ece93e5fe75315c7407c4967918b4fd9da87ddb2a588e67b7fdaf4a98fde678

输出:

{ "Metadata": { "Id": "50893c0af679524d1a0e0651130ed6d073e1a05f95bd12c42dcde5d35634ed08", "Name": "documents", "CreatorId": "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c", "ParentFolderId": "1ece93e5fe75315c7407c4967918b4fd9da87ddb2a588e67b7fdaf4a98fde678", "CreatedTimestamp": 1534450467.622, "ModifiedTimestamp": 1534450467.622, "ResourceState": "ACTIVE", "Signature": "", "Size": 0, "LatestVersionSize": 0 } }

以下代码示例演示如何使用 create-labels

AWS CLI

创建标签

此示例为文档创建了一系列标签。

命令:

aws workdocs create-labels --resource-id d90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65 --labels "documents" "examples" "my_documents"

输出:

None

以下代码示例演示如何使用 create-notification-subscription

AWS CLI

创建通知订阅

以下create-notification-subscription示例为指定的 Amazon WorkDocs 组织配置通知订阅。

aws workdocs create-notification-subscription \ --organization-id d-123456789c \ --protocol HTTPS \ --subscription-type ALL \ --notification-endpoint "https://example.com/example"

输出:

{ "Subscription": { "SubscriptionId": "123ab4c5-678d-901e-f23g-45h6789j0123", "EndPoint": "https://example.com/example", "Protocol": "HTTPS" } }

有关更多信息,请参阅《Amazon WorkDocs 开发者指南》中的订阅通知

以下代码示例演示如何使用 create-user

AWS CLI

创建新用户

此示例在 Simple AD 或 Microsoft AD 目录中创建了一个新用户。

命令:

aws workdocs create-user --organization-id d-926726012c --username exampleUser2 --email-address exampleUser2@site.awsapps.com --given-name example2Name --surname example2Surname --password examplePa$$w0rd

输出:

{ "User": { "Id": "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c", "Username": "exampleUser2", "EmailAddress": "exampleUser2@site.awsapps.com", "GivenName": "example2Name", "Surname": "example2Surname", "OrganizationId": "d-926726012c", "RootFolderId": "35b886cb17198cbd547655e58b025dff0cf34aaed638be52009567e23dc67390", "RecycleBinFolderId": "9858c3e9ed4c2460dde9aadb4c69fde998070dd46e5e985bd08ec6169ea249ff", "Status": "ACTIVE", "Type": "MINIMALUSER", "CreatedTimestamp": 1535478836.584, "ModifiedTimestamp": 1535478836.584, "Storage": { "StorageUtilizedInBytes": 0, "StorageRule": { "StorageAllocatedInBytes": 0, "StorageType": "QUOTA" } } } }

以下代码示例演示如何使用 deactivate-user

AWS CLI

停用用户

此示例停用活跃用户。

命令:

aws workdocs deactivate-user --user-id "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c"

输出:

None

以下代码示例演示如何使用 delete-comment

AWS CLI

从文档版本中删除指定注释

此示例从指定文档版本中删除指定的注释。

命令:

aws workdocs delete-comment --document-id 15df51e0335cfcc6a2e4de9dd8be9f22ee40545ad9176f54758dcf903be982d3 --version-id 1521672507741-9f7df0ea5dd0b121c4f3564a0c7c0b4da95cd12c635d3c442af337a88e297920 --comment-id 1534799058197-c7f5c84de9115875bbca93e0367bbebac609541d461636b760849b88b1609dd5

输出:

None

以下代码示例演示如何使用 delete-custom-metadata

AWS CLI

从资源中删除自定义元数据

此示例从指定资源中删除所有自定义元数据。

命令:

aws workdocs delete-custom-metadata --resource-id d90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65 --delete-all

输出:

None

以下代码示例演示如何使用 delete-document

AWS CLI

删除文档

此示例删除了指定的文档。

命令:

aws workdocs delete-document --document-id b83ed5e5b167b65ef69de9d597627ff1a0d4f07a45e67f1fab7d26b54427de0a

输出:

None

以下代码示例演示如何使用 delete-folder-contents

AWS CLI

删除文件夹的内容

此示例删除指定文件夹的内容。

命令:

aws workdocs delete-folder-contents --folder-id 26fa8aa4ba2071447c194f7b150b07149dbdb9e1c8a301872dcd93a4735ce65d

输出:

None

以下代码示例演示如何使用 delete-folder

AWS CLI

删除文件夹

此示例删除了指定的文件夹。

命令:

aws workdocs delete-folder --folder-id 26fa8aa4ba2071447c194f7b150b07149dbdb9e1c8a301872dcd93a4735ce65d

输出:

None

以下代码示例演示如何使用 delete-labels

AWS CLI

删除标签

此示例从文档中删除指定的标签。

命令:

aws workdocs delete-labels --resource-id d90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65 --labels "documents" "examples"

输出:

None

以下代码示例演示如何使用 delete-notification-subscription

AWS CLI

删除通知订阅

以下delete-notification-subscription示例删除了指定的通知订阅。

aws workdocs delete-notification-subscription \ --subscription-id 123ab4c5-678d-901e-f23g-45h6789j0123 \ --organization-id d-123456789c

此命令不生成任何输出。

有关更多信息,请参阅《Amazon WorkDocs 开发者指南》中的订阅通知

以下代码示例演示如何使用 delete-user

AWS CLI

删除用户

此示例删除一个用户。

命令:

aws workdocs delete-user --user-id "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c"

输出:

None

以下代码示例演示如何使用 describe-activities

AWS CLI

获取用户活动列表

此示例返回指定组织的最新用户活动列表,并对最新的两个活动设置了限制。

命令:

aws workdocs describe-activities --organization-id d-926726012c --limit 2

输出:

{ "UserActivities": [ { "Type": "DOCUMENT_VERSION_DOWNLOADED", "TimeStamp": 1534800122.17, "Initiator": { "Id": "arn:aws:iam::123456789123:user/exampleUser" }, "ResourceMetadata": { "Type": "document", "Name": "updatedDoc", "Id": "15df51e0335cfcc6a2e4de9dd8be9f22ee40545ad9176f54758dcf903be982d3", "Owner": { "Id": "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c", "GivenName": "exampleName", "Surname": "exampleSurname" } } }, { "Type": "DOCUMENT_VERSION_VIEWED", "TimeStamp": 1534799079.207, "Initiator": { "Id": "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c", "GivenName": "exampleName", "Surname": "exampleSurname" }, "ResourceMetadata": { "Type": "document", "Name": "updatedDoc", "Id": "15df51e0335cfcc6a2e4de9dd8be9f22ee40545ad9176f54758dcf903be982d3", "Owner": { "Id": "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c", "GivenName": "exampleName", "Surname": "exampleSurname" } } } ], "Marker": "DnF1ZXJ5VGhlbkZldGNoAgAAAAAAAAS7FmlTaU1OdlFTU1h1UU00VVFIbDlRWHcAAAAAAAAJTRY3bWh5eUgzaVF1ZXN2RUE5Wm8tTTdR" }

以下代码示例演示如何使用 describe-comments

AWS CLI

列出指定文档版本的所有评论

此示例列出了指定文档版本的所有注释。

命令:

aws workdocs describe-comments --document-id 15df51e0335cfcc6a2e4de9dd8be9f22ee40545ad9176f54758dcf903be982d3 --version-id 1521672507741-9f7df0ea5dd0b121c4f3564a0c7c0b4da95cd12c635d3c442af337a88e297920

输出:

{ "Comments": [ { "CommentId": "1534799058197-c7f5c84de9115875bbca93e0367bbebac609541d461636b760849b88b1609dd5", "ThreadId": "1534799058197-c7f5c84de9115875bbca93e0367bbebac609541d461636b760849b88b1609dd5", "Text": "This is a comment.", "Contributor": { "Username": "arn:aws:iam::123456789123:user/exampleUser", "Type": "USER" }, "CreatedTimestamp": 1534799058.197, "Status": "PUBLISHED", "Visibility": "PUBLIC" } ] }

以下代码示例演示如何使用 describe-document-versions

AWS CLI

检索文档的版本

此示例检索指定文档的文档版本,包括初始化版本和源文档URL的。

命令:

aws workdocs describe-document-versions --document-id d90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65 --fields SOURCE

输出:

{ "DocumentVersions": [ { "Id": "1534452029587-15e129dfc187505c407588df255be83de2920d733859f1d2762411d22a83e3ef", "Name": "exampleDoc.docx", "ContentType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Size": 13922, "Signature": "1a23456b78901c23d4ef56gh7EXAMPLE", "Status": "ACTIVE", "CreatedTimestamp": 1534452029.587, "ModifiedTimestamp": 1534452029.849, "CreatorId": "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c", "Source": { "ORIGINAL": "https://gb-us-west-2-prod-doc-source.s3.us-west-2.amazonaws.com/d90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65/1534452029587-15e129dfc187505c407588df255be83de2920d733859f1d2762411d22a83e3ef?response-content-disposition=attachment%3B%20filename%2A%3DUTF-8%27%27exampleDoc29.docx&X-Amz-Algorithm=AWS1-ABCD-EFG234&X-Amz-Date=20180816T204149Z&X-Amz-SignedHeaders=host&X-Amz-Expires=900&X-Amz-Credential=AKIAIOSFODNN7EXAMPLE%2F20180816%2Fus-west-2%2Fs3%2Faws1_request&X-Amz-Signature=01Ab2c34d567e8f90123g456hi78j901k2345678l901234mno56pqr78EXAMPLE" } }, { "Id": "1529005196082-bb75fa19abc287699cb07147f75816dce43a53a10f28dc001bf61ef2fab01c59", "Name": "exampleDoc.pdf", "ContentType": "application/pdf", "Size": 425916, "Signature": "1a23456b78901c23d4ef56gh7EXAMPLE", "Status": "ACTIVE", "CreatedTimestamp": 1529005196.082, "ModifiedTimestamp": 1529005196.796, "CreatorId": "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c", "Source": { "ORIGINAL": "https://gb-us-west-2-prod-doc-source.s3.us-west-2.amazonaws.com/d90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65/1529005196082-bb75fa19abc287699cb07147f75816dce43a53a10f28dc001bf61ef2fab01c59?response-content-disposition=attachment%3B%20filename%2A%3DUTF-8%27%27exampleDoc29.pdf&X-Amz-Algorithm=AWS1-ABCD-EFG234&X-Amz-Date=20180816T204149Z&X-Amz-SignedHeaders=host&X-Amz-Expires=900&X-Amz-Credential=AKIAIOSFODNN7EXAMPLE%2F20180816%2Fus-west-2%2Fs3%2Faws1_request&X-Amz-Signature=01Ab2c34d567e8f90123g456hi78j901k2345678l901234mno56pqr78EXAMPLE" } } ] }

以下代码示例演示如何使用 describe-folder-contents

AWS CLI

描述文件夹的内容

此示例描述了按日期升序排序的指定文件夹(包括其文档和子文件夹)的所有活动内容。

命令:

aws workdocs describe-folder-contents --folder-id 1ece93e5fe75315c7407c4967918b4fd9da87ddb2a588e67b7fdaf4a98fde678 --sort DATE --order ASCENDING --type ALL

输出:

{ "Folders": [ { "Id": "50893c0af679524d1a0e0651130ed6d073e1a05f95bd12c42dcde5d35634ed08", "Name": "testing", "CreatorId": "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c", "ParentFolderId": "1ece93e5fe75315c7407c4967918b4fd9da87ddb2a588e67b7fdaf4a98fde678", "CreatedTimestamp": 1534450467.622, "ModifiedTimestamp": 1534451113.504, "ResourceState": "ACTIVE", "Signature": "1a23456b78901c23d4ef56gh7EXAMPLE", "Size": 23019, "LatestVersionSize": 11537 } ], "Documents": [ { "Id": "d90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65", "CreatorId": "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c", "ParentFolderId": "1ece93e5fe75315c7407c4967918b4fd9da87ddb2a588e67b7fdaf4a98fde678", "CreatedTimestamp": 1529005196.082, "ModifiedTimestamp": 1534452483.01, "LatestVersionMetadata": { "Id": "1534452029587-15e129dfc187505c407588df255be83de2920d733859f1d2762411d22a83e3ef", "Name": "exampleDoc.docx", "ContentType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Size": 13922, "Signature": "1a23456b78901c23d4ef56gh7EXAMPLE", "Status": "ACTIVE", "CreatedTimestamp": 1534452029.587, "ModifiedTimestamp": 1534452029.587, "CreatorId": "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c" }, "ResourceState": "ACTIVE" } ] }

以下代码示例演示如何使用 describe-groups

AWS CLI

检索群组列表

以下describe-groups示例列出了与指定 Amazon WorkDocs 组织关联的群组。

aws workdocs describe-groups \ --search-query "e" \ --organization-id d-123456789c

输出:

{ "Groups": [ { "Id": "S-1-1-11-1122222222-2222233333-3333334444-4444&d-123456789c", "Name": "Example Group 1" }, { "Id": "S-1-1-11-1122222222-2222233333-3333334444-5555&d-123456789c", "Name": "Example Group 2" } ] }

有关更多信息,请参阅《亚马逊 WorkDocs 管理指南》 WorkDocs中的 “亚马逊入门”。

以下代码示例演示如何使用 describe-notification-subscriptions

AWS CLI

检索通知订阅列表

以下describe-notification-subscriptions示例检索指定 Amazon WorkDocs 组织的通知订阅。

aws workdocs describe-notification-subscriptions \ --organization-id d-123456789c

输出:

{ "Subscriptions": [ { "SubscriptionId": "123ab4c5-678d-901e-f23g-45h6789j0123", "EndPoint": "https://example.com/example", "Protocol": "HTTPS" } ] }

有关更多信息,请参阅《Amazon WorkDocs 开发者指南》中的订阅通知

以下代码示例演示如何使用 describe-resource-permissions

AWS CLI

获取资源的权限列表

此示例返回指定资源(文档或文件夹)的权限列表。

命令:

aws workdocs describe-resource-permissions --resource-id 15df51e0335cfcc6a2e4de9dd8be9f22ee40545ad9176f54758dcf903be982d3

输出:

{ "Principals": [ { "Id": "anonymous", "Type": "ANONYMOUS", "Roles": [ { "Role": "VIEWER", "Type": "DIRECT" } ] }, { "Id": "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c", "Type": "USER", "Roles": [ { "Role": "OWNER", "Type": "DIRECT" } ] }, { "Id": "d-926726012c", "Type": "ORGANIZATION", "Roles": [ { "Role": "VIEWER", "Type": "INHERITED" } ] } ] }

以下代码示例演示如何使用 describe-users

AWS CLI

检索指定用户的详细信息

此示例检索指定组织中所有用户的详细信息。

命令:

aws workdocs describe-users --organization-id d-926726012c

输出:

{ "Users": [ { "Id": "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c", "Username": "example1User", "OrganizationId": "d-926726012c", "RootFolderId": "3c0e3f849dd20a9771d937b9bbcc97e18796150ae56c26d64a4fa0320a2dedc9", "RecycleBinFolderId": "c277f4c4d647be1f5147b3184ffa96e1e2bf708278b696cacba68ba13b91f4fe", "Status": "INACTIVE", "Type": "USER", "CreatedTimestamp": 1535478999.452, "ModifiedTimestamp": 1535478999.452 }, { "Id": "S-1-1-11-1111111111-2222222222-3333333333-4444&d-926726012c", "Username": "example2User", "EmailAddress": "example2User@site.awsapps.com", "GivenName": "example2Name", "Surname": "example2Surname", "OrganizationId": "d-926726012c", "RootFolderId": "35b886cb17198cbd547655e58b025dff0cf34aaed638be52009567e23dc67390", "RecycleBinFolderId": "9858c3e9ed4c2460dde9aadb4c69fde998070dd46e5e985bd08ec6169ea249ff", "Status": "ACTIVE", "Type": "MINIMALUSER", "CreatedTimestamp": 1535478836.584, "ModifiedTimestamp": 1535478836.584 } ] }

以下代码示例演示如何使用 get-document-path

AWS CLI

检索文档的路径信息

此示例检索指定文档的路径信息(根文件夹中的层次结构),并包括父文件夹的名称。

命令:

aws workdocs get-document-path --document-id d90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65 --fields NAME

输出:

{ "Path": { "Components": [ { "Id": "a43d29cbb8e7c4d25cfee8b803a504b0dc63e760b55ad0c611c6b87691eb6ff3", "Name": "/" }, { "Id": "1ece93e5fe75315c7407c4967918b4fd9da87ddb2a588e67b7fdaf4a98fde678", "Name": "Top Level Folder" }, { "Id": "d90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65", "Name": "exampleDoc.docx" } ] } }

以下代码示例演示如何使用 get-document-version

AWS CLI

检索指定文档的版本元数据

此示例检索指定文档的版本元数据,包括源URL和自定义元数据。

命令:

aws workdocs get-document-version --document-id 15df51e0335cfcc6a2e4de9dd8be9f22ee40545ad9176f54758dcf903be982d3 --version-id 1521672507741-9f7df0ea5dd0b121c4f3564a0c7c0b4da95cd12c635d3c442af337a88e297920 --fields SOURCE --include-custom-metadata

输出:

{ "Metadata": { "Id": "1521672507741-9f7df0ea5dd0b121c4f3564a0c7c0b4da95cd12c635d3c442af337a88e297920", "Name": "exampleDoc", "ContentType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Size": 11537, "Signature": "1a23456b78901c23d4ef56gh7EXAMPLE", "Status": "ACTIVE", "CreatedTimestamp": 1521672507.741, "ModifiedTimestamp": 1534451113.504, "CreatorId": "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c", "Source": { "ORIGINAL": "https://gb-us-west-2-prod-doc-source.s3.us-west-2.amazonaws.com/15df51e0335cfcc6a2e4de9dd8be9f22ee40545ad9176f54758dcf903be982d3/1521672507741-9f7df0ea5dd0b121c4f3564a0c7c0b4da95cd12c635d3c442af337a88e297920?response-content-disposition=attachment%3B%20filename%2A%3DUTF-8%27%27exampleDoc&X-Amz-Algorithm=AWS1-ABCD-EFG234&X-Amz-Date=20180820T212202Z&X-Amz-SignedHeaders=host&X-Amz-Expires=900&X-Amz-Credential=AKIAIOSFODNN7EXAMPLE%2F20180820%2Fus-west-2%2Fs3%2Faws1_request&X-Amz-Signature=01Ab2c34d567e8f90123g456hi78j901k2345678l901234mno56pqr78EXAMPLE" } } }

以下代码示例演示如何使用 get-document

AWS CLI

检索文档详细信息

此示例检索指定文档的详细信息。

命令:

aws workdocs get-document --document-id d90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65

输出:

{ "Metadata": { "Id": "d90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65", "CreatorId": "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c", "ParentFolderId": "1ece93e5fe75315c7407c4967918b4fd9da87ddb2a588e67b7fdaf4a98fde678", "CreatedTimestamp": 1529005196.082, "ModifiedTimestamp": 1534452483.01, "LatestVersionMetadata": { "Id": "1534452029587-15e129dfc187505c407588df255be83de2920d733859f1d2762411d22a83e3ef", "Name": "exampleDoc.docx", "ContentType": "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "Size": 13922, "Signature": "1a23456b78901c23d4ef56gh7EXAMPLE", "Status": "ACTIVE", "CreatedTimestamp": 1534452029.587, "ModifiedTimestamp": 1534452029.587, "CreatorId": "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c" }, "ResourceState": "ACTIVE" } }

以下代码示例演示如何使用 get-folder-path

AWS CLI

检索文件夹的路径信息

此示例检索指定文件夹的路径信息(根文件夹的层次结构),并包括父文件夹的名称。

命令:

aws workdocs get-folder-path --folder-id 50893c0af679524d1a0e0651130ed6d073e1a05f95bd12c42dcde5d35634ed08 --fields NAME

输出:

{ "Path": { "Components": [ { "Id": "a43d29cbb8e7c4d25cfee8b803a504b0dc63e760b55ad0c611c6b87691eb6ff3", "Name": "/" }, { "Id": "1ece93e5fe75315c7407c4967918b4fd9da87ddb2a588e67b7fdaf4a98fde678", "Name": "Top Level Folder" }, { "Id": "50893c0af679524d1a0e0651130ed6d073e1a05f95bd12c42dcde5d35634ed08", "Name": "Sublevel Folder" } ] } }

以下代码示例演示如何使用 get-folder

AWS CLI

检索文件夹的元数据

此示例检索指定文件夹的元数据。

命令:

aws workdocs get-folder --folder-id 50893c0af679524d1a0e0651130ed6d073e1a05f95bd12c42dcde5d35634ed08

输出:

{ "Metadata": { "Id": "50893c0af679524d1a0e0651130ed6d073e1a05f95bd12c42dcde5d35634ed08", "Name": "exampleFolder", "CreatorId": "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c", "ParentFolderId": "1ece93e5fe75315c7407c4967918b4fd9da87ddb2a588e67b7fdaf4a98fde678", "CreatedTimestamp": 1534450467.622, "ModifiedTimestamp": 1534451113.504, "ResourceState": "ACTIVE", "Signature": "1a23456b78901c23d4ef56gh7EXAMPLE", "Size": 23019, "LatestVersionSize": 11537 } }

以下代码示例演示如何使用 get-resources

AWS CLI

检索共享资源

以下get-resources示例检索与指定 Amazon WorkDocs 用户共享的资源。

aws workdocs get-resources \ --user-id "S-1-1-11-1111111111-2222222222-3333333333-3333" \ --collection-type SHARED_WITH_ME

输出:

{ "Folders": [], "Documents": [] }

有关更多信息,请参阅 Amazon WorkDocs 用户指南中的共享文件和文件夹

以下代码示例演示如何使用 initiate-document-version-upload

AWS CLI

启动文档版本上传

以下initiate-document-upload示例创建了一个新的文档对象和版本对象。

aws workdocs initiate-document-version-upload \ --name exampledocname \ --parent-folder-id eacd546d952531c633452ed67cac23161aa0d5df2e8061223a59e8f67e7b6189

输出:

{ "Metadata": { "Id": "feaba64d4efdf271c2521b60a2a44a8f057e84beaabbe22f01267313209835f2", "CreatorId": "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c", "ParentFolderId": "eacd546d952531c633452ed67cac23161aa0d5df2e8061223a59e8f67e7b6189", "CreatedTimestamp": 1536773972.914, "ModifiedTimestamp": 1536773972.914, "LatestVersionMetadata": { "Id": "1536773972914-ddb67663e782e7ce8455ebc962217cf9f9e47b5a9a702e5c84dcccd417da9313", "Name": "exampledocname", "ContentType": "application/octet-stream", "Size": 0, "Status": "INITIALIZED", "CreatedTimestamp": 1536773972.914, "ModifiedTimestamp": 1536773972.914, "CreatorId": "arn:aws:iam::123456789123:user/EXAMPLE" }, "ResourceState": "ACTIVE" }, "UploadMetadata": { "UploadUrl": "https://gb-us-west-2-prod-doc-source.s3.us-west-2.amazonaws.com/feaba64d4efdf271c2521b60a2a44a8f057e84beaabbe22f01267313209835f2/1536773972914-ddb67663e782e7ce8455ebc962217cf9f9e47b5a9a702e5c84dcccd417da9313?X-Amz-Algorithm=AWS1-ABCD-EFG234&X-Amz-Date=20180912T173932Z&X-Amz-SignedHeaders=content-type%3Bhost%3Bx-amz-server-side-encryption&X-Amz-Expires=899&X-Amz-Credential=AKIAIOSFODNN7EXAMPLE%2F20180912%2Fus-west-2%2Fs3%2Faws1_request&X-Amz-Signature=01Ab2c34d567e8f90123g456hi78j901k2345678l901234mno56pqr78EXAMPLE", "SignedHeaders": { "Content-Type": "application/octet-stream", "x-amz-server-side-encryption": "ABC123" } } }

以下代码示例演示如何使用 remove-all-resource-permissions

AWS CLI

移除指定资源的所有权限

此示例从指定资源中删除所有权限。

命令:

aws workdocs remove-all-resource-permissions --resource-id 1ece93e5fe75315c7407c4967918b4fd9da87ddb2a588e67b7fdaf4a98fde678

输出:

None

以下代码示例演示如何使用 remove-resource-permission

AWS CLI

从资源中移除权限

此示例从资源中删除指定委托人的权限。

命令:

aws workdocs remove-resource-permission --resource-id 1ece93e5fe75315c7407c4967918b4fd9da87ddb2a588e67b7fdaf4a98fde678 --principal-id anonymous

输出:

None

以下代码示例演示如何使用 update-document-version

AWS CLI

将文档版本状态更改为 “活动”

此示例将文档版本的状态更改为 “活动”。

命令:

aws workdocs update-document-version --document-id 15df51e0335cfcc6a2e4de9dd8be9f22ee40545ad9176f54758dcf903be982d3 --version-id 1521672507741-9f7df0ea5dd0b121c4f3564a0c7c0b4da95cd12c635d3c442af337a88e297920 --version-status ACTIVE

输出:

None

以下代码示例演示如何使用 update-document

AWS CLI

更新文档

此示例更新文档的名称和父文件夹。

命令:

aws workdocs update-document --document-id 15df51e0335cfcc6a2e4de9dd8be9f22ee40545ad9176f54758dcf903be982d3 --name updatedDoc --parent-folder-id 50893c0af679524d1a0e0651130ed6d073e1a05f95bd12c42dcde5d35634ed08

输出:

None

以下代码示例演示如何使用 update-folder

AWS CLI

更新文件夹

此示例更新了文件夹的名称和父文件夹。

命令:

aws workdocs update-folder --folder-id 50893c0af679524d1a0e0651130ed6d073e1a05f95bd12c42dcde5d35634ed08 --name exampleFolder1 --parent-folder-id 1ece93e5fe75315c7407c4967918b4fd9da87ddb2a588e67b7fdaf4a98fde678

输出:

None

以下代码示例演示如何使用 update-user

AWS CLI

更新用户

此示例更新了指定用户的时区。

命令:

aws workdocs update-user --user-id "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c" --time-zone-id "America/Los_Angeles"

输出:

{ "User": { "Id": "S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c", "Username": "exampleUser", "EmailAddress": "exampleUser@site.awsapps.com", "GivenName": "Example", "Surname": "User", "OrganizationId": "d-926726012c", "RootFolderId": "c5eceb5e1a2d1d460c9d1af8330ae117fc8d39bb1d3ed6acd0992d5ff192d986", "RecycleBinFolderId": "6ca20102926ad15f04b1d248d6d6e44f2449944eda5c758f9a1e9df6a6b7fa66", "Status": "ACTIVE", "Type": "USER", "TimeZoneId": "America/Los_Angeles", "Storage": { "StorageUtilizedInBytes": 0, "StorageRule": { "StorageAllocatedInBytes": 53687091200, "StorageType": "QUOTA" } } } }