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



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

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

#exists?(options) ⇒ Boolean

Returns:

  • (Boolean)


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

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



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

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

#get_allObject



24
25
26
27
# File 'lib/zapix/proxies/scenarios.rb', line 24

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

#get_id(options) ⇒ Object



8
9
10
# 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