AWS SDK for Ruby
Developer Guide

Listing Users

The following example lists the names, email addresses, and root folders of all users in the organization. Choose Copy to save the code locally, or see the link to the complete example at the end of this topic.

Require the AWS SDK for Ruby module and create a Amazon WorkDocs client.

require 'aws-sdk-workdocs' # v2: require 'aws-sdk' client = 'us-west-2')

Call describe_users with your organization ID, and get all of the user names in ascending order.

# Set to the OrganizationId of your WorkDocs site orgId = 'd-123456789c' resp = client.describe_users({ organization_id: orgId, include: "ALL", # accepts ALL, ACTIVE_PENDING order: "ASCENDING", # accepts ASCENDING, DESCENDING sort: "USER_NAME", # accepts USER_NAME, FULL_NAME, STORAGE_LIMIT, USER_STATUS, STORAGE_USED })

Display the information about the users.

resp.users.each do |user| puts "First name: #{user.given_name}" puts "Last name: #{user.surname}" puts "Email: #{user.email_address}" puts "Root folder: #{user.root_folder_id}" puts end

See the complete example on GitHub.