Class: ZabbixApi::Applications

Inherits:
Object
  • Object
show all
Defined in:
lib/zabbixapi/applications.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Applications

Returns a new instance of Applications.



4
5
6
7
# File 'lib/zabbixapi/applications.rb', line 4

def initialize(options = {})
  @client = Client.new(options)
  @options = options
end

Instance Method Details

#add(data) ⇒ Object



14
15
16
# File 'lib/zabbixapi/applications.rb', line 14

def add(data)
  create(data)
end

#create(data) ⇒ Object



9
10
11
12
# File 'lib/zabbixapi/applications.rb', line 9

def create(data)
  result = @client.api_request(:method => "application.create", :params => [data])
  result.empty? ? nil : result['applicationids'][0].to_i
end

#delete(data) ⇒ Object



18
19
20
21
# File 'lib/zabbixapi/applications.rb', line 18

def delete(data)
  result = @client.api_request(:method => "application.delete", :params => [data])
  result.empty? ? nil : result['applicationids'][0].to_i
end

#destroy(data) ⇒ Object



30
31
32
# File 'lib/zabbixapi/applications.rb', line 30

def destroy(data)
  delete(data)
end

#get_full_data(data) ⇒ Object



34
35
36
# File 'lib/zabbixapi/applications.rb', line 34

def get_full_data(data)
  @client.api_request(:method => "application.get", :params => {:filter => data, :output => "extend"})
end

#get_id(data) ⇒ Object



38
39
40
41
42
43
# File 'lib/zabbixapi/applications.rb', line 38

def get_id(data)
  result = get_full_data(data)
  applicationid = nil
  result.each { |app| applicationid = app['applicationid'].to_i if app['name'] == data[:name] }
  applicationid
end

#get_or_create(data) ⇒ Object



23
24
25
26
27
28
# File 'lib/zabbixapi/applications.rb', line 23

def get_or_create(data)
  unless appid = get_id(data)
    appid = create(data)
  end
  appid
end