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
8
9
10
|
# File 'lib/zapix/proxies/templates.rb', line 8
def create(options)
client.template_create(options) unless exists?(options['host'])
end
|
#exists?(name) ⇒ Boolean
4
5
6
|
# File 'lib/zapix/proxies/templates.rb', line 4
def exists?(name)
client.template_exists({'name' => name})
end
|
#get_id(name) ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/zapix/proxies/templates.rb', line 12
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
20
21
22
|
# File 'lib/zapix/proxies/templates.rb', line 20
def get_templates_for_host(id)
client.template_get({'hostids' => [id]}).map { |result_set| result_set['templateid'] }
end
|