stacker_bee 2.0.0 → 2.1.0.pre180

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +13 -5
  2. data/.travis.yml +13 -1
  3. data/README.md +134 -64
  4. data/bin/stacker_bee +4 -3
  5. data/config.default.yml +1 -1
  6. data/lib/stacker_bee/api.rb +2 -3
  7. data/lib/stacker_bee/client.rb +101 -19
  8. data/lib/stacker_bee/connection.rb +31 -16
  9. data/lib/stacker_bee/{middleware → http_middleware}/detokenizer.rb +3 -2
  10. data/lib/stacker_bee/http_middleware/graylog.rb +14 -0
  11. data/lib/stacker_bee/{middleware → http_middleware}/signed_query.rb +1 -1
  12. data/lib/stacker_bee/middleware/adapter.rb +16 -0
  13. data/lib/stacker_bee/middleware/base.rb +33 -0
  14. data/lib/stacker_bee/middleware/clean_response.rb +42 -0
  15. data/lib/stacker_bee/middleware/cloud_stack_api.rb +17 -0
  16. data/lib/stacker_bee/middleware/console_access.rb +38 -0
  17. data/lib/stacker_bee/middleware/de_namespace.rb +15 -0
  18. data/lib/stacker_bee/middleware/dictionary_flattener.rb +44 -0
  19. data/lib/stacker_bee/middleware/endpoint_normalizer.rb +23 -0
  20. data/lib/stacker_bee/middleware/environment.rb +23 -0
  21. data/lib/stacker_bee/middleware/format_keys.rb +13 -0
  22. data/lib/stacker_bee/middleware/format_values.rb +13 -0
  23. data/lib/stacker_bee/middleware/http_status.rb +14 -0
  24. data/lib/stacker_bee/middleware/json_body.rb +14 -0
  25. data/lib/stacker_bee/middleware/raise_on_http_error.rb +11 -0
  26. data/lib/stacker_bee/middleware/rashify_response.rb +21 -0
  27. data/lib/stacker_bee/middleware/remove_empty_strings.rb +11 -0
  28. data/lib/stacker_bee/middleware/remove_nils.rb +9 -0
  29. data/lib/stacker_bee/request_error.rb +8 -16
  30. data/lib/stacker_bee/utilities.rb +30 -0
  31. data/lib/stacker_bee/version.rb +1 -1
  32. data/lib/stacker_bee.rb +1 -1
  33. data/spec/cassettes/A_request_sent_to_CloudStack_for_console_access/returns_html_for_console_access.yml +33 -0
  34. data/spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/{a_request_parameter_with_a_Map → a_request_parameter_with_a_map}/can_create_an_object.yml +0 -0
  35. data/spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/a_request_that_triggers_an_error/properly_signs_the_request.yml +35 -0
  36. data/spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/middleware/a_middleware_that_doesn_t_match_the_content_type/uses_the_middleware.yml +33 -0
  37. data/spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/middleware/a_middleware_that_matches_the_content_type/uses_the_middleware.yml +33 -0
  38. data/spec/integration/check_spec.rb +48 -0
  39. data/spec/integration/configure_middleware_spec.rb +54 -16
  40. data/spec/integration/console_spec.rb +21 -0
  41. data/spec/integration/request_spec.rb +57 -2
  42. data/spec/spec_helper.rb +11 -1
  43. data/spec/units/faraday_graylog_middleware_spec.rb +1 -1
  44. data/spec/units/stacker_bee/client_spec.rb +47 -78
  45. data/spec/units/stacker_bee/connection_spec.rb +34 -11
  46. data/spec/units/stacker_bee/console_spec.rb +0 -0
  47. data/spec/units/stacker_bee/{graylog_faraday_middleware_spec.rb → http_middleware/graylog_spec.rb} +18 -2
  48. data/spec/units/stacker_bee/middleware/adapter_spec.rb +54 -0
  49. data/spec/units/stacker_bee/middleware/base_spec.rb +128 -0
  50. data/spec/units/stacker_bee/middleware/cloudstack_api_spec.rb +37 -0
  51. data/spec/units/stacker_bee/middleware/console_access_spec.rb +59 -0
  52. data/spec/units/stacker_bee/{dictionary_flattener_spec.rb → middleware/dictionary_flattener_spec.rb} +7 -7
  53. data/spec/units/stacker_bee/middleware/endpoint_normalizer_spec.rb +36 -0
  54. data/spec/units/stacker_bee/middleware/format_keys_spec.rb +18 -0
  55. data/spec/units/stacker_bee/middleware/format_values_spec.rb +15 -0
  56. data/spec/units/stacker_bee/middleware/http_status_spec.rb +34 -0
  57. data/spec/units/stacker_bee/middleware/raise_on_http_errors_spec.rb +5 -0
  58. data/spec/units/stacker_bee/middleware/remove_empty_strings_spec.rb +54 -0
  59. data/spec/units/stacker_bee/middleware/remove_nils_spec.rb +8 -0
  60. data/spec/units/stacker_bee/request_error_spec.rb +25 -37
  61. data/spec/units/stacker_bee/utilities_spec.rb +26 -0
  62. data/stacker_bee.gemspec +6 -2
  63. metadata +84 -38
  64. data/lib/stacker_bee/body_parser.rb +0 -23
  65. data/lib/stacker_bee/dictionary_flattener.rb +0 -41
  66. data/lib/stacker_bee/graylog_faraday_middleware.rb +0 -12
  67. data/lib/stacker_bee/middleware/logger.rb +0 -47
  68. data/lib/stacker_bee/request.rb +0 -46
  69. data/lib/stacker_bee/response.rb +0 -29
  70. data/spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/a_request_parameter_with_a_Map/object.yml +0 -153
  71. data/spec/units/stacker_bee/middleware/logger_spec.rb +0 -55
  72. data/spec/units/stacker_bee/request_spec.rb +0 -51
  73. data/spec/units/stacker_bee/response_spec.rb +0 -79
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stacker_bee
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0.pre180
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Sterndale
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-16 00:00:00.000000000 Z
12
+ date: 2014-04-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -18,6 +18,9 @@ dependencies:
18
18
  - - ~>
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0.8'
21
+ - - <
22
+ - !ruby/object:Gem::Version
23
+ version: '0.9'
21
24
  type: :runtime
22
25
  prerelease: false
23
26
  version_requirements: !ruby/object:Gem::Requirement
@@ -25,34 +28,37 @@ dependencies:
25
28
  - - ~>
26
29
  - !ruby/object:Gem::Version
27
30
  version: '0.8'
31
+ - - <
32
+ - !ruby/object:Gem::Version
33
+ version: '0.9'
28
34
  - !ruby/object:Gem::Dependency
29
- name: faraday_middleware
35
+ name: multi_json
30
36
  requirement: !ruby/object:Gem::Requirement
31
37
  requirements:
32
38
  - - ~>
33
39
  - !ruby/object:Gem::Version
34
- version: '0.9'
40
+ version: '1.8'
35
41
  type: :runtime
36
42
  prerelease: false
37
43
  version_requirements: !ruby/object:Gem::Requirement
38
44
  requirements:
39
45
  - - ~>
40
46
  - !ruby/object:Gem::Version
41
- version: '0.9'
47
+ version: '1.8'
42
48
  - !ruby/object:Gem::Dependency
43
- name: multi_json
49
+ name: faraday_middleware
44
50
  requirement: !ruby/object:Gem::Requirement
45
51
  requirements:
46
52
  - - ~>
47
53
  - !ruby/object:Gem::Version
48
- version: '1.8'
54
+ version: '0.9'
49
55
  type: :runtime
50
56
  prerelease: false
51
57
  version_requirements: !ruby/object:Gem::Requirement
52
58
  requirements:
53
59
  - - ~>
54
60
  - !ruby/object:Gem::Version
55
- version: '1.8'
61
+ version: '0.9'
56
62
  - !ruby/object:Gem::Dependency
57
63
  name: bundler
58
64
  requirement: !ruby/object:Gem::Requirement
@@ -127,28 +133,28 @@ dependencies:
127
133
  name: rubocop
128
134
  requirement: !ruby/object:Gem::Requirement
129
135
  requirements:
130
- - - '>='
136
+ - - ! '>='
131
137
  - !ruby/object:Gem::Version
132
138
  version: '0'
133
139
  type: :development
134
140
  prerelease: false
135
141
  version_requirements: !ruby/object:Gem::Requirement
136
142
  requirements:
137
- - - '>='
143
+ - - ! '>='
138
144
  - !ruby/object:Gem::Version
139
145
  version: '0'
140
146
  - !ruby/object:Gem::Dependency
141
147
  name: pry
142
148
  requirement: !ruby/object:Gem::Requirement
143
149
  requirements:
144
- - - '>='
150
+ - - ! '>='
145
151
  - !ruby/object:Gem::Version
146
152
  version: '0'
147
153
  type: :development
148
154
  prerelease: false
149
155
  version_requirements: !ruby/object:Gem::Requirement
150
156
  requirements:
151
- - - '>='
157
+ - - ! '>='
152
158
  - !ruby/object:Gem::Version
153
159
  version: '0'
154
160
  description: Ruby CloudStack client and CLI
@@ -173,39 +179,56 @@ files:
173
179
  - lib/faraday_middleware/response/graylog.rb
174
180
  - lib/stacker_bee.rb
175
181
  - lib/stacker_bee/api.rb
176
- - lib/stacker_bee/body_parser.rb
177
182
  - lib/stacker_bee/client.rb
178
183
  - lib/stacker_bee/configuration.rb
179
184
  - lib/stacker_bee/connection.rb
180
- - lib/stacker_bee/dictionary_flattener.rb
181
- - lib/stacker_bee/graylog_faraday_middleware.rb
182
- - lib/stacker_bee/middleware/detokenizer.rb
183
- - lib/stacker_bee/middleware/logger.rb
184
- - lib/stacker_bee/middleware/signed_query.rb
185
+ - lib/stacker_bee/http_middleware/detokenizer.rb
186
+ - lib/stacker_bee/http_middleware/graylog.rb
187
+ - lib/stacker_bee/http_middleware/signed_query.rb
188
+ - lib/stacker_bee/middleware/adapter.rb
189
+ - lib/stacker_bee/middleware/base.rb
190
+ - lib/stacker_bee/middleware/clean_response.rb
191
+ - lib/stacker_bee/middleware/cloud_stack_api.rb
192
+ - lib/stacker_bee/middleware/console_access.rb
193
+ - lib/stacker_bee/middleware/de_namespace.rb
194
+ - lib/stacker_bee/middleware/dictionary_flattener.rb
195
+ - lib/stacker_bee/middleware/endpoint_normalizer.rb
196
+ - lib/stacker_bee/middleware/environment.rb
197
+ - lib/stacker_bee/middleware/format_keys.rb
198
+ - lib/stacker_bee/middleware/format_values.rb
199
+ - lib/stacker_bee/middleware/http_status.rb
200
+ - lib/stacker_bee/middleware/json_body.rb
201
+ - lib/stacker_bee/middleware/raise_on_http_error.rb
202
+ - lib/stacker_bee/middleware/rashify_response.rb
203
+ - lib/stacker_bee/middleware/remove_empty_strings.rb
204
+ - lib/stacker_bee/middleware/remove_nils.rb
185
205
  - lib/stacker_bee/rash.rb
186
- - lib/stacker_bee/request.rb
187
206
  - lib/stacker_bee/request_error.rb
188
- - lib/stacker_bee/response.rb
189
207
  - lib/stacker_bee/utilities.rb
190
208
  - lib/stacker_bee/version.rb
209
+ - spec/cassettes/A_request_sent_to_CloudStack_for_console_access/returns_html_for_console_access.yml
191
210
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/.yml
192
211
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/a_nil_request_parameter/properly_executes_the_request.yml
193
- - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/a_request_parameter_with_a_Map/can_create_an_object.yml
194
- - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/a_request_parameter_with_a_Map/object.yml
212
+ - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/a_request_parameter_with_a_map/can_create_an_object.yml
195
213
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/a_request_parameter_with_an_Array/.yml
196
214
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/a_request_parameter_with_and_empty_string/properly_executes_the_request.yml
215
+ - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/a_request_that_triggers_an_error/properly_signs_the_request.yml
197
216
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/containing_an_error/.yml
198
217
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/containing_an_error/should_log_response_as_error.yml
199
218
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/first/.yml
200
219
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/first_item/.yml
201
220
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/first_item/_account_type_/.yml
202
221
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/first_item/_accounttype_/.yml
222
+ - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/middleware/a_middleware_that_doesn_t_match_the_content_type/uses_the_middleware.yml
223
+ - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/middleware/a_middleware_that_matches_the_content_type/uses_the_middleware.yml
203
224
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/should_log_request.yml
204
225
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/should_not_log_response_as_error.yml
205
226
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/space_character_in_a_request_parameter/properly_signs_the_request.yml
206
227
  - spec/fixtures/4.2.json
207
228
  - spec/fixtures/simple.json
229
+ - spec/integration/check_spec.rb
208
230
  - spec/integration/configure_middleware_spec.rb
231
+ - spec/integration/console_spec.rb
209
232
  - spec/integration/request_spec.rb
210
233
  - spec/spec_helper.rb
211
234
  - spec/units/faraday_graylog_middleware_spec.rb
@@ -213,13 +236,22 @@ files:
213
236
  - spec/units/stacker_bee/client_spec.rb
214
237
  - spec/units/stacker_bee/configuration_spec.rb
215
238
  - spec/units/stacker_bee/connection_spec.rb
216
- - spec/units/stacker_bee/dictionary_flattener_spec.rb
217
- - spec/units/stacker_bee/graylog_faraday_middleware_spec.rb
218
- - spec/units/stacker_bee/middleware/logger_spec.rb
239
+ - spec/units/stacker_bee/console_spec.rb
240
+ - spec/units/stacker_bee/http_middleware/graylog_spec.rb
241
+ - spec/units/stacker_bee/middleware/adapter_spec.rb
242
+ - spec/units/stacker_bee/middleware/base_spec.rb
243
+ - spec/units/stacker_bee/middleware/cloudstack_api_spec.rb
244
+ - spec/units/stacker_bee/middleware/console_access_spec.rb
245
+ - spec/units/stacker_bee/middleware/dictionary_flattener_spec.rb
246
+ - spec/units/stacker_bee/middleware/endpoint_normalizer_spec.rb
247
+ - spec/units/stacker_bee/middleware/format_keys_spec.rb
248
+ - spec/units/stacker_bee/middleware/format_values_spec.rb
249
+ - spec/units/stacker_bee/middleware/http_status_spec.rb
250
+ - spec/units/stacker_bee/middleware/raise_on_http_errors_spec.rb
251
+ - spec/units/stacker_bee/middleware/remove_empty_strings_spec.rb
252
+ - spec/units/stacker_bee/middleware/remove_nils_spec.rb
219
253
  - spec/units/stacker_bee/rash_spec.rb
220
254
  - spec/units/stacker_bee/request_error_spec.rb
221
- - spec/units/stacker_bee/request_spec.rb
222
- - spec/units/stacker_bee/response_spec.rb
223
255
  - spec/units/stacker_bee/utilities_spec.rb
224
256
  - spec/units/stacker_bee_spec.rb
225
257
  - stacker_bee.gemspec
@@ -233,39 +265,44 @@ require_paths:
233
265
  - lib
234
266
  required_ruby_version: !ruby/object:Gem::Requirement
235
267
  requirements:
236
- - - '>='
268
+ - - ! '>='
237
269
  - !ruby/object:Gem::Version
238
270
  version: '0'
239
271
  required_rubygems_version: !ruby/object:Gem::Requirement
240
272
  requirements:
241
- - - '>='
273
+ - - ! '>'
242
274
  - !ruby/object:Gem::Version
243
- version: '0'
275
+ version: 1.3.1
244
276
  requirements: []
245
277
  rubyforge_project:
246
- rubygems_version: 2.2.1
278
+ rubygems_version: 2.2.2
247
279
  signing_key:
248
280
  specification_version: 4
249
281
  summary: Ruby CloudStack client
250
282
  test_files:
283
+ - spec/cassettes/A_request_sent_to_CloudStack_for_console_access/returns_html_for_console_access.yml
251
284
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/.yml
252
285
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/a_nil_request_parameter/properly_executes_the_request.yml
253
- - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/a_request_parameter_with_a_Map/can_create_an_object.yml
254
- - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/a_request_parameter_with_a_Map/object.yml
286
+ - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/a_request_parameter_with_a_map/can_create_an_object.yml
255
287
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/a_request_parameter_with_an_Array/.yml
256
288
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/a_request_parameter_with_and_empty_string/properly_executes_the_request.yml
289
+ - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/a_request_that_triggers_an_error/properly_signs_the_request.yml
257
290
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/containing_an_error/.yml
258
291
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/containing_an_error/should_log_response_as_error.yml
259
292
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/first/.yml
260
293
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/first_item/.yml
261
294
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/first_item/_account_type_/.yml
262
295
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/first_item/_accounttype_/.yml
296
+ - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/middleware/a_middleware_that_doesn_t_match_the_content_type/uses_the_middleware.yml
297
+ - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/middleware/a_middleware_that_matches_the_content_type/uses_the_middleware.yml
263
298
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/should_log_request.yml
264
299
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/should_not_log_response_as_error.yml
265
300
  - spec/cassettes/A_response_to_a_request_sent_to_the_CloudStack_API/space_character_in_a_request_parameter/properly_signs_the_request.yml
266
301
  - spec/fixtures/4.2.json
267
302
  - spec/fixtures/simple.json
303
+ - spec/integration/check_spec.rb
268
304
  - spec/integration/configure_middleware_spec.rb
305
+ - spec/integration/console_spec.rb
269
306
  - spec/integration/request_spec.rb
270
307
  - spec/spec_helper.rb
271
308
  - spec/units/faraday_graylog_middleware_spec.rb
@@ -273,12 +310,21 @@ test_files:
273
310
  - spec/units/stacker_bee/client_spec.rb
274
311
  - spec/units/stacker_bee/configuration_spec.rb
275
312
  - spec/units/stacker_bee/connection_spec.rb
276
- - spec/units/stacker_bee/dictionary_flattener_spec.rb
277
- - spec/units/stacker_bee/graylog_faraday_middleware_spec.rb
278
- - spec/units/stacker_bee/middleware/logger_spec.rb
313
+ - spec/units/stacker_bee/console_spec.rb
314
+ - spec/units/stacker_bee/http_middleware/graylog_spec.rb
315
+ - spec/units/stacker_bee/middleware/adapter_spec.rb
316
+ - spec/units/stacker_bee/middleware/base_spec.rb
317
+ - spec/units/stacker_bee/middleware/cloudstack_api_spec.rb
318
+ - spec/units/stacker_bee/middleware/console_access_spec.rb
319
+ - spec/units/stacker_bee/middleware/dictionary_flattener_spec.rb
320
+ - spec/units/stacker_bee/middleware/endpoint_normalizer_spec.rb
321
+ - spec/units/stacker_bee/middleware/format_keys_spec.rb
322
+ - spec/units/stacker_bee/middleware/format_values_spec.rb
323
+ - spec/units/stacker_bee/middleware/http_status_spec.rb
324
+ - spec/units/stacker_bee/middleware/raise_on_http_errors_spec.rb
325
+ - spec/units/stacker_bee/middleware/remove_empty_strings_spec.rb
326
+ - spec/units/stacker_bee/middleware/remove_nils_spec.rb
279
327
  - spec/units/stacker_bee/rash_spec.rb
280
328
  - spec/units/stacker_bee/request_error_spec.rb
281
- - spec/units/stacker_bee/request_spec.rb
282
- - spec/units/stacker_bee/response_spec.rb
283
329
  - spec/units/stacker_bee/utilities_spec.rb
284
330
  - spec/units/stacker_bee_spec.rb
@@ -1,23 +0,0 @@
1
- require "multi_json"
2
- require "stacker_bee/rash"
3
-
4
- module StackerBee
5
- module BodyParser
6
- attr_reader :body
7
-
8
- def body=(raw_response)
9
- @body = parse(raw_response.body)
10
- end
11
-
12
- def parse(json)
13
- parsed = MultiJson.load(json)
14
- fail "Cannot determine response key in #{parsed.keys}" if parsed.size > 1
15
- case value = parsed.values.first
16
- when Hash then Rash.new(value)
17
- when Array then value.map { |item| Rash.new(item) }
18
- else
19
- value
20
- end
21
- end
22
- end
23
- end
@@ -1,41 +0,0 @@
1
- module StackerBee
2
- class DictionaryFlattener
3
- LB = "SBLEFTBRACKET"
4
- RB = "SBRIGHTBRACKET"
5
-
6
- attr_accessor :params
7
-
8
- def self.tokenize(key)
9
- key.gsub(/\[/, LB).gsub(/\]/, RB)
10
- end
11
-
12
- def self.detokenize(key)
13
- key.gsub(/#{LB}/, "[").gsub(/#{RB}/, "]")
14
- end
15
-
16
- def initialize(params)
17
- @params = params.dup
18
- flatten_params
19
- end
20
-
21
- def flatten_params
22
- hashes = params.select { |key, val| val.respond_to? :keys }
23
- flatten_map_values(params, hashes)
24
- end
25
-
26
- def flatten_map_values(params, hashes)
27
- hashes.each do |outer|
28
- remove_empties(outer[1]).each_with_index do |array, index|
29
- key = self.class.tokenize("#{outer[0]}[#{index}]")
30
- params["#{key}.key"] = params["#{key}.name"] = array[0]
31
- params["#{key}.value"] = array[1]
32
- end
33
- params.delete outer[0]
34
- end
35
- end
36
-
37
- def remove_empties(hash)
38
- hash.reject { |k, v| v.nil? || v == "" }
39
- end
40
- end
41
- end
@@ -1,12 +0,0 @@
1
- module StackerBee
2
- class GraylogFaradayMiddleware < FaradayMiddleware::Graylog
3
- def facility
4
- 'stacker-bee'
5
- end
6
-
7
- def short_message(env)
8
- message = env[:url].query.match(/&command=([^&]*)/)[1]
9
- "StackerBee #{message}"
10
- end
11
- end
12
- end
@@ -1,47 +0,0 @@
1
- require "forwardable"
2
- require "logger"
3
- require "pp"
4
-
5
- module StackerBee
6
- module Middleware
7
- class Logger < Faraday::Response::Middleware
8
- extend Forwardable
9
- PROGNAME = "StackerBee"
10
-
11
- attr_accessor :logger
12
-
13
- def initialize(app, _logger = nil)
14
- super(app)
15
- self.logger = _logger
16
- logger.progname ||= PROGNAME if logger.respond_to?(:progname=)
17
- end
18
-
19
- def logger
20
- @logger ||= ::Logger.new($stdout)
21
- end
22
-
23
- def_delegators :logger, :debug, :info, :warn, :error, :fatal
24
-
25
- def call(env)
26
- log_request(env)
27
- super
28
- end
29
-
30
- def on_complete(env)
31
- log_response(env)
32
- end
33
-
34
- def log_request(env)
35
- info "#{env[:method]} #{env[:url]}"
36
- debug env[:request_headers].pretty_inspect
37
- end
38
-
39
- def log_response(env)
40
- status_message = "Status: #{env[:status]}"
41
- env[:status] < 400 ? info(status_message) : error(status_message)
42
- debug env[:response_headers].pretty_inspect
43
- debug env[:body]
44
- end
45
- end
46
- end
47
- end
@@ -1,46 +0,0 @@
1
- require "stacker_bee/utilities"
2
-
3
- module StackerBee
4
- class Request
5
- include Utilities
6
-
7
- RESPONSE_TYPE = "json"
8
-
9
- attr_writer :allow_empty_string_params
10
- attr_accessor :endpoint, :api_key
11
-
12
- def initialize(endpoint, api_key, params = {})
13
- @params = params
14
- self.endpoint = endpoint
15
- self.api_key = api_key
16
- end
17
-
18
- def query_params
19
- flat_params = DictionaryFlattener.new(@params).params
20
-
21
- flat_params[:api_key] = api_key
22
- flat_params[:command] = endpoint
23
- flat_params[:response] = RESPONSE_TYPE
24
-
25
- flat_params
26
- .reject { |key, val| val.nil? }
27
- .reject { |key, val| !allow_empty_string_params && val == '' }
28
- .sort_by { |key, val| key.to_s }
29
- .map { |(key, val)| [cloud_stack_key(key), cloud_stack_value(val)] }
30
- end
31
-
32
- def allow_empty_string_params
33
- @allow_empty_string_params ||= false
34
- end
35
-
36
- private
37
-
38
- def cloud_stack_key(key)
39
- camel_case(key, true)
40
- end
41
-
42
- def cloud_stack_value(value)
43
- value.respond_to?(:join) ? value.join(',') : value
44
- end
45
- end
46
- end
@@ -1,29 +0,0 @@
1
- require "stacker_bee/body_parser"
2
- require "stacker_bee/request_error"
3
- require "delegate"
4
-
5
- module StackerBee
6
- class Response < SimpleDelegator
7
- include BodyParser
8
-
9
- def initialize(raw_response)
10
- fail RequestError.for(raw_response) unless raw_response.success?
11
- self.body = raw_response
12
- super body
13
- end
14
-
15
- protected
16
-
17
- def parse(json)
18
- parsed = super(json)
19
- return parsed unless parsed.respond_to? :keys
20
- if parsed.size == 2 && parsed.key?("count")
21
- parsed.reject { |key, val| key == "count" }.values.first
22
- elsif parsed.size == 1 && parsed.values.first.respond_to?(:keys)
23
- parsed.values.first
24
- else
25
- parsed
26
- end
27
- end
28
- end
29
- end
@@ -1,153 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: get
5
- uri: <CLOUD_STACK_URL>?apiKey=<CLOUD_STACK_API_KEY>&command=listZones&response=json&signature=/MnHgTBKGc%2BXx0Z8KwMllvw92vg=
6
- body:
7
- encoding: US-ASCII
8
- string: ''
9
- headers:
10
- User-Agent:
11
- - Faraday v0.8.8
12
- Accept-Encoding:
13
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
14
- Accept:
15
- - ! '*/*'
16
- response:
17
- status:
18
- code: 200
19
- message: OK
20
- headers:
21
- Content-Type:
22
- - text/javascript; charset=UTF-8
23
- Content-Length:
24
- - '403'
25
- Server:
26
- - Jetty(6.1.26)
27
- body:
28
- encoding: US-ASCII
29
- string: ! '{ "listzonesresponse" : { "count":1 ,"zone" : [ {"id":"39e9e31e-925c-4b55-8d33-f99912b73dfc","name":"Sandbox-simulator","dns1":"10.147.28.6","internaldns1":"10.147.28.6","guestcidraddress":"10.1.1.0/24","networktype":"Advanced","securitygroupsenabled":false,"allocationstate":"Enabled","zonetoken":"ea3acbc4-cae8-3b82-b42f-7492ddfede00","dhcpprovider":"VirtualRouter","localstorageenabled":false}
30
- ] } }'
31
- http_version:
32
- recorded_at: Wed, 18 Dec 2013 21:25:06 GMT
33
- - request:
34
- method: get
35
- uri: <CLOUD_STACK_URL>?apiKey=<CLOUD_STACK_API_KEY>&command=listNetworkOfferings&response=json&signature=BAdYatJ5Rjcffi6sU8P%2BZtLhSF8=&supportedServices=sourcenat&type=isolated
36
- body:
37
- encoding: US-ASCII
38
- string: ''
39
- headers:
40
- User-Agent:
41
- - Faraday v0.8.8
42
- Accept-Encoding:
43
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
44
- Accept:
45
- - ! '*/*'
46
- response:
47
- status:
48
- code: 200
49
- message: OK
50
- headers:
51
- Content-Type:
52
- - text/javascript; charset=UTF-8
53
- Content-Length:
54
- - '6006'
55
- Server:
56
- - Jetty(6.1.26)
57
- body:
58
- encoding: US-ASCII
59
- string: ! '{ "listnetworkofferingsresponse" : { "count":4 ,"networkoffering"
60
- : [ {"id":"fa126319-f822-4786-9cd3-30bd0c55ca94","name":"DefaultIsolatedNetworkOfferingWithSourceNatService","displaytext":"Offering
61
- for Isolated networks with Source Nat service enabled","traffictype":"Guest","isdefault":true,"specifyvlan":false,"conservemode":true,"specifyipranges":false,"availability":"Required","networkrate":200,"state":"Enabled","guestiptype":"Isolated","serviceofferingid":"983410fa-b51b-439c-b8ba-be973804c38f","service":[{"name":"SourceNat","provider":[{"name":"VirtualRouter"}],"capability":[{"name":"SupportedSourceNatTypes","value":"peraccount","canchooseservicecapability":false},{"name":"RedundantRouter","value":"false","canchooseservicecapability":false}]},{"name":"Dns","provider":[{"name":"VirtualRouter"}]},{"name":"UserData","provider":[{"name":"VirtualRouter"}]},{"name":"PortForwarding","provider":[{"name":"VirtualRouter"}]},{"name":"Firewall","provider":[{"name":"VirtualRouter"}]},{"name":"Lb","provider":[{"name":"VirtualRouter"}],"capability":[{"name":"SupportedLBIsolation","value":"dedicated","canchooseservicecapability":false},{"name":"ElasticLb","value":"false","canchooseservicecapability":false},{"name":"InlineMode","value":"false","canchooseservicecapability":false}]},{"name":"Dhcp","provider":[{"name":"VirtualRouter"}]},{"name":"Vpn","provider":[{"name":"VirtualRouter"}]},{"name":"StaticNat","provider":[{"name":"VirtualRouter"}],"capability":[{"name":"ElasticIp","value":"false","canchooseservicecapability":false},{"name":"AssociatePublicIP","value":"true","canchooseservicecapability":false}]}],"forvpc":false,"ispersistent":false,"egressdefaultpolicy":false},
62
- {"id":"7e70b3b5-5e2c-42cb-9b49-93a87c13a675","name":"DefaultIsolatedNetworkOfferingForVpcNetworks","displaytext":"Offering
63
- for Isolated Vpc networks with Source Nat service enabled","traffictype":"Guest","isdefault":true,"specifyvlan":false,"conservemode":false,"specifyipranges":false,"availability":"Optional","networkrate":200,"state":"Enabled","guestiptype":"Isolated","serviceofferingid":"983410fa-b51b-439c-b8ba-be973804c38f","service":[{"name":"SourceNat","provider":[{"name":"VpcVirtualRouter"}],"capability":[{"name":"SupportedSourceNatTypes","value":"peraccount","canchooseservicecapability":false},{"name":"RedundantRouter","value":"false","canchooseservicecapability":false}]},{"name":"Dns","provider":[{"name":"VpcVirtualRouter"}]},{"name":"UserData","provider":[{"name":"VpcVirtualRouter"}]},{"name":"PortForwarding","provider":[{"name":"VpcVirtualRouter"}]},{"name":"Lb","provider":[{"name":"VpcVirtualRouter"}],"capability":[{"name":"SupportedLBIsolation","value":"dedicated","canchooseservicecapability":false},{"name":"ElasticLb","value":"false","canchooseservicecapability":false},{"name":"InlineMode","value":"false","canchooseservicecapability":false}]},{"name":"Dhcp","provider":[{"name":"VpcVirtualRouter"}]},{"name":"Vpn","provider":[{"name":"VpcVirtualRouter"}]},{"name":"StaticNat","provider":[{"name":"VpcVirtualRouter"}],"capability":[{"name":"ElasticIp","value":"false","canchooseservicecapability":false},{"name":"AssociatePublicIP","value":"true","canchooseservicecapability":false}]},{"name":"NetworkACL","provider":[{"name":"VpcVirtualRouter"}]}],"forvpc":true,"ispersistent":false,"egressdefaultpolicy":false},
64
- {"id":"a9d78d52-f306-44c5-bb6d-c121a507db05","name":"DefaultIsolatedNetworkOfferingForVpcNetworksNoLB","displaytext":"Offering
65
- for Isolated Vpc networks with Source Nat service enabled and LB service Disabled","traffictype":"Guest","isdefault":true,"specifyvlan":false,"conservemode":false,"specifyipranges":false,"availability":"Optional","networkrate":200,"state":"Enabled","guestiptype":"Isolated","serviceofferingid":"983410fa-b51b-439c-b8ba-be973804c38f","service":[{"name":"SourceNat","provider":[{"name":"VpcVirtualRouter"}],"capability":[{"name":"SupportedSourceNatTypes","value":"peraccount","canchooseservicecapability":false},{"name":"RedundantRouter","value":"false","canchooseservicecapability":false}]},{"name":"Dns","provider":[{"name":"VpcVirtualRouter"}]},{"name":"UserData","provider":[{"name":"VpcVirtualRouter"}]},{"name":"PortForwarding","provider":[{"name":"VpcVirtualRouter"}]},{"name":"Dhcp","provider":[{"name":"VpcVirtualRouter"}]},{"name":"Vpn","provider":[{"name":"VpcVirtualRouter"}]},{"name":"StaticNat","provider":[{"name":"VpcVirtualRouter"}],"capability":[{"name":"ElasticIp","value":"false","canchooseservicecapability":false},{"name":"AssociatePublicIP","value":"true","canchooseservicecapability":false}]},{"name":"NetworkACL","provider":[{"name":"VpcVirtualRouter"}]}],"forvpc":true,"ispersistent":false,"egressdefaultpolicy":false},
66
- {"id":"f9a7b0d0-ce61-4f8d-a360-be1040d67287","name":"DefaultIsolatedNetworkOfferingForVpcNetworksWithInternalLB","displaytext":"Offering
67
- for Isolated Vpc networks with Internal LB support","traffictype":"Guest","isdefault":true,"specifyvlan":false,"conservemode":false,"specifyipranges":false,"availability":"Optional","networkrate":200,"state":"Enabled","guestiptype":"Isolated","serviceofferingid":"983410fa-b51b-439c-b8ba-be973804c38f","service":[{"name":"SourceNat","provider":[{"name":"VpcVirtualRouter"}],"capability":[{"name":"SupportedSourceNatTypes","value":"peraccount","canchooseservicecapability":false},{"name":"RedundantRouter","value":"false","canchooseservicecapability":false}]},{"name":"Dns","provider":[{"name":"VpcVirtualRouter"}]},{"name":"UserData","provider":[{"name":"VpcVirtualRouter"}]},{"name":"Lb","provider":[{"name":"InternalLbVm"}],"capability":[{"name":"SupportedLBIsolation","value":"dedicated","canchooseservicecapability":false},{"name":"ElasticLb","value":"false","canchooseservicecapability":false},{"name":"InlineMode","value":"false","canchooseservicecapability":false}]},{"name":"Dhcp","provider":[{"name":"VpcVirtualRouter"}]},{"name":"NetworkACL","provider":[{"name":"VpcVirtualRouter"}]}],"forvpc":true,"ispersistent":false,"egressdefaultpolicy":false}
68
- ] } }'
69
- http_version:
70
- recorded_at: Wed, 18 Dec 2013 21:25:06 GMT
71
- - request:
72
- method: get
73
- uri: <CLOUD_STACK_URL>?apiKey=<CLOUD_STACK_API_KEY>&command=createNetwork&displaytext=John&name=John&networkOfferingId=fa126319-f822-4786-9cd3-30bd0c55ca94&response=json&signature=UDcfFqlzwpHJib/9kLKzR0%2BCbyc=&zoneId=39e9e31e-925c-4b55-8d33-f99912b73dfc
74
- body:
75
- encoding: US-ASCII
76
- string: ''
77
- headers:
78
- User-Agent:
79
- - Faraday v0.8.8
80
- Accept-Encoding:
81
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
82
- Accept:
83
- - ! '*/*'
84
- response:
85
- status:
86
- code: 200
87
- message: OK
88
- headers:
89
- Content-Type:
90
- - text/javascript; charset=UTF-8
91
- Content-Length:
92
- - '4441'
93
- Server:
94
- - Jetty(6.1.26)
95
- body:
96
- encoding: US-ASCII
97
- string: ! '{ "createnetworkresponse" : { "network" : {"id":"02e5fd84-e9ea-49f7-ba6a-6d63ea23a27f","name":"John","displaytext":"John","broadcastdomaintype":"Vlan","traffictype":"Guest","gateway":"10.1.1.1","netmask":"255.255.255.0","cidr":"10.1.1.0/24","zoneid":"39e9e31e-925c-4b55-8d33-f99912b73dfc","zonename":"Sandbox-simulator","networkofferingid":"fa126319-f822-4786-9cd3-30bd0c55ca94","networkofferingname":"DefaultIsolatedNetworkOfferingWithSourceNatService","networkofferingdisplaytext":"Offering
98
- for Isolated networks with Source Nat service enabled","networkofferingconservemode":true,"networkofferingavailability":"Required","issystem":false,"state":"Allocated","related":"02e5fd84-e9ea-49f7-ba6a-6d63ea23a27f","dns1":"10.147.28.6","type":"Isolated","acltype":"Account","account":"admin","domainid":"ce4585b8-41f5-11e3-aaa7-d6558ad1fb9f","domain":"ROOT","service":[{"name":"SourceNat","capability":[{"name":"SupportedSourceNatTypes","value":"peraccount","canchooseservicecapability":false},{"name":"RedundantRouter","value":"true","canchooseservicecapability":false}]},{"name":"Dns","capability":[{"name":"AllowDnsSuffixModification","value":"true","canchooseservicecapability":false}]},{"name":"UserData"},{"name":"PortForwarding"},{"name":"Firewall","capability":[{"name":"TrafficStatistics","value":"per
99
- public ip","canchooseservicecapability":false},{"name":"SupportedTrafficDirection","value":"ingress,
100
- egress","canchooseservicecapability":false},{"name":"SupportedProtocols","value":"tcp,udp,icmp","canchooseservicecapability":false},{"name":"MultipleIps","value":"true","canchooseservicecapability":false},{"name":"SupportedEgressProtocols","value":"tcp,udp,icmp,
101
- all","canchooseservicecapability":false}]},{"name":"Lb","capability":[{"name":"SupportedLbAlgorithms","value":"roundrobin,leastconn,source","canchooseservicecapability":false},{"name":"LbSchemes","value":"Public","canchooseservicecapability":false},{"name":"SupportedStickinessMethods","value":"[{\"methodname\":\"LbCookie\",\"paramlist\":[{\"paramname\":\"cookie-name\",\"required\":false,\"isflag\":false,\"description\":\"
102
- \"},{\"paramname\":\"mode\",\"required\":false,\"isflag\":false,\"description\":\"
103
- \"},{\"paramname\":\"nocache\",\"required\":false,\"isflag\":true,\"description\":\"
104
- \"},{\"paramname\":\"indirect\",\"required\":false,\"isflag\":true,\"description\":\"
105
- \"},{\"paramname\":\"postonly\",\"required\":false,\"isflag\":true,\"description\":\"
106
- \"},{\"paramname\":\"domain\",\"required\":false,\"isflag\":false,\"description\":\"
107
- \"}],\"description\":\"This is loadbalancer cookie based stickiness method.\"},{\"methodname\":\"AppCookie\",\"paramlist\":[{\"paramname\":\"cookie-name\",\"required\":false,\"isflag\":false,\"description\":\"
108
- \"},{\"paramname\":\"length\",\"required\":false,\"isflag\":false,\"description\":\"
109
- \"},{\"paramname\":\"holdtime\",\"required\":false,\"isflag\":false,\"description\":\"
110
- \"},{\"paramname\":\"request-learn\",\"required\":false,\"isflag\":true,\"description\":\"
111
- \"},{\"paramname\":\"prefix\",\"required\":false,\"isflag\":true,\"description\":\"
112
- \"},{\"paramname\":\"mode\",\"required\":false,\"isflag\":false,\"description\":\"
113
- \"}],\"description\":\"This is App session based sticky method. Define session
114
- stickiness on an existing application cookie. It can be used only for a specific
115
- http traffic\"},{\"methodname\":\"SourceBased\",\"paramlist\":[{\"paramname\":\"tablesize\",\"required\":false,\"isflag\":false,\"description\":\"
116
- \"},{\"paramname\":\"expire\",\"required\":false,\"isflag\":false,\"description\":\"
117
- \"}],\"description\":\"This is source based Stickiness method, it can be used
118
- for any type of protocol.\"}]","canchooseservicecapability":false},{"name":"SupportedProtocols","value":"tcp,
119
- udp","canchooseservicecapability":false},{"name":"SupportedLBIsolation","value":"dedicated","canchooseservicecapability":false}]},{"name":"Dhcp","capability":[{"name":"DhcpAccrossMultipleSubnets","value":"true","canchooseservicecapability":false}]},{"name":"Vpn","capability":[{"name":"SupportedVpnTypes","value":"pptp,l2tp,ipsec","canchooseservicecapability":false},{"name":"VpnTypes","value":"removeaccessvpn","canchooseservicecapability":false}]},{"name":"StaticNat"}],"networkdomain":"cs2sandbox.simulator","physicalnetworkid":"46d08659-81e9-4f31-a589-a15aca972af0","restartrequired":false,"specifyipranges":false,"canusefordeploy":true,"ispersistent":false,"tags":[],"displaynetwork":true}
120
- } }'
121
- http_version:
122
- recorded_at: Wed, 18 Dec 2013 21:25:06 GMT
123
- - request:
124
- method: get
125
- uri: <CLOUD_STACK_URL>?apiKey=<CLOUD_STACK_API_KEY>&command=createTags&resourceIds=02e5fd84-e9ea-49f7-ba6a-6d63ea23a27f&resourceType=Network&response=json&signature=KnWoymoA3Q34Iz%2BZ9iFEc8R0lEo=&tags%5B0%5D%5B.key%5D=speed&tags%5B0%5D%5B.name%5D=speed&tags%5B0%5D%5B.value%5D=fast
126
- body:
127
- encoding: US-ASCII
128
- string: ''
129
- headers:
130
- User-Agent:
131
- - Faraday v0.8.8
132
- Accept-Encoding:
133
- - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
134
- Accept:
135
- - ! '*/*'
136
- response:
137
- status:
138
- code: 200
139
- message: OK
140
- headers:
141
- Content-Type:
142
- - text/javascript; charset=UTF-8
143
- Content-Length:
144
- - '75'
145
- Server:
146
- - Jetty(6.1.26)
147
- body:
148
- encoding: US-ASCII
149
- string: ! '{ "createtagsresponse" : {"jobid":"90bdb3e9-dcd5-4aac-9aa9-1879863082cc"}
150
- }'
151
- http_version:
152
- recorded_at: Wed, 18 Dec 2013 21:25:07 GMT
153
- recorded_with: VCR 2.8.0