uptimerobot_cmd 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/uptimerobot_cmd/version.rb +1 -1
- data/lib/uptimerobot_cmd.rb +27 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6d3c07825b9142c3ab8ac0af6cf3f6d4aa737f58
|
4
|
+
data.tar.gz: 608173d37042a905e52d0400af4e4919951e6828
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24684369e5cb3939dbdeca57641be8c453567ea8266792f751971c1b42d190ebe45ca74ac5cdbe01ab70399c8c72e19a0ed2a6777e7182f72d4b4aeae1ef5783
|
7
|
+
data.tar.gz: 7a073a9eda3ac8cfb3e3345cf1d48510461e7fd581d60451206435e00f784be4606191dc214a93b147646861c6ea5d2003306e848aaacd5034837841dd6f2f64
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
[![Build Status](https://travis-ci.org/vigo/uptimerobot_cmd.svg?branch=master)](https://travis-ci.org/vigo/uptimerobot_cmd)
|
2
|
-
![Version](https://img.shields.io/badge/version-0.3.
|
2
|
+
![Version](https://img.shields.io/badge/version-0.3.1-yellow.svg)
|
3
3
|
|
4
4
|
|
5
5
|
# UptimerobotCmd
|
data/lib/uptimerobot_cmd.rb
CHANGED
@@ -6,7 +6,7 @@ module UptimerobotCmd
|
|
6
6
|
APIKEY = ENV['UPTIMEROBOT_APIKEY'] || nil
|
7
7
|
ENDPOINT_BASE_URL = 'https://api.uptimerobot.com'
|
8
8
|
ENDPOINT_SERVICE_URLS = {
|
9
|
-
get_monitors: '%{base_url}/getMonitors?apiKey=%{apikey}&%{json_result}',
|
9
|
+
get_monitors: '%{base_url}/getMonitors?apiKey=%{apikey}&limit=%{limit}&offset=%{offset}&%{json_result}',
|
10
10
|
get_alert_contacts: '%{base_url}/getAlertContacts?apiKey=%{apikey}&%{json_result}',
|
11
11
|
add_new_monitor: '%{base_url}/newMonitor?apiKey=%{apikey}&%{json_result}'\
|
12
12
|
'&monitorType=%{monitor_type}'\
|
@@ -49,8 +49,32 @@ module UptimerobotCmd
|
|
49
49
|
|
50
50
|
def self.get_monitors
|
51
51
|
if ::UptimerobotCmd.apikey_defined
|
52
|
-
|
53
|
-
|
52
|
+
limit = 50
|
53
|
+
offset = 0
|
54
|
+
options = {
|
55
|
+
limit: limit,
|
56
|
+
offset: offset,
|
57
|
+
}
|
58
|
+
output = []
|
59
|
+
response = HTTParty.get(::UptimerobotCmd.build_service_url(:get_monitors, options))
|
60
|
+
total = response["total"].to_i
|
61
|
+
output += response["monitors"]["monitor"]
|
62
|
+
|
63
|
+
if total > limit
|
64
|
+
max_pages = total / limit
|
65
|
+
left_over = total % limit
|
66
|
+
max_pages += 1 if left_over > 0
|
67
|
+
current_page = 1
|
68
|
+
while current_page <= max_pages
|
69
|
+
options[:offset] = offset
|
70
|
+
response = HTTParty.get(::UptimerobotCmd.build_service_url(:get_monitors, options))
|
71
|
+
output += response["monitors"]["monitor"]
|
72
|
+
offset = current_page * limit
|
73
|
+
current_page += 1
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
output
|
54
78
|
end
|
55
79
|
end
|
56
80
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uptimerobot_cmd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Uğur Özyılmazel
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|