Class: ZabbixApi::Drules
Instance Method Summary collapse
-
#create_or_update(data) ⇒ Integer
Create or update Drule object using Zabbix API.
-
#default_options ⇒ Hash
The default options used when creating Drule objects via Zabbix API.
-
#get_or_create(data) ⇒ Integer
Get or Create Drule object using Zabbix API.
-
#indentify ⇒ String
The id field name used for identifying specific Drule objects via Zabbix API.
-
#method_name ⇒ String
The method name used for interacting with Drules via Zabbix API.
Methods inherited from Basic
#add, #all, #create, #delete, #destroy, #dump_by_id, #get, #get_full_data, #get_id, #get_raw, #hash_equals?, #initialize, #key, #keys, #log, #merge_params, #normalize_array, #normalize_hash, #parse_keys, #symbolize_keys, #update
Constructor Details
This class inherits a constructor from ZabbixApi::Basic
Instance Method Details
#create_or_update(data) ⇒ Integer
Create or update Drule object using Zabbix API
50 51 52 53 |
# File 'lib/zabbixapi/classes/drules.rb', line 50 def create_or_update(data) druleid = get_id(name: data[:name]) druleid ? update(data.merge(druleid: druleid)) : create(data) end |
#default_options ⇒ Hash
The default options used when creating Drule objects via Zabbix API
20 21 22 23 24 25 26 27 |
# File 'lib/zabbixapi/classes/drules.rb', line 20 def { name: nil, iprange: nil, delay: 3600, status: 0, } end |
#get_or_create(data) ⇒ Integer
Get or Create Drule object using Zabbix API
35 36 37 38 39 40 41 42 |
# File 'lib/zabbixapi/classes/drules.rb', line 35 def get_or_create(data) log "[DEBUG] Call get_or_create with parameters: #{data.inspect}" unless (id = get_id(name: data[:name])) id = create(data) end id end |
#indentify ⇒ String
The id field name used for identifying specific Drule objects via Zabbix API
13 14 15 |
# File 'lib/zabbixapi/classes/drules.rb', line 13 def indentify 'name' end |
#method_name ⇒ String
The method name used for interacting with Drules via Zabbix API
6 7 8 |
# File 'lib/zabbixapi/classes/drules.rb', line 6 def method_name 'drule' end |