copperegg-alerts 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/copperegg/alerts/client.rb +5 -6
- data/lib/copperegg/alerts/schedule.rb +12 -15
- data/lib/copperegg/alerts/version.rb +1 -1
- metadata +17 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c78c120a8a32d710c50be87fab4ad4347bb685e3
|
4
|
+
data.tar.gz: d13e0d46c5afaf6a905c313f924c031b16854887
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e40ce0301732cedb2b9c5b3d89806a26f0a394ceed96f1e7eb38d5b713d207f62d7fdf2fcfdf93d36aea91e39ff3cda9755a3b570cb988acf1226691c80e2ad7
|
7
|
+
data.tar.gz: 3b42f67e4ce5db9ef23d9840a626880ba4626c4edacfe237afe7cf951a20d5a3def9e271fc5ab143889c722052094a7ecddbeb35000f1481869cd96e82f3cc93
|
@@ -14,16 +14,16 @@ module Copperegg
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def auth_setup(api_key)
|
17
|
-
@auth = {:
|
18
|
-
|
17
|
+
@auth = { basic_auth: { username: api_key, password: 'U' } }
|
18
|
+
self
|
19
19
|
end
|
20
20
|
|
21
|
-
JSON = {'content-type' => 'application/json'}
|
21
|
+
JSON = { 'content-type' => 'application/json' }.freeze
|
22
22
|
|
23
23
|
def method_missing(method, resource, *args)
|
24
24
|
if method.to_s =~ /\?$/
|
25
25
|
method = method.to_s.sub!(/\?$/, '')
|
26
|
-
result =
|
26
|
+
result = send(method.to_sym, resource, *args)
|
27
27
|
return result if result.code == 200
|
28
28
|
end
|
29
29
|
end
|
@@ -49,7 +49,7 @@ module Copperegg
|
|
49
49
|
def _send(method, path, body = {})
|
50
50
|
auth = @auth.clone
|
51
51
|
unless body.empty?
|
52
|
-
auth.merge!({:
|
52
|
+
auth.merge!({ headers: JSON }.merge!(body: body.to_json))
|
53
53
|
end
|
54
54
|
response = HTTParty.send(method.to_sym, @api_base_uri + path, auth.to_hash)
|
55
55
|
if response.code != 200
|
@@ -57,7 +57,6 @@ module Copperegg
|
|
57
57
|
end
|
58
58
|
response
|
59
59
|
end
|
60
|
-
|
61
60
|
end
|
62
61
|
end
|
63
62
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'deep_merge'
|
2
2
|
require 'copperegg/alerts'
|
3
3
|
|
4
|
-
|
5
4
|
module Copperegg
|
6
5
|
module Alerts
|
7
6
|
class Schedule
|
@@ -25,26 +24,25 @@ module Copperegg
|
|
25
24
|
@schedules -= selected_schedules
|
26
25
|
selected_schedules.each do |s|
|
27
26
|
result = @client.put?("alerts/schedules/#{s['id']}.json", body)
|
28
|
-
if result
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
27
|
+
@schedules << if result.nil?
|
28
|
+
s
|
29
|
+
else
|
30
|
+
result
|
31
|
+
end
|
33
32
|
end
|
34
33
|
end
|
35
34
|
end
|
36
35
|
|
37
36
|
def add(name, *args)
|
38
37
|
defaults = {
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
'name' => name,
|
39
|
+
'state' => 'enabled',
|
40
|
+
'duration' => 10,
|
41
|
+
'start_time' => Time.now.gmtime.strftime('%Y-%m-%dt%H:%M:%Sz')
|
43
42
|
}
|
44
43
|
args.each { |arg| defaults.deep_merge!(arg) }
|
45
|
-
|
46
|
-
|
47
|
-
end
|
44
|
+
result = @client.post?('alerts/schedules.json', defaults)
|
45
|
+
@schedules << result.parsed_response if result
|
48
46
|
end
|
49
47
|
|
50
48
|
def delete(name)
|
@@ -52,7 +50,7 @@ module Copperegg
|
|
52
50
|
if selected_schedules
|
53
51
|
@schedules -= selected_schedules
|
54
52
|
selected_schedules.each do |s|
|
55
|
-
if @client.delete?("alerts/schedules/#{s['id']}.json")
|
53
|
+
if @client.delete?("alerts/schedules/#{s['id']}.json").nil?
|
56
54
|
@schedules << s
|
57
55
|
end
|
58
56
|
end
|
@@ -61,4 +59,3 @@ module Copperegg
|
|
61
59
|
end
|
62
60
|
end
|
63
61
|
end
|
64
|
-
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: copperegg-alerts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cargo Media
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-10-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -137,6 +137,20 @@ dependencies:
|
|
137
137
|
- - "~>"
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: 0.2.1
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: rubocop
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: 0.41.2
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: 0.41.2
|
140
154
|
description: Set and remove alert silencing schedules aka maintenance windows
|
141
155
|
email: hello@cargomedia.ch
|
142
156
|
executables: []
|
@@ -169,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
183
|
version: '0'
|
170
184
|
requirements: []
|
171
185
|
rubyforge_project:
|
172
|
-
rubygems_version: 2.
|
186
|
+
rubygems_version: 2.5.1
|
173
187
|
signing_key:
|
174
188
|
specification_version: 4
|
175
189
|
summary: A very minimalistic Copperegg API client for managing alert schedules
|