Class: ZabbixApi::Hosts

Inherits:
Basic
  • Object
show all
Defined in:
lib/zabbixapi/classes/hosts.rb

Instance Method Summary collapse

Methods inherited from Basic

#add, #all, #create, #destroy, #dump_by_id, #get, #get_full_data, #get_id, #get_or_create, #hash_equals?, #initialize, #key, #keys, #log, #merge_params, #normalize_hash, #parse_keys, #symbolize_keys, #update

Constructor Details

This class inherits a constructor from ZabbixApi::Basic

Instance Method Details

#array_flagObject



4
5
6
# File 'lib/zabbixapi/classes/hosts.rb', line 4

def array_flag
  true
end

#create_or_update(data) ⇒ Object



38
39
40
41
# File 'lib/zabbixapi/classes/hosts.rb', line 38

def create_or_update(data)
  hostid = get_id(:host => data[:host])
  hostid ? update(data.merge(:hostid => hostid)) : create(data)
end

#default_optionsObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/zabbixapi/classes/hosts.rb', line 16

def default_options
  {
    :host => nil,
    :interfaces => [],
    :status => 0,
    :available => 1,
    :groups => [],
    :proxy_hostid => nil
  }
end

#delete(hostid) ⇒ Object

to make delete call idempotent for all resources



44
45
46
# File 'lib/zabbixapi/classes/hosts.rb', line 44

def delete(hostid)
  super(:hostid => hostid)
end

#indentifyObject



12
13
14
# File 'lib/zabbixapi/classes/hosts.rb', line 12

def indentify
  "host"
end

#method_nameObject



8
9
10
# File 'lib/zabbixapi/classes/hosts.rb', line 8

def method_name
  "host"
end


27
28
29
30
31
32
33
34
35
36
# File 'lib/zabbixapi/classes/hosts.rb', line 27

def unlink_templates(data)
  result = @client.api_request(
    :method => "host.massRemove",
    :params => {
      :hostids => data[:hosts_id],
      :templates => data[:templates_id]
    }
  )
  result.empty? ? false : true
end