Class: Templates
- Inherits:
-
Base
show all
- Defined in:
- lib/zapix/proxies/templates.rb
Defined Under Namespace
Classes: NonExistingTemplate
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
12
13
14
|
# File 'lib/zapix/proxies/templates.rb', line 12
def create(options)
client.template_create(options) unless exists?(options['host'])
end
|
#exists?(name) ⇒ Boolean
3
4
5
6
7
8
9
10
|
# File 'lib/zapix/proxies/templates.rb', line 3
def exists?(name)
result = client.template_get('filter' => { 'name' => name })
if result.nil? || result.empty?
false
else
true
end
end
|
#get_id(name) ⇒ Object
16
17
18
19
20
21
22
|
# File 'lib/zapix/proxies/templates.rb', line 16
def get_id(name)
if exists?(name)
client.template_get('filter' => { 'name' => name }).first['templateid']
else
raise NonExistingTemplate, "Template #{name} does not exist !"
end
end
|
#get_templates_for_host(id) ⇒ Object
24
25
26
|
# File 'lib/zapix/proxies/templates.rb', line 24
def get_templates_for_host(id)
client.template_get('hostids' => [id]).map { |result_set| result_set['templateid'] }
end
|