Class: Applications

Inherits:
Base
  • Object
show all
Defined in:
lib/zapix/proxies/applications.rb

Defined Under Namespace

Classes: NonExistingApplication

Instance Attribute Summary

Attributes inherited from Base

#client

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from Base

Instance Method Details

#create(options) ⇒ Object



5
6
7
# File 'lib/zapix/proxies/applications.rb', line 5

def create(options)
  client.application_create(options) unless exists?(options)
end

#exists?(options) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/zapix/proxies/applications.rb', line 9

def exists?(options)
  client.application_exists(options)
end

#get_id(options) ⇒ Object



13
14
15
16
17
18
19
20
21
# File 'lib/zapix/proxies/applications.rb', line 13

def get_id(options)
  if exists?(options)
    client.application_get({
      'filter' => {'name' => options['name'],
      'hostid' => options['hostid']}}).first['applicationid']
  else
    raise NonExistingApplication, "Application #{options['name']} does not exist !"
  end
end