flapjack-diner 2.0.0.pre.alpha.1 → 2.0.0.pre.alpha.2
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 +4 -4
- data/lib/flapjack-diner.rb +2 -1
- data/lib/flapjack-diner/resources/blackholes.rb +73 -0
- data/lib/flapjack-diner/resources/relationships.rb +27 -0
- data/lib/flapjack-diner/resources/rules.rb +0 -2
- data/lib/flapjack-diner/version.rb +1 -1
- data/spec/resources/blackholes_spec.rb +278 -0
- data/spec/support/fixture_data.rb +60 -4
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ac8e83fdc9d402c3e60acfeb01b64a0d8f352ad6
|
4
|
+
data.tar.gz: ce8eecce83ca64e01dca304c8a453eb019c5c313
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5b3c08505bea0ed12897b2b437cc418f6194f09d4d6041a8155b86be638b5f8ce86538d1be8d30deb969c46c45db07f1ae959dc59ce8a6255c7ae292f308251
|
7
|
+
data.tar.gz: e741106cde2ec5631730f27708f0d775c806250c6850f3c05d6559e218ec2e635b888923265caab155cc97ea424448778bb000ead02340ef5f7e9db99868bdaf
|
data/lib/flapjack-diner.rb
CHANGED
@@ -4,7 +4,7 @@ require 'json'
|
|
4
4
|
require 'flapjack-diner/version'
|
5
5
|
require 'flapjack-diner/argument_validator'
|
6
6
|
|
7
|
-
%w(checks contacts events maintenance_periods media metrics rules
|
7
|
+
%w(blackholes checks contacts events maintenance_periods media metrics rules
|
8
8
|
states statistics tags relationships).each do |resource|
|
9
9
|
require "flapjack-diner/resources/#{resource}"
|
10
10
|
end
|
@@ -26,6 +26,7 @@ module Flapjack
|
|
26
26
|
class << self
|
27
27
|
attr_accessor :logger, :return_keys_as_strings
|
28
28
|
|
29
|
+
include Flapjack::Diner::Resources::Blackholes
|
29
30
|
include Flapjack::Diner::Resources::Checks
|
30
31
|
include Flapjack::Diner::Resources::Contacts
|
31
32
|
include Flapjack::Diner::Resources::Events
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'httparty'
|
2
|
+
require 'json'
|
3
|
+
require 'uri'
|
4
|
+
|
5
|
+
require 'flapjack-diner/version'
|
6
|
+
require 'flapjack-diner/argument_validator'
|
7
|
+
|
8
|
+
module Flapjack
|
9
|
+
module Diner
|
10
|
+
module Resources
|
11
|
+
module Blackholes
|
12
|
+
|
13
|
+
def create_blackholes(*args)
|
14
|
+
data = unwrap_data(*args)
|
15
|
+
validate_params(data) do
|
16
|
+
validate :query => :id, :as => :uuid
|
17
|
+
# TODO proper validation of time_restrictions field
|
18
|
+
validate :query => :conditions_list, :as => :string
|
19
|
+
validate :query => :contact, :as => [:singular_link_uuid, :required]
|
20
|
+
validate :query => :media, :as => :multiple_link_uuid
|
21
|
+
validate :query => :tags, :as => :multiple_link
|
22
|
+
end
|
23
|
+
_blackholes_validate_association(data)
|
24
|
+
perform_post(:blackholes, '/blackholes', data)
|
25
|
+
end
|
26
|
+
|
27
|
+
def blackholes(*args)
|
28
|
+
ids, data = unwrap_uuids(*args), unwrap_data(*args)
|
29
|
+
validate_params(data) do
|
30
|
+
validate :query => [:fields, :sort, :include], :as => :string_or_array_of_strings
|
31
|
+
validate :query => :filter, :as => :hash
|
32
|
+
validate :query => [:page, :per_page], :as => :positive_integer
|
33
|
+
end
|
34
|
+
perform_get('/blackholes', ids, data)
|
35
|
+
end
|
36
|
+
|
37
|
+
def update_blackholes(*args)
|
38
|
+
data = unwrap_data(*args)
|
39
|
+
validate_params(data) do
|
40
|
+
validate :query => :id, :as => [:uuid, :required]
|
41
|
+
# TODO proper validation of time_restrictions field
|
42
|
+
validate :query => :conditions_list, :as => :string
|
43
|
+
validate :query => :media, :as => :multiple_link_uuid
|
44
|
+
validate :query => :tags, :as => :multiple_link
|
45
|
+
end
|
46
|
+
perform_patch(:blackholes, "/blackholes", data)
|
47
|
+
end
|
48
|
+
|
49
|
+
def delete_blackholes(*ids)
|
50
|
+
raise "'delete_blackholes' requires at least one blackhole id parameter" if ids.nil? || ids.empty?
|
51
|
+
perform_delete(:blackholes, '/blackholes', *ids)
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def _blackholes_validate_association(data)
|
57
|
+
case data
|
58
|
+
when Array
|
59
|
+
data.each do |d|
|
60
|
+
unless d.has_key?(:contact)
|
61
|
+
raise ArgumentError.new("Contact association must be provided for all blackholes")
|
62
|
+
end
|
63
|
+
end
|
64
|
+
when Hash
|
65
|
+
unless data.has_key?(:contact)
|
66
|
+
raise ArgumentError.new("Contact association must be provided for blackhole")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
@@ -12,6 +12,7 @@ module Flapjack
|
|
12
12
|
|
13
13
|
TYPES = {
|
14
14
|
:acknowledgements => 'acknowledgement',
|
15
|
+
:blackholes => 'blackhole',
|
15
16
|
:checks => 'check',
|
16
17
|
:contacts => 'contact',
|
17
18
|
:media => 'medium',
|
@@ -37,6 +38,20 @@ module Flapjack
|
|
37
38
|
:number => :singular, :link => false, :includable => false
|
38
39
|
}
|
39
40
|
},
|
41
|
+
:blackholes => {
|
42
|
+
:contact => {
|
43
|
+
:post => true, :get => true,
|
44
|
+
:number => :singular, :link => true, :includable => true
|
45
|
+
},
|
46
|
+
:media => {
|
47
|
+
:post => true, :get => true, :patch => true, :delete => true,
|
48
|
+
:number => :multiple, :link => true, :includable => true
|
49
|
+
},
|
50
|
+
:tags => {
|
51
|
+
:post => true, :get => true, :patch => true, :delete => true,
|
52
|
+
:number => :multiple, :link => true, :includable => true
|
53
|
+
}
|
54
|
+
},
|
40
55
|
:checks => {
|
41
56
|
:alerting_media => {
|
42
57
|
:get => true,
|
@@ -80,6 +95,10 @@ module Flapjack
|
|
80
95
|
}
|
81
96
|
},
|
82
97
|
:contacts => {
|
98
|
+
:blackholes => {
|
99
|
+
:get => true,
|
100
|
+
:number => :multiple, :link => true, :includable => true
|
101
|
+
},
|
83
102
|
:checks => {
|
84
103
|
:get => true,
|
85
104
|
:number => :multiple, :link => true, :includable => true
|
@@ -98,6 +117,10 @@ module Flapjack
|
|
98
117
|
:get => true,
|
99
118
|
:number => :multiple, :link => true, :includable => true
|
100
119
|
},
|
120
|
+
:blackholes => {
|
121
|
+
:post => true, :get => true, :patch => true, :delete => true,
|
122
|
+
:number => :multiple, :link => true, :includable => true
|
123
|
+
},
|
101
124
|
:contact => {
|
102
125
|
:post => true, :get => true,
|
103
126
|
:number => :singular, :link => true, :includable => true
|
@@ -138,6 +161,10 @@ module Flapjack
|
|
138
161
|
}
|
139
162
|
},
|
140
163
|
:tags => {
|
164
|
+
:blackholes => {
|
165
|
+
:post => true, :get => true, :patch => true, :delete => true,
|
166
|
+
:number => :multiple, :link => true, :includable => true
|
167
|
+
},
|
141
168
|
:checks => {
|
142
169
|
:post => true, :get => true, :patch => true, :delete => true,
|
143
170
|
:number => :multiple, :link => true, :includable => true
|
@@ -16,7 +16,6 @@ module Flapjack
|
|
16
16
|
validate :query => :id, :as => :uuid
|
17
17
|
# TODO proper validation of time_restrictions field
|
18
18
|
validate :query => :conditions_list, :as => :string
|
19
|
-
validate :query => :is_blackhole, :as => :boolean
|
20
19
|
validate :query => :contact, :as => [:singular_link_uuid, :required]
|
21
20
|
validate :query => :media, :as => :multiple_link_uuid
|
22
21
|
validate :query => :tags, :as => :multiple_link
|
@@ -41,7 +40,6 @@ module Flapjack
|
|
41
40
|
validate :query => :id, :as => [:uuid, :required]
|
42
41
|
# TODO proper validation of time_restrictions field
|
43
42
|
validate :query => :conditions_list, :as => :string
|
44
|
-
validate :query => :is_blackhole, :as => :boolean
|
45
43
|
validate :query => :media, :as => :multiple_link_uuid
|
46
44
|
validate :query => :tags, :as => :multiple_link
|
47
45
|
end
|
@@ -0,0 +1,278 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'flapjack-diner'
|
3
|
+
|
4
|
+
describe Flapjack::Diner::Resources::Blackholes, :pact => true do
|
5
|
+
|
6
|
+
before(:each) do
|
7
|
+
Flapjack::Diner.base_uri('localhost:19081')
|
8
|
+
Flapjack::Diner.logger = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'create' do
|
12
|
+
|
13
|
+
it "submits a POST request for a blackhole" do
|
14
|
+
req_data = blackhole_json(blackhole_data).merge(
|
15
|
+
:relationships => {
|
16
|
+
:contact => {
|
17
|
+
:data => {
|
18
|
+
:type => 'contact',
|
19
|
+
:id => contact_data[:id]
|
20
|
+
}
|
21
|
+
}
|
22
|
+
}
|
23
|
+
)
|
24
|
+
resp_data = blackhole_json(blackhole_data).merge(:relationships => blackhole_rel(blackhole_data))
|
25
|
+
|
26
|
+
flapjack.given("a contact exists").
|
27
|
+
upon_receiving("a POST request with one blackhole").
|
28
|
+
with(:method => :post, :path => '/blackholes',
|
29
|
+
:headers => {'Content-Type' => 'application/vnd.api+json'},
|
30
|
+
:body => {:data => req_data}).
|
31
|
+
will_respond_with(
|
32
|
+
:status => 201,
|
33
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
34
|
+
:body => {:data => resp_data}
|
35
|
+
)
|
36
|
+
|
37
|
+
result = Flapjack::Diner.create_blackholes(blackhole_data.merge(:contact => contact_data[:id]))
|
38
|
+
expect(result).not_to be_nil
|
39
|
+
expect(result).to eq(resultify(resp_data))
|
40
|
+
end
|
41
|
+
|
42
|
+
it "submits a POST request for several blackholes" do
|
43
|
+
req_data = [blackhole_json(blackhole_data).merge(
|
44
|
+
:relationships => {
|
45
|
+
:contact => {
|
46
|
+
:data => {
|
47
|
+
:type => 'contact',
|
48
|
+
:id => contact_data[:id]
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
52
|
+
), blackhole_json(blackhole_2_data).merge(
|
53
|
+
:relationships => {
|
54
|
+
:contact => {
|
55
|
+
:data => {
|
56
|
+
:type => 'contact',
|
57
|
+
:id => contact_data[:id]
|
58
|
+
}
|
59
|
+
}
|
60
|
+
}
|
61
|
+
)]
|
62
|
+
resp_data = [
|
63
|
+
blackhole_json(blackhole_data).merge(:relationships => blackhole_rel(blackhole_data)),
|
64
|
+
blackhole_json(blackhole_2_data).merge(:relationships => blackhole_rel(blackhole_2_data))
|
65
|
+
]
|
66
|
+
|
67
|
+
flapjack.given("a contact exists").
|
68
|
+
upon_receiving("a POST request with two blackholes").
|
69
|
+
with(:method => :post, :path => '/blackholes',
|
70
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; ext=bulk'},
|
71
|
+
:body => {:data => req_data}).
|
72
|
+
will_respond_with(
|
73
|
+
:status => 201,
|
74
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
75
|
+
:body => {:data => resp_data}
|
76
|
+
)
|
77
|
+
|
78
|
+
result = Flapjack::Diner.create_blackholes(blackhole_data.merge(:contact => contact_data[:id]),
|
79
|
+
blackhole_2_data.merge(:contact => contact_data[:id]))
|
80
|
+
expect(result).not_to be_nil
|
81
|
+
expect(result).to eq(resultify(resp_data))
|
82
|
+
end
|
83
|
+
|
84
|
+
# TODO error due to invalid data
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'read' do
|
89
|
+
|
90
|
+
it "submits a GET request for all blackholes" do
|
91
|
+
resp_data = [blackhole_json(blackhole_data).merge(:relationships => blackhole_rel(blackhole_data))]
|
92
|
+
|
93
|
+
flapjack.given("a blackhole exists").
|
94
|
+
upon_receiving("a GET request for all blackholes").
|
95
|
+
with(:method => :get, :path => '/blackholes').
|
96
|
+
will_respond_with(
|
97
|
+
:status => 200,
|
98
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
99
|
+
:body => {:data => resp_data} )
|
100
|
+
|
101
|
+
result = Flapjack::Diner.blackholes
|
102
|
+
expect(result).not_to be_nil
|
103
|
+
expect(result).to eq(resultify(resp_data))
|
104
|
+
end
|
105
|
+
|
106
|
+
it "submits a GET request for one blackhole" do
|
107
|
+
resp_data = blackhole_json(blackhole_data).merge(:relationships => blackhole_rel(blackhole_data))
|
108
|
+
|
109
|
+
flapjack.given("a blackhole exists").
|
110
|
+
upon_receiving("a GET request for a single blackhole").
|
111
|
+
with(:method => :get, :path => "/blackholes/#{blackhole_data[:id]}").
|
112
|
+
will_respond_with(
|
113
|
+
:status => 200,
|
114
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
115
|
+
:body => {:data => resp_data}
|
116
|
+
)
|
117
|
+
|
118
|
+
result = Flapjack::Diner.blackholes(blackhole_data[:id])
|
119
|
+
expect(result).not_to be_nil
|
120
|
+
expect(result).to eq(resultify(resp_data))
|
121
|
+
end
|
122
|
+
|
123
|
+
it "submits a GET request for several blackholes" do
|
124
|
+
resp_data = [
|
125
|
+
blackhole_json(blackhole_data).merge(:relationships => blackhole_rel(blackhole_data)),
|
126
|
+
blackhole_json(blackhole_2_data).merge(:relationships => blackhole_rel(blackhole_2_data))
|
127
|
+
]
|
128
|
+
|
129
|
+
blackholes_data = [blackhole_data.merge(:type => 'blackhole'), blackhole_2_data.merge(:type => 'blackhole')]
|
130
|
+
|
131
|
+
flapjack.given("two blackholes exist").
|
132
|
+
upon_receiving("a GET request for two blackholes").
|
133
|
+
with(:method => :get, :path => "/blackholes",
|
134
|
+
:query => "filter%5B%5D=id%3A#{blackhole_data[:id]}%7C#{blackhole_2_data[:id]}").
|
135
|
+
will_respond_with(
|
136
|
+
:status => 200,
|
137
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
138
|
+
:body => {:data => resp_data} )
|
139
|
+
|
140
|
+
result = Flapjack::Diner.blackholes(blackhole_data[:id], blackhole_2_data[:id])
|
141
|
+
expect(result).not_to be_nil
|
142
|
+
expect(result).to eq(resultify(resp_data))
|
143
|
+
end
|
144
|
+
|
145
|
+
it "can't find the blackhole to read" do
|
146
|
+
flapjack.given("no data exists").
|
147
|
+
upon_receiving("a GET request for a single blackhole").
|
148
|
+
with(:method => :get, :path => "/blackholes/#{blackhole_data[:id]}").
|
149
|
+
will_respond_with(
|
150
|
+
:status => 404,
|
151
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
152
|
+
:body => {:errors => [{
|
153
|
+
:status => '404',
|
154
|
+
:detail => "could not find Blackhole record, id: '#{blackhole_data[:id]}'"
|
155
|
+
}]}
|
156
|
+
)
|
157
|
+
|
158
|
+
result = Flapjack::Diner.blackholes(blackhole_data[:id])
|
159
|
+
expect(result).to be_nil
|
160
|
+
expect(Flapjack::Diner.last_error).to eq([{:status => '404',
|
161
|
+
:detail => "could not find Blackhole record, id: '#{blackhole_data[:id]}'"}])
|
162
|
+
end
|
163
|
+
|
164
|
+
end
|
165
|
+
|
166
|
+
# # Not immediately relevant, no data fields to update until time_restrictions are fixed
|
167
|
+
# context 'update' do
|
168
|
+
# it 'submits a PUT request for a blackhole' do
|
169
|
+
# flapjack.given("a blackhole exists").
|
170
|
+
# upon_receiving("a PUT request for a single blackhole").
|
171
|
+
# with(:method => :put,
|
172
|
+
# :path => "/blackholes/#{blackhole_data[:id]}",
|
173
|
+
# :body => {:blackholes => {:id => blackhole_data[:id], :time_restrictions => []}},
|
174
|
+
# :headers => {'Content-Type' => 'application/vnd.api+json'}).
|
175
|
+
# will_respond_with(
|
176
|
+
# :status => 204,
|
177
|
+
# :body => '' )
|
178
|
+
|
179
|
+
# result = Flapjack::Diner.update_blackholes(:id => blackhole_data[:id], :time_restrictions => [])
|
180
|
+
# expect(result).to be_a(TrueClass)
|
181
|
+
# end
|
182
|
+
|
183
|
+
# it 'submits a PUT request for several blackholes' do
|
184
|
+
# flapjack.given("two blackholes exist").
|
185
|
+
# upon_receiving("a PUT request for two blackholes").
|
186
|
+
# with(:method => :put,
|
187
|
+
# :path => "/blackholes/#{blackhole_data[:id]},#{blackhole_2_data[:id]}",
|
188
|
+
# :body => {:blackholes => [{:id => blackhole_data[:id], :time_restrictions => []},
|
189
|
+
# {:id => blackhole_2_data[:id], :enabled => true}]},
|
190
|
+
# :headers => {'Content-Type' => 'application/vnd.api+json'}).
|
191
|
+
# will_respond_with(
|
192
|
+
# :status => 204,
|
193
|
+
# :body => '' )
|
194
|
+
|
195
|
+
# result = Flapjack::Diner.update_blackholes(
|
196
|
+
# {:id => blackhole_data[:id], :time_restrictions => []},
|
197
|
+
# {:id => blackhole_2_data[:id], :enabled => true})
|
198
|
+
# expect(result).to be_a(TrueClass)
|
199
|
+
# end
|
200
|
+
|
201
|
+
# it "can't find the blackhole to update" do
|
202
|
+
# flapjack.given("no data exists").
|
203
|
+
# upon_receiving("a PUT request for a single blackhole").
|
204
|
+
# with(:method => :put,
|
205
|
+
# :path => "/blackholes/#{blackhole_data[:id]}",
|
206
|
+
# :body => {:blackholes => {:id => blackhole_data[:id], :time_restrictions => []}},
|
207
|
+
# :headers => {'Content-Type' => 'application/vnd.api+json'}).
|
208
|
+
# will_respond_with(
|
209
|
+
# :status => 404,
|
210
|
+
# :headers => {'Content-Type' => 'application/vnd.api+json; charset=utf-8'},
|
211
|
+
# :body => {:errors => [{
|
212
|
+
# :status => '404',
|
213
|
+
# :detail => "could not find Blackhole records, ids: '#{blackhole_data[:id]}'"
|
214
|
+
# }]}
|
215
|
+
# )
|
216
|
+
|
217
|
+
# result = Flapjack::Diner.update_blackholes(:id => blackhole_data[:id], :time_restrictions => [])
|
218
|
+
# expect(result).to be_nil
|
219
|
+
# expect(Flapjack::Diner.last_error).to eq([{:status => '404',
|
220
|
+
# :detail => "could not find Blackhole records, ids: '#{blackhole_data[:id]}'"}])
|
221
|
+
# end
|
222
|
+
# end
|
223
|
+
|
224
|
+
context 'delete' do
|
225
|
+
|
226
|
+
it "submits a DELETE request for a blackhole" do
|
227
|
+
flapjack.given("a blackhole exists").
|
228
|
+
upon_receiving("a DELETE request for a single blackhole").
|
229
|
+
with(:method => :delete,
|
230
|
+
:path => "/blackholes/#{blackhole_data[:id]}",
|
231
|
+
:body => nil).
|
232
|
+
will_respond_with(:status => 204,
|
233
|
+
:body => '')
|
234
|
+
|
235
|
+
result = Flapjack::Diner.delete_blackholes(blackhole_data[:id])
|
236
|
+
expect(result).to be_a(TrueClass)
|
237
|
+
end
|
238
|
+
|
239
|
+
it "submits a DELETE request for several blackholes" do
|
240
|
+
blackholes_data = [{:type => 'blackhole', :id => blackhole_data[:id]},
|
241
|
+
{:type => 'blackhole', :id => blackhole_2_data[:id]}]
|
242
|
+
|
243
|
+
flapjack.given("two blackholes exist").
|
244
|
+
upon_receiving("a DELETE request for two blackholes").
|
245
|
+
with(:method => :delete,
|
246
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; ext=bulk'},
|
247
|
+
:path => "/blackholes",
|
248
|
+
:body => {:data => blackholes_data}).
|
249
|
+
will_respond_with(:status => 204,
|
250
|
+
:body => '')
|
251
|
+
|
252
|
+
result = Flapjack::Diner.delete_blackholes(blackhole_data[:id], blackhole_2_data[:id])
|
253
|
+
expect(result).to be_a(TrueClass)
|
254
|
+
end
|
255
|
+
|
256
|
+
it "can't find the blackhole to delete" do
|
257
|
+
flapjack.given("no data exists").
|
258
|
+
upon_receiving("a DELETE request for a single blackhole").
|
259
|
+
with(:method => :delete,
|
260
|
+
:path => "/blackholes/#{blackhole_data[:id]}",
|
261
|
+
:body => nil).
|
262
|
+
will_respond_with(
|
263
|
+
:status => 404,
|
264
|
+
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
265
|
+
:body => {:errors => [{
|
266
|
+
:status => '404',
|
267
|
+
:detail => "could not find Blackhole record, id: '#{blackhole_data[:id]}'"
|
268
|
+
}]}
|
269
|
+
)
|
270
|
+
|
271
|
+
result = Flapjack::Diner.delete_blackholes(blackhole_data[:id])
|
272
|
+
expect(result).to be_nil
|
273
|
+
expect(Flapjack::Diner.last_error).to eq([{:status => '404',
|
274
|
+
:detail => "could not find Blackhole record, id: '#{blackhole_data[:id]}'"}])
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
end
|
@@ -162,6 +162,12 @@ module FixtureData
|
|
162
162
|
def contact_rel(co_data)
|
163
163
|
id = co_data[:id]
|
164
164
|
{
|
165
|
+
:blackholes => {
|
166
|
+
:links => {
|
167
|
+
:self => "http://#{api_host}/contacts/#{id}/relationships/blackholes",
|
168
|
+
:related => "http://#{api_host}/contacts/#{id}/blackholes"
|
169
|
+
}
|
170
|
+
},
|
165
171
|
:checks => {
|
166
172
|
:links => {
|
167
173
|
:self => "http://#{api_host}/contacts/#{id}/relationships/checks",
|
@@ -301,7 +307,6 @@ module FixtureData
|
|
301
307
|
def rule_data
|
302
308
|
@rule_data ||= {
|
303
309
|
:id => '05983623-fcef-42da-af44-ed6990b500fa',
|
304
|
-
:is_blackhole => false,
|
305
310
|
:conditions_list => 'critical'
|
306
311
|
}
|
307
312
|
end
|
@@ -309,7 +314,6 @@ module FixtureData
|
|
309
314
|
def rule_2_data
|
310
315
|
@rule_2_data ||= {
|
311
316
|
:id => '20f182fc-6e32-4794-9007-97366d162c51',
|
312
|
-
:is_blackhole => false,
|
313
317
|
:conditions_list => 'warning'
|
314
318
|
}
|
315
319
|
end
|
@@ -346,12 +350,58 @@ module FixtureData
|
|
346
350
|
}
|
347
351
|
end
|
348
352
|
|
353
|
+
def blackhole_data
|
354
|
+
@blackhole_data ||= {
|
355
|
+
:id => '05983623-fcef-42da-af44-ed6990b500fa',
|
356
|
+
:conditions_list => 'critical'
|
357
|
+
}
|
358
|
+
end
|
359
|
+
|
360
|
+
def blackhole_2_data
|
361
|
+
@blackhole_2_data ||= {
|
362
|
+
:id => '20f182fc-6e32-4794-9007-97366d162c51',
|
363
|
+
:conditions_list => 'warning'
|
364
|
+
}
|
365
|
+
end
|
366
|
+
|
367
|
+
def blackhole_json(bl_data)
|
368
|
+
{
|
369
|
+
:id => bl_data[:id],
|
370
|
+
:type => 'blackhole',
|
371
|
+
:attributes => bl_data.reject {|k,v| :id.eql?(k) }
|
372
|
+
}
|
373
|
+
end
|
374
|
+
|
375
|
+
def blackhole_rel(bl_data)
|
376
|
+
id = bl_data[:id]
|
377
|
+
{
|
378
|
+
:contact => {
|
379
|
+
:links => {
|
380
|
+
:self => "http://example.org/blackholes/#{id}/relationships/contact",
|
381
|
+
:related => "http://example.org/blackholes/#{id}/contact"
|
382
|
+
}
|
383
|
+
},
|
384
|
+
:media => {
|
385
|
+
:links => {
|
386
|
+
:self => "http://example.org/blackholes/#{id}/relationships/media",
|
387
|
+
:related => "http://example.org/blackholes/#{id}/media"
|
388
|
+
}
|
389
|
+
},
|
390
|
+
:tags => {
|
391
|
+
:links => {
|
392
|
+
:self => "http://example.org/blackholes/#{id}/relationships/tags",
|
393
|
+
:related => "http://example.org/blackholes/#{id}/tags"
|
394
|
+
}
|
395
|
+
}
|
396
|
+
}
|
397
|
+
end
|
398
|
+
|
349
399
|
def state_data
|
350
400
|
@state_data ||= {
|
351
401
|
:id => '142acf62-31e7-4074-ada9-a30ae73d880d',
|
352
402
|
:created_at => (fixture_time - 30).iso8601,
|
353
403
|
:updated_at => (fixture_time - 30).iso8601,
|
354
|
-
:condition => 'critical'
|
404
|
+
:condition => 'critical',
|
355
405
|
}
|
356
406
|
end
|
357
407
|
|
@@ -360,7 +410,7 @@ module FixtureData
|
|
360
410
|
:id => '008d78fc-1c72-4c2a-8057-0d44b64c6f3d',
|
361
411
|
:created_at => (fixture_time - 10).iso8601,
|
362
412
|
:updated_at => (fixture_time - 10).iso8601,
|
363
|
-
:condition => 'ok'
|
413
|
+
:condition => 'ok',
|
364
414
|
}
|
365
415
|
end
|
366
416
|
|
@@ -408,6 +458,12 @@ module FixtureData
|
|
408
458
|
def tag_rel(ta_data)
|
409
459
|
id = ta_data[:name]
|
410
460
|
{
|
461
|
+
:blackholes => {
|
462
|
+
:links => {
|
463
|
+
:self => "http://#{api_host}/tags/#{id}/relationships/blackholes",
|
464
|
+
:related => "http://#{api_host}/tags/#{id}/blackholes"
|
465
|
+
}
|
466
|
+
},
|
411
467
|
:checks => {
|
412
468
|
:links => {
|
413
469
|
:self => "http://#{api_host}/tags/#{id}/relationships/checks",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flapjack-diner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.pre.alpha.
|
4
|
+
version: 2.0.0.pre.alpha.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ali Graham
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -58,6 +58,7 @@ files:
|
|
58
58
|
- lib/flapjack-diner.rb
|
59
59
|
- lib/flapjack-diner/argument_validator.rb
|
60
60
|
- lib/flapjack-diner/index_range.rb
|
61
|
+
- lib/flapjack-diner/resources/blackholes.rb
|
61
62
|
- lib/flapjack-diner/resources/checks.rb
|
62
63
|
- lib/flapjack-diner/resources/contacts.rb
|
63
64
|
- lib/flapjack-diner/resources/events.rb
|
@@ -74,6 +75,7 @@ files:
|
|
74
75
|
- log/.gitkeep
|
75
76
|
- spec/argument_validator_spec.rb
|
76
77
|
- spec/flapjack-diner_spec.rb
|
78
|
+
- spec/resources/blackholes_spec.rb
|
77
79
|
- spec/resources/checks_spec.rb
|
78
80
|
- spec/resources/contacts_spec.rb
|
79
81
|
- spec/resources/events_spec.rb
|
@@ -113,6 +115,7 @@ summary: Access the API of a Flapjack system monitoring server
|
|
113
115
|
test_files:
|
114
116
|
- spec/argument_validator_spec.rb
|
115
117
|
- spec/flapjack-diner_spec.rb
|
118
|
+
- spec/resources/blackholes_spec.rb
|
116
119
|
- spec/resources/checks_spec.rb
|
117
120
|
- spec/resources/contacts_spec.rb
|
118
121
|
- spec/resources/events_spec.rb
|