uppityrobot 0.2.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/Gemfile.lock +12 -8
- data/README.md +19 -9
- data/Rakefile +2 -0
- data/lib/uppityrobot/Rakefile +4 -0
- data/lib/uppityrobot/tasks/uppityrobot.rake +84 -0
- data/lib/uppityrobot/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 343f05015c34d7aa261f85ff37aa3ec32dce89afc56a8d7c5753ed09899837b2
|
4
|
+
data.tar.gz: 3b3ae5b2897e25d28743c2b5de6b8dadef72e49072d0d028d6cc10d083c531c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31d7900e684a36840e30ee4d06f3687ed4dc83349ede3e5cf72b906b86208e648c15c258651db84e7b72712806b61721a8ebcbc27a7f61d4d91ab67a62fcdb27
|
7
|
+
data.tar.gz: fe39c68cf5760d100840864c0e6d0670f2f81bdd986dc750592adbb7e07adb053e668d73489ff9125a0f04d2aa2af2343e606ae9c50f0c89e6b604a93f2efa92
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
uppityrobot (0.
|
4
|
+
uppityrobot (0.3.1)
|
5
5
|
dry-cli (~> 0.7)
|
6
6
|
json (~> 2.5)
|
7
7
|
uptimerobot (~> 0.2)
|
@@ -68,30 +68,34 @@ GEM
|
|
68
68
|
cucumber-messages (~> 17.0, >= 17.0.1)
|
69
69
|
diff-lcs (1.4.4)
|
70
70
|
dry-cli (0.7.0)
|
71
|
-
faraday (1.
|
71
|
+
faraday (1.10.0)
|
72
72
|
faraday-em_http (~> 1.0)
|
73
73
|
faraday-em_synchrony (~> 1.0)
|
74
74
|
faraday-excon (~> 1.1)
|
75
|
-
faraday-httpclient (~> 1.0
|
75
|
+
faraday-httpclient (~> 1.0)
|
76
|
+
faraday-multipart (~> 1.0)
|
76
77
|
faraday-net_http (~> 1.0)
|
77
|
-
faraday-net_http_persistent (~> 1.
|
78
|
+
faraday-net_http_persistent (~> 1.0)
|
78
79
|
faraday-patron (~> 1.0)
|
79
80
|
faraday-rack (~> 1.0)
|
80
|
-
|
81
|
+
faraday-retry (~> 1.0)
|
81
82
|
ruby2_keywords (>= 0.0.4)
|
82
83
|
faraday-em_http (1.0.0)
|
83
84
|
faraday-em_synchrony (1.0.0)
|
84
85
|
faraday-excon (1.1.0)
|
85
86
|
faraday-httpclient (1.0.1)
|
87
|
+
faraday-multipart (1.0.3)
|
88
|
+
multipart-post (>= 1.2, < 3)
|
86
89
|
faraday-net_http (1.0.1)
|
87
90
|
faraday-net_http_persistent (1.2.0)
|
88
91
|
faraday-patron (1.0.0)
|
89
92
|
faraday-rack (1.0.0)
|
90
|
-
|
93
|
+
faraday-retry (1.0.3)
|
94
|
+
faraday_middleware (1.2.0)
|
91
95
|
faraday (~> 1.0)
|
92
96
|
ffi (1.15.4)
|
93
97
|
hashdiff (1.0.1)
|
94
|
-
json (2.
|
98
|
+
json (2.6.1)
|
95
99
|
json_spec (1.1.5)
|
96
100
|
multi_json (~> 1.0)
|
97
101
|
rspec (>= 2.0, < 4.0)
|
@@ -192,4 +196,4 @@ DEPENDENCIES
|
|
192
196
|
webmock
|
193
197
|
|
194
198
|
BUNDLED WITH
|
195
|
-
2.2.
|
199
|
+
2.2.28
|
data/README.md
CHANGED
@@ -107,18 +107,28 @@ client = UppityRobot::Client.new(:getMonitors, {search: 'aspace'})
|
|
107
107
|
client.filter({'friendly_name' => 'columbia'}).each { |m| puts m.inspect; }
|
108
108
|
```
|
109
109
|
|
110
|
-
##
|
111
|
-
|
112
|
-
To release a new version:
|
110
|
+
## Including UppityRobot tasks in another project
|
113
111
|
|
114
|
-
|
115
|
-
|
112
|
+
```ruby
|
113
|
+
require "uppityrobot"
|
114
|
+
spec = Gem::Specification.find_by_name("uppityrobot")
|
115
|
+
load File.join(spec.gem_dir, "lib", "uppityrobot", "Rakefile")
|
116
|
+
```
|
116
117
|
|
117
|
-
|
118
|
+
## Release
|
118
119
|
|
119
|
-
|
120
|
-
|
121
|
-
|
120
|
+
```bash
|
121
|
+
gem install gem-release
|
122
|
+
# https://github.com/svenfuchs/gem-release#gem-bump
|
123
|
+
gem bump --version $VERSION --tag
|
124
|
+
# i.e.
|
125
|
+
gem bump --version minor --tag --pretend # dryrun
|
126
|
+
gem bump --version minor --tag # do it for real
|
127
|
+
|
128
|
+
bundle
|
129
|
+
git commit --amend # needed via Rakefile
|
130
|
+
# now push & release
|
131
|
+
```
|
122
132
|
|
123
133
|
## Contributing
|
124
134
|
|
data/Rakefile
CHANGED
@@ -0,0 +1,84 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# rubocop:disable Metrics/BlockLength
|
4
|
+
|
5
|
+
namespace :uppityrobot do
|
6
|
+
namespace :tasks do
|
7
|
+
def alert_contacts
|
8
|
+
ENV.fetch("UPTIMEROBOT_ALERT_CONTACTS") do
|
9
|
+
contacts = UppityRobot::Client.new(:getAlertContacts, {}).execute
|
10
|
+
contact = contacts["alert_contacts"].find { |c| c["friendly_name"] == friendly_name }
|
11
|
+
raise "CONTACT NOT FOUND" unless contact
|
12
|
+
|
13
|
+
contact["id"]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def friendly_name
|
18
|
+
ENV.fetch("UPTIMEROBOT_FRIENDLY_NAME", "")
|
19
|
+
end
|
20
|
+
|
21
|
+
def monitors(prefix:)
|
22
|
+
monitors = {}
|
23
|
+
UppityRobot::Client.new(:getMonitors, search: prefix).filter("friendly_name" => "^#{prefix}").each do |m|
|
24
|
+
monitors[m["friendly_name"]] = m
|
25
|
+
end
|
26
|
+
monitors
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Display uptimerobot contacts set via environment"
|
30
|
+
task :contacts do
|
31
|
+
raise "UPTIMEROBOT_API_KEY is required" unless ENV["UPTIMEROBOT_API_KEY"]
|
32
|
+
|
33
|
+
puts alert_contacts
|
34
|
+
end
|
35
|
+
|
36
|
+
desc "List all uptimerobot monitors by prefix"
|
37
|
+
task :list, [:prefix] do |_, args|
|
38
|
+
raise "UPTIMEROBOT_API_KEY is required" unless ENV["UPTIMEROBOT_API_KEY"]
|
39
|
+
|
40
|
+
puts monitors(prefix: args.fetch(:prefix)).to_json
|
41
|
+
end
|
42
|
+
|
43
|
+
desc "Process uptimerobot monitors csv"
|
44
|
+
task :process, [:prefix, :csv] do |_, args|
|
45
|
+
raise "UPTIMEROBOT_API_KEY is required" unless ENV["UPTIMEROBOT_API_KEY"]
|
46
|
+
|
47
|
+
prefix = args[:prefix]
|
48
|
+
csv = args.fetch(:csv, File.join(Dir.getwd, "files", "monitors", "uptimerobot.csv"))
|
49
|
+
raise "CSV not found" unless File.file? csv
|
50
|
+
|
51
|
+
contacts = alert_contacts
|
52
|
+
current_monitors = monitors(prefix: prefix)
|
53
|
+
|
54
|
+
CSV.read(csv, headers: true).each do |row|
|
55
|
+
data = row.to_hash
|
56
|
+
name = data["friendly_name"]
|
57
|
+
url = data["url"]
|
58
|
+
|
59
|
+
begin
|
60
|
+
if !current_monitors.key?(name)
|
61
|
+
puts "Creating monitor: #{name} #{url}"
|
62
|
+
d = {
|
63
|
+
friendly_name: name,
|
64
|
+
url: url,
|
65
|
+
type: UptimeRobot::Monitor::Type::HTTP,
|
66
|
+
subtype: UptimeRobot::Monitor::SubType::HTTPS,
|
67
|
+
alert_contacts: contacts
|
68
|
+
}
|
69
|
+
UppityRobot::Client.new(:newMonitor, d).execute
|
70
|
+
elsif current_monitors.key?(name) && current_monitors[name]["url"] != url
|
71
|
+
puts "Updating monitor: #{current_monitors[name]["url"]} TO #{url} WITH CONTACTS #{contacts}"
|
72
|
+
# avoid uptimerobot client weirdness
|
73
|
+
d = { id: current_monitors[name]["id"], url: url, alert_contacts: contacts }.dup
|
74
|
+
UppityRobot::Client.new(:editMonitor, d).execute
|
75
|
+
end
|
76
|
+
rescue UptimeRobot::Error => e
|
77
|
+
puts "Error processing monitor: #{data} #{e.message}"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# rubocop:enable Metrics/BlockLength
|
data/lib/uppityrobot/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uppityrobot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Cooper
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-05-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dry-cli
|
@@ -222,6 +222,7 @@ files:
|
|
222
222
|
- fixtures/getMonitors.mywebpage.json
|
223
223
|
- fixtures/newMonitor.json
|
224
224
|
- lib/uppityrobot.rb
|
225
|
+
- lib/uppityrobot/Rakefile
|
225
226
|
- lib/uppityrobot/cli/commands/exec.rb
|
226
227
|
- lib/uppityrobot/cli/commands/monitors/create.rb
|
227
228
|
- lib/uppityrobot/cli/commands/monitors/delete.rb
|
@@ -231,6 +232,7 @@ files:
|
|
231
232
|
- lib/uppityrobot/cli/commands/registry.rb
|
232
233
|
- lib/uppityrobot/cli/commands/version.rb
|
233
234
|
- lib/uppityrobot/client.rb
|
235
|
+
- lib/uppityrobot/tasks/uppityrobot.rake
|
234
236
|
- lib/uppityrobot/version.rb
|
235
237
|
- uppityrobot.gemspec
|
236
238
|
homepage: https://github.com/lyrasis/uppityrobot.git
|