copperegg 0.5.2 → 0.5.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,11 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- copperegg (0.0.0)
4
+ copperegg (0.5.3.pre2)
5
+ multi_json (>= 1.3.0)
5
6
 
6
7
  GEM
7
8
  remote: http://rubygems.org/
8
9
  specs:
10
+ multi_json (1.5.0)
9
11
 
10
12
  PLATFORMS
11
13
  ruby
Binary file
data/copperegg-0.5.2.gem CHANGED
Binary file
Binary file
Binary file
@@ -23,8 +23,26 @@ module CopperEgg
23
23
  return
24
24
  end
25
25
 
26
- def samples(starttime, endtime, group_name, metricname)
27
- samples = @util.make_api_get_request("/samples.json", @apikey, nil)
26
+ def samples(group_name, metricname, starttime=nil, duration=nil, sample_size=nil)
27
+ return if group_name.nil?
28
+ return if metricname.nil?
29
+
30
+ metric_name = []
31
+ metrics = {}
32
+ metric_gid = []
33
+ query = {}
34
+ params = {}
35
+
36
+ metric_name = [metricname]
37
+ metrics["metrics"] = metric_name
38
+ metric_gid = [metrics]
39
+ query[group_name] = metric_gid
40
+ params["queries"] = query
41
+ params["starttime"] = starttime if !starttime.nil?
42
+ params["duration"] = duration if !duration.nil?
43
+ params["sample_size"] = sample_size if !sample_size.nil?
44
+
45
+ samples = @util.make_api_get_request("/samples.json", @apikey, params)
28
46
  return samples
29
47
  end
30
48
 
@@ -58,7 +76,9 @@ module CopperEgg
58
76
  dashes = @util.make_api_get_request("/dashboards.json", @apikey, nil)
59
77
  return nil if dashes.nil?
60
78
 
61
- dashboards = JSON.parse(dashes.body)
79
+ # dashboards = JSON.parse(dashes.body)
80
+ # modified 12-10-2012 ... get returns the body
81
+ dashboards = JSON.parse(dashes)
62
82
  dashboards.each do |dash|
63
83
  if dash["name"] == dashboard_name
64
84
  return dash
@@ -42,20 +42,38 @@ module CopperEgg
42
42
  end
43
43
 
44
44
  if type == "get"
45
- uri.query = URI.encode_www_form(params) if !params.nil?
46
45
  request = Net::HTTP::Get.new(uri.request_uri)
46
+ request.body = MultiJson.dump(params)
47
47
  else
48
48
  request = Net::HTTP::Post.new(uri.request_uri)
49
49
  request.body = MultiJson.dump(params)
50
50
  end
51
-
51
+
52
52
  request.basic_auth(apikey, "U")
53
53
  request["Content-Type"] = "application/json"
54
- response = http.request(request)
55
- if response.code != "200"
54
+
55
+ connect_try_count = 0
56
+ response = nil
57
+ begin
58
+ response = http.request(request)
59
+ rescue Exception => e
60
+ connect_try_count += 1
61
+ if connect_try_count > 1
62
+ log "#{e.inspect}"
63
+ raise e
64
+ end
65
+ sleep 0.5
66
+ retry
67
+ end
68
+
69
+ if response == nil || response.code != "200"
56
70
  return nil
57
71
  end
58
- return response
72
+ if type == "get"
73
+ return response.body
74
+ else
75
+ return response
76
+ end
59
77
  end
60
78
 
61
79
  end
data/lib/copperegg/ver.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CopperEgg
2
- GEM_VERSION = '0.5.2'
2
+ GEM_VERSION = '0.5.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: copperegg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.2
4
+ version: 0.5.3
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: 2012-12-03 00:00:00.000000000 Z
12
+ date: 2012-12-11 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json
@@ -38,7 +38,10 @@ files:
38
38
  - ./LICENSE
39
39
  - ./README.md
40
40
  - ./Rakefile
41
+ - ./copperegg-0.5.2.1.gem
41
42
  - ./copperegg-0.5.2.gem
43
+ - ./copperegg-0.5.3.pre.gem
44
+ - ./copperegg-0.5.3.pre2.gem
42
45
  - ./copperegg.gemspec
43
46
  - ./examples/example.rb
44
47
  - ./lib/copperegg/metrics.rb