Listing Users - AWS SDK for Ruby

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.

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

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

  1. Display the information about the users.

# Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # This file is licensed under the Apache License, Version 2.0 (the "License"). # You may not use this file except in compliance with the License. A copy of the # License is located at # # http://aws.amazon.com/apache2.0/ # # This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS # OF ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. require 'aws-sdk-workdocs' # v2: require 'aws-sdk' client = Aws::WorkDocs::Client.new(region: 'us-west-2') # 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 }) 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.