ory-hydra-client 1.9.0.alpha2 → 1.10.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.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +9 -5
  3. data/docs/AcceptConsentRequest.md +18 -17
  4. data/docs/AcceptLoginRequest.md +18 -17
  5. data/docs/AdminApi.md +883 -304
  6. data/docs/CompletedRequest.md +8 -7
  7. data/docs/ConsentRequest.md +30 -29
  8. data/docs/ConsentRequestSession.md +10 -9
  9. data/docs/ContainerWaitOKBodyError.md +8 -7
  10. data/docs/FlushInactiveOAuth2TokensRequest.md +8 -7
  11. data/docs/GenericError.md +14 -13
  12. data/docs/HealthNotReadyStatus.md +8 -7
  13. data/docs/HealthStatus.md +8 -7
  14. data/docs/JSONWebKey.md +40 -39
  15. data/docs/JSONWebKeySet.md +8 -7
  16. data/docs/JsonWebKeySetGeneratorRequest.md +12 -11
  17. data/docs/LoginRequest.md +24 -23
  18. data/docs/LogoutRequest.md +16 -13
  19. data/docs/OAuth2Client.md +72 -71
  20. data/docs/OAuth2TokenIntrospection.md +34 -31
  21. data/docs/Oauth2TokenResponse.md +18 -17
  22. data/docs/OpenIDConnectContext.md +16 -15
  23. data/docs/PatchDocument.md +24 -0
  24. data/docs/PluginConfig.md +38 -37
  25. data/docs/PluginConfigArgs.md +14 -13
  26. data/docs/PluginConfigInterface.md +10 -9
  27. data/docs/PluginConfigLinux.md +12 -11
  28. data/docs/PluginConfigNetwork.md +8 -7
  29. data/docs/PluginConfigRootfs.md +10 -9
  30. data/docs/PluginConfigUser.md +10 -9
  31. data/docs/PluginDevice.md +14 -13
  32. data/docs/PluginEnv.md +14 -13
  33. data/docs/PluginInterfaceType.md +12 -11
  34. data/docs/PluginMount.md +20 -19
  35. data/docs/PluginSettings.md +14 -13
  36. data/docs/PreviousConsentSession.md +20 -19
  37. data/docs/PublicApi.md +201 -60
  38. data/docs/RejectRequest.md +16 -15
  39. data/docs/RequestWasHandledResponse.md +18 -0
  40. data/docs/UserinfoResponse.md +44 -43
  41. data/docs/Version.md +8 -7
  42. data/docs/Volume.md +34 -0
  43. data/docs/VolumeUsageData.md +10 -9
  44. data/docs/WellKnown.md +58 -55
  45. data/lib/ory-hydra-client.rb +5 -2
  46. data/lib/ory-hydra-client/api/admin_api.rb +197 -96
  47. data/lib/ory-hydra-client/api/public_api.rb +34 -26
  48. data/lib/ory-hydra-client/api_client.rb +51 -49
  49. data/lib/ory-hydra-client/api_error.rb +2 -2
  50. data/lib/ory-hydra-client/configuration.rb +40 -11
  51. data/lib/ory-hydra-client/models/accept_consent_request.rb +21 -9
  52. data/lib/ory-hydra-client/models/accept_login_request.rb +20 -8
  53. data/lib/ory-hydra-client/models/completed_request.rb +20 -8
  54. data/lib/ory-hydra-client/models/consent_request.rb +20 -8
  55. data/lib/ory-hydra-client/models/consent_request_session.rb +20 -8
  56. data/lib/ory-hydra-client/models/container_wait_ok_body_error.rb +20 -8
  57. data/lib/ory-hydra-client/models/flush_inactive_o_auth2_tokens_request.rb +21 -9
  58. data/lib/ory-hydra-client/models/generic_error.rb +20 -8
  59. data/lib/ory-hydra-client/models/health_not_ready_status.rb +20 -8
  60. data/lib/ory-hydra-client/models/health_status.rb +20 -8
  61. data/lib/ory-hydra-client/models/json_web_key.rb +20 -8
  62. data/lib/ory-hydra-client/models/json_web_key_set.rb +20 -8
  63. data/lib/ory-hydra-client/models/json_web_key_set_generator_request.rb +20 -8
  64. data/lib/ory-hydra-client/models/login_request.rb +20 -8
  65. data/lib/ory-hydra-client/models/logout_request.rb +31 -9
  66. data/lib/ory-hydra-client/models/o_auth2_client.rb +22 -10
  67. data/lib/ory-hydra-client/models/o_auth2_token_introspection.rb +32 -10
  68. data/lib/ory-hydra-client/models/oauth2_token_response.rb +20 -8
  69. data/lib/ory-hydra-client/models/open_id_connect_context.rb +20 -8
  70. data/lib/ory-hydra-client/models/patch_document.rb +260 -0
  71. data/lib/ory-hydra-client/models/plugin_config.rb +20 -8
  72. data/lib/ory-hydra-client/models/plugin_config_args.rb +20 -8
  73. data/lib/ory-hydra-client/models/plugin_config_interface.rb +20 -8
  74. data/lib/ory-hydra-client/models/plugin_config_linux.rb +20 -8
  75. data/lib/ory-hydra-client/models/plugin_config_network.rb +20 -8
  76. data/lib/ory-hydra-client/models/plugin_config_rootfs.rb +20 -8
  77. data/lib/ory-hydra-client/models/plugin_config_user.rb +20 -8
  78. data/lib/ory-hydra-client/models/plugin_device.rb +20 -8
  79. data/lib/ory-hydra-client/models/plugin_env.rb +20 -8
  80. data/lib/ory-hydra-client/models/plugin_interface_type.rb +20 -8
  81. data/lib/ory-hydra-client/models/plugin_mount.rb +20 -8
  82. data/lib/ory-hydra-client/models/plugin_settings.rb +20 -8
  83. data/lib/ory-hydra-client/models/previous_consent_session.rb +21 -9
  84. data/lib/ory-hydra-client/models/reject_request.rb +20 -8
  85. data/lib/ory-hydra-client/models/request_was_handled_response.rb +224 -0
  86. data/lib/ory-hydra-client/models/userinfo_response.rb +20 -8
  87. data/lib/ory-hydra-client/models/version.rb +20 -8
  88. data/lib/ory-hydra-client/models/volume.rb +333 -0
  89. data/lib/ory-hydra-client/models/volume_usage_data.rb +20 -8
  90. data/lib/ory-hydra-client/models/well_known.rb +33 -9
  91. data/lib/ory-hydra-client/version.rb +3 -3
  92. data/ory-hydra-client.gemspec +4 -5
  93. data/spec/api_client_spec.rb +3 -3
  94. data/spec/configuration_spec.rb +2 -2
  95. data/spec/models/patch_document_spec.rb +52 -0
  96. data/spec/models/request_was_handled_response_spec.rb +34 -0
  97. data/spec/models/volume_spec.rb +82 -0
  98. data/spec/spec_helper.rb +2 -2
  99. metadata +45 -53
@@ -3,10 +3,10 @@
3
3
 
4
4
  #Welcome to the ORY Hydra HTTP API documentation. You will find documentation for all HTTP APIs here.
5
5
 
6
- The version of the OpenAPI document: v1.9.0-alpha.2
6
+ The version of the OpenAPI document: v1.10.2
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ OpenAPI Generator version: 5.1.0
10
10
 
11
11
  =end
12
12
 
@@ -49,15 +49,16 @@ module OryHydraClient
49
49
  form_params = opts[:form_params] || {}
50
50
 
51
51
  # http body (model)
52
- post_body = opts[:body]
52
+ post_body = opts[:debug_body]
53
53
 
54
54
  # return_type
55
- return_type = opts[:return_type]
55
+ return_type = opts[:debug_return_type]
56
56
 
57
57
  # auth_names
58
- auth_names = opts[:auth_names] || []
58
+ auth_names = opts[:debug_auth_names] || []
59
59
 
60
60
  new_options = opts.merge(
61
+ :operation => :"PublicApi.disconnect_user",
61
62
  :header_params => header_params,
62
63
  :query_params => query_params,
63
64
  :form_params => form_params,
@@ -105,15 +106,16 @@ module OryHydraClient
105
106
  form_params = opts[:form_params] || {}
106
107
 
107
108
  # http body (model)
108
- post_body = opts[:body]
109
+ post_body = opts[:debug_body]
109
110
 
110
111
  # return_type
111
- return_type = opts[:return_type] || 'WellKnown'
112
+ return_type = opts[:debug_return_type] || 'WellKnown'
112
113
 
113
114
  # auth_names
114
- auth_names = opts[:auth_names] || []
115
+ auth_names = opts[:debug_auth_names] || []
115
116
 
116
117
  new_options = opts.merge(
118
+ :operation => :"PublicApi.discover_open_id_configuration",
117
119
  :header_params => header_params,
118
120
  :query_params => query_params,
119
121
  :form_params => form_params,
@@ -161,15 +163,16 @@ module OryHydraClient
161
163
  form_params = opts[:form_params] || {}
162
164
 
163
165
  # http body (model)
164
- post_body = opts[:body]
166
+ post_body = opts[:debug_body]
165
167
 
166
168
  # return_type
167
- return_type = opts[:return_type] || 'HealthStatus'
169
+ return_type = opts[:debug_return_type] || 'HealthStatus'
168
170
 
169
171
  # auth_names
170
- auth_names = opts[:auth_names] || []
172
+ auth_names = opts[:debug_auth_names] || []
171
173
 
172
174
  new_options = opts.merge(
175
+ :operation => :"PublicApi.is_instance_ready",
173
176
  :header_params => header_params,
174
177
  :query_params => query_params,
175
178
  :form_params => form_params,
@@ -238,15 +241,16 @@ module OryHydraClient
238
241
  form_params['client_id'] = opts[:'client_id'] if !opts[:'client_id'].nil?
239
242
 
240
243
  # http body (model)
241
- post_body = opts[:body]
244
+ post_body = opts[:debug_body]
242
245
 
243
246
  # return_type
244
- return_type = opts[:return_type] || 'Oauth2TokenResponse'
247
+ return_type = opts[:debug_return_type] || 'Oauth2TokenResponse'
245
248
 
246
249
  # auth_names
247
- auth_names = opts[:auth_names] || ['basic', 'oauth2']
250
+ auth_names = opts[:debug_auth_names] || ['basic', 'oauth2']
248
251
 
249
252
  new_options = opts.merge(
253
+ :operation => :"PublicApi.oauth2_token",
250
254
  :header_params => header_params,
251
255
  :query_params => query_params,
252
256
  :form_params => form_params,
@@ -294,15 +298,16 @@ module OryHydraClient
294
298
  form_params = opts[:form_params] || {}
295
299
 
296
300
  # http body (model)
297
- post_body = opts[:body]
301
+ post_body = opts[:debug_body]
298
302
 
299
303
  # return_type
300
- return_type = opts[:return_type]
304
+ return_type = opts[:debug_return_type]
301
305
 
302
306
  # auth_names
303
- auth_names = opts[:auth_names] || []
307
+ auth_names = opts[:debug_auth_names] || []
304
308
 
305
309
  new_options = opts.merge(
310
+ :operation => :"PublicApi.oauth_auth",
306
311
  :header_params => header_params,
307
312
  :query_params => query_params,
308
313
  :form_params => form_params,
@@ -359,15 +364,16 @@ module OryHydraClient
359
364
  form_params['token'] = token
360
365
 
361
366
  # http body (model)
362
- post_body = opts[:body]
367
+ post_body = opts[:debug_body]
363
368
 
364
369
  # return_type
365
- return_type = opts[:return_type]
370
+ return_type = opts[:debug_return_type]
366
371
 
367
372
  # auth_names
368
- auth_names = opts[:auth_names] || ['basic', 'oauth2']
373
+ auth_names = opts[:debug_auth_names] || ['basic', 'oauth2']
369
374
 
370
375
  new_options = opts.merge(
376
+ :operation => :"PublicApi.revoke_o_auth2_token",
371
377
  :header_params => header_params,
372
378
  :query_params => query_params,
373
379
  :form_params => form_params,
@@ -415,15 +421,16 @@ module OryHydraClient
415
421
  form_params = opts[:form_params] || {}
416
422
 
417
423
  # http body (model)
418
- post_body = opts[:body]
424
+ post_body = opts[:debug_body]
419
425
 
420
426
  # return_type
421
- return_type = opts[:return_type] || 'UserinfoResponse'
427
+ return_type = opts[:debug_return_type] || 'UserinfoResponse'
422
428
 
423
429
  # auth_names
424
- auth_names = opts[:auth_names] || ['oauth2']
430
+ auth_names = opts[:debug_auth_names] || ['oauth2']
425
431
 
426
432
  new_options = opts.merge(
433
+ :operation => :"PublicApi.userinfo",
427
434
  :header_params => header_params,
428
435
  :query_params => query_params,
429
436
  :form_params => form_params,
@@ -471,15 +478,16 @@ module OryHydraClient
471
478
  form_params = opts[:form_params] || {}
472
479
 
473
480
  # http body (model)
474
- post_body = opts[:body]
481
+ post_body = opts[:debug_body]
475
482
 
476
483
  # return_type
477
- return_type = opts[:return_type] || 'JSONWebKeySet'
484
+ return_type = opts[:debug_return_type] || 'JSONWebKeySet'
478
485
 
479
486
  # auth_names
480
- auth_names = opts[:auth_names] || []
487
+ auth_names = opts[:debug_auth_names] || []
481
488
 
482
489
  new_options = opts.merge(
490
+ :operation => :"PublicApi.well_known",
483
491
  :header_params => header_params,
484
492
  :query_params => query_params,
485
493
  :form_params => form_params,
@@ -3,10 +3,10 @@
3
3
 
4
4
  #Welcome to the ORY Hydra HTTP API documentation. You will find documentation for all HTTP APIs here.
5
5
 
6
- The version of the OpenAPI document: v1.9.0-alpha.2
6
+ The version of the OpenAPI document: v1.10.2
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ OpenAPI Generator version: 5.1.0
10
10
 
11
11
  =end
12
12
 
@@ -14,6 +14,7 @@ require 'date'
14
14
  require 'json'
15
15
  require 'logger'
16
16
  require 'tempfile'
17
+ require 'time'
17
18
  require 'typhoeus'
18
19
 
19
20
  module OryHydraClient
@@ -86,7 +87,7 @@ module OryHydraClient
86
87
  # @option opts [Object] :body HTTP body (JSON/XML)
87
88
  # @return [Typhoeus::Request] A Typhoeus Request
88
89
  def build_request(http_method, path, opts = {})
89
- url = build_request_url(path)
90
+ url = build_request_url(path, opts)
90
91
  http_method = http_method.to_sym.downcase
91
92
 
92
93
  header_params = @default_headers.merge(opts[:header_params] || {})
@@ -155,6 +156,44 @@ module OryHydraClient
155
156
  data
156
157
  end
157
158
 
159
+ # Save response body into a file in (the defined) temporary folder, using the filename
160
+ # from the "Content-Disposition" header if provided, otherwise a random filename.
161
+ # The response body is written to the file in chunks in order to handle files which
162
+ # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
163
+ # process can use.
164
+ #
165
+ # @see Configuration#temp_folder_path
166
+ def download_file(request)
167
+ tempfile = nil
168
+ encoding = nil
169
+ request.on_headers do |response|
170
+ content_disposition = response.headers['Content-Disposition']
171
+ if content_disposition && content_disposition =~ /filename=/i
172
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
173
+ prefix = sanitize_filename(filename)
174
+ else
175
+ prefix = 'download-'
176
+ end
177
+ prefix = prefix + '-' unless prefix.end_with?('-')
178
+ encoding = response.body.encoding
179
+ tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
180
+ @tempfile = tempfile
181
+ end
182
+ request.on_body do |chunk|
183
+ chunk.force_encoding(encoding)
184
+ tempfile.write(chunk)
185
+ end
186
+ request.on_complete do |response|
187
+ if tempfile
188
+ tempfile.close
189
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
190
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
191
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
192
+ "explicitly with `tempfile.delete`"
193
+ end
194
+ end
195
+ end
196
+
158
197
  # Check if the given MIME is a JSON MIME.
159
198
  # JSON MIME examples:
160
199
  # application/json
@@ -191,7 +230,7 @@ module OryHydraClient
191
230
  begin
192
231
  data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
193
232
  rescue JSON::ParserError => e
194
- if %w(String Date DateTime).include?(return_type)
233
+ if %w(String Date Time).include?(return_type)
195
234
  data = body
196
235
  else
197
236
  raise e
@@ -216,9 +255,9 @@ module OryHydraClient
216
255
  data.to_f
217
256
  when 'Boolean'
218
257
  data == true
219
- when 'DateTime'
258
+ when 'Time'
220
259
  # parse date time (expecting ISO 8601 format)
221
- DateTime.parse data
260
+ Time.parse data
222
261
  when 'Date'
223
262
  # parse date time (expecting ISO 8601 format)
224
263
  Date.parse data
@@ -236,46 +275,9 @@ module OryHydraClient
236
275
  data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
237
276
  end
238
277
  else
239
- # models, e.g. Pet
240
- OryHydraClient.const_get(return_type).build_from_hash(data)
241
- end
242
- end
243
-
244
- # Save response body into a file in (the defined) temporary folder, using the filename
245
- # from the "Content-Disposition" header if provided, otherwise a random filename.
246
- # The response body is written to the file in chunks in order to handle files which
247
- # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
248
- # process can use.
249
- #
250
- # @see Configuration#temp_folder_path
251
- def download_file(request)
252
- tempfile = nil
253
- encoding = nil
254
- request.on_headers do |response|
255
- content_disposition = response.headers['Content-Disposition']
256
- if content_disposition && content_disposition =~ /filename=/i
257
- filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
258
- prefix = sanitize_filename(filename)
259
- else
260
- prefix = 'download-'
261
- end
262
- prefix = prefix + '-' unless prefix.end_with?('-')
263
- encoding = response.body.encoding
264
- tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
265
- @tempfile = tempfile
266
- end
267
- request.on_body do |chunk|
268
- chunk.force_encoding(encoding)
269
- tempfile.write(chunk)
270
- end
271
- request.on_complete do |response|
272
- if tempfile
273
- tempfile.close
274
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
275
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
276
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
277
- "explicitly with `tempfile.delete`"
278
- end
278
+ # models (e.g. Pet) or oneOf
279
+ klass = OryHydraClient.const_get(return_type)
280
+ klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
279
281
  end
280
282
  end
281
283
 
@@ -288,10 +290,10 @@ module OryHydraClient
288
290
  filename.gsub(/.*[\/\\]/, '')
289
291
  end
290
292
 
291
- def build_request_url(path)
293
+ def build_request_url(path, opts = {})
292
294
  # Add leading and trailing slashes to path
293
295
  path = "/#{path}".gsub(/\/+/, '/')
294
- @config.base_url + path
296
+ @config.base_url(opts[:operation]) + path
295
297
  end
296
298
 
297
299
  # Update hearder and query params based on authentication settings.
@@ -306,7 +308,7 @@ module OryHydraClient
306
308
  case auth_setting[:in]
307
309
  when 'header' then header_params[auth_setting[:key]] = auth_setting[:value]
308
310
  when 'query' then query_params[auth_setting[:key]] = auth_setting[:value]
309
- else fail ArgumentError, 'Authentication token must be in `query` of `header`'
311
+ else fail ArgumentError, 'Authentication token must be in `query` or `header`'
310
312
  end
311
313
  end
312
314
  end
@@ -3,10 +3,10 @@
3
3
 
4
4
  #Welcome to the ORY Hydra HTTP API documentation. You will find documentation for all HTTP APIs here.
5
5
 
6
- The version of the OpenAPI document: v1.9.0-alpha.2
6
+ The version of the OpenAPI document: v1.10.2
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ OpenAPI Generator version: 5.1.0
10
10
 
11
11
  =end
12
12
 
@@ -3,10 +3,10 @@
3
3
 
4
4
  #Welcome to the ORY Hydra HTTP API documentation. You will find documentation for all HTTP APIs here.
5
5
 
6
- The version of the OpenAPI document: v1.9.0-alpha.2
6
+ The version of the OpenAPI document: v1.10.2
7
7
 
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ OpenAPI Generator version: 5.1.0
10
10
 
11
11
  =end
12
12
 
@@ -21,6 +21,18 @@ module OryHydraClient
21
21
  # Defines url base path
22
22
  attr_accessor :base_path
23
23
 
24
+ # Define server configuration index
25
+ attr_accessor :server_index
26
+
27
+ # Define server operation configuration index
28
+ attr_accessor :server_operation_index
29
+
30
+ # Default server variables
31
+ attr_accessor :server_variables
32
+
33
+ # Default server operation variables
34
+ attr_accessor :server_operation_variables
35
+
24
36
  # Defines API keys used with API Key authentications.
25
37
  #
26
38
  # @return [Hash] key: parameter name, value: parameter value (API key)
@@ -129,6 +141,10 @@ module OryHydraClient
129
141
  @scheme = 'http'
130
142
  @host = 'localhost'
131
143
  @base_path = ''
144
+ @server_index = 0
145
+ @server_operation_index = {}
146
+ @server_variables = {}
147
+ @server_operation_variables = {}
132
148
  @api_key = {}
133
149
  @api_key_prefix = {}
134
150
  @timeout = 0
@@ -171,17 +187,23 @@ module OryHydraClient
171
187
  @base_path = '' if @base_path == '/'
172
188
  end
173
189
 
174
- def base_url
175
- "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
190
+ # Returns base URL for specified operation based on server settings
191
+ def base_url(operation = nil)
192
+ index = server_operation_index.fetch(operation, server_index)
193
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
194
+
195
+ server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
176
196
  end
177
197
 
178
198
  # Gets API key (with prefix if set).
179
199
  # @param [String] param_name the parameter name of API key auth
180
- def api_key_with_prefix(param_name)
200
+ def api_key_with_prefix(param_name, param_alias = nil)
201
+ key = @api_key[param_name]
202
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
181
203
  if @api_key_prefix[param_name]
182
- "#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
204
+ "#{@api_key_prefix[param_name]} #{key}"
183
205
  else
184
- @api_key[param_name]
206
+ key
185
207
  end
186
208
  end
187
209
 
@@ -214,18 +236,23 @@ module OryHydraClient
214
236
  def server_settings
215
237
  [
216
238
  {
217
- url: "/",
239
+ url: "",
218
240
  description: "No description provided",
219
241
  }
220
242
  ]
221
243
  end
222
244
 
245
+ def operation_server_settings
246
+ {
247
+ }
248
+ end
249
+
223
250
  # Returns URL based on server settings
224
251
  #
225
252
  # @param index array index of the server settings
226
253
  # @param variables hash of variable and the corresponding value
227
- def server_url(index, variables = {})
228
- servers = server_settings
254
+ def server_url(index, variables = {}, servers = nil)
255
+ servers = server_settings if servers == nil
229
256
 
230
257
  # check array index out of bound
231
258
  if (index < 0 || index >= servers.size)
@@ -235,10 +262,12 @@ module OryHydraClient
235
262
  server = servers[index]
236
263
  url = server[:url]
237
264
 
265
+ return url unless server.key? :variables
266
+
238
267
  # go through variable and assign a value
239
268
  server[:variables].each do |name, variable|
240
269
  if variables.key?(name)
241
- if (server[:variables][name][:enum_values].include? variables[name])
270
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
242
271
  url.gsub! "{" + name.to_s + "}", variables[name]
243
272
  else
244
273
  fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."