WorkDocs examples using AWS CLI
The following code examples show you how to perform actions and implement common scenarios by using the AWS Command Line Interface with WorkDocs.
Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.
Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.
Topics
Actions
The following code example shows how to use abort-document-version-upload.
- AWS CLI
-
To stop a document version upload
The following
abort-document-version-uploadexample stops a previously initiated document version upload.aws workdocs abort-document-version-upload \ --document-idfeaba64d4efdf271c2521b60a2a44a8f057e84beaabbe22f01267313209835f2\ --version-id1536773972914-ddb67663e782e7ce8455ebc962217cf9f9e47b5a9a702e5c84dcccd417da9313This command produces no output.
-
For API details, see AbortDocumentVersionUpload
in AWS CLI Command Reference.
-
The following code example shows how to use activate-user.
- AWS CLI
-
To activate a user
The following
activate-userexample activates an inactive user.aws workdocs activate-user \ --user-id"S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c"Output:
{ "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" } } } }-
For API details, see ActivateUser
in AWS CLI Command Reference.
-
The following code example shows how to use add-resource-permissions.
- AWS CLI
-
To add permissions for a resource
The following
add-resource-permissionsexample adds permissions to the resource for the specified principals.aws workdocs add-resource-permissions \ --resource-idd90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65\ --principalsId=anonymous,Type=ANONYMOUS,Role=VIEWEROutput:
{ "ShareResults": [ { "PrincipalId": "anonymous", "Role": "VIEWER", "Status": "SUCCESS", "ShareId": "d90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65", "StatusMessage": "" } ] }-
For API details, see AddResourcePermissions
in AWS CLI Command Reference.
-
The following code example shows how to use create-comment.
- AWS CLI
-
To add a new comment
The following
create-commentexample adds a new comment to the specified document version.aws workdocs create-comment \ --document-id15df51e0335cfcc6a2e4de9dd8be9f22ee40545ad9176f54758dcf903be982d3\ --version-id1521672507741-9f7df0ea5dd0b121c4f3564a0c7c0b4da95cd12c635d3c442af337a88e297920\ --text"This is a comment."Output:
{ "Comment": { "CommentId": "1534799058197-c7f5c84de9115875bbca93e0367bbebac609541d461636b760849b88b1609dd5", "ThreadId": "1534799058197-c7f5c84de9115875bbca93e0367bbebac609541d461636b760849b88b1609dd5", "Text": "This is a comment.", "Contributor": { "Id": "arn:aws:iam::123456789012:user/exampleUser", "Username": "exampleUser", "GivenName": "Example", "Surname": "User", "Status": "ACTIVE" }, "CreatedTimestamp": 1534799058.197, "Status": "PUBLISHED", "Visibility": "PUBLIC" } }-
For API details, see CreateComment
in AWS CLI Command Reference.
-
The following code example shows how to use create-custom-metadata.
- AWS CLI
-
To create custom metadata
The following
create-custom-metadataexample creates custom metadata for the specified document.aws workdocs create-custom-metadata \ --resource-idd90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65\ --custom-metadataKeyName1=example,KeyName2=example2This command produces no output.
-
For API details, see CreateCustomMetadata
in AWS CLI Command Reference.
-
The following code example shows how to use create-folder.
- AWS CLI
-
To create a folder
The following
create-folderexample creates a folder.aws workdocs create-folder \ --namedocuments\ --parent-folder-id1ece93e5fe75315c7407c4967918b4fd9da87ddb2a588e67b7fdaf4a98fde678Output:
{ "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 } }-
For API details, see CreateFolder
in AWS CLI Command Reference.
-
The following code example shows how to use create-labels.
- AWS CLI
-
To create labels
The following
create-labelsexample creates a series of labels for a document.aws workdocs create-labels \ --resource-idd90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65\ --labels"documents""examples""my_documents"This command produces no output.
-
For API details, see CreateLabels
in AWS CLI Command Reference.
-
The following code example shows how to use create-notification-subscription.
- AWS CLI
-
To create a notification subscription
The following
create-notification-subscriptionexample configures a notification subscription for the specified Amazon WorkDocs organization.aws workdocs create-notification-subscription \ --organization-idd-123456789c\ --protocolHTTPS\ --subscription-typeALL\ --notification-endpoint"https://example.com/example"Output:
{ "Subscription": { "SubscriptionId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "EndPoint": "https://example.com/example", "Protocol": "HTTPS" } }-
For API details, see CreateNotificationSubscription
in AWS CLI Command Reference.
-
The following code example shows how to use create-user.
- AWS CLI
-
To create a new user
The following
create-userexample creates a new user in a Simple AD or Microsoft AD directory.aws workdocs create-user \ --organization-idd-926726012c\ --usernameexampleUser2\ --email-addressexampleUser2@site.awsapps.com\ --given-nameexample2Name\ --surnameexample2Surname\ --passwordexamplePa$$w0rdOutput:
{ "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" } } } }-
For API details, see CreateUser
in AWS CLI Command Reference.
-
The following code example shows how to use deactivate-user.
- AWS CLI
-
To deactivate a user
The following
deactivate-userexample deactivates an active user.aws workdocs deactivate-user \ --user-id"S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c"This command produces no output.
-
For API details, see DeactivateUser
in AWS CLI Command Reference.
-
The following code example shows how to use delete-comment.
- AWS CLI
-
To delete a specified comment from a document version
The following
delete-commentexample deletes the specified comment from the specified document version.aws workdocs delete-comment \ --document-id15df51e0335cfcc6a2e4de9dd8be9f22ee40545ad9176f54758dcf903be982d3\ --version-id1521672507741-9f7df0ea5dd0b121c4f3564a0c7c0b4da95cd12c635d3c442af337a88e297920\ --comment-id1534799058197-c7f5c84de9115875bbca93e0367bbebac609541d461636b760849b88b1609dd5This command produces no output.
-
For API details, see DeleteComment
in AWS CLI Command Reference.
-
The following code example shows how to use delete-custom-metadata.
- AWS CLI
-
To delete custom metadata from a resource
The following
delete-custom-metadataexample deletes all custom metadata from the specified resource.aws workdocs delete-custom-metadata \ --resource-idd90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65\ --delete-allThis command produces no output.
-
For API details, see DeleteCustomMetadata
in AWS CLI Command Reference.
-
The following code example shows how to use delete-document.
- AWS CLI
-
To delete a document
The following
delete-documentexample deletes the specified document.aws workdocs delete-document \ --document-idb83ed5e5b167b65ef69de9d597627ff1a0d4f07a45e67f1fab7d26b54427de0aThis command produces no output.
-
For API details, see DeleteDocument
in AWS CLI Command Reference.
-
The following code example shows how to use delete-folder-contents.
- AWS CLI
-
To delete the contents of a folder
The following
delete-folder-contentsexample deletes the contents of the specified folder.aws workdocs delete-folder-contents \ --folder-id26fa8aa4ba2071447c194f7b150b07149dbdb9e1c8a301872dcd93a4735ce65dThis command produces no output.
-
For API details, see DeleteFolderContents
in AWS CLI Command Reference.
-
The following code example shows how to use delete-folder.
- AWS CLI
-
To delete a folder
The following
delete-folderexample deletes the specified folder.aws workdocs delete-folder \ --folder-id26fa8aa4ba2071447c194f7b150b07149dbdb9e1c8a301872dcd93a4735ce65dThis command produces no output.
-
For API details, see DeleteFolder
in AWS CLI Command Reference.
-
The following code example shows how to use delete-labels.
- AWS CLI
-
To delete labels
The following
delete-labelsexample deletes the specified labels from a document.aws workdocs delete-labels \ --resource-idd90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65\ --labels"documents""examples"This command produces no output.
-
For API details, see DeleteLabels
in AWS CLI Command Reference.
-
The following code example shows how to use delete-notification-subscription.
- AWS CLI
-
To delete a notification subscription
The following
delete-notification-subscriptionexample deletes the specified notification subscription.aws workdocs delete-notification-subscription \ --subscription-ida1b2c3d4-5678-90ab-cdef-EXAMPLE11111\ --organization-idd-123456789cThis command produces no output.
-
For API details, see DeleteNotificationSubscription
in AWS CLI Command Reference.
-
The following code example shows how to use delete-user.
- AWS CLI
-
To delete a user
The following
delete-userexample deletes a user.aws workdocs delete-user \ --user-id"S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c"This command produces no output.
-
For API details, see DeleteUser
in AWS CLI Command Reference.
-
The following code example shows how to use describe-activities.
- AWS CLI
-
To get a list of user activities
The following
describe-activitiesexample returns a list of the latest user activities for the specified organization, with a limit set for the latest two activities.aws workdocs describe-activities \ --organization-idd-926726012c\ --limit2Output:
{ "UserActivities": [ { "Type": "DOCUMENT_VERSION_DOWNLOADED", "TimeStamp": 1534800122.17, "Initiator": { "Id": "arn:aws:iam::123456789012: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" }-
For API details, see DescribeActivities
in AWS CLI Command Reference.
-
The following code example shows how to use describe-comments.
- AWS CLI
-
To list all comments for a specified document version
The following
describe-commentsexample lists all the comments for the specified document version.aws workdocs describe-comments \ --document-id15df51e0335cfcc6a2e4de9dd8be9f22ee40545ad9176f54758dcf903be982d3\ --version-id1521672507741-9f7df0ea5dd0b121c4f3564a0c7c0b4da95cd12c635d3c442af337a88e297920Output:
{ "Comments": [ { "CommentId": "1534799058197-c7f5c84de9115875bbca93e0367bbebac609541d461636b760849b88b1609dd5", "ThreadId": "1534799058197-c7f5c84de9115875bbca93e0367bbebac609541d461636b760849b88b1609dd5", "Text": "This is a comment.", "Contributor": { "Username": "arn:aws:iam::123456789012:user/exampleUser", "Type": "USER" }, "CreatedTimestamp": 1534799058.197, "Status": "PUBLISHED", "Visibility": "PUBLIC" } ] }-
For API details, see DescribeComments
in AWS CLI Command Reference.
-
The following code example shows how to use describe-document-versions.
- AWS CLI
-
To retrieve a document's versions
The following
describe-document-versionsexample retrieves the document versions for the specified document, including initialized versions and a URL for the source document.aws workdocs describe-document-versions \ --document-idd90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65\ --fieldsSOURCEOutput:
{ "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" } } ] }-
For API details, see DescribeDocumentVersions
in AWS CLI Command Reference.
-
The following code example shows how to use describe-folder-contents.
- AWS CLI
-
To describe the contents of a folder
The following
describe-folder-contentsexample describes all the active contents of the specified folder, including its documents and subfolders, sorted by date in ascending order.aws workdocs describe-folder-contents \ --folder-id1ece93e5fe75315c7407c4967918b4fd9da87ddb2a588e67b7fdaf4a98fde678\ --sortDATE\ --orderASCENDING\ --typeALLOutput:
{ "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" } ] }-
For API details, see DescribeFolderContents
in AWS CLI Command Reference.
-
The following code example shows how to use describe-groups.
- AWS CLI
-
To retrieve a list of groups
The following
describe-groupsexample lists the groups associated with the specified Amazon WorkDocs organization.aws workdocs describe-groups \ --search-query "e" \ --organization-idd-123456789cOutput:
{ "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" } ] }-
For API details, see DescribeGroups
in AWS CLI Command Reference.
-
The following code example shows how to use describe-notification-subscriptions.
- AWS CLI
-
To retrieve a list of notification subscriptions
The following
describe-notification-subscriptionsexample retrieves the notification subscriptions for the specified Amazon WorkDocs organization.aws workdocs describe-notification-subscriptions \ --organization-idd-123456789cOutput:
{ "Subscriptions": [ { "SubscriptionId": "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111", "EndPoint": "https://example.com/example", "Protocol": "HTTPS" } ] }-
For API details, see DescribeNotificationSubscriptions
in AWS CLI Command Reference.
-
The following code example shows how to use describe-resource-permissions.
- AWS CLI
-
To get a list of permissions for a resource
The following
describe-resource-permissionsexample returns a list of the permissions for the specified resource (document or folder).aws workdocs describe-resource-permissions \ --resource-id15df51e0335cfcc6a2e4de9dd8be9f22ee40545ad9176f54758dcf903be982d3Output:
{ "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" } ] } ] }-
For API details, see DescribeResourcePermissions
in AWS CLI Command Reference.
-
The following code example shows how to use describe-users.
- AWS CLI
-
To retrieve details for specified users
The following
describe-usersexample retrieves details for all the users in the specified organization.aws workdocs describe-users \ --organization-idd-926726012cOutput:
{ "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 } ] }-
For API details, see DescribeUsers
in AWS CLI Command Reference.
-
The following code example shows how to use get-document-path.
- AWS CLI
-
To retrieve a document's path information
The following
get-document-pathexample retrieves the path information (hierarchy from the root folder) for the specified document, and includes the names of the parent folders.aws workdocs get-document-path \ --document-idd90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65\ --fieldsNAMEOutput:
{ "Path": { "Components": [ { "Id": "a43d29cbb8e7c4d25cfee8b803a504b0dc63e760b55ad0c611c6b87691eb6ff3", "Name": "/" }, { "Id": "1ece93e5fe75315c7407c4967918b4fd9da87ddb2a588e67b7fdaf4a98fde678", "Name": "Top Level Folder" }, { "Id": "d90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65", "Name": "exampleDoc.docx" } ] } }-
For API details, see GetDocumentPath
in AWS CLI Command Reference.
-
The following code example shows how to use get-document-version.
- AWS CLI
-
To retrieve version metadata for a specified document
The following
get-document-versionexample retrieves version metadata for the specified document, including a source URL and custom metadata.aws workdocs get-document-version \ --document-id15df51e0335cfcc6a2e4de9dd8be9f22ee40545ad9176f54758dcf903be982d3\ --version-id1521672507741-9f7df0ea5dd0b121c4f3564a0c7c0b4da95cd12c635d3c442af337a88e297920\ --fieldsSOURCE\ --include-custom-metadataOutput:
{ "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" } } }-
For API details, see GetDocumentVersion
in AWS CLI Command Reference.
-
The following code example shows how to use get-document.
- AWS CLI
-
To retrieve document details
The following
get-documentexample retrieves the details of the specified document.aws workdocs get-document \ --document-idd90d93c1fe44bad0c8471e973ebaab339090401a95e777cffa58e977d2983b65Output:
{ "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" } }-
For API details, see GetDocument
in AWS CLI Command Reference.
-
The following code example shows how to use get-folder-path.
- AWS CLI
-
To retrieve path information for a folder
The following
get-folder-pathexample retrieves the path information (hierarchy from the root folder) for the specified folder, and includes the names of the parent folders.aws workdocs get-folder-path \ --folder-id50893c0af679524d1a0e0651130ed6d073e1a05f95bd12c42dcde5d35634ed08\ --fieldsNAMEOutput:
{ "Path": { "Components": [ { "Id": "a43d29cbb8e7c4d25cfee8b803a504b0dc63e760b55ad0c611c6b87691eb6ff3", "Name": "/" }, { "Id": "1ece93e5fe75315c7407c4967918b4fd9da87ddb2a588e67b7fdaf4a98fde678", "Name": "Top Level Folder" }, { "Id": "50893c0af679524d1a0e0651130ed6d073e1a05f95bd12c42dcde5d35634ed08", "Name": "Sublevel Folder" } ] } }-
For API details, see GetFolderPath
in AWS CLI Command Reference.
-
The following code example shows how to use get-folder.
- AWS CLI
-
To retrieve the metadata for a folder
The following
get-folderexample retrieves the metadata for the specified folder.aws workdocs get-folder \ --folder-id50893c0af679524d1a0e0651130ed6d073e1a05f95bd12c42dcde5d35634ed08Output:
{ "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 } }-
For API details, see GetFolder
in AWS CLI Command Reference.
-
The following code example shows how to use get-resources.
- AWS CLI
-
To retrieve shared resources
The following
get-resourcesexample retrieves the resources shared with the specified Amazon WorkDocs user.aws workdocs get-resources \ --user-id"S-1-1-11-1111111111-2222222222-3333333333-3333"\ --collection-typeSHARED_WITH_MEOutput:
{ "Folders": [], "Documents": [] }-
For API details, see GetResources
in AWS CLI Command Reference.
-
The following code example shows how to use initiate-document-version-upload.
- AWS CLI
-
To initiate a document version upload
The following
initiate-document-version-uploadexample creates a new document object and version object.aws workdocs initiate-document-version-upload \ --nameexampledocname\ --parent-folder-ideacd546d952531c633452ed67cac23161aa0d5df2e8061223a59e8f67e7b6189Output:
{ "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::123456789012: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" } } }-
For API details, see InitiateDocumentVersionUpload
in AWS CLI Command Reference.
-
The following code example shows how to use remove-all-resource-permissions.
- AWS CLI
-
To remove all permissions from a specified resource
The following
remove-all-resource-permissionsexample removes all permissions from the specified resource.aws workdocs remove-all-resource-permissions \ --resource-id1ece93e5fe75315c7407c4967918b4fd9da87ddb2a588e67b7fdaf4a98fde678This command produces no output.
-
For API details, see RemoveAllResourcePermissions
in AWS CLI Command Reference.
-
The following code example shows how to use remove-resource-permission.
- AWS CLI
-
To remove permissions from a resource
The following
remove-resource-permissionexample removes permissions from the resource for the specified principal.aws workdocs remove-resource-permission \ --resource-id1ece93e5fe75315c7407c4967918b4fd9da87ddb2a588e67b7fdaf4a98fde678\ --principal-idanonymousThis command produces no output.
-
For API details, see RemoveResourcePermission
in AWS CLI Command Reference.
-
The following code example shows how to use update-document-version.
- AWS CLI
-
To change a document version status to Active
The following
update-document-versionexample changes the status of the document version to Active.aws workdocs update-document-version \ --document-id15df51e0335cfcc6a2e4de9dd8be9f22ee40545ad9176f54758dcf903be982d3\ --version-id1521672507741-9f7df0ea5dd0b121c4f3564a0c7c0b4da95cd12c635d3c442af337a88e297920\ --version-statusACTIVEThis command produces no output.
-
For API details, see UpdateDocumentVersion
in AWS CLI Command Reference.
-
The following code example shows how to use update-document.
- AWS CLI
-
To update a document
The following
update-documentexample updates a document's name and parent folder.aws workdocs update-document \ --document-id15df51e0335cfcc6a2e4de9dd8be9f22ee40545ad9176f54758dcf903be982d3\ --nameupdatedDoc\ --parent-folder-id50893c0af679524d1a0e0651130ed6d073e1a05f95bd12c42dcde5d35634ed08This command produces no output.
-
For API details, see UpdateDocument
in AWS CLI Command Reference.
-
The following code example shows how to use update-folder.
- AWS CLI
-
To update a folder
The following
update-folderexample updates a folder's name and parent folder.aws workdocs update-folder \ --folder-id50893c0af679524d1a0e0651130ed6d073e1a05f95bd12c42dcde5d35634ed08\ --nameexampleFolder1\ --parent-folder-id1ece93e5fe75315c7407c4967918b4fd9da87ddb2a588e67b7fdaf4a98fde678This command produces no output.
-
For API details, see UpdateFolder
in AWS CLI Command Reference.
-
The following code example shows how to use update-user.
- AWS CLI
-
To update a user
The following
update-userexample updates the time zone for the specified user.aws workdocs update-user \ --user-id"S-1-1-11-1111111111-2222222222-3333333333-3333&d-926726012c"\ --time-zone-id"America/Los_Angeles"Output:
{ "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" } } } }-
For API details, see UpdateUser
in AWS CLI Command Reference.
-