Sha256: b3b58e4817b573346552230fa1078e691d6398ff098e57fff14e98bf8dbfffdd

Contents?: true

Size: 879 Bytes

Versions: 12

Compression:

Stored size: 879 Bytes

Contents

class User < CloudstackCli::Base

  desc 'list', 'list users'
  option :listall
  option :account
  option :format, default: "table",
    enum: %w(table json yaml)
  def list
    resolve_account
    users = client.list_users(options)
    if users.size < 1
      say "No users found."
    else
      case options[:format].to_sym
      when :yaml
        puts({users: users}.to_yaml)
      when :json
        puts JSON.pretty_generate(users: users)
      else
        table = [["Account", "Type", "Name", "Email", "State", "Domain"]]
        users.each do |user|
          table << [
            user['account'], Account::TYPES[user['accounttype']], "#{user['firstname']} #{user['lastname']}",
            user['email'], user['state'], user['domain']
          ]
        end
        print_table table
        say "Total number of users: #{users.size}"
      end
    end
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
cloudstack-cli-1.5.10 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.5.9 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.5.8 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.5.7 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.5.6 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.5.5 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.5.4 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.5.3 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.5.2 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.5.1 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.5.0 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.4.2 lib/cloudstack-cli/commands/user.rb