Class: Nexpose::MultiTenantUser
- Inherits:
-
Object
- Object
- Nexpose::MultiTenantUser
- Defined in:
- lib/nexpose/multi_tenant_user.rb
Instance Attribute Summary collapse
-
#auth_source_id ⇒ Object
Returns the value of attribute auth_source_id.
-
#email ⇒ Object
Returns the value of attribute email.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#full_name ⇒ Object
Returns the value of attribute full_name.
-
#id ⇒ Object
Returns the value of attribute id.
-
#password ⇒ Object
Returns the value of attribute password.
-
#silo_access ⇒ Object
Returns the value of attribute silo_access.
-
#superuser ⇒ Object
Returns the value of attribute superuser.
-
#user_name ⇒ Object
Returns the value of attribute user_name.
Class Method Summary collapse
Instance Method Summary collapse
- #as_xml ⇒ Object
-
#create(connection) ⇒ String
Saves this silo user to a Nexpose console.
- #delete(connection) ⇒ Object
-
#initialize(&block) ⇒ MultiTenantUser
constructor
A new instance of MultiTenantUser.
- #save(connection) ⇒ Object
- #to_xml ⇒ Object
-
#update(connection) ⇒ String
Updates this silo user on a Nexpose console.
Constructor Details
#initialize(&block) ⇒ MultiTenantUser
Returns a new instance of MultiTenantUser.
74 75 76 77 78 |
# File 'lib/nexpose/multi_tenant_user.rb', line 74 def initialize(&block) instance_eval &block if block_given? @silo_access = Array(@silo_access) end |
Instance Attribute Details
#auth_source_id ⇒ Object
Returns the value of attribute auth_source_id.
67 68 69 |
# File 'lib/nexpose/multi_tenant_user.rb', line 67 def auth_source_id @auth_source_id end |
#email ⇒ Object
Returns the value of attribute email.
68 69 70 |
# File 'lib/nexpose/multi_tenant_user.rb', line 68 def email @email end |
#enabled ⇒ Object
Returns the value of attribute enabled.
71 72 73 |
# File 'lib/nexpose/multi_tenant_user.rb', line 71 def enabled @enabled end |
#full_name ⇒ Object
Returns the value of attribute full_name.
65 66 67 |
# File 'lib/nexpose/multi_tenant_user.rb', line 65 def full_name @full_name end |
#id ⇒ Object
Returns the value of attribute id.
64 65 66 |
# File 'lib/nexpose/multi_tenant_user.rb', line 64 def id @id end |
#password ⇒ Object
Returns the value of attribute password.
69 70 71 |
# File 'lib/nexpose/multi_tenant_user.rb', line 69 def password @password end |
#silo_access ⇒ Object
Returns the value of attribute silo_access.
72 73 74 |
# File 'lib/nexpose/multi_tenant_user.rb', line 72 def silo_access @silo_access end |
#superuser ⇒ Object
Returns the value of attribute superuser.
70 71 72 |
# File 'lib/nexpose/multi_tenant_user.rb', line 70 def superuser @superuser end |
#user_name ⇒ Object
Returns the value of attribute user_name.
66 67 68 |
# File 'lib/nexpose/multi_tenant_user.rb', line 66 def user_name @user_name end |
Class Method Details
.load(connection, user_id) ⇒ Object
149 150 151 152 153 154 155 156 157 158 |
# File 'lib/nexpose/multi_tenant_user.rb', line 149 def self.load(connection, user_id) r = connection.execute(connection.make_xml('MultiTenantUserConfigRequest', {'user-id' => user_id}), '1.2') if r.success r.res.elements.each('MultiTenantUserConfigResponse/MultiTenantUserConfig') do |config| return MultiTenantUser.parse(config) end end nil end |
.parse(xml) ⇒ Object
135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/nexpose/multi_tenant_user.rb', line 135 def self.parse(xml) new do |user| user.id = xml.attributes['id'].to_i user.full_name = xml.attributes['full-name'] user.user_name = xml.attributes['user-name'] user.email = xml.attributes['email'] user.superuser = xml.attributes['superuser'].to_s.chomp.eql?('true') user.enabled = xml.attributes['enabled'].to_s.chomp.eql?('true') user.auth_source_id = xml.attributes['authsrcid'].to_i user.silo_access = [] xml.elements.each('SiloAccesses/SiloAccess') { |access| user.silo_access << SiloAccess.parse(access) } end end |
Instance Method Details
#as_xml ⇒ Object
112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/nexpose/multi_tenant_user.rb', line 112 def as_xml xml = REXML::Element.new('MultiTenantUserConfig') xml.add_attributes({'id' => @id, 'full-name' => @full_name, 'user-name' => @user_name, 'authsrcid' => @auth_source_id, 'email' => @email, 'password' => @password, 'superuser' => @superuser, 'enabled' => @enabled}) siloaccesses = xml.add_element('SiloAccesses') @silo_access.each { |silo_access| siloaccesses.add_element(silo_access.as_xml) } xml end |
#create(connection) ⇒ String
Saves this silo user to a Nexpose console.
105 106 107 108 109 110 |
# File 'lib/nexpose/multi_tenant_user.rb', line 105 def create(connection) xml = connection.make_xml('MultiTenantUserCreateRequest') xml.add_element(as_xml) r = connection.execute(xml, '1.2') @id = r.attributes['user-id'] if r.success end |
#delete(connection) ⇒ Object
127 128 129 |
# File 'lib/nexpose/multi_tenant_user.rb', line 127 def delete(connection) connection.delete_silo_user(@id) end |
#save(connection) ⇒ Object
80 81 82 83 84 85 86 |
# File 'lib/nexpose/multi_tenant_user.rb', line 80 def save(connection) if (@id) update(connection) else create(connection) end end |
#to_xml ⇒ Object
131 132 133 |
# File 'lib/nexpose/multi_tenant_user.rb', line 131 def to_xml as_xml.to_s end |
#update(connection) ⇒ String
Updates this silo user on a Nexpose console.
93 94 95 96 97 98 |
# File 'lib/nexpose/multi_tenant_user.rb', line 93 def update(connection) xml = connection.make_xml('MultiTenantUserUpdateRequest') xml.add_element(as_xml) r = connection.execute(xml, '1.2') @id = r.attributes['user-id'] if r.success end |