Use DescribeRootFolders with an AWS SDK - AWS SDK Code Examples

There are more AWS SDK examples available in the AWS Doc SDK Examples GitHub repo.

Use DescribeRootFolders with an AWS SDK

The following code example shows how to use DescribeRootFolders.

Ruby
SDK for Ruby
Note

There's more on GitHub. Find the complete example and learn how to set up and run in the AWS Code Examples Repository.

# 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