ory-keto-client 0.5.3.alpha1 → 0.6.0.alpha1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +1 -1
  3. data/README.md +22 -31
  4. data/docs/AddOryAccessControlPolicyRoleMembersBody.md +8 -7
  5. data/docs/AuthorizationResult.md +8 -7
  6. data/docs/EnginesApi.md +319 -129
  7. data/docs/ExpandTree.md +22 -0
  8. data/docs/GetCheckResponse.md +18 -0
  9. data/docs/GetRelationTuplesResponse.md +20 -0
  10. data/docs/HealthApi.md +50 -15
  11. data/docs/HealthNotReadyStatus.md +8 -7
  12. data/docs/HealthStatus.md +8 -7
  13. data/docs/InlineResponse400.md +28 -0
  14. data/docs/InlineResponse500.md +18 -17
  15. data/docs/InternalRelationTuple.md +24 -0
  16. data/docs/OryAccessControlPolicy.md +20 -19
  17. data/docs/OryAccessControlPolicyAllowedInput.md +14 -13
  18. data/docs/OryAccessControlPolicyRole.md +10 -9
  19. data/docs/PatchDelta.md +20 -0
  20. data/docs/ReadApi.md +297 -0
  21. data/docs/Version.md +8 -7
  22. data/docs/VersionApi.md +26 -9
  23. data/docs/WriteApi.md +212 -0
  24. data/lib/ory-keto-client.rb +10 -9
  25. data/lib/ory-keto-client/api/engines_api.rb +46 -35
  26. data/lib/ory-keto-client/api/health_api.rb +10 -8
  27. data/lib/ory-keto-client/api/read_api.rb +324 -0
  28. data/lib/ory-keto-client/api/version_api.rb +6 -5
  29. data/lib/ory-keto-client/api/write_api.rb +225 -0
  30. data/lib/ory-keto-client/api_client.rb +50 -46
  31. data/lib/ory-keto-client/api_error.rb +2 -2
  32. data/lib/ory-keto-client/configuration.rb +34 -7
  33. data/lib/ory-keto-client/models/add_ory_access_control_policy_role_members_body.rb +20 -8
  34. data/lib/ory-keto-client/models/authorization_result.rb +20 -8
  35. data/lib/ory-keto-client/models/expand_tree.rb +282 -0
  36. data/lib/ory-keto-client/models/get_check_response.rb +225 -0
  37. data/lib/ory-keto-client/models/get_relation_tuples_response.rb +230 -0
  38. data/lib/ory-keto-client/models/health_not_ready_status.rb +20 -8
  39. data/lib/ory-keto-client/models/health_status.rb +20 -8
  40. data/lib/ory-keto-client/models/inline_response400.rb +265 -0
  41. data/lib/ory-keto-client/models/inline_response500.rb +21 -9
  42. data/lib/ory-keto-client/models/internal_relation_tuple.rb +268 -0
  43. data/lib/ory-keto-client/models/ory_access_control_policy.rb +22 -12
  44. data/lib/ory-keto-client/models/ory_access_control_policy_allowed_input.rb +22 -12
  45. data/lib/ory-keto-client/models/ory_access_control_policy_role.rb +20 -8
  46. data/lib/ory-keto-client/models/patch_delta.rb +227 -0
  47. data/lib/ory-keto-client/models/version.rb +20 -8
  48. data/lib/ory-keto-client/version.rb +3 -3
  49. data/ory-keto-client.gemspec +4 -5
  50. data/spec/api/read_api_spec.rb +94 -0
  51. data/spec/api/write_api_spec.rb +74 -0
  52. data/spec/api_client_spec.rb +4 -4
  53. data/spec/configuration_spec.rb +3 -3
  54. data/spec/models/expand_tree_spec.rb +50 -0
  55. data/spec/models/get_check_response_spec.rb +34 -0
  56. data/spec/models/get_relation_tuples_response_spec.rb +40 -0
  57. data/spec/models/inline_response400_spec.rb +64 -0
  58. data/spec/models/internal_relation_tuple_spec.rb +52 -0
  59. data/spec/models/patch_delta_spec.rb +40 -0
  60. data/spec/spec_helper.rb +3 -3
  61. metadata +90 -78
@@ -3,10 +3,10 @@
3
3
 
4
4
  #Ory Keto is a cloud native access control server providing best-practice patterns (RBAC, ABAC, ACL, AWS IAM Policies, Kubernetes Roles, ...) via REST APIs.
5
5
 
6
- The version of the OpenAPI document: Latest
6
+ The version of the OpenAPI document: v0.6.0-alpha.1
7
7
  Contact: hi@ory.sh
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.2.3
9
+ OpenAPI Generator version: 5.0.0
10
10
 
11
11
  =end
12
12
 
@@ -51,15 +51,16 @@ module OryHydraClient
51
51
  form_params = opts[:form_params] || {}
52
52
 
53
53
  # http body (model)
54
- post_body = opts[:body]
54
+ post_body = opts[:debug_body]
55
55
 
56
56
  # return_type
57
- return_type = opts[:return_type] || 'Version'
57
+ return_type = opts[:debug_return_type] || 'Version'
58
58
 
59
59
  # auth_names
60
- auth_names = opts[:auth_names] || []
60
+ auth_names = opts[:debug_auth_names] || []
61
61
 
62
62
  new_options = opts.merge(
63
+ :operation => :"VersionApi.get_version",
63
64
  :header_params => header_params,
64
65
  :query_params => query_params,
65
66
  :form_params => form_params,
@@ -0,0 +1,225 @@
1
+ =begin
2
+ #ORY Keto
3
+
4
+ #Ory Keto is a cloud native access control server providing best-practice patterns (RBAC, ABAC, ACL, AWS IAM Policies, Kubernetes Roles, ...) via REST APIs.
5
+
6
+ The version of the OpenAPI document: v0.6.0-alpha.1
7
+ Contact: hi@ory.sh
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.0
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module OryHydraClient
16
+ class WriteApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Create a Relation Tuple
23
+ # Use this endpoint to create a relation tuple.
24
+ # @param [Hash] opts the optional parameters
25
+ # @option opts [InternalRelationTuple] :payload
26
+ # @return [InternalRelationTuple]
27
+ def create_relation_tuple(opts = {})
28
+ data, _status_code, _headers = create_relation_tuple_with_http_info(opts)
29
+ data
30
+ end
31
+
32
+ # Create a Relation Tuple
33
+ # Use this endpoint to create a relation tuple.
34
+ # @param [Hash] opts the optional parameters
35
+ # @option opts [InternalRelationTuple] :payload
36
+ # @return [Array<(InternalRelationTuple, Integer, Hash)>] InternalRelationTuple data, response status code and response headers
37
+ def create_relation_tuple_with_http_info(opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: WriteApi.create_relation_tuple ...'
40
+ end
41
+ # resource path
42
+ local_var_path = '/relation-tuples'
43
+
44
+ # query parameters
45
+ query_params = opts[:query_params] || {}
46
+
47
+ # header parameters
48
+ header_params = opts[:header_params] || {}
49
+ # HTTP header 'Accept' (if needed)
50
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
51
+ # HTTP header 'Content-Type'
52
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
53
+
54
+ # form parameters
55
+ form_params = opts[:form_params] || {}
56
+
57
+ # http body (model)
58
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'payload'])
59
+
60
+ # return_type
61
+ return_type = opts[:debug_return_type] || 'InternalRelationTuple'
62
+
63
+ # auth_names
64
+ auth_names = opts[:debug_auth_names] || []
65
+
66
+ new_options = opts.merge(
67
+ :operation => :"WriteApi.create_relation_tuple",
68
+ :header_params => header_params,
69
+ :query_params => query_params,
70
+ :form_params => form_params,
71
+ :body => post_body,
72
+ :auth_names => auth_names,
73
+ :return_type => return_type
74
+ )
75
+
76
+ data, status_code, headers = @api_client.call_api(:PUT, local_var_path, new_options)
77
+ if @api_client.config.debugging
78
+ @api_client.config.logger.debug "API called: WriteApi#create_relation_tuple\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
79
+ end
80
+ return data, status_code, headers
81
+ end
82
+
83
+ # Delete a Relation Tuple
84
+ # Use this endpoint to delete a relation tuple.
85
+ # @param namespace [String] Namespace of the Relation Tuple
86
+ # @param object [String] Object of the Relation Tuple
87
+ # @param relation [String] Relation of the Relation Tuple
88
+ # @param [Hash] opts the optional parameters
89
+ # @option opts [String] :subject Subject of the Relation Tuple The subject follows the subject string encoding format.
90
+ # @return [nil]
91
+ def delete_relation_tuple(namespace, object, relation, opts = {})
92
+ delete_relation_tuple_with_http_info(namespace, object, relation, opts)
93
+ nil
94
+ end
95
+
96
+ # Delete a Relation Tuple
97
+ # Use this endpoint to delete a relation tuple.
98
+ # @param namespace [String] Namespace of the Relation Tuple
99
+ # @param object [String] Object of the Relation Tuple
100
+ # @param relation [String] Relation of the Relation Tuple
101
+ # @param [Hash] opts the optional parameters
102
+ # @option opts [String] :subject Subject of the Relation Tuple The subject follows the subject string encoding format.
103
+ # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
104
+ def delete_relation_tuple_with_http_info(namespace, object, relation, opts = {})
105
+ if @api_client.config.debugging
106
+ @api_client.config.logger.debug 'Calling API: WriteApi.delete_relation_tuple ...'
107
+ end
108
+ # verify the required parameter 'namespace' is set
109
+ if @api_client.config.client_side_validation && namespace.nil?
110
+ fail ArgumentError, "Missing the required parameter 'namespace' when calling WriteApi.delete_relation_tuple"
111
+ end
112
+ # verify the required parameter 'object' is set
113
+ if @api_client.config.client_side_validation && object.nil?
114
+ fail ArgumentError, "Missing the required parameter 'object' when calling WriteApi.delete_relation_tuple"
115
+ end
116
+ # verify the required parameter 'relation' is set
117
+ if @api_client.config.client_side_validation && relation.nil?
118
+ fail ArgumentError, "Missing the required parameter 'relation' when calling WriteApi.delete_relation_tuple"
119
+ end
120
+ # resource path
121
+ local_var_path = '/relation-tuples'
122
+
123
+ # query parameters
124
+ query_params = opts[:query_params] || {}
125
+ query_params[:'namespace'] = namespace
126
+ query_params[:'object'] = object
127
+ query_params[:'relation'] = relation
128
+ query_params[:'subject'] = opts[:'subject'] if !opts[:'subject'].nil?
129
+
130
+ # header parameters
131
+ header_params = opts[:header_params] || {}
132
+ # HTTP header 'Accept' (if needed)
133
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
134
+
135
+ # form parameters
136
+ form_params = opts[:form_params] || {}
137
+
138
+ # http body (model)
139
+ post_body = opts[:debug_body]
140
+
141
+ # return_type
142
+ return_type = opts[:debug_return_type]
143
+
144
+ # auth_names
145
+ auth_names = opts[:debug_auth_names] || []
146
+
147
+ new_options = opts.merge(
148
+ :operation => :"WriteApi.delete_relation_tuple",
149
+ :header_params => header_params,
150
+ :query_params => query_params,
151
+ :form_params => form_params,
152
+ :body => post_body,
153
+ :auth_names => auth_names,
154
+ :return_type => return_type
155
+ )
156
+
157
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
158
+ if @api_client.config.debugging
159
+ @api_client.config.logger.debug "API called: WriteApi#delete_relation_tuple\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
160
+ end
161
+ return data, status_code, headers
162
+ end
163
+
164
+ # Patch Multiple Relation Tuples
165
+ # Use this endpoint to patch one or more relation tuples.
166
+ # @param [Hash] opts the optional parameters
167
+ # @option opts [Array<PatchDelta>] :payload
168
+ # @return [nil]
169
+ def patch_relation_tuples(opts = {})
170
+ patch_relation_tuples_with_http_info(opts)
171
+ nil
172
+ end
173
+
174
+ # Patch Multiple Relation Tuples
175
+ # Use this endpoint to patch one or more relation tuples.
176
+ # @param [Hash] opts the optional parameters
177
+ # @option opts [Array<PatchDelta>] :payload
178
+ # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
179
+ def patch_relation_tuples_with_http_info(opts = {})
180
+ if @api_client.config.debugging
181
+ @api_client.config.logger.debug 'Calling API: WriteApi.patch_relation_tuples ...'
182
+ end
183
+ # resource path
184
+ local_var_path = '/relation-tuples'
185
+
186
+ # query parameters
187
+ query_params = opts[:query_params] || {}
188
+
189
+ # header parameters
190
+ header_params = opts[:header_params] || {}
191
+ # HTTP header 'Accept' (if needed)
192
+ header_params['Accept'] = @api_client.select_header_accept(['application/json'])
193
+ # HTTP header 'Content-Type'
194
+ header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])
195
+
196
+ # form parameters
197
+ form_params = opts[:form_params] || {}
198
+
199
+ # http body (model)
200
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'payload'])
201
+
202
+ # return_type
203
+ return_type = opts[:debug_return_type]
204
+
205
+ # auth_names
206
+ auth_names = opts[:debug_auth_names] || []
207
+
208
+ new_options = opts.merge(
209
+ :operation => :"WriteApi.patch_relation_tuples",
210
+ :header_params => header_params,
211
+ :query_params => query_params,
212
+ :form_params => form_params,
213
+ :body => post_body,
214
+ :auth_names => auth_names,
215
+ :return_type => return_type
216
+ )
217
+
218
+ data, status_code, headers = @api_client.call_api(:PATCH, local_var_path, new_options)
219
+ if @api_client.config.debugging
220
+ @api_client.config.logger.debug "API called: WriteApi#patch_relation_tuples\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
221
+ end
222
+ return data, status_code, headers
223
+ end
224
+ end
225
+ end
@@ -3,10 +3,10 @@
3
3
 
4
4
  #Ory Keto is a cloud native access control server providing best-practice patterns (RBAC, ABAC, ACL, AWS IAM Policies, Kubernetes Roles, ...) via REST APIs.
5
5
 
6
- The version of the OpenAPI document: Latest
6
+ The version of the OpenAPI document: v0.6.0-alpha.1
7
7
  Contact: hi@ory.sh
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.2.3
9
+ OpenAPI Generator version: 5.0.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] || {})
@@ -154,6 +155,44 @@ module OryHydraClient
154
155
  data
155
156
  end
156
157
 
158
+ # Save response body into a file in (the defined) temporary folder, using the filename
159
+ # from the "Content-Disposition" header if provided, otherwise a random filename.
160
+ # The response body is written to the file in chunks in order to handle files which
161
+ # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
162
+ # process can use.
163
+ #
164
+ # @see Configuration#temp_folder_path
165
+ def download_file(request)
166
+ tempfile = nil
167
+ encoding = nil
168
+ request.on_headers do |response|
169
+ content_disposition = response.headers['Content-Disposition']
170
+ if content_disposition && content_disposition =~ /filename=/i
171
+ filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
172
+ prefix = sanitize_filename(filename)
173
+ else
174
+ prefix = 'download-'
175
+ end
176
+ prefix = prefix + '-' unless prefix.end_with?('-')
177
+ encoding = response.body.encoding
178
+ tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
179
+ @tempfile = tempfile
180
+ end
181
+ request.on_body do |chunk|
182
+ chunk.force_encoding(encoding)
183
+ tempfile.write(chunk)
184
+ end
185
+ request.on_complete do |response|
186
+ if tempfile
187
+ tempfile.close
188
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
189
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
190
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
191
+ "explicitly with `tempfile.delete`"
192
+ end
193
+ end
194
+ end
195
+
157
196
  # Check if the given MIME is a JSON MIME.
158
197
  # JSON MIME examples:
159
198
  # application/json
@@ -190,7 +229,7 @@ module OryHydraClient
190
229
  begin
191
230
  data = JSON.parse("[#{body}]", :symbolize_names => true)[0]
192
231
  rescue JSON::ParserError => e
193
- if %w(String Date DateTime).include?(return_type)
232
+ if %w(String Date Time).include?(return_type)
194
233
  data = body
195
234
  else
196
235
  raise e
@@ -215,9 +254,9 @@ module OryHydraClient
215
254
  data.to_f
216
255
  when 'Boolean'
217
256
  data == true
218
- when 'DateTime'
257
+ when 'Time'
219
258
  # parse date time (expecting ISO 8601 format)
220
- DateTime.parse data
259
+ Time.parse data
221
260
  when 'Date'
222
261
  # parse date time (expecting ISO 8601 format)
223
262
  Date.parse data
@@ -235,44 +274,9 @@ module OryHydraClient
235
274
  data.each { |k, v| hash[k] = convert_to_type(v, sub_type) }
236
275
  end
237
276
  else
238
- # models, e.g. Pet
239
- OryHydraClient.const_get(return_type).build_from_hash(data)
240
- end
241
- end
242
-
243
- # Save response body into a file in (the defined) temporary folder, using the filename
244
- # from the "Content-Disposition" header if provided, otherwise a random filename.
245
- # The response body is written to the file in chunks in order to handle files which
246
- # size is larger than maximum Ruby String or even larger than the maximum memory a Ruby
247
- # process can use.
248
- #
249
- # @see Configuration#temp_folder_path
250
- def download_file(request)
251
- tempfile = nil
252
- encoding = nil
253
- request.on_headers do |response|
254
- content_disposition = response.headers['Content-Disposition']
255
- if content_disposition && content_disposition =~ /filename=/i
256
- filename = content_disposition[/filename=['"]?([^'"\s]+)['"]?/, 1]
257
- prefix = sanitize_filename(filename)
258
- else
259
- prefix = 'download-'
260
- end
261
- prefix = prefix + '-' unless prefix.end_with?('-')
262
- encoding = response.body.encoding
263
- tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
264
- @tempfile = tempfile
265
- end
266
- request.on_body do |chunk|
267
- chunk.force_encoding(encoding)
268
- tempfile.write(chunk)
269
- end
270
- request.on_complete do |response|
271
- tempfile.close if tempfile
272
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
273
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
274
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
275
- "explicitly with `tempfile.delete`"
277
+ # models (e.g. Pet) or oneOf
278
+ klass = OryHydraClient.const_get(return_type)
279
+ klass.respond_to?(:openapi_one_of) ? klass.build(data) : klass.build_from_hash(data)
276
280
  end
277
281
  end
278
282
 
@@ -285,10 +289,10 @@ module OryHydraClient
285
289
  filename.gsub(/.*[\/\\]/, '')
286
290
  end
287
291
 
288
- def build_request_url(path)
292
+ def build_request_url(path, opts = {})
289
293
  # Add leading and trailing slashes to path
290
294
  path = "/#{path}".gsub(/\/+/, '/')
291
- @config.base_url + path
295
+ @config.base_url(opts[:operation]) + path
292
296
  end
293
297
 
294
298
  # Update hearder and query params based on authentication settings.
@@ -3,10 +3,10 @@
3
3
 
4
4
  #Ory Keto is a cloud native access control server providing best-practice patterns (RBAC, ABAC, ACL, AWS IAM Policies, Kubernetes Roles, ...) via REST APIs.
5
5
 
6
- The version of the OpenAPI document: Latest
6
+ The version of the OpenAPI document: v0.6.0-alpha.1
7
7
  Contact: hi@ory.sh
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.2.3
9
+ OpenAPI Generator version: 5.0.0
10
10
 
11
11
  =end
12
12
 
@@ -3,10 +3,10 @@
3
3
 
4
4
  #Ory Keto is a cloud native access control server providing best-practice patterns (RBAC, ABAC, ACL, AWS IAM Policies, Kubernetes Roles, ...) via REST APIs.
5
5
 
6
- The version of the OpenAPI document: Latest
6
+ The version of the OpenAPI document: v0.6.0-alpha.1
7
7
  Contact: hi@ory.sh
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.2.3
9
+ OpenAPI Generator version: 5.0.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,8 +187,12 @@ 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).
@@ -206,12 +226,17 @@ module OryHydraClient
206
226
  ]
207
227
  end
208
228
 
229
+ def operation_server_settings
230
+ {
231
+ }
232
+ end
233
+
209
234
  # Returns URL based on server settings
210
235
  #
211
236
  # @param index array index of the server settings
212
237
  # @param variables hash of variable and the corresponding value
213
- def server_url(index, variables = {})
214
- servers = server_settings
238
+ def server_url(index, variables = {}, servers = nil)
239
+ servers = server_settings if servers == nil
215
240
 
216
241
  # check array index out of bound
217
242
  if (index < 0 || index >= servers.size)
@@ -221,10 +246,12 @@ module OryHydraClient
221
246
  server = servers[index]
222
247
  url = server[:url]
223
248
 
249
+ return url unless server.key? :variables
250
+
224
251
  # go through variable and assign a value
225
252
  server[:variables].each do |name, variable|
226
253
  if variables.key?(name)
227
- if (server[:variables][name][:enum_values].include? variables[name])
254
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
228
255
  url.gsub! "{" + name.to_s + "}", variables[name]
229
256
  else
230
257
  fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."