Class: Templates

Inherits:
Basic show all
Defined in:
lib/zapix/proxies/templates.rb

Defined Under Namespace

Classes: NonExistingTemplate

Instance Method Summary collapse

Methods inherited from Basic

#initialize

Constructor Details

This class inherits a constructor from Basic

Instance Method Details

#create(name) ⇒ Object



8
9
# File 'lib/zapix/proxies/templates.rb', line 8

def create(name)
end

#delete(name) ⇒ Object



11
12
# File 'lib/zapix/proxies/templates.rb', line 11

def delete(name)
end

#exists?(name) ⇒ Boolean

Returns:

  • (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



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

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



22
23
24
# File 'lib/zapix/proxies/templates.rb', line 22

def get_templates_for_host(id)
  @client.template_get({'hostids' => [id]}).map { |result_set| result_set['templateid'] }
end