使用 Ruby SDK 的亚马逊 WorkDocs 示例 - Amazon SDK对于 Ruby
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

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

使用 Ruby SDK 的亚马逊 WorkDocs 示例

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

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

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

主题

操作

以下代码示例演示如何使用 DescribeRootFolders

SDK对于 Ruby
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

# Retrieves the root folder for a user by email # @param users [Array<Types::User>] A list of users selected from API response # @param user_email [String] The email of the user. def get_user_folder(users, user_email) user = users.find { |user| user.email_address == user_email } if user user.root_folder_id else @logger.error "Could not get root folder for user with email address #{user_email}" exit(1) end end # Describes the contents of a folder # @param [String] folder_id - The Id of the folder to describe. def describe_folder_contents(folder_id) resp = @client.describe_folder_contents({ folder_id: folder_id, # required sort: 'NAME', # accepts DATE, NAME order: 'ASCENDING' # accepts ASCENDING, DESCENDING }) resp.documents.each do |doc| md = doc.latest_version_metadata @logger.info "Name: #{md.name}" @logger.info "Size (bytes): #{md.size}" @logger.info "Last modified: #{doc.modified_timestamp}" @logger.info "Doc ID: #{doc.id}" @logger.info "Version ID: #{md.id}" @logger.info '' end rescue Aws::WorkDocs::Errors::ServiceError => e @logger.error "Error listing folder contents: #{e.message}" exit(1) end
  • 有关API详细信息,请参阅 “Amazon SDK for Ruby API参考 DescribeRootFolders” 中的。

以下代码示例演示如何使用 DescribeUsers

SDK对于 Ruby
注意

还有更多相关信息 GitHub。查找完整示例,学习如何在 Amazon 代码示例存储库中进行设置和运行。

# Describes users within an organization # @param [String] org_id: The ID of the org. def describe_users(org_id) resp = @client.describe_users({ organization_id: org_id, include: 'ALL', # accepts ALL, ACTIVE_PENDING order: 'ASCENDING', # accepts ASCENDING, DESCENDING sort: 'USER_NAME', # accepts USER_NAME fields: %w[FULL_NAME STORAGE_LIMIT USER_STATUS STORAGE_USED] # Corrected field names }) resp.users.each do |user| @logger.info "First name: #{user.given_name}" @logger.info "Last name: #{user.surname}" @logger.info "Email: #{user.email_address}" @logger.info "Root folder: #{user.root_folder_id}" @logger.info '' end resp.users rescue Aws::WorkDocs::Errors::ServiceError => e @logger.error "AWS WorkDocs Service Error: #{e.message}" exit(1) end
  • 有关API详细信息,请参阅 “Amazon SDK for Ruby API参考 DescribeUsers” 中的。