flapjack-diner 2.0.0b1 → 2.0.0.pre.alpha.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +21 -0
- data/.rubocop_todo.yml +135 -0
- data/.travis.yml +10 -5
- data/README.md +125 -143
- data/flapjack-diner.gemspec +1 -1
- data/lib/flapjack-diner.rb +24 -54
- data/lib/flapjack-diner/argument_validator.rb +17 -0
- data/lib/flapjack-diner/resources/checks.rb +52 -0
- data/lib/flapjack-diner/resources/contacts.rb +54 -0
- data/lib/flapjack-diner/resources/events.rb +54 -0
- data/lib/flapjack-diner/resources/maintenance_periods.rb +76 -0
- data/lib/flapjack-diner/resources/media.rb +75 -0
- data/lib/flapjack-diner/resources/metrics.rb +23 -0
- data/lib/flapjack-diner/resources/relationships.rb +275 -0
- data/lib/flapjack-diner/resources/rules.rb +75 -0
- data/lib/flapjack-diner/resources/states.rb +24 -0
- data/lib/flapjack-diner/resources/statistics.rb +24 -0
- data/lib/flapjack-diner/resources/tags.rb +47 -0
- data/lib/flapjack-diner/tools.rb +456 -46
- data/lib/flapjack-diner/version.rb +1 -1
- data/spec/flapjack-diner_spec.rb +18 -9
- data/spec/resources/checks_spec.rb +7 -7
- data/spec/resources/contacts_spec.rb +12 -14
- data/spec/resources/events_spec.rb +13 -13
- data/spec/resources/maintenance_periods_spec.rb +3 -3
- data/spec/resources/media_spec.rb +3 -3
- data/spec/resources/metrics_spec.rb +1 -1
- data/spec/{relationships_spec.rb → resources/relationships_spec.rb} +25 -71
- data/spec/resources/rules_spec.rb +62 -62
- data/spec/resources/states_spec.rb +1 -1
- data/spec/resources/statistics_spec.rb +1 -1
- data/spec/resources/tags_spec.rb +19 -75
- data/spec/support/fixture_data.rb +43 -80
- metadata +22 -17
- data/lib/flapjack-diner/configuration.rb +0 -417
- data/lib/flapjack-diner/log_formatter.rb +0 -22
- data/lib/flapjack-diner/query.rb +0 -114
- data/lib/flapjack-diner/relationships.rb +0 -180
- data/lib/flapjack-diner/request.rb +0 -280
- data/lib/flapjack-diner/resources.rb +0 -64
- data/lib/flapjack-diner/response.rb +0 -91
- data/lib/flapjack-diner/utility.rb +0 -16
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'flapjack-diner'
|
3
3
|
|
4
|
-
describe Flapjack::Diner::Resources, :pact => true do
|
4
|
+
describe Flapjack::Diner::Resources::Rules, :pact => true do
|
5
5
|
|
6
6
|
before(:each) do
|
7
7
|
Flapjack::Diner.base_uri('localhost:19081')
|
@@ -10,7 +10,7 @@ describe Flapjack::Diner::Resources, :pact => true do
|
|
10
10
|
|
11
11
|
context 'create' do
|
12
12
|
|
13
|
-
it "submits a POST request for
|
13
|
+
it "submits a POST request for a rule" do
|
14
14
|
req_data = rule_json(rule_data).merge(
|
15
15
|
:relationships => {
|
16
16
|
:contact => {
|
@@ -157,73 +157,73 @@ describe Flapjack::Diner::Resources, :pact => true do
|
|
157
157
|
|
158
158
|
result = Flapjack::Diner.rules(rule_data[:id])
|
159
159
|
expect(result).to be_nil
|
160
|
-
expect(Flapjack::Diner.
|
160
|
+
expect(Flapjack::Diner.last_error).to eq([{:status => '404',
|
161
161
|
:detail => "could not find Rule record, id: '#{rule_data[:id]}'"}])
|
162
162
|
end
|
163
163
|
|
164
164
|
end
|
165
165
|
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
end
|
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 rule' do
|
169
|
+
# flapjack.given("a rule exists").
|
170
|
+
# upon_receiving("a PUT request for a single rule").
|
171
|
+
# with(:method => :put,
|
172
|
+
# :path => "/rules/#{rule_data[:id]}",
|
173
|
+
# :body => {:rules => {:id => rule_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_rules(:id => rule_data[:id], :time_restrictions => [])
|
180
|
+
# expect(result).to be_a(TrueClass)
|
181
|
+
# end
|
182
|
+
|
183
|
+
# it 'submits a PUT request for several rules' do
|
184
|
+
# flapjack.given("two rules exist").
|
185
|
+
# upon_receiving("a PUT request for two rules").
|
186
|
+
# with(:method => :put,
|
187
|
+
# :path => "/rules/#{rule_data[:id]},#{rule_2_data[:id]}",
|
188
|
+
# :body => {:rules => [{:id => rule_data[:id], :time_restrictions => []},
|
189
|
+
# {:id => rule_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_rules(
|
196
|
+
# {:id => rule_data[:id], :time_restrictions => []},
|
197
|
+
# {:id => rule_2_data[:id], :enabled => true})
|
198
|
+
# expect(result).to be_a(TrueClass)
|
199
|
+
# end
|
200
|
+
|
201
|
+
# it "can't find the rule to update" do
|
202
|
+
# flapjack.given("no data exists").
|
203
|
+
# upon_receiving("a PUT request for a single rule").
|
204
|
+
# with(:method => :put,
|
205
|
+
# :path => "/rules/#{rule_data[:id]}",
|
206
|
+
# :body => {:rules => {:id => rule_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 Rule records, ids: '#{rule_data[:id]}'"
|
214
|
+
# }]}
|
215
|
+
# )
|
216
|
+
|
217
|
+
# result = Flapjack::Diner.update_rules(:id => rule_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 Rule records, ids: '#{rule_data[:id]}'"}])
|
221
|
+
# end
|
222
|
+
# end
|
223
223
|
|
224
224
|
context 'delete' do
|
225
225
|
|
226
|
-
it "submits a DELETE request for
|
226
|
+
it "submits a DELETE request for a rule" do
|
227
227
|
flapjack.given("a rule exists").
|
228
228
|
upon_receiving("a DELETE request for a single rule").
|
229
229
|
with(:method => :delete,
|
@@ -270,7 +270,7 @@ describe Flapjack::Diner::Resources, :pact => true do
|
|
270
270
|
|
271
271
|
result = Flapjack::Diner.delete_rules(rule_data[:id])
|
272
272
|
expect(result).to be_nil
|
273
|
-
expect(Flapjack::Diner.
|
273
|
+
expect(Flapjack::Diner.last_error).to eq([{:status => '404',
|
274
274
|
:detail => "could not find Rule record, id: '#{rule_data[:id]}'"}])
|
275
275
|
end
|
276
276
|
end
|
data/spec/resources/tags_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
require 'flapjack-diner'
|
3
3
|
|
4
|
-
describe Flapjack::Diner::Resources, :pact => true do
|
4
|
+
describe Flapjack::Diner::Resources::Tags, :pact => true do
|
5
5
|
|
6
6
|
before(:each) do
|
7
7
|
Flapjack::Diner.base_uri('localhost:19081')
|
@@ -95,96 +95,40 @@ describe Flapjack::Diner::Resources, :pact => true do
|
|
95
95
|
|
96
96
|
flapjack.given("a tag exists").
|
97
97
|
upon_receiving("a GET request for tag 'www.example.com:SSH'").
|
98
|
-
with(:method => :get, :path => "/tags/#{tag_data[:
|
98
|
+
with(:method => :get, :path => "/tags/#{tag_data[:name]}").
|
99
99
|
will_respond_with(
|
100
100
|
:status => 200,
|
101
101
|
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
102
102
|
:body => {:data => resp_data} )
|
103
103
|
|
104
|
-
result = Flapjack::Diner.tags(tag_data[:
|
104
|
+
result = Flapjack::Diner.tags(tag_data[:name])
|
105
105
|
expect(result).to eq(resultify(resp_data))
|
106
106
|
end
|
107
107
|
|
108
108
|
it "can't find tag" do
|
109
109
|
flapjack.given("no data exists").
|
110
110
|
upon_receiving("a GET request for tag 'www.example.com:SSH'").
|
111
|
-
with(:method => :get, :path => "/tags/#{tag_data[:
|
111
|
+
with(:method => :get, :path => "/tags/#{tag_data[:name]}").
|
112
112
|
will_respond_with(
|
113
113
|
:status => 404,
|
114
114
|
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
115
115
|
:body => {:errors => [{
|
116
116
|
:status => '404',
|
117
|
-
:detail => "could not find Tag record, id: '#{tag_data[:
|
117
|
+
:detail => "could not find Tag record, id: '#{tag_data[:name]}'"
|
118
118
|
}]}
|
119
119
|
)
|
120
120
|
|
121
|
-
result = Flapjack::Diner.tags(tag_data[:
|
121
|
+
result = Flapjack::Diner.tags(tag_data[:name])
|
122
122
|
expect(result).to be_nil
|
123
|
-
expect(Flapjack::Diner.
|
124
|
-
:detail => "could not find Tag record, id: '#{tag_data[:
|
123
|
+
expect(Flapjack::Diner.last_error).to eq([{:status => '404',
|
124
|
+
:detail => "could not find Tag record, id: '#{tag_data[:name]}'"}])
|
125
125
|
end
|
126
126
|
|
127
127
|
end
|
128
128
|
|
129
129
|
end
|
130
130
|
|
131
|
-
|
132
|
-
|
133
|
-
it 'submits a PATCH request for a tag' do
|
134
|
-
flapjack.given("a tag exists").
|
135
|
-
upon_receiving("a PATCH request for a single tag").
|
136
|
-
with(:method => :patch,
|
137
|
-
:path => "/tags/#{tag_data[:id]}",
|
138
|
-
:body => {:data => {:id => tag_data[:id], :type => 'tag', :attributes => {:name => 'database_only'}}},
|
139
|
-
:headers => {'Content-Type' => 'application/vnd.api+json'}).
|
140
|
-
will_respond_with(
|
141
|
-
:status => 204,
|
142
|
-
:body => '' )
|
143
|
-
|
144
|
-
result = Flapjack::Diner.update_tags(:id => tag_data[:id], :name => 'database_only')
|
145
|
-
expect(result).to be_a(TrueClass)
|
146
|
-
end
|
147
|
-
|
148
|
-
it 'submits a PATCH request for several tags' do
|
149
|
-
flapjack.given("two tags exist").
|
150
|
-
upon_receiving("a PATCH request for two tags").
|
151
|
-
with(:method => :patch,
|
152
|
-
:path => "/tags",
|
153
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; ext=bulk'},
|
154
|
-
:body => {:data => [{:id => tag_data[:id], :type => 'tag', :attributes => {:name => 'database_only'}},
|
155
|
-
{:id => tag_2_data[:id], :type => 'tag', :attributes => {:name => 'app_only'}}]}).
|
156
|
-
will_respond_with(
|
157
|
-
:status => 204,
|
158
|
-
:body => '' )
|
159
|
-
|
160
|
-
result = Flapjack::Diner.update_tags(
|
161
|
-
{:id => tag_data[:id], :name => 'database_only'},
|
162
|
-
{:id => tag_2_data[:id], :name => 'app_only'})
|
163
|
-
expect(result).to be_a(TrueClass)
|
164
|
-
end
|
165
|
-
|
166
|
-
it "can't find the tag to update" do
|
167
|
-
flapjack.given("no data exists").
|
168
|
-
upon_receiving("a PATCH request for a single tag").
|
169
|
-
with(:method => :patch,
|
170
|
-
:path => "/tags/#{tag_data[:id]}",
|
171
|
-
:body => {:data => {:id => tag_data[:id], :type => 'tag', :attributes => {:name => 'database_only'}}},
|
172
|
-
:headers => {'Content-Type' => 'application/vnd.api+json'}).
|
173
|
-
will_respond_with(
|
174
|
-
:status => 404,
|
175
|
-
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
176
|
-
:body => {:errors => [{
|
177
|
-
:status => '404',
|
178
|
-
:detail => "could not find Tag record, id: '#{tag_data[:id]}'"
|
179
|
-
}]}
|
180
|
-
)
|
181
|
-
|
182
|
-
result = Flapjack::Diner.update_tags(:id => tag_data[:id], :name => 'database_only')
|
183
|
-
expect(result).to be_nil
|
184
|
-
expect(Flapjack::Diner.error).to eq([{:status => '404',
|
185
|
-
:detail => "could not find Tag record, id: '#{tag_data[:id]}'"}])
|
186
|
-
end
|
187
|
-
end
|
131
|
+
# no tag updates allowed
|
188
132
|
|
189
133
|
context 'delete' do
|
190
134
|
|
@@ -192,18 +136,18 @@ describe Flapjack::Diner::Resources, :pact => true do
|
|
192
136
|
flapjack.given("a tag exists").
|
193
137
|
upon_receiving("a DELETE request for a single tag").
|
194
138
|
with(:method => :delete,
|
195
|
-
:path => "/tags/#{tag_data[:
|
139
|
+
:path => "/tags/#{tag_data[:name]}",
|
196
140
|
:body => nil).
|
197
141
|
will_respond_with(:status => 204,
|
198
142
|
:body => '')
|
199
143
|
|
200
|
-
result = Flapjack::Diner.delete_tags(tag_data[:
|
144
|
+
result = Flapjack::Diner.delete_tags(tag_data[:name])
|
201
145
|
expect(result).to be_a(TrueClass)
|
202
146
|
end
|
203
147
|
|
204
148
|
it "submits a DELETE request for several tags" do
|
205
|
-
tags_data = [{:type => 'tag', :id => tag_data[:
|
206
|
-
{:type => 'tag', :id => tag_2_data[:
|
149
|
+
tags_data = [{:type => 'tag', :id => tag_data[:name]},
|
150
|
+
{:type => 'tag', :id => tag_2_data[:name]}]
|
207
151
|
|
208
152
|
flapjack.given("two tags exist").
|
209
153
|
upon_receiving("a DELETE request for two tags").
|
@@ -214,7 +158,7 @@ describe Flapjack::Diner::Resources, :pact => true do
|
|
214
158
|
will_respond_with(:status => 204,
|
215
159
|
:body => '')
|
216
160
|
|
217
|
-
result = Flapjack::Diner.delete_tags(tag_data[:
|
161
|
+
result = Flapjack::Diner.delete_tags(tag_data[:name], tag_2_data[:name])
|
218
162
|
expect(result).to be_a(TrueClass)
|
219
163
|
end
|
220
164
|
|
@@ -222,21 +166,21 @@ describe Flapjack::Diner::Resources, :pact => true do
|
|
222
166
|
flapjack.given("no data exists").
|
223
167
|
upon_receiving("a DELETE request for a single tag").
|
224
168
|
with(:method => :delete,
|
225
|
-
:path => "/tags/#{tag_data[:
|
169
|
+
:path => "/tags/#{tag_data[:name]}",
|
226
170
|
:body => nil).
|
227
171
|
will_respond_with(
|
228
172
|
:status => 404,
|
229
173
|
:headers => {'Content-Type' => 'application/vnd.api+json; supported-ext=bulk; charset=utf-8'},
|
230
174
|
:body => {:errors => [{
|
231
175
|
:status => '404',
|
232
|
-
:detail => "could not find Tag record, id: '#{tag_data[:
|
176
|
+
:detail => "could not find Tag record, id: '#{tag_data[:name]}'"
|
233
177
|
}]}
|
234
178
|
)
|
235
179
|
|
236
|
-
result = Flapjack::Diner.delete_tags(tag_data[:
|
180
|
+
result = Flapjack::Diner.delete_tags(tag_data[:name])
|
237
181
|
expect(result).to be_nil
|
238
|
-
expect(Flapjack::Diner.
|
239
|
-
:detail => "could not find Tag record, id: '#{tag_data[:
|
182
|
+
expect(Flapjack::Diner.last_error).to eq([{:status => '404',
|
183
|
+
:detail => "could not find Tag record, id: '#{tag_data[:name]}'"}])
|
240
184
|
end
|
241
185
|
end
|
242
186
|
|
@@ -40,13 +40,15 @@ module FixtureData
|
|
40
40
|
ret
|
41
41
|
end
|
42
42
|
|
43
|
+
# def contextify(resp_data)
|
44
|
+
|
45
|
+
# end
|
46
|
+
|
43
47
|
def check_data
|
44
48
|
@check_data ||= {
|
45
49
|
:id => '1ed80833-6d28-4aba-8603-d81c249b8c23',
|
46
50
|
:name => 'www.example.com:SSH',
|
47
|
-
:enabled => true
|
48
|
-
:initial_failure_delay => nil,
|
49
|
-
:repeat_failure_delay => nil
|
51
|
+
:enabled => true
|
50
52
|
}
|
51
53
|
end
|
52
54
|
|
@@ -54,9 +56,7 @@ module FixtureData
|
|
54
56
|
@check_2_data ||= {
|
55
57
|
:id => '29e913cf-29ea-4ae5-94f6-7069cf4a1514',
|
56
58
|
:name => 'www2.example.com:PING',
|
57
|
-
:enabled => true
|
58
|
-
:initial_failure_delay => nil,
|
59
|
-
:repeat_failure_delay => nil
|
59
|
+
:enabled => true
|
60
60
|
}
|
61
61
|
end
|
62
62
|
|
@@ -74,62 +74,62 @@ module FixtureData
|
|
74
74
|
{
|
75
75
|
:alerting_media => {
|
76
76
|
:links => {
|
77
|
-
:self => "http
|
78
|
-
:related => "http
|
77
|
+
:self => "http://example.org/checks/#{id}/relationships/alerting_media",
|
78
|
+
:related => "http://example.org/checks/#{id}/alerting_media"
|
79
79
|
}
|
80
80
|
},
|
81
81
|
:contacts => {
|
82
82
|
:links => {
|
83
|
-
:self => "http
|
84
|
-
:related => "http
|
83
|
+
:self => "http://example.org/checks/#{id}/relationships/contacts",
|
84
|
+
:related => "http://example.org/checks/#{id}/contacts"
|
85
85
|
}
|
86
86
|
},
|
87
87
|
:current_scheduled_maintenances => {
|
88
88
|
:links => {
|
89
|
-
:self => "http
|
90
|
-
:related => "http
|
89
|
+
:self => "http://example.org/checks/#{id}/relationships/current_scheduled_maintenances",
|
90
|
+
:related => "http://example.org/checks/#{id}/current_scheduled_maintenances"
|
91
91
|
}
|
92
92
|
},
|
93
93
|
:current_state => {
|
94
94
|
:links => {
|
95
|
-
:self => "http
|
96
|
-
:related => "http
|
95
|
+
:self => "http://example.org/checks/#{id}/relationships/current_state",
|
96
|
+
:related => "http://example.org/checks/#{id}/current_state"
|
97
97
|
}
|
98
98
|
},
|
99
99
|
:current_unscheduled_maintenance => {
|
100
100
|
:links => {
|
101
|
-
:self => "http
|
102
|
-
:related => "http
|
101
|
+
:self => "http://example.org/checks/#{id}/relationships/current_unscheduled_maintenance",
|
102
|
+
:related => "http://example.org/checks/#{id}/current_unscheduled_maintenance"
|
103
103
|
}
|
104
104
|
},
|
105
105
|
:latest_notifications => {
|
106
106
|
:links => {
|
107
|
-
:self => "http
|
108
|
-
:related => "http
|
107
|
+
:self => "http://example.org/checks/#{id}/relationships/latest_notifications",
|
108
|
+
:related => "http://example.org/checks/#{id}/latest_notifications"
|
109
109
|
}
|
110
110
|
},
|
111
111
|
:scheduled_maintenances => {
|
112
112
|
:links => {
|
113
|
-
:self => "http
|
114
|
-
:related => "http
|
113
|
+
:self => "http://example.org/checks/#{id}/relationships/scheduled_maintenances",
|
114
|
+
:related => "http://example.org/checks/#{id}/scheduled_maintenances"
|
115
115
|
}
|
116
116
|
},
|
117
117
|
:states => {
|
118
118
|
:links => {
|
119
|
-
:self => "http
|
120
|
-
:related => "http
|
119
|
+
:self => "http://example.org/checks/#{id}/relationships/states",
|
120
|
+
:related => "http://example.org/checks/#{id}/states"
|
121
121
|
}
|
122
122
|
},
|
123
123
|
:tags => {
|
124
124
|
:links => {
|
125
|
-
:self => "http
|
126
|
-
:related => "http
|
125
|
+
:self => "http://example.org/checks/#{id}/relationships/tags",
|
126
|
+
:related => "http://example.org/checks/#{id}/tags"
|
127
127
|
}
|
128
128
|
},
|
129
129
|
:unscheduled_maintenances => {
|
130
130
|
:links => {
|
131
|
-
:self => "http
|
132
|
-
:related => "http
|
131
|
+
:self => "http://example.org/checks/#{id}/relationships/unscheduled_maintenances",
|
132
|
+
:related => "http://example.org/checks/#{id}/unscheduled_maintenances"
|
133
133
|
}
|
134
134
|
}
|
135
135
|
}
|
@@ -179,12 +179,6 @@ module FixtureData
|
|
179
179
|
:self => "http://#{api_host}/contacts/#{id}/relationships/rules",
|
180
180
|
:related => "http://#{api_host}/contacts/#{id}/rules"
|
181
181
|
}
|
182
|
-
},
|
183
|
-
:tags => {
|
184
|
-
:links => {
|
185
|
-
:self => "http://#{api_host}/contacts/#{id}/relationships/tags",
|
186
|
-
:related => "http://#{api_host}/contacts/#{id}/tags"
|
187
|
-
}
|
188
182
|
}
|
189
183
|
}
|
190
184
|
end
|
@@ -238,8 +232,8 @@ module FixtureData
|
|
238
232
|
{
|
239
233
|
:check => {
|
240
234
|
:links => {
|
241
|
-
:self => "http
|
242
|
-
:related => "http
|
235
|
+
:self => "http://example.org/#{type}_maintenances/#{id}/relationships/check",
|
236
|
+
:related => "http://example.org/#{type}_maintenances/#{id}/check"
|
243
237
|
}
|
244
238
|
}
|
245
239
|
}
|
@@ -307,9 +301,7 @@ module FixtureData
|
|
307
301
|
def rule_data
|
308
302
|
@rule_data ||= {
|
309
303
|
:id => '05983623-fcef-42da-af44-ed6990b500fa',
|
310
|
-
:
|
311
|
-
:blackhole => false,
|
312
|
-
:strategy => 'all_tags',
|
304
|
+
:is_blackhole => false,
|
313
305
|
:conditions_list => 'critical'
|
314
306
|
}
|
315
307
|
end
|
@@ -317,9 +309,7 @@ module FixtureData
|
|
317
309
|
def rule_2_data
|
318
310
|
@rule_2_data ||= {
|
319
311
|
:id => '20f182fc-6e32-4794-9007-97366d162c51',
|
320
|
-
:
|
321
|
-
:blackhole => true,
|
322
|
-
:strategy => 'all_tags',
|
312
|
+
:is_blackhole => false,
|
323
313
|
:conditions_list => 'warning'
|
324
314
|
}
|
325
315
|
end
|
@@ -337,20 +327,20 @@ module FixtureData
|
|
337
327
|
{
|
338
328
|
:contact => {
|
339
329
|
:links => {
|
340
|
-
:self => "http
|
341
|
-
:related => "http
|
330
|
+
:self => "http://example.org/rules/#{id}/relationships/contact",
|
331
|
+
:related => "http://example.org/rules/#{id}/contact"
|
342
332
|
}
|
343
333
|
},
|
344
334
|
:media => {
|
345
335
|
:links => {
|
346
|
-
:self => "http
|
347
|
-
:related => "http
|
336
|
+
:self => "http://example.org/rules/#{id}/relationships/media",
|
337
|
+
:related => "http://example.org/rules/#{id}/media"
|
348
338
|
}
|
349
339
|
},
|
350
340
|
:tags => {
|
351
341
|
:links => {
|
352
|
-
:self => "http
|
353
|
-
:related => "http
|
342
|
+
:self => "http://example.org/rules/#{id}/relationships/tags",
|
343
|
+
:related => "http://example.org/rules/#{id}/tags"
|
354
344
|
}
|
355
345
|
}
|
356
346
|
}
|
@@ -361,7 +351,7 @@ module FixtureData
|
|
361
351
|
:id => '142acf62-31e7-4074-ada9-a30ae73d880d',
|
362
352
|
:created_at => (fixture_time - 30).iso8601,
|
363
353
|
:updated_at => (fixture_time - 30).iso8601,
|
364
|
-
:condition => 'critical'
|
354
|
+
:condition => 'critical'
|
365
355
|
}
|
366
356
|
end
|
367
357
|
|
@@ -370,7 +360,7 @@ module FixtureData
|
|
370
360
|
:id => '008d78fc-1c72-4c2a-8057-0d44b64c6f3d',
|
371
361
|
:created_at => (fixture_time - 10).iso8601,
|
372
362
|
:updated_at => (fixture_time - 10).iso8601,
|
373
|
-
:condition => 'ok'
|
363
|
+
:condition => 'ok'
|
374
364
|
}
|
375
365
|
end
|
376
366
|
|
@@ -388,8 +378,8 @@ module FixtureData
|
|
388
378
|
{
|
389
379
|
:check => {
|
390
380
|
:links => {
|
391
|
-
:self => "http
|
392
|
-
:related => "http
|
381
|
+
:self => "http://example.org/states/#{id}/relationships/check",
|
382
|
+
:related => "http://example.org/states/#{id}/check"
|
393
383
|
}
|
394
384
|
}
|
395
385
|
}
|
@@ -397,29 +387,26 @@ module FixtureData
|
|
397
387
|
|
398
388
|
def tag_data
|
399
389
|
@tag_data ||= {
|
400
|
-
:id => '1850b8d7-1055-4a6e-9c96-f8f50e55bd0f',
|
401
390
|
:name => 'database',
|
402
391
|
}
|
403
392
|
end
|
404
393
|
|
405
394
|
def tag_2_data
|
406
395
|
@tag_2_data ||= {
|
407
|
-
:id => 'c7a12328-8902-4974-8efa-68ec3e284507',
|
408
396
|
:name => 'physical',
|
409
397
|
}
|
410
398
|
end
|
411
399
|
|
412
400
|
def tag_json(ta_data)
|
413
|
-
id = ta_data[:
|
401
|
+
id = ta_data[:name]
|
414
402
|
{
|
415
|
-
:id => id,
|
416
403
|
:type => 'tag',
|
417
|
-
:attributes => ta_data
|
404
|
+
:attributes => ta_data
|
418
405
|
}
|
419
406
|
end
|
420
407
|
|
421
408
|
def tag_rel(ta_data)
|
422
|
-
id = ta_data[:
|
409
|
+
id = ta_data[:name]
|
423
410
|
{
|
424
411
|
:checks => {
|
425
412
|
:links => {
|
@@ -427,35 +414,11 @@ module FixtureData
|
|
427
414
|
:related => "http://#{api_host}/tags/#{id}/checks"
|
428
415
|
}
|
429
416
|
},
|
430
|
-
:contacts => {
|
431
|
-
:links => {
|
432
|
-
:self => "http://#{api_host}/tags/#{id}/relationships/contacts",
|
433
|
-
:related => "http://#{api_host}/tags/#{id}/contacts"
|
434
|
-
}
|
435
|
-
},
|
436
417
|
:rules => {
|
437
418
|
:links => {
|
438
419
|
:self => "http://#{api_host}/tags/#{id}/relationships/rules",
|
439
420
|
:related => "http://#{api_host}/tags/#{id}/rules"
|
440
421
|
}
|
441
|
-
},
|
442
|
-
:scheduled_maintenances => {
|
443
|
-
:links => {
|
444
|
-
:self => "http://#{api_host}/tags/#{id}/relationships/scheduled_maintenances",
|
445
|
-
:related => "http://#{api_host}/tags/#{id}/scheduled_maintenances"
|
446
|
-
}
|
447
|
-
},
|
448
|
-
:states => {
|
449
|
-
:links => {
|
450
|
-
:self => "http://#{api_host}/tags/#{id}/relationships/states",
|
451
|
-
:related => "http://#{api_host}/tags/#{id}/states"
|
452
|
-
}
|
453
|
-
},
|
454
|
-
:unscheduled_maintenances => {
|
455
|
-
:links => {
|
456
|
-
:self => "http://#{api_host}/tags/#{id}/relationships/unscheduled_maintenances",
|
457
|
-
:related => "http://#{api_host}/tags/#{id}/unscheduled_maintenances"
|
458
|
-
}
|
459
422
|
}
|
460
423
|
}
|
461
424
|
end
|