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.httptest_create(options) unless exists?(options)
end

#delete(options) ⇒ Object



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

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

#exists?(options) ⇒ Boolean

Returns:

  • (Boolean)


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

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

  result.to_i >= 1 ? true : false
end

#extract_names(scenarios) ⇒ Object



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

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

#get_allObject



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

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

#get_id(options) ⇒ Object



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

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