uptrends 0.5.0 → 0.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 78fa8b9b3cc7b45b11bacd36e2c011c66e272830
4
- data.tar.gz: 94ced9671b00a46aa74dbb7d32e94bee4eb0b6f1
3
+ metadata.gz: f3eec07be4199710dfb8183f46e9d116b2a5ead3
4
+ data.tar.gz: c7f300a0ae25056637c54311c3484c0e19f98ba5
5
5
  SHA512:
6
- metadata.gz: f6a1536e1e06ecf5c14ced0ef67ccc6c28cddc6022ced43d874489ec3ee25a68819b524ee99efd24729827b667976322325fa68909710192836cee034bc77eb6
7
- data.tar.gz: 0af5cd18bef97137322ec8c2583389ae698db370b09ae55ca5eb397b479dea89a55ccc8692ad71ac1f20b9b236ce0c34710161ab46c27cba0b515caf94b8191f
6
+ metadata.gz: 945ec3fbe5042a5600b655da7c7b717d1267f25946849a597beb2eea3aa6eab753462c826a6344a2b73b28ed53039aa523934f71de67aaf120c4ea9762d1436e
7
+ data.tar.gz: 30bcaaae4a6cd20923cb70fb8c6cc0b00cb5465bfc51f4ae91578039f8b4624efa47222723f2e0c94cd9b937d010ce29abbe6c7094458b857c9247aa973d3eff
@@ -2,5 +2,5 @@
2
2
 
3
3
  ## 0.5.0
4
4
  - Added Uptrends::Monitor class.
5
- - Added Uptrends::Client#monitors methods to fetch all monitors.
5
+ - Added Uptrends::Client#monitors method to fetch all monitors.
6
6
 
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
- # Uptrends
1
+ # Uptrends RESTful API Client
2
2
 
3
3
  [![Code Climate](https://codeclimate.com/github/jasonwbarnett/uptrends-gem/badges/gpa.svg)](https://codeclimate.com/github/jasonwbarnett/uptrends-gem) [![Test Coverage](https://codeclimate.com/github/jasonwbarnett/uptrends-gem/badges/coverage.svg)](https://codeclimate.com/github/jasonwbarnett/uptrends-gem) [![Build Status](https://travis-ci.org/jasonwbarnett/uptrends-gem.svg?branch=master)](https://travis-ci.org/jasonwbarnett/uptrends-gem)
4
4
 
5
5
  This is a ruby wrapper around the [Uptrends API][2]. Uptrends is a monitoring service that let's you monitor Web pages, Web services, Mail servers, Database servers, DNS, SSL certificates, FTP and more.
6
6
 
7
+ NOTE: This is a 3rd party gem and not an official product from Uptrends.
8
+
7
9
  ## Installation
8
10
 
9
11
  Add this line to your application's Gemfile:
@@ -20,68 +22,27 @@ Or install it yourself as:
20
22
 
21
23
  ## Usage
22
24
 
23
- First initialize an instance of the API Client and then we play with it:
24
-
25
25
  require 'uptrends'
26
- u = Uptrends::Client.new(username: 'my@email.com', password: 'MyP@sswo0rd')
27
- # => #<Uptrends::Client:0x00000101309e48 @username="my@email.com">
28
-
29
- Query your account for all probes:
30
-
31
- probes = u.probes # Returns an array of probes
32
- # => [#<Uptrends::Probe:0x0000010336cac8 ...>, #<Uptrends::Probe:0x0000010336cac9 ...>, ... ]
33
-
34
- Query your account for all probe __groups__:
35
-
36
- probe_groups = u.probe_groups # Returns an array of probe groups
37
- # => [#<Uptrends::ProbeGroup:0x000001021594f8 ...>, #<Uptrends::ProbeGroup:0x000001021592f0 ...>, ... ]
38
-
39
- Let's select the first probe and look at it's attributes
40
-
41
- p = probes.first
42
- # => #<Uptrends::Probe:0x0000010336cac8 ...>
43
-
44
- p.attributes
45
- # => [:guid, :name, :url, :port, :check_frequency, :probe_type, :is_active, :generate_alert, :notes, :performance_limit1, :performance_limit2, :error_on_limit1, :error_on_limit2, :min_bytes, :error_on_min_bytes, :timeout, :tcp_connect_timeout, :match_pattern, :dns_lookup_mode, :user_agent, :user_name, :password, :is_competitor, :checkpoints, :http_method, :post_data]
46
-
47
- p.guid
48
- # => "7ef43a1b255949f5a052444348971690"
26
+ u = Uptrends::Client.new(username: 'my@email.com', password: 'MyP@sswo0rd') #=> #<Uptrends::Client>
49
27
 
50
- p.name
51
- # => "My Probe's Name"
28
+ probes = u.probes #=> [#<Uptrends::Probe>, #<Uptrends::Probe>, ...]
29
+ p = probes.first #=> #<Uptrends::Probe>
30
+ p.attributes #=> [:guid, :name, :url, :port, :check_frequency, :probe_type, :is_active, :generate_alert, :notes, :performance_limit1, :performance_limit2, :error_on_limit1, :error_on_limit2, :min_bytes, :error_on_min_bytes, :timeout, :tcp_connect_timeout, :match_pattern, :dns_lookup_mode, :user_agent, :user_name, :password, :is_competitor, :checkpoints, :http_method, :post_data]
31
+ p.guid #=> "7ef43a1b255949f5a052444348971690"
32
+ p.name #=> "My Probe's Name"
52
33
 
53
- Let's select the first probe __group__ and look at it's attributes
54
-
55
- pg = probe_groups.first
56
- # => #<Uptrends::ProbeGroup:0x000001021594f8 ...>
57
-
58
- pg.attributes
59
- # => [:guid, :name, :is_all, :is_client_probe_group]
60
-
61
- pg.guid
62
- # => "c8d6a0f704494c37823850f3d4fd4273"
63
-
64
- pg.name
65
- # => "All probes"
66
-
67
- If you wanted to update the probe, all you need to do is change as many attributes as you want and then update, e.g.
34
+ probe_groups = u.probe_groups #=> [#<Uptrends::ProbeGroup>, #<Uptrends::ProbeGroup>, ... ]
35
+ pg = probe_groups.first #=> #<Uptrends::ProbeGroup>
36
+ pg.attributes #=> [:guid, :name, :is_all, :is_client_probe_group]
37
+ pg.guid #=> "c8d6a0f704494c37823850f3d4fd4273"
38
+ pg.name #=> "All probes"
68
39
 
69
40
  # Let's change the name of the probe:
41
+ p.name = "My Probe's NEW name" #=> "My Probe's NEW name"
42
+ p.update! #=> nil
70
43
 
71
- p.name = "My Probe's NEW name"
72
- # => "My Probe's NEW name"
73
-
74
- response = u.update_probe(p)
75
- # => #<HTTParty::Response:0x10 parsed_response=nil, @response=#<Net::HTTPOK 200 OK readbody=true>, @headers={"cache-control"=>["private"], "server"=>["Microsoft-IIS/7.5"], "x-servername"=>["OBI"], "x-aspnet-version"=>["4.0.30319"], "x-powered-by"=>["ASP.NET"], "x-server"=>["OBI"], "date"=>["Sat, 26 Jul 2014 20:21:00 GMT"], "connection"=>["close"], "content-length"=>["0"]}>
76
-
77
- response.response
78
- # => #<Net::HTTPOK 200 OK readbody=true>
79
-
80
- Let's add our probe to a probe group
81
-
82
- response = u.add_probe_to_group(probe: p, group: pg)
83
- response.response
84
- # => #<Net::HTTPCreated 201 Created readbody=true>
44
+ # Let's add our probe to our probe group
45
+ pg.add_probe(p) #=> [#<Uptrends::ProbeGroup>, #<Uptrends::Probe>]
85
46
 
86
47
  ## Contributing
87
48
 
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- require 'uptrends/client'
2
+ require 'uptrends'
3
3
 
4
4
  (puts "You must set both the \"UPTRENDS_USERNAME\" and \"UPTRENDS_PASSWORD\" environment variables, exiting..."; exit 1;) unless ENV['UPTRENDS_USERNAME'] && ENV['UPTRENDS_PASSWORD']
5
5
 
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env ruby
2
+ require "uptrends"
3
+ require "ipaddr"
4
+
5
+ (puts "You must set both the \"UPTRENDS_USERNAME\" and \"UPTRENDS_PASSWORD\" environment variables, exiting..."; exit 1;) unless ENV['UPTRENDS_USERNAME'] && ENV['UPTRENDS_PASSWORD']
6
+
7
+ u = Uptrends::Client.new(username: ENV['UPTRENDS_USERNAME'], password: ENV['UPTRENDS_PASSWORD'])
8
+ checkpoint_ips = u.checkpoints.inject([]) { |memo,x| memo << x.ip_address; memo }.sort_by { |x| IPAddr.new(x) }
9
+
10
+ checkpoint_ips.each do |ip|
11
+ puts "allow #{ip};"
12
+ end
@@ -1,6 +1,3 @@
1
1
  require "uptrends/version"
2
2
  require "uptrends/client"
3
3
 
4
- module Uptrends
5
- # Your code goes here...
6
- end
@@ -1,20 +1,105 @@
1
- require 'json'
2
- require 'uptrends/utils'
1
+ require "uptrends/api_error"
2
+ require "json"
3
+ require "active_support/inflector"
3
4
 
4
5
  module Uptrends
5
6
  class Base
6
7
 
7
- attr_reader :original_hash, :attributes
8
+ attr_reader :attributes
8
9
 
9
- def initialize(probe_hash = {})
10
- @original_hash = probe_hash
10
+ def initialize(client, response, attributes = {})
11
+ @client = client
12
+ @attributes = attributes
13
+ gen_and_set_accessors
14
+ end
15
+
16
+ def create!
17
+ response = @client.class.post(api_url, body: gen_request_body)
18
+ self.class.parse(@client, response)
19
+ end
11
20
 
12
- Uptrends::Utils.gen_and_set_accessors(self)
21
+ def update!
22
+ response = @client.class.put("#{api_url}/#{@guid}", body: gen_request_body)
23
+ self.class.check_error!(response)
24
+ end
25
+
26
+ def delete!
27
+ response = @client.class.delete("#{api_url}/#{@guid}")
28
+ self.class.check_error!(response)
29
+ end
30
+
31
+ def self.check_error!(response)
32
+ response_code = response.response.code.to_i
33
+ case response_code
34
+ when 200...300
35
+ response.parsed_response
36
+ else
37
+ raise Uptrends::ApiError.new(response.parsed_response)
38
+ end
39
+ end
40
+
41
+ def self.parse(client, response)
42
+ check_error!(response)
43
+ parsed_response = response.parsed_response
44
+ if Array === parsed_response
45
+ parsed_response.map do |item|
46
+ new(client, response, item)
47
+ end
48
+ else
49
+ new(client, response, parsed_response)
50
+ end
13
51
  end
14
52
 
15
53
  def to_s
16
- Uptrends::Utils.to_s(self)
54
+ string = []
55
+ attributes.each do |attr|
56
+ string << "#{attr}: #{self.send(attr)}"
57
+ end
58
+
59
+ "#{string.join("\n")}"
60
+ end
61
+
62
+ private
63
+
64
+ # This method sets up all of our attr_accessor so we can easily edit probe attributes
65
+ def gen_and_set_accessors
66
+ attributes = []
67
+ self.attributes.each_pair do |k,v|
68
+
69
+ k = k.to_s.underscore
70
+ case k
71
+ when "guid"
72
+ # setup attr_reader for guid and set it's value.
73
+ self.class.send(:attr_reader, k)
74
+ self.instance_variable_set("@#{k}", v)
75
+ else
76
+ # setup a attr_accessor for all other attributes
77
+ self.class.send(:attr_accessor, k)
78
+ self.send("#{k}=", v)
79
+ end
80
+ attributes << k.to_sym
81
+
82
+ end
83
+
84
+ @attributes = attributes
85
+ end
86
+
87
+ def gen_request_body
88
+ new_hash = @attributes.inject({}) do |memo,(k,v)|
89
+ if k.to_s.underscore == 'guid'
90
+ memo
91
+ else
92
+ memo[k.to_s.camelize] = self.send(k.to_s.underscore)
93
+ memo
94
+ end
95
+ end
96
+
97
+ request_body = JSON.dump(new_hash)
98
+ puts "DEBUG :: Request Body :: #{request_body}" if @client.debug
99
+
100
+ request_body
17
101
  end
18
102
 
19
103
  end
20
104
  end
105
+
@@ -1,8 +1,36 @@
1
- require 'json'
2
- require 'uptrends/utils'
3
1
  require 'uptrends/base'
4
2
 
5
3
  module Uptrends
6
4
  class Checkpoint < Base
5
+
6
+ def initialize(client, response, attributes = {})
7
+ @attributes = attributes
8
+ gen_and_set_accessors
9
+ end
10
+
11
+ undef_method :create!
12
+ undef_method :update!
13
+ undef_method :delete!
14
+
15
+ private
16
+ def api_url
17
+ "/checkpointservers"
18
+ end
19
+
20
+ def gen_and_set_accessors
21
+ attributes = []
22
+ self.attributes.each_pair do |k,v|
23
+
24
+ k = k.to_s.underscore
25
+ # setup attr_reader for all attributes and set it's value.
26
+ self.class.send(:attr_reader, k)
27
+ self.instance_variable_set("@#{k}", v)
28
+
29
+ attributes << k.to_sym
30
+ end
31
+
32
+ @attributes = attributes
33
+ end
34
+
7
35
  end
8
36
  end
@@ -2,8 +2,6 @@ require "httparty"
2
2
  require "uptrends/probe"
3
3
  require "uptrends/probe_group"
4
4
  require "uptrends/checkpoint"
5
- require "uptrends/utils"
6
- require "uptrends/api_error"
7
5
 
8
6
  module Uptrends
9
7
  class Client
@@ -11,11 +9,12 @@ module Uptrends
11
9
  format :json
12
10
  base_uri('https://api.uptrends.com/v3')
13
11
 
14
- attr_reader :username
12
+ attr_reader :username, :debug
15
13
 
16
14
  def initialize(opts = {})
17
15
  @username = opts[:username] ? opts[:username] : fail("You must specify the :username option")
18
16
  password = opts[:password] ? opts[:password] : fail("You must specify the :password option")
17
+ @debug = opts[:debug]
19
18
 
20
19
  # This makes it so that every request uses basic auth
21
20
  self.class.basic_auth(@username, password)
@@ -25,152 +24,60 @@ module Uptrends
25
24
  self.class.headers({'Content-Type' => 'application/json', 'Accept' => 'application/json'})
26
25
  end
27
26
 
28
- def probes(opts = {})
29
- if opts[:refresh]
30
- @probes = get_probes
31
- else
32
- @probes ||= get_probes
33
- end
27
+ def probe(guid)
28
+ get(Uptrends::Probe, guid: guid)
34
29
  end
35
30
 
36
- def checkpoints(opts = {})
37
- if opts[:refresh]
38
- @checkpoints = get_checkpoints
39
- else
40
- @checkpoints ||= get_checkpoints
41
- end
31
+ def probe_group(guid)
32
+ get(Uptrends::ProbeGroup, guid: guid)
42
33
  end
43
34
 
44
- def probe_groups
45
- @probe_groups ||= get_probe_groups
35
+ def probes
36
+ get(Uptrends::Probe, all: true)
46
37
  end
47
38
 
48
- def get_probe_group_members(opts = {})
49
- group = opts[:group]
50
- fail("You must pass a probe group using group: option.") unless Uptrends::ProbeGroup === group
51
- group_guid = opts[:group].guid ? opts[:group].guid : fail("The probe group you passed does not have a guid.")
52
-
53
- res = self.class.get("/probegroups/#{group_guid}/members")
54
- parsed_response = raise_or_return(res)
55
- probe_group_members = parsed_response.inject([]) do |memo, x|
56
- memo << Uptrends::Probe.new(x)
57
- memo
58
- end
39
+ def checkpoints
40
+ get(Uptrends::Checkpoint, all: true)
59
41
  end
60
42
 
61
- def add_probe(opts = {})
62
- probe = Uptrends::Probe.new(opts)
63
- res = self.class.post("/probes", body: Uptrends::Utils.gen_request_body(probe))
64
- parsed_response = raise_or_return(res)
65
- new_probe = Uptrends::Probe.new(parsed_response)
66
-
67
- probes << new_probe
68
-
69
- new_probe
70
- end
71
-
72
- def add_probe_to_group(opts = {})
73
- probe = opts[:probe]
74
- group = opts[:group]
75
-
76
- fail("You must pass a probe and probe group using probe: and group: opts.") unless Uptrends::Probe === probe && Uptrends::ProbeGroup === group
77
-
78
- probe_guid = opts[:probe].guid ? opts[:probe].guid : fail("The probe you passed does not have a guid.")
79
- group_guid = opts[:group].guid ? opts[:group].guid : fail("The probe group you passed does not have a guid.")
80
-
81
-
82
- post_body = JSON.dump({"ProbeGuid" => probe_guid})
83
- res = self.class.post("/probegroups/#{group_guid}/members", body: post_body)
84
- raise_or_return(res)
85
- end
86
-
87
- def update_probe(probe)
88
- res = self.class.put("/probes/#{probe.guid}", body: Uptrends::Utils.gen_request_body(probe))
89
- raise_or_return(res)
43
+ def probe_groups
44
+ get(Uptrends::ProbeGroup, all: true)
90
45
  end
91
46
 
92
- def delete_probe(probe)
93
- res = self.class.delete("/probes/#{probe.guid}")
94
- raise_or_return(res)
95
-
96
- probes.delete_if { |x| x.guid == probe.guid }
47
+ def add_probe(opts = {})
48
+ p = Uptrends::Probe.new(self, nil, opts)
49
+ p.create!
97
50
  end
98
51
 
99
- def create_http_probe(opts = {})
100
- name = opts[:name] ? opts[:name] : fail("You must provide a name!")
101
- url = opts[:url] ? opts[:url] : fail("You must provide a URL!")
102
- check_frequency = opts[:check_frequency] ? opts[:check_frequency] : 15
103
- match_pattern = opts[:match_pattern]
104
-
105
- probe = Uptrends::Probe.new(gen_new_probe_hash(name, url, check_frequency, match_pattern))
106
- res = self.class.post("/probes", body: Uptrends::Utils.gen_request_body(probe))
107
- parsed_response = raise_or_return(res)
108
- new_probe = Uptrends::Probe.new(parsed_response)
109
-
110
- probes << new_probe
111
-
112
- new_probe
52
+ def add_probe_group(opts = {})
53
+ pg = Uptrends::ProbeGroup.new(self, nil, opts)
54
+ pg.create!
113
55
  end
114
56
 
115
57
  private
116
- def get_probes
117
- get_all(Uptrends::Probe)
118
- end
119
-
120
- def get_checkpoints
121
- get_all(Uptrends::Checkpoint)
122
- end
58
+ def get(type, opts = {})
59
+ all = opts[:all] ? opts[:all] : false
60
+ guid = opts[:guid] ? opts[:guid] : nil
123
61
 
124
- def get_probe_groups
125
- get_all(Uptrends::ProbeGroup)
126
- end
127
-
128
- def get_all(type)
129
- case type.new
130
- when Uptrends::ProbeGroup
131
- uri = '/probegroups'
132
- when Uptrends::Probe
62
+ if type == Uptrends::Probe
133
63
  uri = '/probes'
134
- when Uptrends::Checkpoint
64
+ elsif type == Uptrends::ProbeGroup
65
+ uri = '/probegroups'
66
+ elsif type == Uptrends::Checkpoint
135
67
  uri = '/checkpointservers'
136
68
  else
137
- fail("You passed an unknown type. Try Uptrends::Probe or Uptrends::ProbeGroup")
69
+ fail("You passed an unknown type. Try Uptrends::Probe, Uptrends::ProbeGroup or Uptrends::Checkpoint")
138
70
  end
139
71
 
140
- res = self.class.get(uri)
141
-
142
- parsed_response = raise_or_return(res)
143
- all = parsed_response.inject([]) do |memo, x|
144
- memo << type.new(x)
145
- memo
146
- end
147
- end
148
-
149
- def gen_new_probe_hash(name, url, check_frequency = 15, match_pattern = nil)
150
- base_hash = {"Name"=>"", "URL"=>"", "CheckFrequency"=>check_frequency, "IsActive"=>true, "GenerateAlert"=>true, "Notes"=>"", "PerformanceLimit1"=>60000, "PerformanceLimit2"=>60000, "ErrorOnLimit1"=>false, "ErrorOnLimit2"=>false, "MinBytes"=>0, "ErrorOnMinBytes"=>false, "Timeout"=>30000, "TcpConnectTimeout"=>10000, "MatchPattern"=>"", "DnsLookupMode"=>"Local", "UserAgent"=>"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;)", "UserName"=>"", "Password"=>"", "IsCompetitor"=>false, "Checkpoints"=>"", "HttpMethod"=>"Get", "PostData"=>""}
151
-
152
- if url =~ %r{^https:}i
153
- base_hash.merge!({"Name"=>name, "URL"=>url, "ProbeType"=>"Https", "Port"=>443})
154
- elsif url =~ %r{^http:}i
155
- base_hash.merge!({"Name"=>name, "URL"=>url, "ProbeType"=>"Http", "Port"=>80})
156
- else
157
- fail("The URL you provided didn't start with http or https!")
72
+ if all
73
+ response = self.class.get(uri)
74
+ elsif guid
75
+ response = self.class.get("#{uri}/#{guid}")
158
76
  end
159
77
 
160
- base_hash.merge!({"MatchPattern"=>match_pattern}) unless match_pattern.nil?
161
-
162
- base_hash
163
- end
164
-
165
- def raise_or_return(result)
166
- response_code = result.response.code.to_i
167
- case response_code
168
- when 200...300
169
- result.parsed_response
170
- else
171
- raise Uptrends::ApiError.new(result.parsed_response)
172
- end
78
+ type.parse(self, response)
173
79
  end
174
80
 
175
81
  end
176
82
  end
83
+
@@ -1,8 +1,32 @@
1
- require 'json'
2
- require 'uptrends/utils'
3
1
  require 'uptrends/base'
4
2
 
5
3
  module Uptrends
6
4
  class Probe < Base
5
+
6
+ def enable
7
+ self.is_active = true
8
+ self.update!
9
+ end
10
+
11
+ def disable
12
+ self.is_active = false
13
+ self.update!
14
+ end
15
+
16
+ def enable_alerts
17
+ self.generate_alert = true
18
+ self.update!
19
+ end
20
+
21
+ def disable_alerts
22
+ self.generate_alert = false
23
+ self.update!
24
+ end
25
+
26
+ private
27
+ def api_url
28
+ "/probes"
29
+ end
30
+
7
31
  end
8
32
  end
@@ -1,8 +1,48 @@
1
- require 'json'
2
- require 'uptrends/utils'
3
1
  require 'uptrends/base'
4
2
 
5
3
  module Uptrends
6
4
  class ProbeGroup < Base
5
+
6
+ def add_probe(probe)
7
+ probe_operation(probe, :post)
8
+ end
9
+
10
+ def remove_probe(probe)
11
+ probe_operation(probe, :delete)
12
+ end
13
+
14
+ def members
15
+ fail("This group does not have a guid.") unless self.attributes.include?(:guid)
16
+
17
+ response = @client.class.get("#{api_url}/#{@guid}/members")
18
+ self.class.check_error!(response)
19
+ Uptrends::Probe.parse(self, response)
20
+ end
21
+
22
+ private
23
+ def api_url
24
+ "/probegroups"
25
+ end
26
+
27
+ def probe_operation(probe, method)
28
+ fail("You must pass an Uptrends::Probe") unless Uptrends::Probe === probe
29
+ fail("The probe you passed does not have a guid.") unless probe.attributes.include?(:guid)
30
+ fail("This group does not have a guid.") unless self.attributes.include?(:guid)
31
+
32
+ body = JSON.dump({"ProbeGuid" => probe.guid})
33
+ response = @client.class.send(method, "#{api_url}/#{@guid}/members", body: body)
34
+ self.class.check_error!(response)
35
+
36
+ parsed_response = response.parsed_response
37
+ if parsed_response.nil?
38
+ parsed_response
39
+ else
40
+ group_guid = parsed_response['Guid']
41
+ probe_guid = parsed_response['ProbeGuid']
42
+
43
+ [ @client.probe_group(group_guid), @client.probe(probe_guid) ]
44
+ end
45
+ end
46
+
7
47
  end
8
48
  end
@@ -1,3 +1,3 @@
1
1
  module Uptrends
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uptrends
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Barnett
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-08 00:00:00.000000000 Z
11
+ date: 2014-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -56,6 +56,7 @@ files:
56
56
  - Rakefile
57
57
  - examples/add_new_probes.rb
58
58
  - examples/add_probes_to_probe_group.rb
59
+ - examples/get_checkpoint_ips.rb
59
60
  - examples/update_all_probe_attributes.rb
60
61
  - lib/uptrends.rb
61
62
  - lib/uptrends/api_error.rb
@@ -64,7 +65,6 @@ files:
64
65
  - lib/uptrends/client.rb
65
66
  - lib/uptrends/probe.rb
66
67
  - lib/uptrends/probe_group.rb
67
- - lib/uptrends/utils.rb
68
68
  - lib/uptrends/version.rb
69
69
  - spec/fixtures/vcr_cassettes/GET_Probes.yml
70
70
  - spec/spec_helper.rb
@@ -1,51 +0,0 @@
1
- require 'json'
2
- require 'active_support/inflector'
3
-
4
- module Uptrends
5
- class Utils
6
- def self.gen_request_body(object)
7
- new_hash = object.original_hash.inject({}) do |memo,(k,v)|
8
- if k.to_s.underscore == 'guid'
9
- memo
10
- else
11
- memo[k.to_s.camelize] = object.send(k.to_s.underscore)
12
- memo
13
- end
14
- end
15
-
16
- request_body = JSON.dump(new_hash)
17
- end
18
-
19
- def self.to_s(object)
20
- string = []
21
- object.attributes.each do |attr|
22
- string << "#{attr}: #{object.send(attr)}"
23
- end
24
-
25
- "#{string.join("\n")}"
26
- end
27
-
28
- # This method sets up all of our attr_accessor so we can easily edit probe attributes
29
- def self.gen_and_set_accessors(object)
30
- attributes = []
31
- object.original_hash.each_pair do |k,v|
32
-
33
- k = k.to_s.underscore
34
- case k
35
- when "guid"
36
- # setup attr_reader for guid and set it's value.
37
- object.class.send(:attr_reader, k)
38
- object.instance_variable_set("@#{k}", v)
39
- else
40
- # setup a attr_accessor for all other attributes
41
- object.class.send(:attr_accessor, k)
42
- object.send("#{k}=", v)
43
- end
44
- attributes << k.to_sym
45
-
46
- end
47
- object.instance_variable_set(:@attributes, attributes)
48
- end
49
-
50
- end
51
- end