ruby-linstor-client 1.0.0

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 (193) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +86 -0
  4. data/LICENSE +21 -0
  5. data/README.md +21 -0
  6. data/Rakefile +10 -0
  7. data/codegen.sh +22 -0
  8. data/generator/custom/one_of_drbd_resource_definition_layer.rb +7 -0
  9. data/generator/custom/one_of_drbd_volume_definition.rb +7 -0
  10. data/generator/custom/one_of_drbd_volume_luks_volume_storage_nvme_volme_writecache_volume.rb +11 -0
  11. data/generator/openapi-generator.yaml +11 -0
  12. data/generator/template/Gemfile.mustache +9 -0
  13. data/generator/template/README.mustache +148 -0
  14. data/generator/template/Rakefile.mustache +10 -0
  15. data/generator/template/api.mustache +209 -0
  16. data/generator/template/api_client.mustache +264 -0
  17. data/generator/template/api_client_faraday_partial.mustache +136 -0
  18. data/generator/template/api_client_spec.mustache +220 -0
  19. data/generator/template/api_client_typhoeus_partial.mustache +153 -0
  20. data/generator/template/api_doc.mustache +118 -0
  21. data/generator/template/api_error.mustache +49 -0
  22. data/generator/template/api_info.mustache +12 -0
  23. data/generator/template/api_test.mustache +47 -0
  24. data/generator/template/base_object.mustache +120 -0
  25. data/generator/template/configuration.mustache +385 -0
  26. data/generator/template/configuration_spec.mustache +34 -0
  27. data/generator/template/configuration_tls_faraday_partial.mustache +29 -0
  28. data/generator/template/configuration_tls_typhoeus_partial.mustache +34 -0
  29. data/generator/template/gem.mustache +53 -0
  30. data/generator/template/gemspec.mustache +35 -0
  31. data/generator/template/git_push.sh.mustache +57 -0
  32. data/generator/template/gitignore.mustache +39 -0
  33. data/generator/template/model.mustache +26 -0
  34. data/generator/template/model_doc.mustache +12 -0
  35. data/generator/template/model_test.mustache +77 -0
  36. data/generator/template/partial_model_enum_class.mustache +20 -0
  37. data/generator/template/partial_model_generic.mustache +371 -0
  38. data/generator/template/partial_model_generic_doc.mustache +28 -0
  39. data/generator/template/partial_oneof_module.mustache +137 -0
  40. data/generator/template/partial_oneof_module_doc.mustache +92 -0
  41. data/generator/template/rspec.mustache +2 -0
  42. data/generator/template/rubocop.mustache +148 -0
  43. data/generator/template/spec_helper.mustache +103 -0
  44. data/generator/template/travis.mustache +14 -0
  45. data/generator/template/version.mustache +7 -0
  46. data/lib/ruby-linstor-client/api/developers_api.rb +5856 -0
  47. data/lib/ruby-linstor-client/api_client.rb +393 -0
  48. data/lib/ruby-linstor-client/api_error.rb +57 -0
  49. data/lib/ruby-linstor-client/configuration.rb +298 -0
  50. data/lib/ruby-linstor-client/models/api_call_rc.rb +293 -0
  51. data/lib/ruby-linstor-client/models/auto_place_request.rb +245 -0
  52. data/lib/ruby-linstor-client/models/auto_select_filter.rb +305 -0
  53. data/lib/ruby-linstor-client/models/candidate.rb +248 -0
  54. data/lib/ruby-linstor-client/models/controller_props_modify.rb +243 -0
  55. data/lib/ruby-linstor-client/models/controller_version.rb +245 -0
  56. data/lib/ruby-linstor-client/models/drbd_proxy_enable.rb +219 -0
  57. data/lib/ruby-linstor-client/models/drbd_proxy_modify.rb +288 -0
  58. data/lib/ruby-linstor-client/models/drbd_resource.rb +276 -0
  59. data/lib/ruby-linstor-client/models/drbd_resource_definition_layer.rb +283 -0
  60. data/lib/ruby-linstor-client/models/drbd_volume.rb +285 -0
  61. data/lib/ruby-linstor-client/models/drbd_volume_definition.rb +236 -0
  62. data/lib/ruby-linstor-client/models/error_report.rb +252 -0
  63. data/lib/ruby-linstor-client/models/key_value_store.rb +231 -0
  64. data/lib/ruby-linstor-client/models/key_value_store_modify.rb +243 -0
  65. data/lib/ruby-linstor-client/models/layer_type.rb +40 -0
  66. data/lib/ruby-linstor-client/models/luks_resource.rb +220 -0
  67. data/lib/ruby-linstor-client/models/luks_volume.rb +275 -0
  68. data/lib/ruby-linstor-client/models/max_volume_sizes.rb +229 -0
  69. data/lib/ruby-linstor-client/models/net_interface.rb +309 -0
  70. data/lib/ruby-linstor-client/models/node.rb +381 -0
  71. data/lib/ruby-linstor-client/models/node_modify.rb +252 -0
  72. data/lib/ruby-linstor-client/models/nvme_resource.rb +220 -0
  73. data/lib/ruby-linstor-client/models/nvme_volume.rb +266 -0
  74. data/lib/ruby-linstor-client/models/one_of_drbd_resource_definition_layer.rb +7 -0
  75. data/lib/ruby-linstor-client/models/one_of_drbd_volume_definition.rb +7 -0
  76. data/lib/ruby-linstor-client/models/one_of_drbd_volume_luks_volume_storage_nvme_volme_writecache_volume.rb +11 -0
  77. data/lib/ruby-linstor-client/models/pass_phrase_create.rb +227 -0
  78. data/lib/ruby-linstor-client/models/physical_storage.rb +238 -0
  79. data/lib/ruby-linstor-client/models/physical_storage_create.rb +337 -0
  80. data/lib/ruby-linstor-client/models/physical_storage_device.rb +245 -0
  81. data/lib/ruby-linstor-client/models/physical_storage_storage_pool_create.rb +232 -0
  82. data/lib/ruby-linstor-client/models/provider_kind.rb +43 -0
  83. data/lib/ruby-linstor-client/models/resource.rb +278 -0
  84. data/lib/ruby-linstor-client/models/resource_connection.rb +261 -0
  85. data/lib/ruby-linstor-client/models/resource_connection_modify.rb +243 -0
  86. data/lib/ruby-linstor-client/models/resource_create.rb +238 -0
  87. data/lib/ruby-linstor-client/models/resource_definition.rb +295 -0
  88. data/lib/ruby-linstor-client/models/resource_definition_create.rb +262 -0
  89. data/lib/ruby-linstor-client/models/resource_definition_layer.rb +228 -0
  90. data/lib/ruby-linstor-client/models/resource_definition_modify.rb +274 -0
  91. data/lib/ruby-linstor-client/models/resource_group.rb +262 -0
  92. data/lib/ruby-linstor-client/models/resource_group_modify.rb +261 -0
  93. data/lib/ruby-linstor-client/models/resource_group_spawn.rb +255 -0
  94. data/lib/ruby-linstor-client/models/resource_layer.rb +283 -0
  95. data/lib/ruby-linstor-client/models/resource_modify.rb +243 -0
  96. data/lib/ruby-linstor-client/models/resource_state.rb +218 -0
  97. data/lib/ruby-linstor-client/models/resource_with_volumes.rb +297 -0
  98. data/lib/ruby-linstor-client/models/resource_with_volumes_all_of.rb +220 -0
  99. data/lib/ruby-linstor-client/models/snapshot.rb +282 -0
  100. data/lib/ruby-linstor-client/models/snapshot_restore.rb +236 -0
  101. data/lib/ruby-linstor-client/models/snapshot_volume_definition.rb +228 -0
  102. data/lib/ruby-linstor-client/models/storage_pool.rb +333 -0
  103. data/lib/ruby-linstor-client/models/storage_pool_definition.rb +230 -0
  104. data/lib/ruby-linstor-client/models/storage_pool_definition_modify.rb +243 -0
  105. data/lib/ruby-linstor-client/models/storage_resource.rb +220 -0
  106. data/lib/ruby-linstor-client/models/storage_volume.rb +256 -0
  107. data/lib/ruby-linstor-client/models/volume.rb +327 -0
  108. data/lib/ruby-linstor-client/models/volume_definition.rb +277 -0
  109. data/lib/ruby-linstor-client/models/volume_definition_create.rb +232 -0
  110. data/lib/ruby-linstor-client/models/volume_definition_layer.rb +233 -0
  111. data/lib/ruby-linstor-client/models/volume_definition_modify.rb +264 -0
  112. data/lib/ruby-linstor-client/models/volume_group.rb +251 -0
  113. data/lib/ruby-linstor-client/models/volume_group_modify.rb +255 -0
  114. data/lib/ruby-linstor-client/models/volume_layer.rb +228 -0
  115. data/lib/ruby-linstor-client/models/volume_modify.rb +243 -0
  116. data/lib/ruby-linstor-client/models/volume_state.rb +218 -0
  117. data/lib/ruby-linstor-client/models/writecache_resource.rb +220 -0
  118. data/lib/ruby-linstor-client/models/writecache_volume.rb +266 -0
  119. data/lib/ruby-linstor-client/version.rb +15 -0
  120. data/lib/ruby-linstor-client.rb +109 -0
  121. data/pkg/ruby-linstor-client-1.0.0.gem +0 -0
  122. data/ruby-linstor-client.gemspec +39 -0
  123. data/spec/api/developers_api_spec.rb +1116 -0
  124. data/spec/api_client_spec.rb +188 -0
  125. data/spec/configuration_spec.rb +42 -0
  126. data/spec/models/api_call_rc_spec.rb +70 -0
  127. data/spec/models/auto_place_request_spec.rb +46 -0
  128. data/spec/models/auto_select_filter_spec.rb +82 -0
  129. data/spec/models/candidate_spec.rb +52 -0
  130. data/spec/models/controller_props_modify_spec.rb +46 -0
  131. data/spec/models/controller_version_spec.rb +52 -0
  132. data/spec/models/drbd_proxy_enable_spec.rb +34 -0
  133. data/spec/models/drbd_proxy_modify_spec.rb +56 -0
  134. data/spec/models/drbd_resource_definition_layer_spec.rb +76 -0
  135. data/spec/models/drbd_resource_spec.rb +70 -0
  136. data/spec/models/drbd_volume_definition_spec.rb +46 -0
  137. data/spec/models/drbd_volume_spec.rb +76 -0
  138. data/spec/models/error_report_spec.rb +52 -0
  139. data/spec/models/key_value_store_modify_spec.rb +46 -0
  140. data/spec/models/key_value_store_spec.rb +40 -0
  141. data/spec/models/layer_type_spec.rb +28 -0
  142. data/spec/models/luks_resource_spec.rb +34 -0
  143. data/spec/models/luks_volume_spec.rb +70 -0
  144. data/spec/models/max_volume_sizes_spec.rb +40 -0
  145. data/spec/models/net_interface_spec.rb +68 -0
  146. data/spec/models/node_modify_spec.rb +52 -0
  147. data/spec/models/node_spec.rb +102 -0
  148. data/spec/models/nvme_resource_spec.rb +34 -0
  149. data/spec/models/nvme_volume_spec.rb +64 -0
  150. data/spec/models/pass_phrase_create_spec.rb +40 -0
  151. data/spec/models/physical_storage_create_spec.rb +80 -0
  152. data/spec/models/physical_storage_device_spec.rb +52 -0
  153. data/spec/models/physical_storage_spec.rb +46 -0
  154. data/spec/models/physical_storage_storage_pool_create_spec.rb +40 -0
  155. data/spec/models/provider_kind_spec.rb +28 -0
  156. data/spec/models/resource_connection_modify_spec.rb +46 -0
  157. data/spec/models/resource_connection_spec.rb +58 -0
  158. data/spec/models/resource_create_spec.rb +46 -0
  159. data/spec/models/resource_definition_create_spec.rb +58 -0
  160. data/spec/models/resource_definition_layer_spec.rb +40 -0
  161. data/spec/models/resource_definition_modify_spec.rb +64 -0
  162. data/spec/models/resource_definition_spec.rb +76 -0
  163. data/spec/models/resource_group_modify_spec.rb +58 -0
  164. data/spec/models/resource_group_spawn_spec.rb +52 -0
  165. data/spec/models/resource_group_spec.rb +58 -0
  166. data/spec/models/resource_layer_spec.rb +76 -0
  167. data/spec/models/resource_modify_spec.rb +46 -0
  168. data/spec/models/resource_spec.rb +70 -0
  169. data/spec/models/resource_state_spec.rb +34 -0
  170. data/spec/models/resource_with_volumes_all_of_spec.rb +34 -0
  171. data/spec/models/resource_with_volumes_spec.rb +76 -0
  172. data/spec/models/snapshot_restore_spec.rb +40 -0
  173. data/spec/models/snapshot_spec.rb +70 -0
  174. data/spec/models/snapshot_volume_definition_spec.rb +40 -0
  175. data/spec/models/storage_pool_definition_modify_spec.rb +46 -0
  176. data/spec/models/storage_pool_definition_spec.rb +40 -0
  177. data/spec/models/storage_pool_spec.rb +94 -0
  178. data/spec/models/storage_resource_spec.rb +34 -0
  179. data/spec/models/storage_volume_spec.rb +58 -0
  180. data/spec/models/volume_definition_create_spec.rb +40 -0
  181. data/spec/models/volume_definition_layer_spec.rb +40 -0
  182. data/spec/models/volume_definition_modify_spec.rb +58 -0
  183. data/spec/models/volume_definition_spec.rb +64 -0
  184. data/spec/models/volume_group_modify_spec.rb +52 -0
  185. data/spec/models/volume_group_spec.rb +52 -0
  186. data/spec/models/volume_layer_spec.rb +40 -0
  187. data/spec/models/volume_modify_spec.rb +46 -0
  188. data/spec/models/volume_spec.rb +100 -0
  189. data/spec/models/volume_state_spec.rb +34 -0
  190. data/spec/models/writecache_resource_spec.rb +34 -0
  191. data/spec/models/writecache_volume_spec.rb +64 -0
  192. data/spec/spec_helper.rb +111 -0
  193. metadata +344 -0
@@ -0,0 +1,385 @@
1
+ =begin
2
+ {{> api_info}}
3
+ =end
4
+
5
+ module {{moduleName}}
6
+ class Configuration
7
+ # Defines url scheme
8
+ attr_accessor :scheme
9
+
10
+ # Defines url host
11
+ attr_accessor :host
12
+
13
+ # Defines url base path
14
+ attr_accessor :base_path
15
+
16
+ # Define server configuration index
17
+ attr_accessor :server_index
18
+
19
+ # Define server operation configuration index
20
+ attr_accessor :server_operation_index
21
+
22
+ # Default server variables
23
+ attr_accessor :server_variables
24
+
25
+ # Default server operation variables
26
+ attr_accessor :server_operation_variables
27
+
28
+ # Defines API keys used with API Key authentications.
29
+ #
30
+ # @return [Hash] key: parameter name, value: parameter value (API key)
31
+ #
32
+ # @example parameter name is "api_key", API key is "xxx" (e.g. "api_key=xxx" in query string)
33
+ # config.api_key['api_key'] = 'xxx'
34
+ attr_accessor :api_key
35
+
36
+ # Defines API key prefixes used with API Key authentications.
37
+ #
38
+ # @return [Hash] key: parameter name, value: API key prefix
39
+ #
40
+ # @example parameter name is "Authorization", API key prefix is "Token" (e.g. "Authorization: Token xxx" in headers)
41
+ # config.api_key_prefix['api_key'] = 'Token'
42
+ attr_accessor :api_key_prefix
43
+
44
+ # Defines the username used with HTTP basic authentication.
45
+ #
46
+ # @return [String]
47
+ attr_accessor :username
48
+
49
+ # Defines the password used with HTTP basic authentication.
50
+ #
51
+ # @return [String]
52
+ attr_accessor :password
53
+
54
+ # Defines the access token (Bearer) used with OAuth2.
55
+ attr_accessor :access_token
56
+
57
+ # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
58
+ # details will be logged with `logger.debug` (see the `logger` attribute).
59
+ # Default to false.
60
+ #
61
+ # @return [true, false]
62
+ attr_accessor :debugging
63
+
64
+ # Defines the logger used for debugging.
65
+ # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
66
+ #
67
+ # @return [#debug]
68
+ attr_accessor :logger
69
+
70
+ # Defines the temporary folder to store downloaded files
71
+ # (for API endpoints that have file response).
72
+ # Default to use `Tempfile`.
73
+ #
74
+ # @return [String]
75
+ attr_accessor :temp_folder_path
76
+
77
+ # The time limit for HTTP request in seconds.
78
+ # Default to 0 (never times out).
79
+ attr_accessor :timeout
80
+
81
+ # Set this to false to skip client side validation in the operation.
82
+ # Default to true.
83
+ # @return [true, false]
84
+ attr_accessor :client_side_validation
85
+
86
+ {{^isFaraday}}
87
+ {{> configuration_tls_typhoeus_partial}}
88
+ {{/isFaraday}}
89
+ {{#isFaraday}}
90
+ {{> configuration_tls_faraday_partial}}
91
+ {{/isFaraday}}
92
+ # Set this to customize parameters encoding of array parameter with multi collectionFormat.
93
+ # Default to nil.
94
+ #
95
+ # @see The params_encoding option of Ethon. Related source code:
96
+ # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
97
+ attr_accessor :params_encoding
98
+
99
+ attr_accessor :inject_format
100
+
101
+ attr_accessor :force_ending_format
102
+
103
+ def initialize
104
+ @scheme = '{{scheme}}'
105
+ @host = '{{host}}{{#port}}:{{{.}}}{{/port}}'
106
+ @base_path = '{{contextPath}}'
107
+ @server_index = nil
108
+ @server_operation_index = {}
109
+ @server_variables = {}
110
+ @server_operation_variables = {}
111
+ @api_key = {}
112
+ @api_key_prefix = {}
113
+ @client_side_validation = true
114
+ {{#isFaraday}}
115
+ @ssl_verify = true
116
+ @ssl_verify_mode = nil
117
+ @ssl_ca_file = nil
118
+ @ssl_client_cert = nil
119
+ @ssl_client_key = nil
120
+ @middlewares = []
121
+ @request_middlewares = []
122
+ @response_middlewares = []
123
+ @timeout = 60
124
+ {{/isFaraday}}
125
+ {{^isFaraday}}
126
+ @verify_ssl = true
127
+ @verify_ssl_host = true
128
+ @params_encoding = nil
129
+ @cert_file = nil
130
+ @key_file = nil
131
+ @timeout = 0
132
+ {{/isFaraday}}
133
+ @debugging = false
134
+ @inject_format = false
135
+ @force_ending_format = false
136
+ @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
137
+
138
+ yield(self) if block_given?
139
+ end
140
+
141
+ # The default Configuration object.
142
+ def self.default
143
+ @@default ||= Configuration.new
144
+ end
145
+
146
+ def configure
147
+ yield(self) if block_given?
148
+ end
149
+
150
+ def scheme=(scheme)
151
+ # remove :// from scheme
152
+ @scheme = scheme.sub(/:\/\//, '')
153
+ end
154
+
155
+ def host=(host)
156
+ # remove http(s):// and anything after a slash
157
+ @host = host.sub(/https?:\/\//, '').split('/').first
158
+ end
159
+
160
+ def base_path=(base_path)
161
+ # Add leading and trailing slashes to base_path
162
+ @base_path = "/#{base_path}".gsub(/\/+/, '/')
163
+ @base_path = '' if @base_path == '/'
164
+ end
165
+
166
+ # Returns base URL for specified operation based on server settings
167
+ def base_url(operation = nil)
168
+ index = server_operation_index.fetch(operation, server_index)
169
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
170
+
171
+ server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
172
+ end
173
+
174
+ # Gets API key (with prefix if set).
175
+ # @param [String] param_name the parameter name of API key auth
176
+ def api_key_with_prefix(param_name, param_alias = nil)
177
+ key = @api_key[param_name]
178
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
179
+ if @api_key_prefix[param_name]
180
+ "#{@api_key_prefix[param_name]} #{key}"
181
+ else
182
+ key
183
+ end
184
+ end
185
+
186
+ # Gets Basic Auth token string
187
+ def basic_auth_token
188
+ 'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
189
+ end
190
+
191
+ # Returns Auth Settings hash for api client.
192
+ def auth_settings
193
+ {
194
+ {{#authMethods}}
195
+ {{#isApiKey}}
196
+ '{{name}}' =>
197
+ {
198
+ type: 'api_key',
199
+ in: {{#isKeyInHeader}}'header'{{/isKeyInHeader}}{{#isKeyInQuery}}'query'{{/isKeyInQuery}},
200
+ key: '{{keyParamName}}',
201
+ value: api_key_with_prefix('{{name}}'{{#vendorExtensions.x-auth-id-alias}}, '{{.}}'{{/vendorExtensions.x-auth-id-alias}})
202
+ },
203
+ {{/isApiKey}}
204
+ {{#isBasic}}
205
+ {{#isBasicBasic}}
206
+ '{{name}}' =>
207
+ {
208
+ type: 'basic',
209
+ in: 'header',
210
+ key: 'Authorization',
211
+ value: basic_auth_token
212
+ },
213
+ {{/isBasicBasic}}
214
+ {{#isBasicBearer}}
215
+ '{{name}}' =>
216
+ {
217
+ type: 'bearer',
218
+ in: 'header',
219
+ {{#bearerFormat}}
220
+ format: '{{{.}}}',
221
+ {{/bearerFormat}}
222
+ key: 'Authorization',
223
+ value: "Bearer #{access_token}"
224
+ },
225
+ {{/isBasicBearer}}
226
+ {{/isBasic}}
227
+ {{#isOAuth}}
228
+ '{{name}}' =>
229
+ {
230
+ type: 'oauth2',
231
+ in: 'header',
232
+ key: 'Authorization',
233
+ value: "Bearer #{access_token}"
234
+ },
235
+ {{/isOAuth}}
236
+ {{/authMethods}}
237
+ }
238
+ end
239
+
240
+ # Returns an array of Server setting
241
+ def server_settings
242
+ [
243
+ {{#servers}}
244
+ {
245
+ url: "{{{url}}}",
246
+ description: "{{{description}}}{{^description}}No description provided{{/description}}",
247
+ {{#variables}}
248
+ {{#-first}}
249
+ variables: {
250
+ {{/-first}}
251
+ {{{name}}}: {
252
+ description: "{{{description}}}{{^description}}No description provided{{/description}}",
253
+ default_value: "{{{defaultValue}}}",
254
+ {{#enumValues}}
255
+ {{#-first}}
256
+ enum_values: [
257
+ {{/-first}}
258
+ "{{{.}}}"{{^-last}},{{/-last}}
259
+ {{#-last}}
260
+ ]
261
+ {{/-last}}
262
+ {{/enumValues}}
263
+ }{{^-last}},{{/-last}}
264
+ {{#-last}}
265
+ }
266
+ {{/-last}}
267
+ {{/variables}}
268
+ }{{^-last}},{{/-last}}
269
+ {{/servers}}
270
+ ]
271
+ end
272
+
273
+ def operation_server_settings
274
+ {
275
+ {{#apiInfo}}
276
+ {{#apis}}
277
+ {{#operations}}
278
+ {{#operation}}
279
+ {{#servers}}
280
+ {{#-first}}
281
+ "{{{classname}}}.{{{nickname}}}": [
282
+ {{/-first}}
283
+ {
284
+ url: "{{{url}}}",
285
+ description: "{{{description}}}{{^description}}No description provided{{/description}}",
286
+ {{#variables}}
287
+ {{#-first}}
288
+ variables: {
289
+ {{/-first}}
290
+ {{{name}}}: {
291
+ description: "{{{description}}}{{^description}}No description provided{{/description}}",
292
+ default_value: "{{{defaultValue}}}",
293
+ {{#enumValues}}
294
+ {{#-first}}
295
+ enum_values: [
296
+ {{/-first}}
297
+ "{{{.}}}"{{^-last}},{{/-last}}
298
+ {{#-last}}
299
+ ]
300
+ {{/-last}}
301
+ {{/enumValues}}
302
+ }{{^-last}},{{/-last}}
303
+ {{#-last}}
304
+ }
305
+ {{/-last}}
306
+ {{/variables}}
307
+ }{{^-last}},{{/-last}}
308
+ {{#-last}}
309
+ ],
310
+ {{/-last}}
311
+ {{/servers}}
312
+ {{/operation}}
313
+ {{/operations}}
314
+ {{/apis}}
315
+ {{/apiInfo}}
316
+ }
317
+ end
318
+
319
+ # Returns URL based on server settings
320
+ #
321
+ # @param index array index of the server settings
322
+ # @param variables hash of variable and the corresponding value
323
+ def server_url(index, variables = {}, servers = nil)
324
+ servers = server_settings if servers == nil
325
+
326
+ # check array index out of bound
327
+ if (index < 0 || index >= servers.size)
328
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
329
+ end
330
+
331
+ server = servers[index]
332
+ url = server[:url]
333
+
334
+ return url unless server.key? :variables
335
+
336
+ # go through variable and assign a value
337
+ server[:variables].each do |name, variable|
338
+ if variables.key?(name)
339
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
340
+ url.gsub! "{" + name.to_s + "}", variables[name]
341
+ else
342
+ fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
343
+ end
344
+ else
345
+ # use default value
346
+ url.gsub! "{" + name.to_s + "}", server[:variables][name][:default_value]
347
+ end
348
+ end
349
+
350
+ url
351
+ end
352
+
353
+ {{#isFaraday}}
354
+ # Adds middleware to the stack
355
+ def use(*middleware)
356
+ @middlewares << middleware
357
+ end
358
+
359
+ # Adds request middleware to the stack
360
+ def request(*middleware)
361
+ @request_middlewares << middleware
362
+ end
363
+
364
+ # Adds response middleware to the stack
365
+ def response(*middleware)
366
+ @response_middlewares << middleware
367
+ end
368
+
369
+ # Set up middleware on the connection
370
+ def configure_middleware(connection)
371
+ @middlewares.each do |middleware|
372
+ connection.use(*middleware)
373
+ end
374
+
375
+ @request_middlewares.each do |middleware|
376
+ connection.request(*middleware)
377
+ end
378
+
379
+ @response_middlewares.each do |middleware|
380
+ connection.response(*middleware)
381
+ end
382
+ end
383
+ {{/isFaraday}}
384
+ end
385
+ end
@@ -0,0 +1,34 @@
1
+ =begin
2
+ {{> api_info}}
3
+ =end
4
+
5
+ require 'spec_helper'
6
+
7
+ describe {{moduleName}}::Configuration do
8
+ let(:config) { {{moduleName}}::Configuration.default }
9
+
10
+ before(:each) do
11
+ # uncomment below to setup host and base_path
12
+ # require 'URI'
13
+ # uri = URI.parse("{{{basePath}}}")
14
+ # {{moduleName}}.configure do |c|
15
+ # c.host = uri.host
16
+ # c.base_path = uri.path
17
+ # end
18
+ end
19
+
20
+ describe '#base_url' do
21
+ it 'should have the default value' do
22
+ # uncomment below to test default value of the base path
23
+ # expect(config.base_url).to eq("{{{basePath}}}")
24
+ end
25
+
26
+ it 'should remove trailing slashes' do
27
+ [nil, '', '/', '//'].each do |base_path|
28
+ config.base_path = base_path
29
+ # uncomment below to test trailing slashes
30
+ # expect(config.base_url).to eq("{{{basePath}}}")
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,29 @@
1
+ ### TLS/SSL setting
2
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
3
+ # Default to true.
4
+ #
5
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
6
+ #
7
+ # @return [true, false]
8
+ attr_accessor :ssl_verify
9
+
10
+ ### TLS/SSL setting
11
+ # Any `OpenSSL::SSL::` constant (see https://ruby-doc.org/stdlib-2.5.1/libdoc/openssl/rdoc/OpenSSL/SSL.html)
12
+ #
13
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
14
+ #
15
+ attr_accessor :ssl_verify_mode
16
+
17
+ ### TLS/SSL setting
18
+ # Set this to customize the certificate file to verify the peer.
19
+ #
20
+ # @return [String] the path to the certificate file
21
+ attr_accessor :ssl_ca_file
22
+
23
+ ### TLS/SSL setting
24
+ # Client certificate file (for client certificate)
25
+ attr_accessor :ssl_client_cert
26
+
27
+ ### TLS/SSL setting
28
+ # Client private key file (for client certificate)
29
+ attr_accessor :ssl_client_key
@@ -0,0 +1,34 @@
1
+ ### TLS/SSL setting
2
+ # Set this to false to skip verifying SSL certificate when calling API from https server.
3
+ # Default to true.
4
+ #
5
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
6
+ #
7
+ # @return [true, false]
8
+ attr_accessor :verify_ssl
9
+
10
+ ### TLS/SSL setting
11
+ # Set this to false to skip verifying SSL host name
12
+ # Default to true.
13
+ #
14
+ # @note Do NOT set it to false in production code, otherwise you would face multiple types of cryptographic attacks.
15
+ #
16
+ # @return [true, false]
17
+ attr_accessor :verify_ssl_host
18
+
19
+ ### TLS/SSL setting
20
+ # Set this to customize the certificate file to verify the peer.
21
+ #
22
+ # @return [String] the path to the certificate file
23
+ #
24
+ # @see The `cainfo` option of Typhoeus, `--cert` option of libcurl. Related source code:
25
+ # https://github.com/typhoeus/typhoeus/blob/master/lib/typhoeus/easy_factory.rb#L145
26
+ attr_accessor :ssl_ca_cert
27
+
28
+ ### TLS/SSL setting
29
+ # Client certificate file (for client certificate)
30
+ attr_accessor :cert_file
31
+
32
+ ### TLS/SSL setting
33
+ # Client private key file (for client certificate)
34
+ attr_accessor :key_file
@@ -0,0 +1,53 @@
1
+ =begin
2
+ {{> api_info}}
3
+ =end
4
+
5
+ # Common files
6
+ require '{{gemName}}/api_client'
7
+ require '{{gemName}}/api_error'
8
+ require '{{gemName}}/version'
9
+ require '{{gemName}}/configuration'
10
+
11
+ # Models
12
+ {{#models}}
13
+ {{#model}}
14
+ {{^parent}}
15
+ require '{{gemName}}/{{modelPackage}}/{{classFilename}}'
16
+ {{/parent}}
17
+ {{/model}}
18
+ {{/models}}
19
+ {{#models}}
20
+ {{#model}}
21
+ {{#parent}}
22
+ require '{{gemName}}/{{modelPackage}}/{{classFilename}}'
23
+ {{/parent}}
24
+ {{/model}}
25
+ {{/models}}
26
+ require '{{gemName}}/{{modelPackage}}/one_of_drbd_resource_definition_layer'
27
+ require '{{gemName}}/{{modelPackage}}/one_of_drbd_volume_definition'
28
+ require '{{gemName}}/{{modelPackage}}/one_of_drbd_volume_luks_volume_storage_nvme_volme_writecache_volume'
29
+
30
+ # APIs
31
+ {{#apiInfo}}
32
+ {{#apis}}
33
+ require '{{importPath}}'
34
+ {{/apis}}
35
+ {{/apiInfo}}
36
+
37
+ module {{moduleName}}
38
+ class << self
39
+ # Customize default settings for the SDK using block.
40
+ # {{moduleName}}.configure do |config|
41
+ # config.username = "xxx"
42
+ # config.password = "xxx"
43
+ # end
44
+ # If no block given, return the default Configuration object.
45
+ def configure
46
+ if block_given?
47
+ yield(Configuration.default)
48
+ else
49
+ Configuration.default
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,35 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ =begin
4
+ {{> api_info}}
5
+ =end
6
+
7
+ $:.push File.expand_path("../lib", __FILE__)
8
+ require "{{gemName}}/version"
9
+
10
+ Gem::Specification.new do |s|
11
+ s.name = "{{gemName}}{{^gemName}}{{{appName}}}{{/gemName}}"
12
+ s.version = {{moduleName}}::VERSION
13
+ s.platform = Gem::Platform::RUBY
14
+ s.authors = ["{{gemAuthor}}{{^gemAuthor}}OpenAPI-Generator{{/gemAuthor}}"]
15
+ s.email = ["{{gemAuthorEmail}}{{^gemAuthorEmail}}{{infoEmail}}{{/gemAuthorEmail}}"]
16
+ s.homepage = "{{gemHomepage}}{{^gemHomepage}}https://openapi-generator.tech{{/gemHomepage}}"
17
+ s.summary = "{{gemSummary}}{{^gemSummary}}{{{appName}}} Ruby Gem{{/gemSummary}}"
18
+ s.description = "{{gemDescription}}{{^gemDescription}}{{{appDescription}}}{{^appDescription}}{{{appName}}} Ruby Gem{{/appDescription}}{{/gemDescription}}"
19
+ s.license = "{{{gemLicense}}}{{^gemLicense}}Unlicense{{/gemLicense}}"
20
+ s.required_ruby_version = "{{{gemRequiredRubyVersion}}}{{^gemRequiredRubyVersion}}>= 2.4{{/gemRequiredRubyVersion}}"
21
+
22
+ {{#isFaraday}}
23
+ s.add_runtime_dependency 'faraday', '~> 1.0', '>= 1.0.1'
24
+ {{/isFaraday}}
25
+ {{^isFaraday}}
26
+ s.add_runtime_dependency 'typhoeus', '~> 1.0', '>= 1.0.1'
27
+ {{/isFaraday}}
28
+
29
+ s.add_development_dependency 'rspec', '~> 3.6', '>= 3.6.0'
30
+
31
+ s.files = `find *`.split("\n").uniq.sort.select { |f| !f.empty? }
32
+ s.test_files = `find spec/*`.split("\n")
33
+ s.executables = []
34
+ s.require_paths = ["lib"]
35
+ end
@@ -0,0 +1,57 @@
1
+ #!/bin/sh
2
+ # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
3
+ #
4
+ # Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
5
+
6
+ git_user_id=$1
7
+ git_repo_id=$2
8
+ release_note=$3
9
+ git_host=$4
10
+
11
+ if [ "$git_host" = "" ]; then
12
+ git_host="{{{gitHost}}}"
13
+ echo "[INFO] No command line input provided. Set \$git_host to $git_host"
14
+ fi
15
+
16
+ if [ "$git_user_id" = "" ]; then
17
+ git_user_id="{{{gitUserId}}}"
18
+ echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
19
+ fi
20
+
21
+ if [ "$git_repo_id" = "" ]; then
22
+ git_repo_id="{{{gitRepoId}}}"
23
+ echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
24
+ fi
25
+
26
+ if [ "$release_note" = "" ]; then
27
+ release_note="{{{releaseNote}}}"
28
+ echo "[INFO] No command line input provided. Set \$release_note to $release_note"
29
+ fi
30
+
31
+ # Initialize the local directory as a Git repository
32
+ git init
33
+
34
+ # Adds the files in the local repository and stages them for commit.
35
+ git add .
36
+
37
+ # Commits the tracked changes and prepares them to be pushed to a remote repository.
38
+ git commit -m "$release_note"
39
+
40
+ # Sets the new remote
41
+ git_remote=$(git remote)
42
+ if [ "$git_remote" = "" ]; then # git remote not defined
43
+
44
+ if [ "$GIT_TOKEN" = "" ]; then
45
+ echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
46
+ git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
47
+ else
48
+ git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
49
+ fi
50
+
51
+ fi
52
+
53
+ git pull origin master
54
+
55
+ # Pushes (Forces) the changes in the local repository up to the remote repository
56
+ echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
57
+ git push origin master 2>&1 | grep -v 'To https'
@@ -0,0 +1,39 @@
1
+ # Generated by: https://openapi-generator.tech
2
+ #
3
+
4
+ *.gem
5
+ *.rbc
6
+ /.config
7
+ /coverage/
8
+ /InstalledFiles
9
+ /pkg/
10
+ /spec/reports/
11
+ /spec/examples.txt
12
+ /test/tmp/
13
+ /test/version_tmp/
14
+ /tmp/
15
+
16
+ ## Specific to RubyMotion:
17
+ .dat*
18
+ .repl_history
19
+ build/
20
+
21
+ ## Documentation cache and generated files:
22
+ /.yardoc/
23
+ /_yardoc/
24
+ /doc/
25
+ /rdoc/
26
+
27
+ ## Environment normalization:
28
+ /.bundle/
29
+ /vendor/bundle
30
+ /lib/bundler/man/
31
+
32
+ # for a library or gem, you might want to ignore these files since the code is
33
+ # intended to run in multiple environments; otherwise, check them in:
34
+ # Gemfile.lock
35
+ # .ruby-version
36
+ # .ruby-gemset
37
+
38
+ # unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
39
+ .rvmrc
@@ -0,0 +1,26 @@
1
+ =begin
2
+ {{> api_info}}
3
+ =end
4
+
5
+ require 'date'
6
+ require 'time'
7
+
8
+ module {{moduleName}}
9
+ {{#models}}
10
+ {{#model}}
11
+ {{#isEnum}}
12
+ {{>partial_model_enum_class}}
13
+ {{/isEnum}}
14
+ {{^isEnum}}
15
+ {{#oneOf}}
16
+ {{#-first}}
17
+ {{>partial_oneof_module}}
18
+ {{/-first}}
19
+ {{/oneOf}}
20
+ {{^oneOf}}
21
+ {{>partial_model_generic}}
22
+ {{/oneOf}}
23
+ {{/isEnum}}
24
+ {{/model}}
25
+ {{/models}}
26
+ end