uptimerobot_cmd 0.3.0 → 0.3.1

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: 5c1b814638e4ab4695ce9a1f7e9e4a60f4cb9772
4
- data.tar.gz: 2b8b18f1779a9e7e61fd7613d5afe03fc52f5cf2
3
+ metadata.gz: 6d3c07825b9142c3ab8ac0af6cf3f6d4aa737f58
4
+ data.tar.gz: 608173d37042a905e52d0400af4e4919951e6828
5
5
  SHA512:
6
- metadata.gz: 5038c443d74e4d931647e9ba08e4a7b18de4b13080145483c45d5f316b22f77db9b1ed87597428b662f270e6151a91a910aa0ecbfd82dd311c0c986a9f94aa91
7
- data.tar.gz: 94ec52d591e6ac249845e6cc576a8ff8b7df6b88dd236289505d23d26a15fd1c849d60458f6d54f8bd6d700282c6ead7d9ec9f53deb07d84fb236d84654eb699
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.0-yellow.svg)
2
+ ![Version](https://img.shields.io/badge/version-0.3.1-yellow.svg)
3
3
 
4
4
 
5
5
  # UptimerobotCmd
@@ -1,3 +1,3 @@
1
1
  module UptimerobotCmd
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -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
- response = HTTParty.get(::UptimerobotCmd.build_service_url(:get_monitors))
53
- response["monitors"]["monitor"]
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.0
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-23 00:00:00.000000000 Z
11
+ date: 2016-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler