Class: Scenarios

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

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/scenarios.rb', line 4

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

#delete(options) ⇒ Object



14
15
16
# File 'lib/zapix/proxies/scenarios.rb', line 14

def delete(options)
  client.webcheck_delete(options)
end

#exists?(options) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
21
22
23
24
25
# File 'lib/zapix/proxies/scenarios.rb', line 18

def exists?(options)
  result = client.webcheck_get({
    'countOutput' => true,
    'filter' => {'name' => options['name'],
    'hostid' => options['hostid']}})

  result.to_i >= 1 ? true : false
end

#extract_names(scenarios) ⇒ Object



32
33
34
# File 'lib/zapix/proxies/scenarios.rb', line 32

def extract_names(scenarios)
  scenarios.map {|scenario| scenario['name']} 
end

#get_allObject



27
28
29
30
# File 'lib/zapix/proxies/scenarios.rb', line 27

def get_all
  scenarios = client.webcheck_get({'output' => 'extend'})
  names = extract_names(scenarios)
end

#get_id(options) ⇒ Object



8
9
10
11
12
# File 'lib/zapix/proxies/scenarios.rb', line 8

def get_id(options)
  client.webcheck_get({
    'filter' => {'name' => options['name'],
    'hostid' => options['hostid']}})
end