Class: Nexpose::UserSummary
- Inherits:
-
Object
- Object
- Nexpose::UserSummary
- Defined in:
- lib/nexpose/user.rb
Overview
Summary only returned by API when issuing a listing request.
Instance Attribute Summary collapse
-
#auth_module ⇒ Object
readonly
Returns the value of attribute auth_module.
-
#auth_source ⇒ Object
readonly
Returns the value of attribute auth_source.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#full_name ⇒ Object
readonly
Returns the value of attribute full_name.
-
#group_count ⇒ Object
readonly
Returns the value of attribute group_count.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#is_admin ⇒ Object
readonly
Returns the value of attribute is_admin.
-
#is_disabled ⇒ Object
readonly
Returns the value of attribute is_disabled.
-
#is_locked ⇒ Object
readonly
Returns the value of attribute is_locked.
-
#site_count ⇒ Object
readonly
Returns the value of attribute site_count.
-
#user_name ⇒ Object
readonly
Returns the value of attribute user_name.
Class Method Summary collapse
-
.get_user_id(connection, user_name) ⇒ Object
Retrieve the User ID based upon the user’s login name.
-
.listing(connection) ⇒ Object
Provide a list of user accounts and information about those accounts.
Instance Method Summary collapse
-
#initialize(id, auth_source, auth_module, user_name, full_name, email, is_admin, is_disabled, is_locked, site_count, group_count) ⇒ UserSummary
constructor
A new instance of UserSummary.
- #to_s ⇒ Object
Constructor Details
#initialize(id, auth_source, auth_module, user_name, full_name, email, is_admin, is_disabled, is_locked, site_count, group_count) ⇒ UserSummary
Returns a new instance of UserSummary.
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/nexpose/user.rb', line 8 def initialize(id, auth_source, auth_module, user_name, full_name, email, is_admin, is_disabled, is_locked, site_count, group_count) @id = id @auth_source = auth_source @auth_module = auth_module @user_name = user_name @full_name = full_name @email = email @is_admin = is_admin @is_disabled = is_disabled @is_locked = is_locked @site_count = site_count @group_count = group_count end |
Instance Attribute Details
#auth_module ⇒ Object (readonly)
Returns the value of attribute auth_module.
5 6 7 |
# File 'lib/nexpose/user.rb', line 5 def auth_module @auth_module end |
#auth_source ⇒ Object (readonly)
Returns the value of attribute auth_source.
5 6 7 |
# File 'lib/nexpose/user.rb', line 5 def auth_source @auth_source end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
5 6 7 |
# File 'lib/nexpose/user.rb', line 5 def email @email end |
#full_name ⇒ Object (readonly)
Returns the value of attribute full_name.
5 6 7 |
# File 'lib/nexpose/user.rb', line 5 def full_name @full_name end |
#group_count ⇒ Object (readonly)
Returns the value of attribute group_count.
6 7 8 |
# File 'lib/nexpose/user.rb', line 6 def group_count @group_count end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/nexpose/user.rb', line 5 def id @id end |
#is_admin ⇒ Object (readonly)
Returns the value of attribute is_admin.
6 7 8 |
# File 'lib/nexpose/user.rb', line 6 def is_admin @is_admin end |
#is_disabled ⇒ Object (readonly)
Returns the value of attribute is_disabled.
6 7 8 |
# File 'lib/nexpose/user.rb', line 6 def is_disabled @is_disabled end |
#is_locked ⇒ Object (readonly)
Returns the value of attribute is_locked.
6 7 8 |
# File 'lib/nexpose/user.rb', line 6 def is_locked @is_locked end |
#site_count ⇒ Object (readonly)
Returns the value of attribute site_count.
6 7 8 |
# File 'lib/nexpose/user.rb', line 6 def site_count @site_count end |
#user_name ⇒ Object (readonly)
Returns the value of attribute user_name.
5 6 7 |
# File 'lib/nexpose/user.rb', line 5 def user_name @user_name end |
Class Method Details
.get_user_id(connection, user_name) ⇒ Object
Retrieve the User ID based upon the user’s login name.
59 60 61 62 63 64 65 66 67 68 |
# File 'lib/nexpose/user.rb', line 59 def self.get_user_id(connection, user_name) xml = '<UserListingRequest session-id="' + connection.session_id + '" />' r = connection.execute(xml, '1.1') if r.success r.res.elements.each('UserListingResponse/UserSummary') do |user| return user.attributes['id'] if user_name.eql? user.attributes['userName'] end end return -1 end |
.listing(connection) ⇒ Object
Provide a list of user accounts and information about those accounts.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/nexpose/user.rb', line 33 def self.listing(connection) xml = '<UserListingRequest session-id="' + connection.session_id + '" />' r = connection.execute(xml, '1.1') if r.success res = [] r.res.elements.each('UserListingResponse/UserSummary') do |summary| res << UserSummary.new( summary.attributes['id'].to_i, summary.attributes['authSource'], summary.attributes['authModule'], summary.attributes['userName'], summary.attributes['fullName'], summary.attributes['email'], summary.attributes['administrator'].to_s.chomp.eql?('1'), summary.attributes['disabled'].to_s.chomp.eql?('1'), summary.attributes['locked'].to_s.chomp.eql?('1'), summary.attributes['siteCount'].to_i, summary.attributes['groupCount'].to_i) end res else false end end |
Instance Method Details
#to_s ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/nexpose/user.rb', line 22 def to_s out = "#{@user_name} (#{@full_name}) [ID: #{@id}]" out << " e-mail: #{@email}" unless @email.empty? out << " Administrator" if @is_admin out << " Disabled" if @is_disabled out << " Locked" if @is_locked out << ", sites: #{@site_count}" out << ", groups: #{@group_count}" end |