Class: Rubix::UserGroup
Instance Attribute Summary
Attributes inherited from Model
#id, #properties
Class Method Summary
collapse
Instance Method Summary
collapse
#user_ids, #user_ids=, #users, #users=
Methods inherited from Model
all, all_params, all_request, #before_destroy, #create, #create_request, #destroy, #destroy_params, #destroy_request, each, find, find_or_create, find_request, #id_field, list, #new_record?, properties, request, #request, #resource_name, resource_name, #save, #to_hash, #update, #update_params, #update_request, #validate, web_request, zabbix_attr, zabbix_define, zabbix_name
Methods included from Logs
#debug, #error, #fatal, #info, #warn
Constructor Details
#initialize(properties = {}) ⇒ UserGroup
Returns a new instance of UserGroup.
23
24
25
26
27
|
# File 'lib/rubix/models/user_group.rb', line 23
def initialize properties={}
super(properties)
self.user_ids = properties[:user_ids]
self.users = properties[:users]
end
|
Class Method Details
.build(user_group) ⇒ Object
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/rubix/models/user_group.rb', line 80
def self.build user_group
new({
:id => user_group[id_field].to_i,
:name => user_group['name'],
:gui_access => self::GUI_ACCESS_NAMES[user_group['gui_access'].to_i],
:banned => (user_group['users_status'].to_i == 1),
:api_access => (user_group['api_access'].to_i == 1),
:debug_mode => (user_group['debug_mode'].to_i == 1),
:user_ids => user_group['users'].map { |user_info| user_info['userid'].to_i }
})
end
|
.find_params(options = {}) ⇒ Object
76
77
78
|
# File 'lib/rubix/models/user_group.rb', line 76
def self.find_params options={}
get_params.merge(:filter => {id_field => options[:id], :name => options[:name]})
end
|
.get_params ⇒ Object
72
73
74
|
# File 'lib/rubix/models/user_group.rb', line 72
def self.get_params
super().merge(:select_users => :refer)
end
|
.id_field ⇒ Object
29
30
31
|
# File 'lib/rubix/models/user_group.rb', line 29
def self.id_field
'usrgrpid'
end
|
Instance Method Details
#after_create ⇒ Object
53
54
55
|
# File 'lib/rubix/models/user_group.rb', line 53
def after_create
update_users
end
|
#before_update ⇒ Object
57
58
59
|
# File 'lib/rubix/models/user_group.rb', line 57
def before_update
update_users
end
|
#create_params ⇒ Object
43
44
45
46
47
48
49
50
51
|
# File 'lib/rubix/models/user_group.rb', line 43
def create_params
{
:name => name,
:gui_access => self.class::GUI_ACCESS_CODES[gui_access],
:users_status => (banned ? 1 : 0),
:api_access => (api_access ? 1 : 0),
:debug_mode => (debug_mode ? 1 : 0)
}
end
|
#update_users ⇒ Object
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/rubix/models/user_group.rb', line 61
def update_users
return true unless self.user_ids
response = request("usergroup.massUpdate", { :usrgrpids => [id], :userids => self.user_ids })
if response.has_data?
true
else
error("Could not update users for #{resource_name}: #{response.error_message}")
false
end
end
|