flapjack-diner 2.0.0.pre.alpha.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -10
- data/README.md +165 -272
- data/flapjack-diner.gemspec +1 -1
- data/lib/flapjack-diner.rb +54 -25
- data/lib/flapjack-diner/argument_validator.rb +0 -17
- data/lib/flapjack-diner/configuration.rb +417 -0
- data/lib/flapjack-diner/log_formatter.rb +22 -0
- data/lib/flapjack-diner/query.rb +114 -0
- data/lib/flapjack-diner/relationships.rb +180 -0
- data/lib/flapjack-diner/request.rb +280 -0
- data/lib/flapjack-diner/resources.rb +64 -0
- data/lib/flapjack-diner/response.rb +91 -0
- data/lib/flapjack-diner/tools.rb +46 -456
- data/lib/flapjack-diner/utility.rb +16 -0
- data/lib/flapjack-diner/version.rb +1 -1
- data/spec/flapjack-diner_spec.rb +9 -18
- data/spec/{resources/relationships_spec.rb → relationships_spec.rb} +75 -29
- data/spec/resources/checks_spec.rb +7 -7
- data/spec/resources/contacts_spec.rb +21 -19
- 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/resources/rules_spec.rb +278 -0
- data/spec/resources/states_spec.rb +1 -1
- data/spec/resources/statistics_spec.rb +1 -1
- data/spec/resources/tags_spec.rb +75 -19
- data/spec/support/fixture_data.rb +57 -98
- metadata +21 -29
- data/.rubocop.yml +0 -21
- data/.rubocop_todo.yml +0 -135
- data/lib/flapjack-diner/resources/acceptors.rb +0 -77
- data/lib/flapjack-diner/resources/checks.rb +0 -52
- data/lib/flapjack-diner/resources/contacts.rb +0 -54
- data/lib/flapjack-diner/resources/events.rb +0 -54
- data/lib/flapjack-diner/resources/maintenance_periods.rb +0 -76
- data/lib/flapjack-diner/resources/media.rb +0 -75
- data/lib/flapjack-diner/resources/metrics.rb +0 -23
- data/lib/flapjack-diner/resources/rejectors.rb +0 -77
- data/lib/flapjack-diner/resources/relationships.rb +0 -314
- data/lib/flapjack-diner/resources/states.rb +0 -24
- data/lib/flapjack-diner/resources/statistics.rb +0 -24
- data/lib/flapjack-diner/resources/tags.rb +0 -47
- data/spec/resources/acceptors_spec.rb +0 -278
- data/spec/resources/rejectors_spec.rb +0 -278
@@ -1,75 +0,0 @@
|
|
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 Media
|
12
|
-
def create_media(*args)
|
13
|
-
data = unwrap_data(*args)
|
14
|
-
validate_params(data) do
|
15
|
-
validate :query => :id, :as => :uuid
|
16
|
-
validate :query => :transport, :as => [:non_empty_string, :required]
|
17
|
-
validate :query => [:address, :pagerduty_subdomain,
|
18
|
-
:pagerduty_token], :as => :non_empty_string
|
19
|
-
validate :query => [:interval, :rollup_threshold,
|
20
|
-
:pagerduty_ack_duration], :as => :positive_integer
|
21
|
-
validate :query => :contact, :as => [:singular_link_uuid, :required]
|
22
|
-
validate :query => [:acceptors, :rejectors], :as => :multiple_link_uuid
|
23
|
-
end
|
24
|
-
perform_post(:media, "/media", data)
|
25
|
-
end
|
26
|
-
|
27
|
-
def media(*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('/media', ids, data)
|
35
|
-
end
|
36
|
-
|
37
|
-
def update_media(*args)
|
38
|
-
data = unwrap_data(*args)
|
39
|
-
validate_params(data) do
|
40
|
-
validate :query => :id, :as => [:uuid, :required]
|
41
|
-
validate :query => [:address, :pagerduty_subdomain,
|
42
|
-
:pagerduty_token], :as => :non_empty_string
|
43
|
-
validate :query => [:interval, :rollup_threshold,
|
44
|
-
:pagerduty_ack_duration], :as => :positive_integer
|
45
|
-
validate :query => [:acceptors, :rejectors], :as => :multiple_link_uuid
|
46
|
-
end
|
47
|
-
perform_patch(:media, "/media", data)
|
48
|
-
end
|
49
|
-
|
50
|
-
def delete_media(*ids)
|
51
|
-
raise "'delete_media' requires at least one medium id " \
|
52
|
-
'parameter' if ids.nil? || ids.empty?
|
53
|
-
perform_delete(:media, '/media', *ids)
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def _media_validate_association(data)
|
59
|
-
case data
|
60
|
-
when Array
|
61
|
-
data.each do |d|
|
62
|
-
unless d.has_key?(:contact)
|
63
|
-
raise ArgumentError.new("Contact association must be provided for all media")
|
64
|
-
end
|
65
|
-
end
|
66
|
-
when Hash
|
67
|
-
unless data.has_key?(:contact)
|
68
|
-
raise ArgumentError.new("Contact association must be provided for medium")
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,23 +0,0 @@
|
|
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 Metrics
|
12
|
-
# singular resource, no id
|
13
|
-
def metrics(*args)
|
14
|
-
data = unwrap_data(*args)
|
15
|
-
validate_params(data) do
|
16
|
-
validate :query => :fields, :as => :string_or_array_of_strings
|
17
|
-
end
|
18
|
-
perform_get('/metrics', [], data)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,77 +0,0 @@
|
|
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 Rejectors
|
12
|
-
|
13
|
-
def create_rejectors(*args)
|
14
|
-
data = unwrap_data(*args)
|
15
|
-
validate_params(data) do
|
16
|
-
validate :query => :id, :as => :uuid
|
17
|
-
validate :query => :name, :as => :string
|
18
|
-
validate :query => :all, :as => :boolean
|
19
|
-
validate :query => :conditions_list, :as => :string
|
20
|
-
# TODO proper validation of time_restrictions field
|
21
|
-
validate :query => :contact, :as => [:singular_link_uuid, :required]
|
22
|
-
validate :query => :media, :as => :multiple_link_uuid
|
23
|
-
validate :query => :tags, :as => :multiple_link
|
24
|
-
end
|
25
|
-
_rejectors_validate_association(data)
|
26
|
-
perform_post(:rejectors, '/rejectors', data)
|
27
|
-
end
|
28
|
-
|
29
|
-
def rejectors(*args)
|
30
|
-
ids, data = unwrap_uuids(*args), unwrap_data(*args)
|
31
|
-
validate_params(data) do
|
32
|
-
validate :query => [:fields, :sort, :include], :as => :string_or_array_of_strings
|
33
|
-
validate :query => :filter, :as => :hash
|
34
|
-
validate :query => [:page, :per_page], :as => :positive_integer
|
35
|
-
end
|
36
|
-
perform_get('/rejectors', ids, data)
|
37
|
-
end
|
38
|
-
|
39
|
-
def update_rejectors(*args)
|
40
|
-
data = unwrap_data(*args)
|
41
|
-
validate_params(data) do
|
42
|
-
validate :query => :id, :as => [:uuid, :required]
|
43
|
-
validate :query => :name, :as => :string
|
44
|
-
validate :query => :all, :as => :boolean
|
45
|
-
validate :query => :conditions_list, :as => :string
|
46
|
-
# TODO proper validation of time_restrictions field
|
47
|
-
validate :query => :media, :as => :multiple_link_uuid
|
48
|
-
validate :query => :tags, :as => :multiple_link
|
49
|
-
end
|
50
|
-
perform_patch(:rejectors, "/rejectors", data)
|
51
|
-
end
|
52
|
-
|
53
|
-
def delete_rejectors(*ids)
|
54
|
-
raise "'delete_rejectors' requires at least one rejector id parameter" if ids.nil? || ids.empty?
|
55
|
-
perform_delete(:rejectors, '/rejectors', *ids)
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def _rejectors_validate_association(data)
|
61
|
-
case data
|
62
|
-
when Array
|
63
|
-
data.each do |d|
|
64
|
-
unless d.has_key?(:contact)
|
65
|
-
raise ArgumentError.new("Contact association must be provided for all rejectors")
|
66
|
-
end
|
67
|
-
end
|
68
|
-
when Hash
|
69
|
-
unless data.has_key?(:contact)
|
70
|
-
raise ArgumentError.new("Contact association must be provided for rejector")
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,314 +0,0 @@
|
|
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 Relationships
|
12
|
-
|
13
|
-
TYPES = {
|
14
|
-
:acceptors => 'acceptor',
|
15
|
-
:acknowledgements => 'acknowledgement',
|
16
|
-
:checks => 'check',
|
17
|
-
:contacts => 'contact',
|
18
|
-
:media => 'medium',
|
19
|
-
:rejectors => 'rejector',
|
20
|
-
:scheduled_maintenances => 'scheduled_maintenance',
|
21
|
-
:states => 'state',
|
22
|
-
:tags => 'tag',
|
23
|
-
:test_notifications => 'test_notification',
|
24
|
-
:unscheduled_maintenances => 'unscheduled_maintenance'
|
25
|
-
}
|
26
|
-
|
27
|
-
# FIXME include option for tools.rb/GET should check these config settings for includable
|
28
|
-
|
29
|
-
# extracted from flapjack data models' "jsonapi_associations" class method
|
30
|
-
ASSOCIATIONS = {
|
31
|
-
:acceptors => {
|
32
|
-
:contact => {
|
33
|
-
:post => true, :get => true,
|
34
|
-
:number => :singular, :link => true, :includable => true
|
35
|
-
},
|
36
|
-
:media => {
|
37
|
-
:post => true, :get => true, :patch => true, :delete => true,
|
38
|
-
:number => :multiple, :link => true, :includable => true
|
39
|
-
},
|
40
|
-
:tags => {
|
41
|
-
:post => true, :get => true, :patch => true, :delete => true,
|
42
|
-
:number => :multiple, :link => true, :includable => true
|
43
|
-
}
|
44
|
-
},
|
45
|
-
:acknowledgements => {
|
46
|
-
:check => {
|
47
|
-
:post => true,
|
48
|
-
:number => :singular, :link => false, :includable => false
|
49
|
-
},
|
50
|
-
:tag => {
|
51
|
-
:post => true,
|
52
|
-
:number => :singular, :link => false, :includable => false
|
53
|
-
}
|
54
|
-
},
|
55
|
-
:checks => {
|
56
|
-
:alerting_media => {
|
57
|
-
:get => true,
|
58
|
-
:number => :multiple, :link => true, :includable => true
|
59
|
-
},
|
60
|
-
:contacts => {
|
61
|
-
:get => true,
|
62
|
-
:number => :multiple, :link => true, :includable => true
|
63
|
-
},
|
64
|
-
:current_scheduled_maintenances => {
|
65
|
-
:get => true,
|
66
|
-
:number => :multiple, :link => true, :includable => true
|
67
|
-
},
|
68
|
-
:current_state => {
|
69
|
-
:get => true,
|
70
|
-
:number => :singular, :link => true, :includable => true
|
71
|
-
},
|
72
|
-
:current_unscheduled_maintenance => {
|
73
|
-
:get => true,
|
74
|
-
:number => :singular, :link => true, :includable => true
|
75
|
-
},
|
76
|
-
:latest_notifications => {
|
77
|
-
:get => true,
|
78
|
-
:number => :multiple, :link => true, :includable => true
|
79
|
-
},
|
80
|
-
:scheduled_maintenances => {
|
81
|
-
:get => true,
|
82
|
-
:number => :multiple, :link => true, :includable => false
|
83
|
-
},
|
84
|
-
:states => {
|
85
|
-
:get => true,
|
86
|
-
:number => :multiple, :link => true, :includable => false
|
87
|
-
},
|
88
|
-
:tags => {
|
89
|
-
:post => true, :get => true, :patch => true, :delete => true,
|
90
|
-
:number => :multiple, :link => true, :includable => true
|
91
|
-
},
|
92
|
-
:unscheduled_maintenances => {
|
93
|
-
:get => true,
|
94
|
-
:number => :multiple, :link => true, :includable => false
|
95
|
-
}
|
96
|
-
},
|
97
|
-
:contacts => {
|
98
|
-
:acceptors => {
|
99
|
-
:get => true,
|
100
|
-
:number => :multiple, :link => true, :includable => true
|
101
|
-
},
|
102
|
-
:checks => {
|
103
|
-
:get => true,
|
104
|
-
:number => :multiple, :link => true, :includable => true
|
105
|
-
},
|
106
|
-
:media => {
|
107
|
-
:get => true,
|
108
|
-
:number => :multiple, :link => true, :includable => true
|
109
|
-
},
|
110
|
-
:rejectors => {
|
111
|
-
:get => :true,
|
112
|
-
:number => :multiple, :link => true, :includable => true
|
113
|
-
}
|
114
|
-
},
|
115
|
-
:media => {
|
116
|
-
:acceptors => {
|
117
|
-
:post => true, :get => true, :patch => true, :delete => true,
|
118
|
-
:number => :multiple, :link => true, :includable => true
|
119
|
-
},
|
120
|
-
:alerting_checks => {
|
121
|
-
:get => true,
|
122
|
-
:number => :multiple, :link => true, :includable => true
|
123
|
-
},
|
124
|
-
:contact => {
|
125
|
-
:post => true, :get => true,
|
126
|
-
:number => :singular, :link => true, :includable => true
|
127
|
-
},
|
128
|
-
:rejectors => {
|
129
|
-
:post => true, :get => true, :patch => true, :delete => true,
|
130
|
-
:number => :multiple, :link => true, :includable => true
|
131
|
-
}
|
132
|
-
},
|
133
|
-
:rejectors => {
|
134
|
-
:contact => {
|
135
|
-
:post => true, :get => true,
|
136
|
-
:number => :singular, :link => true, :includable => true
|
137
|
-
},
|
138
|
-
:media => {
|
139
|
-
:post => true, :get => true, :patch => true, :delete => true,
|
140
|
-
:number => :multiple, :link => true, :includable => true
|
141
|
-
},
|
142
|
-
:tags => {
|
143
|
-
:post => true, :get => true, :patch => true, :delete => true,
|
144
|
-
:number => :multiple, :link => true, :includable => true
|
145
|
-
}
|
146
|
-
},
|
147
|
-
:scheduled_maintenances => {
|
148
|
-
:check => {
|
149
|
-
:post => true, :get => true,
|
150
|
-
:number => :singular, :link => true, :includable => true
|
151
|
-
},
|
152
|
-
:tag => {
|
153
|
-
:post => true,
|
154
|
-
:number => :singular, :link => false, :includable => false
|
155
|
-
}
|
156
|
-
},
|
157
|
-
:states => {
|
158
|
-
:check => {
|
159
|
-
:get => true,
|
160
|
-
:number => :singular, :link => true, :includable => true
|
161
|
-
}
|
162
|
-
},
|
163
|
-
:tags => {
|
164
|
-
:acceptors => {
|
165
|
-
:post => true, :get => true, :patch => true, :delete => true,
|
166
|
-
:number => :multiple, :link => true, :includable => true
|
167
|
-
},
|
168
|
-
:checks => {
|
169
|
-
:post => true, :get => true, :patch => true, :delete => true,
|
170
|
-
:number => :multiple, :link => true, :includable => true
|
171
|
-
},
|
172
|
-
:rejectors => {
|
173
|
-
:post => true, :get => true, :patch => true, :delete => true,
|
174
|
-
:number => :multiple, :link => true, :includable => true
|
175
|
-
},
|
176
|
-
:scheduled_maintenances => {
|
177
|
-
:get => true,
|
178
|
-
:number => :multiple, :link => true, :includable => false
|
179
|
-
},
|
180
|
-
:states => {
|
181
|
-
:get => true,
|
182
|
-
:number => :multiple, :link => true, :includable => false
|
183
|
-
},
|
184
|
-
:unscheduled_maintenances => {
|
185
|
-
:get => true,
|
186
|
-
:number => :multiple, :link => true, :includable => false
|
187
|
-
}
|
188
|
-
},
|
189
|
-
:test_notifications => {
|
190
|
-
:check => {
|
191
|
-
:post => true,
|
192
|
-
:number => :singular, :link => false, :includable => false
|
193
|
-
},
|
194
|
-
:tag => {
|
195
|
-
:post => true,
|
196
|
-
:number => :singular, :link => false, :includable => false
|
197
|
-
}
|
198
|
-
},
|
199
|
-
:unscheduled_maintenances => {
|
200
|
-
:check => {
|
201
|
-
:get => true,
|
202
|
-
:number => :singular, :link => false, :includable => true
|
203
|
-
}
|
204
|
-
}
|
205
|
-
}
|
206
|
-
|
207
|
-
ASSOCIATIONS.each_pair do |resource, mappings|
|
208
|
-
res = TYPES[resource]
|
209
|
-
resource_id_validator = :tags.eql?(resource) ? :string : :uuid
|
210
|
-
|
211
|
-
# NB: no remaining non-GET singular link methods, so these are commented out for now
|
212
|
-
|
213
|
-
# mappings.select {|n, a| a[:post] && a[:link] && :singular.eql?(a[:number]) }.each do |linked, assoc|
|
214
|
-
|
215
|
-
# linked_id_validator = :tag.eql?(linked) ? :singular_link : :singular_link_uuid
|
216
|
-
|
217
|
-
# define_method("create_#{res}_link_#{linked}") do |resource_id, linked_id|
|
218
|
-
# validate_params(:resource_id => resource_id, :linked_id => linked_id) do
|
219
|
-
# validate :query => :resource_id, :as => resource_id_validator
|
220
|
-
# validate :query => :linked_id, :as => linked_id_validator
|
221
|
-
# end
|
222
|
-
# perform_post_links(linked,
|
223
|
-
# "/#{resource}/#{resource_id}/relationships/#{linked}", linked_id)
|
224
|
-
# end
|
225
|
-
# end
|
226
|
-
|
227
|
-
mappings.select {|n, a| a[:post] && a[:link] && :multiple.eql?(a[:number]) }.each do |linked, assoc|
|
228
|
-
type = TYPES[linked] || linked
|
229
|
-
linked_ids_validator = :tags.eql?(linked) ? :multiple_link : :multiple_link_uuid
|
230
|
-
|
231
|
-
define_method("create_#{res}_link_#{linked}") do |resource_id, *linked_ids|
|
232
|
-
validate_params(:resource_id => resource_id, :linked_ids => linked_ids) do
|
233
|
-
validate :query => :resource_id, :as => resource_id_validator
|
234
|
-
validate :query => :linked_ids, :as => linked_ids_validator
|
235
|
-
end
|
236
|
-
perform_post_links(type,
|
237
|
-
"/#{resource}/#{resource_id}/relationships/#{linked}", *linked_ids)
|
238
|
-
end
|
239
|
-
end
|
240
|
-
|
241
|
-
mappings.select {|n, a| a[:get] && a[:link] }.each do |linked, assoc|
|
242
|
-
define_method("#{res}_link_#{linked}") do |resource_id, opts = {}|
|
243
|
-
validate_params(:resource_id => resource_id) do
|
244
|
-
validate :query => :resource_id, :as => resource_id_validator
|
245
|
-
end
|
246
|
-
validate_params(opts) do
|
247
|
-
validate :query => [:fields, :sort, :include], :as => :string_or_array_of_strings
|
248
|
-
validate :query => :filter, :as => :hash
|
249
|
-
validate :query => [:page, :per_page], :as => :positive_integer
|
250
|
-
end
|
251
|
-
perform_get("/#{resource}/#{resource_id}/#{linked}", [], opts, {:assoc => linked})
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
# mappings.select {|n, a| a[:patch] && a[:link] && :singular.eql?(a[:number]) }.each do |linked, assoc|
|
256
|
-
# linked_id_validator = :tag.eql?(linked) ? :singular_link : :singular_link_uuid
|
257
|
-
|
258
|
-
# define_method("update_#{res}_link_#{linked}") do |resource_id, linked_id|
|
259
|
-
# validate_params(:resource_id => resource_id, :linked_id => linked_id) do
|
260
|
-
# validate :query => :resource_id, :as => resource_id_validator
|
261
|
-
# validate :query => :linked_id, :as => linked_id_validator
|
262
|
-
# end
|
263
|
-
# perform_patch_links(linked,
|
264
|
-
# "/#{resource}/#{resource_id}/relationships/#{linked}", true, linked_id)
|
265
|
-
# end
|
266
|
-
# end
|
267
|
-
|
268
|
-
mappings.select {|n, a| a[:patch] && a[:link] && :multiple.eql?(a[:number]) }.each do |linked, assoc|
|
269
|
-
type = TYPES[linked] || linked
|
270
|
-
linked_ids_validator = :tags.eql?(linked) ? :multiple_link : :multiple_link_uuid
|
271
|
-
|
272
|
-
define_method("update_#{res}_link_#{linked}") do |resource_id, *linked_ids|
|
273
|
-
validate_params(:resource_id => resource_id, :linked_ids => linked_ids) do
|
274
|
-
validate :query => :resource_id, :as => resource_id_validator
|
275
|
-
validate :query => :linked_id, :as => linked_ids_validator
|
276
|
-
end
|
277
|
-
perform_patch_links(type,
|
278
|
-
"/#{resource}/#{resource_id}/relationships/#{linked}", false, *linked_ids)
|
279
|
-
end
|
280
|
-
end
|
281
|
-
|
282
|
-
# mappings.select {|n, a| a[:delete] && a[:link] && :singular.eql?(a[:number]) }.each do |linked, assoc|
|
283
|
-
# linked_id_validator = :tag.eql?(linked) ? :singular_link : :singular_link_uuid
|
284
|
-
|
285
|
-
# define_method("delete_#{res}_link_#{linked}") do |resource_id, linked_id|
|
286
|
-
# validate_params(:resource_id => resource_id, :linked_id => linked_id) do
|
287
|
-
# validate :query => :resource_id, :as => resource_id_validator
|
288
|
-
# validate :query => :linked_id, :as => linked_id_validator
|
289
|
-
# end
|
290
|
-
# perform_delete_links(linked,
|
291
|
-
# "/#{resource}/#{resource_id}/relationships/#{linked}", linked_id)
|
292
|
-
# end
|
293
|
-
# end
|
294
|
-
|
295
|
-
mappings.select {|n, a| a[:delete] && a[:link] && :multiple.eql?(a[:number]) }.each do |linked, assoc|
|
296
|
-
type = TYPES[linked] || linked
|
297
|
-
linked_ids_validator = :tags.eql?(linked) ? :string_or_array_of_strings : :uuid_or_array_of_uuids
|
298
|
-
|
299
|
-
define_method("delete_#{res}_link_#{linked}") do |resource_id, *linked_ids|
|
300
|
-
validate_params(:resource_id => resource_id, :linked_ids => linked_ids) do
|
301
|
-
validate :query => :resource_id, :as => resource_id_validator
|
302
|
-
validate :query => :linked_ids, :as => linked_ids_validator
|
303
|
-
end
|
304
|
-
perform_delete_links(type,
|
305
|
-
"/#{resource}/#{resource_id}/relationships/#{linked}", *linked_ids)
|
306
|
-
end
|
307
|
-
end
|
308
|
-
end
|
309
|
-
|
310
|
-
end
|
311
|
-
|
312
|
-
end
|
313
|
-
end
|
314
|
-
end
|