zabbixapi 0.6.6 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +11 -6
  3. data/README.md +21 -25
  4. data/lib/zabbixapi.rb +23 -10
  5. data/lib/zabbixapi/{1.8/basic → basic}/basic_alias.rb +0 -0
  6. data/lib/zabbixapi/{1.8/basic → basic}/basic_func.rb +3 -3
  7. data/lib/zabbixapi/{1.8/basic → basic}/basic_init.rb +0 -0
  8. data/lib/zabbixapi/{2.0/basic → basic}/basic_logic.rb +3 -3
  9. data/lib/zabbixapi/{1.8/classes → classes}/applications.rb +0 -0
  10. data/lib/zabbixapi/{1.8/classes → classes}/errors.rb +0 -0
  11. data/lib/zabbixapi/{1.8/classes → classes}/graphs.rb +0 -0
  12. data/lib/zabbixapi/{2.0/classes → classes}/hostgroups.rb +0 -0
  13. data/lib/zabbixapi/{2.0/classes → classes}/hosts.rb +4 -0
  14. data/lib/zabbixapi/{2.0/classes → classes}/items.rb +8 -0
  15. data/lib/zabbixapi/{1.8/classes → classes}/mediatypes.rb +0 -0
  16. data/lib/zabbixapi/{2.0/classes → classes}/proxies.rb +0 -0
  17. data/lib/zabbixapi/{2.0/classes → classes}/screens.rb +1 -19
  18. data/lib/zabbixapi/{1.8/classes → classes}/server.rb +0 -0
  19. data/lib/zabbixapi/{2.0/classes → classes}/templates.rb +4 -4
  20. data/lib/zabbixapi/{1.8/classes → classes}/triggers.rb +0 -0
  21. data/lib/zabbixapi/{1.8/classes → classes}/unusable.rb +0 -0
  22. data/lib/zabbixapi/{2.0/classes → classes}/usergroups.rb +0 -12
  23. data/lib/zabbixapi/{2.0/classes → classes}/usermacros.rb +0 -0
  24. data/lib/zabbixapi/{2.0/classes → classes}/users.rb +2 -2
  25. data/lib/zabbixapi/version.rb +1 -1
  26. data/spec/application.rb +74 -0
  27. data/spec/basic_func.rb +4 -0
  28. data/spec/graph.rb +135 -0
  29. data/spec/host.rb +136 -0
  30. data/spec/hostgroup.rb +55 -0
  31. data/spec/item.rb +132 -0
  32. data/spec/mediatype.rb +47 -0
  33. data/spec/query.rb +13 -0
  34. data/spec/screen.rb +88 -0
  35. data/spec/server.rb +17 -0
  36. data/spec/spec_helper.rb +21 -0
  37. data/spec/template.rb +148 -0
  38. data/spec/trigger.rb +74 -0
  39. data/spec/user.rb +99 -0
  40. data/spec/usergroup.rb +69 -0
  41. data/zabbixapi.gemspec +3 -3
  42. metadata +52 -44
  43. data/lib/zabbixapi/1.8/basic/basic_logic.rb +0 -103
  44. data/lib/zabbixapi/1.8/classes/hostgroups.rb +0 -26
  45. data/lib/zabbixapi/1.8/classes/hosts.rb +0 -58
  46. data/lib/zabbixapi/1.8/classes/items.rb +0 -54
  47. data/lib/zabbixapi/1.8/classes/screens.rb +0 -101
  48. data/lib/zabbixapi/1.8/classes/templates.rb +0 -109
  49. data/lib/zabbixapi/1.8/classes/usergroups.rb +0 -82
  50. data/lib/zabbixapi/1.8/classes/users.rb +0 -32
  51. data/lib/zabbixapi/2.0/basic/basic_alias.rb +0 -21
  52. data/lib/zabbixapi/2.0/basic/basic_func.rb +0 -55
  53. data/lib/zabbixapi/2.0/basic/basic_init.rb +0 -33
  54. data/lib/zabbixapi/2.0/classes/applications.rb +0 -45
  55. data/lib/zabbixapi/2.0/classes/errors.rb +0 -15
  56. data/lib/zabbixapi/2.0/classes/graphs.rb +0 -66
  57. data/lib/zabbixapi/2.0/classes/mediatypes.rb +0 -31
  58. data/lib/zabbixapi/2.0/classes/server.rb +0 -12
  59. data/lib/zabbixapi/2.0/classes/triggers.rb +0 -67
  60. data/lib/zabbixapi/2.0/classes/unusable.rb +0 -10
  61. data/spec/localhost.rb +0 -514
  62. data/spec/run.rb +0 -486
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
- metadata.gz: 635adc2b44f68bdca298f1fa7a72839901528f0e
4
- data.tar.gz: f257c9c6f322b313de54fb9b4893ddc37f217488
3
+ metadata.gz: acfb3f390844a6875bacfda608080b148a3872a2
4
+ data.tar.gz: 5c6a2e839a324b6de537b9e93d68db825a4e818f
5
5
  SHA512:
6
- metadata.gz: 4e893b3fc1a1cee7cc81d9e44e2f1af92f4a5f96cf0f3f2a62d3cdb007bae119b7988078dace1818a6d73cf64087ba7b216c52905d838dbf61d5b586b40d3c5f
7
- data.tar.gz: 3f1cc8fe7bfa1dc99d779c44d536fde3aa3e84dff2a666266f463c7b1f415e78f53ee75e6bcb0690f9690e5b4303b93e42c8a038b4f515e8d80b23f459e1cc72
6
+ metadata.gz: d47ef057a22a1268ea94f67c98381bff223037e8ff8f84fc48323c42bd96a5f5248bfd1396497a3ece93920acf25718f1d159fdda1e343b57d20d797a1781f76
7
+ data.tar.gz: 2af73a1a183dee4576ed0a213993579d454646b77db072deb77c69b06389c10661c9360b4ab3cd266d42abc510d2f67e2778a07600b59246a2e61747f01528f5
data/.travis.yml CHANGED
@@ -1,9 +1,14 @@
1
- language:
1
+ language:
2
2
  - ruby
3
- rvm:
3
+ rvm:
4
4
  - 1.9.3
5
+ - 2.0.0
6
+ - 2.1.1
5
7
  before_script:
6
- - sudo apt-get update; sudo apt-get install mysql-server zabbix-server-mysql zabbix-frontend-php
7
- - mysql -u root -e "use zabbix; insert into users_groups(usrgrpid, userid) values(10,1);"
8
- - echo "$(curl -fsSL https://gist.github.com/vadv/8f0df0d1824ea25a3827/raw/29b9fdd258d5cfcc89a505c166231359ad70d326/zabbix.php)" | sudo tee /usr/share/zabbix/conf/zabbix.conf.php
9
- script: "bundle exec rspec spec/run.rb"
8
+ - wget -qO - http://obs.express42.com/project_root:/zabbix2.0/precise/Release.key | sudo apt-key add -
9
+ - echo "deb http://obs.express42.com/project_root:/zabbix2.0/precise/ ./" | sudo tee /etc/apt/sources.list.d/zabbix.list
10
+ - sudo apt-get update
11
+ - sudo apt-get install libiodbc2
12
+ - sudo apt-get install zabbix-server-pgsql zabbix-frontend-php
13
+ - echo "$(curl -fsSL https://gist.githubusercontent.com/evtuhovich/9544441/raw/d661863063b76cc8e2599bc44d8595b1f86ece38/zabbix)" | sudo tee /etc/zabbix/web/zabbix.conf.php
14
+ script: "ZABBIX_HOST_URL=http://localhost/zabbix/api_jsonrpc.php bundle exec rspec spec/*"
data/README.md CHANGED
@@ -2,19 +2,31 @@
2
2
 
3
3
  Simple and lightweight ruby module for work with zabbix api
4
4
 
5
- [![Build Status](https://travis-ci.org/vadv/zabbixapi.png)](https://travis-ci.org/vadv/zabbixapi)
5
+ [![Build Status](https://travis-ci.org/express42/zabbixapi.png)](https://travis-ci.org/express42/zabbixapi)
6
6
 
7
7
  #####Now worked with zabbix
8
- * 1.8.2 (api version 1.2)
9
- * 1.8.9 (api version 1.3)
10
- * 2.0.x (api version 1.4 -> 2.0.6) [unstable]
8
+ * 1.8.2 (api version 1.2) /zabbixapi 0.6.x
9
+ * 1.8.9 (api version 1.3) /zabbixapi 0.6.x
10
+ * 2.0.x (api version 1.4 -> 2.0.10) /zabbixapi 2.0.x
11
+
12
+ ## Version policy
13
+
14
+ Zabbixapi has next version policy:
15
+ * for zabbix 1.8.9 and below you should use zabbixapi 0.6.x
16
+ * for zabbix 2.0.x you should use zabbixapi 2.0.y
17
+ * for zabbix 2.2.x you should use zabbixapi 2.2.y (coming soon)
18
+
19
+ The PATCH (third digit) version of zabbixapi should not correspond to PATCH version of zabbix, for example
20
+ zabbixapi-2.0.x should works with all version of zabbix 2.0.y
21
+
22
+ We support only two last versions of zabbix (2.0 and 2.2), so you should consider zabbixapi 0.6.x depricated.
11
23
 
12
24
  ## Installation
13
25
  ```
14
26
  gem install zabbixapi
15
27
  ```
16
28
 
17
- ## Get Start
29
+ ## Getting Started
18
30
 
19
31
  ### Connect
20
32
  ```ruby
@@ -30,8 +42,8 @@ zbx = ZabbixApi.connect(
30
42
  :url => 'http://localhost/zabbix/api_jsonrpc.php',
31
43
  :user => 'Admin',
32
44
  :password => 'zabbix',
33
- :http_password => 'bla-bla',
34
- :http_user => 'bla-bla'
45
+ :http_password => 'foo',
46
+ :http_user => 'bar'
35
47
  )
36
48
  ```
37
49
  ### Create Hostgroup
@@ -83,23 +95,7 @@ zbx.items.update(
83
95
  puts zbx.items.get_full_data(:description => "item")
84
96
  ```
85
97
 
86
- ### Create host (1.8)
87
- ```ruby
88
- zbx.hosts.add(
89
- :host => "hostname",
90
- :usedns => 1,
91
- :groups => [ :groupid => zbx.hostgroups.get_id(:name => "hostgroup") ]
92
- )
93
- #or use:
94
- zbx.hosts.create_or_update(
95
- :host => host,
96
- :usedns => 0,
97
- :ip => "10.20.48.89",
98
- :groups => [:groupid => zbx.hostgroups.get_id(:name => hostgroup)]
99
- )
100
- ```
101
-
102
- ### Create host (2.0 and later)
98
+ ### Create host
103
99
  ```ruby
104
100
  zbx.hosts.create(
105
101
  :host => host.fqdn,
@@ -370,4 +366,4 @@ zbx.query(
370
366
  ## Zabbix documentation
371
367
 
372
368
  * [Zabbix Project Homepage](http://zabbix.com/)
373
- * [Zabbix Api docs](http://www.zabbix.com/documentation/1.8/api)
369
+ * [Zabbix Api docs](https://www.zabbix.com/documentation/2.0/manual/appendix/api/api)
data/lib/zabbixapi.rb CHANGED
@@ -1,6 +1,27 @@
1
1
  require "zabbixapi/version"
2
2
  require "zabbixapi/client"
3
3
 
4
+ require "zabbixapi/basic/basic_alias"
5
+ require "zabbixapi/basic/basic_func"
6
+ require "zabbixapi/basic/basic_init"
7
+ require "zabbixapi/basic/basic_logic"
8
+
9
+ require "zabbixapi/classes/applications"
10
+ require "zabbixapi/classes/errors"
11
+ require "zabbixapi/classes/graphs"
12
+ require "zabbixapi/classes/hostgroups"
13
+ require "zabbixapi/classes/hosts"
14
+ require "zabbixapi/classes/items"
15
+ require "zabbixapi/classes/mediatypes"
16
+ require "zabbixapi/classes/proxies"
17
+ require "zabbixapi/classes/screens"
18
+ require "zabbixapi/classes/server"
19
+ require "zabbixapi/classes/templates"
20
+ require "zabbixapi/classes/triggers"
21
+ require "zabbixapi/classes/unusable"
22
+ require "zabbixapi/classes/usergroups"
23
+ require "zabbixapi/classes/usermacros"
24
+ require "zabbixapi/classes/users"
4
25
 
5
26
  class ZabbixApi
6
27
 
@@ -20,17 +41,9 @@ class ZabbixApi
20
41
 
21
42
  def initialize(options = {})
22
43
  @client = Client.new(options)
23
- case @client.api_version
24
- when "1.3", "1.2"
25
- apidir = "1.8"
26
- when "1.4", "2.0.4", "2.0.5", "2.0.6", "2.0.7", "2.0.8", "2.0.9"
27
- apidir = "2.0"
28
- else
29
- apidir = "2.0"
30
- puts "[DEBUG] Unknown API version: #{@client.api_version}. Continuing with #{apidir} apidir" if @client.options[:debug]
44
+ unless @client.api_version == "1.4" || @client.api_version =~ /2\.0\.\d+/
45
+ raise "Zabbix API version: #{@client.api_version} is not support by this version of zabbixapi"
31
46
  end
32
- Dir["#{File.dirname(__FILE__)}/zabbixapi/#{apidir}/basic/*.rb"].each { |f| load(f) }
33
- Dir["#{File.dirname(__FILE__)}/zabbixapi/#{apidir}/classes/*.rb"].each { |f| load(f) }
34
47
  end
35
48
 
36
49
  def server
File without changes
@@ -46,9 +46,9 @@ class ZabbixApi
46
46
  end
47
47
  end
48
48
 
49
- def merge_params(params)
50
- result = JSON.generate(default_options).to_s + "," + JSON.generate(params).to_s
51
- JSON.parse(result.gsub('},{', ','))
49
+ def merge_params(a, b)
50
+ new = a.dup
51
+ new.merge(b)
52
52
  end
53
53
 
54
54
  end
File without changes
@@ -4,7 +4,7 @@ class ZabbixApi
4
4
  def create(data)
5
5
  log "[DEBUG] Call create with parametrs: #{data.inspect}"
6
6
 
7
- data_with_default = default_options.empty? ? data : merge_params(data)
7
+ data_with_default = default_options.empty? ? data : merge_params(default_options, data)
8
8
  data_create = array_flag ? [data_with_default] : data_with_default
9
9
  result = @client.api_request(:method => "#{method_name}.create", :params => data_create)
10
10
  parse_keys result
@@ -25,9 +25,9 @@ class ZabbixApi
25
25
  id ? update(data.merge(key.to_sym => id.to_s)) : create(data)
26
26
  end
27
27
 
28
- def update(data)
28
+ def update(data)
29
29
  log "[DEBUG] Call update with parametrs: #{data.inspect}"
30
-
30
+
31
31
  dump = {}
32
32
  item_id = data[key.to_sym].to_i
33
33
  dump_by_id(key.to_sym => data[key.to_sym]).each do |item|
File without changes
File without changes
@@ -40,5 +40,9 @@ class ZabbixApi
40
40
  hostid ? update(data.merge(:hostid => hostid)) : create(data)
41
41
  end
42
42
 
43
+ # to make delete call idempotent for all resources
44
+ def delete(hostid)
45
+ super(:hostid => hostid)
46
+ end
43
47
  end
44
48
  end
@@ -50,5 +50,13 @@ class ZabbixApi
50
50
  }
51
51
  end
52
52
 
53
+ def delete(data)
54
+ log "[DEBUG] Call delete with parametrs: #{data.inspect}"
55
+
56
+ data_delete = array_flag ? [data] : [key.to_sym => data]
57
+ result = @client.api_request(:method => "#{method_name}.delete", :params => data_delete)
58
+ result['itemids'].keys[0].to_i
59
+ end
60
+
53
61
  end
54
62
  end
File without changes
@@ -29,25 +29,7 @@ class ZabbixApi
29
29
  end
30
30
 
31
31
  def delete(data)
32
- screen_name = data[:screen_name]
33
- screen_id = data[:screen_id]
34
-
35
- unless screen_name.nil?
36
- unless screen_name.instance_of?(Array)
37
- screen_id = get_id(:name => screen_name)
38
- else
39
- screen_id = []
40
- screen_name.each do |name|
41
- screen_id << get_id(:name => name)
42
- end
43
- end
44
- end
45
-
46
- unless screen_id.instance_of?(Array)
47
- screen_id = [screen_id, screen_id]
48
- end
49
-
50
- result = @client.api_request(:method => "screen.delete", :params => screen_id)
32
+ result = @client.api_request(:method => "screen.delete", :params => [data])
51
33
  result.empty? ? nil : result['screenids'][0].to_i
52
34
  end
53
35
 
File without changes
@@ -21,7 +21,7 @@ class ZabbixApi
21
21
  # * *Returns* :
22
22
  # - Nil or Integer
23
23
  def delete(data)
24
- result = @client.api_request(:method => "template.delete", :params => [:templateid => data])
24
+ result = @client.api_request(:method => "template.delete", :params => [data])
25
25
  result.empty? ? nil : result['templateids'][0].to_i
26
26
  end
27
27
 
@@ -87,14 +87,14 @@ class ZabbixApi
87
87
  end
88
88
 
89
89
  # Analog Zabbix api call massRemove
90
- #
90
+ #
91
91
  # * *Args* :
92
92
  # - +data+ -> Hash with :hosts_id => [hostid1, hostid2 ...], and :templates_id => [templateid1, templateid2 ...]
93
93
  # * *Returns* :
94
94
  # - True or False
95
95
  def mass_remove(data)
96
96
  result = @client.api_request(
97
- :method => "template.massRemove",
97
+ :method => "template.massRemove",
98
98
  :params => {
99
99
  :hostids => data[:hosts_id],
100
100
  :templateids => data[:templates_id],
@@ -102,7 +102,7 @@ class ZabbixApi
102
102
  :force => 1
103
103
  }
104
104
  )
105
- result.empty? ? false : true
105
+ result.empty? ? false : true
106
106
  end
107
107
 
108
108
  end
File without changes
File without changes
@@ -17,18 +17,6 @@ class ZabbixApi
17
17
  "name"
18
18
  end
19
19
 
20
- # Delete UserGroup
21
- #
22
- # * *Args* :
23
- # - +data+ -> Array with usrgrpids
24
- # * *Returns* :
25
- # - Nil or Integer
26
- def delete(data)
27
- result = @client.api_request(:method => "usergroup.delete", :params => data)
28
- result ? result['usrgrpids'][0].to_i : nil
29
- end
30
-
31
-
32
20
  # Return usrgrpid
33
21
  #
34
22
  # * *Args* :
@@ -19,13 +19,13 @@ class ZabbixApi
19
19
 
20
20
  def add_medias(data)
21
21
  result = @client.api_request(
22
- :method => "user.addMedia",
22
+ :method => "user.addMedia",
23
23
  :params => {
24
24
  :users => data[:userids].map { |t| {:userid => t} },
25
25
  :medias => data[:media]
26
26
  }
27
27
  )
28
- result ? result['userids'][0].to_i : nil
28
+ result ? result['mediaids'][0].to_i : nil
29
29
  end
30
30
 
31
31
  end
@@ -1,3 +1,3 @@
1
1
  class ZabbixApi
2
- VERSION = "0.6.6"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -0,0 +1,74 @@
1
+ #encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'application' do
6
+ before :all do
7
+ @hostgroup = gen_name 'hostgroup'
8
+ @hostgroupid = zbx.hostgroups.create(:name => @hostgroup)
9
+ @template = gen_name 'template'
10
+ @templateid = zbx.templates.create(
11
+ :host => @template,
12
+ :groups => [:groupid => @hostgroupid]
13
+ )
14
+ end
15
+
16
+ context 'when name not exists' do
17
+ before do
18
+ @application = gen_name 'application'
19
+ end
20
+
21
+ describe 'create' do
22
+ it "should return integer id" do
23
+ applicationid = zbx.applications.create(
24
+ :name => @application,
25
+ :hostid => @templateid
26
+ )
27
+ applicationid.should be_kind_of(Integer)
28
+ end
29
+ end
30
+
31
+ describe 'get_id' do
32
+ it "should return nil" do
33
+ expect(zbx.applications.get_id(:host => @application)).to be_kind_of(NilClass)
34
+ end
35
+ end
36
+ end
37
+
38
+ context 'when name exists' do
39
+ before :all do
40
+ @application = gen_name 'application'
41
+ @applicationid = zbx.applications.create(
42
+ :name => @application,
43
+ :hostid => @templateid
44
+ )
45
+ end
46
+
47
+ describe 'get_or_create' do
48
+ it "should return id of application" do
49
+ expect(zbx.applications.get_or_create(
50
+ :name => @application,
51
+ :hostid => @templateid
52
+ )).to eq @applicationid
53
+ end
54
+ end
55
+
56
+ describe 'get_full_data' do
57
+ it "should contains created application" do
58
+ expect(zbx.applications.get_full_data(:name => @application)[0]).to include("name" => @application)
59
+ end
60
+ end
61
+
62
+ describe 'get_id' do
63
+ it "should return id of application" do
64
+ expect(zbx.applications.get_id(:name => @application)).to eq @applicationid
65
+ end
66
+ end
67
+
68
+ describe "delete" do
69
+ it "should return id" do
70
+ zbx.applications.delete(@applicationid).should eq @applicationid
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,4 @@
1
+ require 'spec_helper'
2
+
3
+ describe ZabbixApi::Basic do
4
+ end
data/spec/graph.rb ADDED
@@ -0,0 +1,135 @@
1
+ #encoding: utf-8
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'graph' do
6
+ before :all do
7
+ @hostgroup = gen_name 'hostgroup'
8
+ @hostgroupid = zbx.hostgroups.create(:name => @hostgroup)
9
+ @template = gen_name 'template'
10
+ @templateid = zbx.templates.create(
11
+ :host => @template,
12
+ :groups => [:groupid => @hostgroupid]
13
+ )
14
+ @application = gen_name 'application'
15
+ @applicationid = zbx.applications.create(
16
+ :name => @application,
17
+ :hostid => @templateid
18
+ )
19
+ @item = gen_name 'item'
20
+ @itemid = zbx.items.create(
21
+ :name => @item,
22
+ :key_ => "proc.num[#{gen_name 'proc'}]",
23
+ :status => 0,
24
+ :hostid => @templateid,
25
+ :applications => [@applicationid]
26
+ )
27
+
28
+ @color = "123456"
29
+ end
30
+
31
+ def gitems
32
+ {
33
+ :itemid => @itemid,
34
+ :calc_fnc => "3",
35
+ :color => @color,
36
+ :type => "0",
37
+ :periods_cnt => "5"
38
+ }
39
+ end
40
+
41
+ def create_graph(graph, itemid)
42
+ zbx.graphs.create(
43
+ :gitems => [gitems],
44
+ :show_triggers => "0",
45
+ :name => graph,
46
+ :width => "900",
47
+ :height => "200"
48
+ )
49
+ end
50
+
51
+
52
+ context 'when name not exists' do
53
+ describe 'create' do
54
+ it "should return integer id" do
55
+ @graph = gen_name 'graph'
56
+ expect(create_graph(@graph, @itemid)).to be_kind_of(Integer)
57
+ end
58
+ end
59
+ end
60
+
61
+ context 'when name exists' do
62
+ before :all do
63
+ @graph = gen_name 'graph'
64
+ @graphid = create_graph(@graph, @itemid)
65
+ end
66
+
67
+ describe 'get_or_create' do
68
+ it "should return id of existing graph" do
69
+ zbx.graphs.get_or_create(
70
+ :gitems => [gitems],
71
+ :show_triggers => "0",
72
+ :name => @graph,
73
+ :width => "900",
74
+ :height => "200"
75
+ ).should eq @graphid
76
+ end
77
+ end
78
+
79
+ describe 'get_items' do
80
+ it "should return array" do
81
+ expect(zbx.graphs.get_items( @graphid )).to be_kind_of(Array)
82
+ end
83
+
84
+ it "should return array of size 1" do
85
+ expect(zbx.graphs.get_items( @graphid ).size).to eq 1
86
+ end
87
+
88
+ it "should include correct item" do
89
+ expect(zbx.graphs.get_items( @graphid )[0]).to include("color" => @color)
90
+ end
91
+ end
92
+
93
+ describe 'get_id' do
94
+ it "should return id" do
95
+ zbx.graphs.get_id( :name => @graph ).should eq @graphid
96
+ end
97
+ end
98
+
99
+ describe 'get_ids_by_host' do
100
+ it "should contains id of graph" do
101
+ graph_array = zbx.graphs.get_ids_by_host( :host => @host )
102
+ graph_array.should be_kind_of(Array)
103
+ graph_array.should include(@graphid.to_s)
104
+ end
105
+ end
106
+
107
+ describe 'update' do
108
+ it "should return id" do
109
+ zbx.graphs.update(
110
+ :graphid => @graphid,
111
+ :gitems => [gitems],
112
+ :ymax_type => 1
113
+ ).should eq @graphid
114
+ end
115
+ end
116
+
117
+ describe 'create_or_update' do
118
+ it "should return existing id" do
119
+ zbx.graphs.create_or_update(
120
+ :gitems => [gitems],
121
+ :show_triggers => "1",
122
+ :name => @graph,
123
+ :width => "900",
124
+ :height => "200"
125
+ ).should eq @graphid
126
+ end
127
+ end
128
+
129
+ describe 'delete' do
130
+ it "should return true" do
131
+ expect(zbx.graphs.delete(@graphid)).to eq @graphid
132
+ end
133
+ end
134
+ end
135
+ end