Class: ZabbixManager::Usergroups
- Defined in:
- lib/zabbix_manager/classes/usergroups.rb
Instance Method Summary collapse
-
#add_user(data) ⇒ Integer?
deprecated
Deprecated.
Zabbix 已移除 massAdd,请使用 update_users。
-
#identify ⇒ String
返回用于唯一识别用户组的业务字段名。.
-
#key ⇒ String
返回用户组对象的主键字段名。.
-
#method_name ⇒ String
返回 Zabbix API 中用户组对象的方法名前缀。.
-
#permissions(data) ⇒ Integer?
更新用户组对主机组的访问权限。.
-
#update_users(data) ⇒ Integer?
批量替换指定用户组中的用户列表。.
Methods inherited from Basic
#add, #all, #create, #create_or_update, #create_raw, #default_options, #delete, #delete_raw, #destroy, #dump_by_id, #get, #get_full_data, #get_id, #get_or_create, #get_raw, #hash_equals?, #identity_filter, #initialize, #keys, #log, #normalize_hash, #parse_keys, #update, #update_raw
Constructor Details
This class inherits a constructor from ZabbixManager::Basic
Instance Method Details
#add_user(data) ⇒ Integer?
Deprecated.
Zabbix 已移除 massAdd,请使用 update_users。
将用户加入用户组;兼容旧调用并委托给 update_users。
51 52 53 |
# File 'lib/zabbix_manager/classes/usergroups.rb', line 51 def add_user(data) update_users(data) end |
#identify ⇒ String
返回用于唯一识别用户组的业务字段名。
22 23 24 |
# File 'lib/zabbix_manager/classes/usergroups.rb', line 22 def identify "name" end |
#key ⇒ String
返回用户组对象的主键字段名。
15 16 17 |
# File 'lib/zabbix_manager/classes/usergroups.rb', line 15 def key "usrgrpid" end |
#method_name ⇒ String
返回 Zabbix API 中用户组对象的方法名前缀。
8 9 10 |
# File 'lib/zabbix_manager/classes/usergroups.rb', line 8 def method_name "usergroup" end |
#permissions(data) ⇒ Integer?
更新用户组对主机组的访问权限。
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/zabbix_manager/classes/usergroups.rb', line 32 def (data) = data[:permission] || 2 result = @client.api_request( method: "usergroup.update", params: { usrgrpid: data[:usrgrpid], rights: data[:hostgroupids].map { |t| { permission: , id: t } } } ) result ? result["usrgrpids"][0].to_i : nil end |
#update_users(data) ⇒ Integer?
批量替换指定用户组中的用户列表。
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/zabbix_manager/classes/usergroups.rb', line 61 def update_users(data) user_groups = data[:usrgrpids].map do |t| { usrgrpid: t, userids: data[:userids] } end result = @client.api_request( method: "usergroup.update", params: user_groups ) result ? result["usrgrpids"][0].to_i : nil end |