Class: HmxClient::Command::Session

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

Overview

Display and manage session information for 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

#expireObject

session:expire

Forces the expiry of any old sessions



31
32
33
# File 'lib/hmx/command/session.rb', line 31

def expire
  display hmx.doExpireSessions([])
end

#indexObject

session

List the sessions and their status on hmx



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/hmx/command/session.rb', line 13

def index
  displayNames = hmx.doQuery(['sys.session', nil])
  objs = []
  displayNames.each do | name |
     data = hmx.doGetContent([name]) 
     dval = JSON.parse(data)
     dval["MXSession"]["validUntil"] = Time.at(dval["MXSession"]["validUntil"] / 1000).to_datetime.strftime
     objs << dval["MXSession"]
  end
  cols = [ 'sessionId', 'userId', 'authenticated','validUntil' ]
  headers = [ 'Session', 'Username', 'Authenticated', 'ValidUntil' ]
  display_table(objs, cols, headers)
end