Class: ZabbixManager::Users
- Defined in:
- lib/zabbix_manager/classes/users.rb
Instance Method Summary collapse
-
#add_medias(data) ⇒ Integer?
为指定用户添加媒介配置,当前通过 user.update 完成。.
-
#identify ⇒ String
返回用于唯一识别用户的业务字段名。.
-
#key ⇒ String
返回用户对象的主键字段名。.
-
#keys ⇒ String
返回用户对象批量结果中的 ID 字段名。.
-
#medias_helper(data, action) ⇒ Integer?
按指定动作批量更新用户媒介配置。.
-
#method_name ⇒ String
返回 Zabbix API 中用户对象的方法名前缀。.
-
#update_medias(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, #log, #normalize_hash, #parse_keys, #update, #update_raw
Constructor Details
This class inherits a constructor from ZabbixManager::Basic
Instance Method Details
#add_medias(data) ⇒ Integer?
为指定用户添加媒介配置,当前通过 user.update 完成。
57 58 59 |
# File 'lib/zabbix_manager/classes/users.rb', line 57 def add_medias(data) medias_helper(data, "update") end |
#identify ⇒ String
返回用于唯一识别用户的业务字段名。
29 30 31 |
# File 'lib/zabbix_manager/classes/users.rb', line 29 def identify "alias" end |
#key ⇒ String
返回用户对象的主键字段名。
22 23 24 |
# File 'lib/zabbix_manager/classes/users.rb', line 22 def key "userid" end |
#keys ⇒ String
返回用户对象批量结果中的 ID 字段名。
15 16 17 |
# File 'lib/zabbix_manager/classes/users.rb', line 15 def keys "userids" end |
#medias_helper(data, action) ⇒ Integer?
按指定动作批量更新用户媒介配置。
38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/zabbix_manager/classes/users.rb', line 38 def medias_helper(data, action) result = @client.api_request( method: "user.#{action}", params: data[:userids].map do |t| { userid: t, user_medias: data[:media] } end ) result ? result["userids"][0].to_i : nil end |
#method_name ⇒ String
返回 Zabbix API 中用户对象的方法名前缀。
8 9 10 |
# File 'lib/zabbix_manager/classes/users.rb', line 8 def method_name "user" end |
#update_medias(data) ⇒ Integer?
批量替换指定用户的媒介配置。
67 68 69 |
# File 'lib/zabbix_manager/classes/users.rb', line 67 def update_medias(data) medias_helper(data, "update") end |