Class: HmxClient::Command::User

Inherits:
Base
  • Object
show all
Defined in:
lib/hmx/command/user.rb

Overview

Manipulate user entities in hmx

Constant Summary

Constants inherited from Base

Base::FILE

Instance Attribute Summary

Attributes inherited from Base

#args, #options

Instance Method Summary collapse

Methods inherited from Base

#hmx, #initialize, #loadConfig!, namespace, #removeConfig, #storeConfig, #writeConfig

Methods included from Helpers

#display, #display_row, #display_tab, #display_table, #error, #getFromUser, #longest

Constructor Details

This class inherits a constructor from HmxClient::Command::Base

Instance Method Details

#deleteObject

user:delete

Removes a user



61
62
63
64
65
66
# File 'lib/hmx/command/user.rb', line 61

def delete
  # We also need to remove the user reference from any groups they belong to (sys.entgroup)
  # We should be clever and use a custom view for that purpose
  # something like
  # (fn[param] (fn[x] (contains (param "user" (.get x '(:document :MXEntitlementGroup :users ))))))
end

#getObject

user:get

Retrieves the definition of a user



37
38
39
# File 'lib/hmx/command/user.rb', line 37

def get
   index
end

#indexObject

user

manipulate user enties in hMX



14
15
16
17
18
19
20
# File 'lib/hmx/command/user.rb', line 14

def index
  unless args.size > 0
    raise CommandFailed, "Usage: hmx user <userId>"
  end
  userName = args.shift
  dout JSON.pretty_generate(hmx.doGetData(["sys.user/#{userName}"]))
end

#listObject

user:list

Lists all of the users in the system



26
27
28
29
30
31
# File 'lib/hmx/command/user.rb', line 26

def list
  views = hmx.doQuery(["sys.user", nil])
  views.each { | v |
             display v.rpartition('/')[2]
            } 
end

#passwordObject

user:password

Sets the password for a user



45
46
47
48
49
50
51
52
53
54
55
# File 'lib/hmx/command/user.rb', line 45

def password
  unless args.size > 1
    raise CommandFailed, "Usage: hmx user:password <userId> <newPassword>"
  end
  user = args.shift
  userName = "sys.user/#{user}"
  password = Digest::MD5.hexdigest(args.shift)
  dataDocument = hmx.doGetData([userName])
  dataDocument['document']['MXUser']['hashPassword'] = password
  display hmx.doPutData([JSON.generate(dataDocument)])
end