circonus 1.0.17 → 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 (3) hide show
  1. data/lib/circonus.rb +10 -56
  2. data/lib/circonus/values.rb +0 -1
  3. metadata +2 -2
data/lib/circonus.rb CHANGED
@@ -2,7 +2,6 @@
2
2
  # Tue Sep 18 20:18:09 EDT 2012
3
3
  # -- David Nicklay
4
4
  #https://circonus.com/resources/api/templates
5
- # --TODO caught in between v1 and v2 docs at the moment ... class is a mess because of it
6
5
 
7
6
  require 'rubygems'
8
7
  require 'restclient'
@@ -34,7 +33,6 @@ class Circonus
34
33
  "X-Circonus-App-Name" => @appname,
35
34
  "Accept" => 'application/json'
36
35
  }
37
- @url_v1_prefix = "https://circonus.com/api/json/"
38
36
  @url_prefix = "https://api.circonus.com/v2/"
39
37
  @options = DEFAULT_OPTIONS.merge(options)
40
38
  end
@@ -104,41 +102,6 @@ class Circonus
104
102
  return Yajl::Parser.parse(r)
105
103
  end
106
104
 
107
- def v1_list(method)
108
- url = @url_v1_prefix + 'list_' + method
109
- r, err = _rest('get',url,@headers)
110
- return nil,err if r.nil?
111
- return Yajl::Parser.parse(r)
112
- end
113
-
114
- def v1_get(method,id)
115
- cid = id.to_s.split('/').last
116
- headers = @headers.merge({:params => {"#{method}_id".to_sym => cid}}) # attempt to guess at the id name expected
117
- url = @url_v1_prefix + 'get_' + method
118
- #print "url=#{url}\n"
119
- #pp headers
120
- r, err = _rest('get',url, headers)
121
- return nil,err if r.nil?
122
- return Yajl::Parser.parse(r)
123
- end
124
-
125
- def v1_delete(method,id)
126
- cid = id.to_s.split('/').last
127
- headers = @headers.merge({:params => {"#{method}_id".to_sym => cid}}) # attempt to guess at the id name expected
128
- url = @url_v1_prefix + 'delete_' + method
129
- r, err = _rest('delete',url, headers)
130
- return nil,err if r.nil?
131
- return Yajl::Parser.parse(r)
132
- end
133
-
134
- def v1_add(method, data, params)
135
- headers = @headers.merge({:params => params})
136
- r,err = _rest 'get',@url_v1_prefix + 'add_' + method, headers, data
137
- return nil,err if r.nil?
138
- return Yajl::Parser.parse(r)
139
- end
140
-
141
- # Version 2
142
105
  # Not all these are available:
143
106
  %w{ account annotation broker check_bundle contact_group graph rule_set template user worksheet check }.each do |m|
144
107
  define_method("list_#{m}".to_sym) do |*filter|
@@ -161,6 +124,15 @@ class Circonus
161
124
  end
162
125
  end
163
126
 
127
+ %w{ alert }.each do |m|
128
+ define_method("list_#{m}".to_sym) do |*filter|
129
+ return list(m,filter.first)
130
+ end
131
+ define_method("get_#{m}".to_sym) do |id|
132
+ return get(m,id)
133
+ end
134
+ end
135
+
164
136
  # extraction of time ranged data (this one is a bit different from the other v2 ones)
165
137
  def get_data(cid,metric,params = {})
166
138
  params['start'] = (Time.now - 3600).to_i unless params.has_key? 'start'
@@ -174,23 +146,5 @@ class Circonus
174
146
  return nil,err if r.nil?
175
147
  return Yajl::Parser.parse(r)
176
148
  end
177
-
178
- # Version 1 (Deprecated)
179
- %w{ metric check template annotation graph worksheet rule account user agent }.each do |m|
180
- define_method("v1_list_#{m}s".to_sym) do
181
- return v1_list(m + 's')
182
- end
183
- define_method("v1_get_#{m}".to_sym) do |id|
184
- return v1_get(m,id)
185
- end
186
- define_method("v1_delete_#{m}".to_sym) do |id|
187
- return v1_delete(m,id)
188
- end
189
- define_method("v1_add_#{m}".to_sym) do |data,params|
190
- return v1_add(m,data,params)
191
- end
192
- define_method ("v1_search_#{m}".to_sym) do |match,field|
193
- return v1_list(m + 's').select { |t| t[field].match(match) }
194
- end
195
- end
196
149
  end
150
+
@@ -37,7 +37,6 @@ class Circonus
37
37
  "X-Circonus-App-Name" => @appname,
38
38
  "Accept" => 'application/json'
39
39
  }
40
- @url_v1_prefix = "https://circonus.com/api/json/"
41
40
  @url_prefix = "https://api.circonus.com/v2/"
42
41
  end
43
42
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: circonus
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.17
4
+ version: 2.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-11-13 00:00:00.000000000 Z
12
+ date: 2014-01-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client