Class: ZabbixManager::Users

Inherits:
Basic
  • Object
show all
Defined in:
lib/zabbix_manager/classes/users.rb

Instance Method Summary collapse

Methods inherited from Basic

#add, #all, #create, #create_or_update, #default_options, #delete, #destroy, #dump_by_id, #get, #get_full_data, #get_id, #get_ids, #get_ids_by_identify, #get_key_ids, #get_key_ids_by_identify, #get_or_create, #get_or_create_keys, #get_raw, #hash_equals?, #initialize, #key, #keys, #log, #merge_hashes, #normalize_array, #normalize_hash, #parse_keys, #request_raw, #symbolize_keys, #update

Constructor Details

This class inherits a constructor from ZabbixManager::Basic

Instance Method Details

#add_medias(data) ⇒ Object

通过 Zabbix API 为用户添加媒体信息



30
31
32
# File 'lib/zabbix_manager/classes/users.rb', line 30

def add_medias(data)
  medias_helper(data, "update")
end

#identifyObject

用于通过 Zabbix API 识别特定 User 对象的 id 字段名称



11
12
13
# File 'lib/zabbix_manager/classes/users.rb', line 11

def identify
  "alias"
end

#medias_helper(data, action) ⇒ Object

用于辅助处理添加或更新用户媒体信息的方法



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/zabbix_manager/classes/users.rb', line 16

def medias_helper(data, action)
  result = @client.api_request(
    method: "user.#{action}",
    params: data[:userids].map do |i|
      {
        userid: i,
        user_medias: data[:media]
      }
    end
  )
  result ? result["userids"][0].to_i : nil
end

#method_nameObject

用于通过 Zabbix API 与 Users 交互的方法名称



6
7
8
# File 'lib/zabbix_manager/classes/users.rb', line 6

def method_name
  "user"
end

#update_medias(data) ⇒ Object

通过 Zabbix API 更新用户媒体信息



35
36
37
# File 'lib/zabbix_manager/classes/users.rb', line 35

def update_medias(data)
  medias_helper(data, "update")
end