Class: Applications
- Inherits:
-
Base
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
4
5
6
|
# File 'lib/zapix/proxies/applications.rb', line 4
def create(options)
client.application_create(options) unless exists?(options)
end
|
#exists?(options) ⇒ Boolean
8
9
10
11
12
13
14
15
|
# File 'lib/zapix/proxies/applications.rb', line 8
def exists?(options)
result = client.application_get('filter' => { 'name' => options['name'] })
if result.nil? || result.empty?
false
else
true
end
end
|
#get_id(options) ⇒ Object
17
18
19
20
21
22
23
24
|
# File 'lib/zapix/proxies/applications.rb', line 17
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
|