Sha256: 561e2808c090097999f290c64f45ca9ef1ee1a8e9e89bd41cb3c059406c57272

Contents?: true

Size: 910 Bytes

Versions: 2

Compression:

Stored size: 910 Bytes

Contents

class User < CloudstackCli::Base

  desc 'list', 'list users'
  option :listall, type: :boolean, default: true
  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

2 entries across 2 versions & 1 rubygems

Version Path
cloudstack-cli-1.5.13 lib/cloudstack-cli/commands/user.rb
cloudstack-cli-1.5.12 lib/cloudstack-cli/commands/user.rb