pnap_ip_api 1.1.5 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d8b714b22829f98f2200ef0a7ddd8824fd6b0308c759dea8535aebae3c6db55a
4
- data.tar.gz: bda64e5f5d18d8d8a3dbfad56c0dc05378bacfbeb5a4d8beead5489c2fae2ad7
3
+ metadata.gz: 286bf8a5fe8b5059e9689d8f445019052990a291374ab763d72b7ba583e06bfe
4
+ data.tar.gz: 4d903469ced8b007026170e198802a4eb4593972c2cd1f54bd9976ac24093ec0
5
5
  SHA512:
6
- metadata.gz: '09b6fcb9b9686d3fae42c7417a5492382c6de77b3c15e5af23ffa24b1d850cd2a973dec6294994854c6603bc86e15a48c2b0d44c448d5ea86f1ac75f84f3ae31'
7
- data.tar.gz: de6858a830b34cad8dfe9bdce6f2024a911f8174548a7e3d52aced61cc55e746f0bb3f6c144a960ae587f363ed95322a3bda1e2c8e09aa577aaa5af9f337ec8d
6
+ metadata.gz: 66647d812e58603d8b9c19e7b0e86e19474bfe00a9ce43e75dff7b6cacf7b0e4fd60cf8ec7d371e0ed041794d9a46667ac5108dab40e2c5dfe853cd2f6d0225e
7
+ data.tar.gz: b074dc0f90fe64f2c5a41161904682682aafd302ce9b6ca86790adf700e948b521f18e2d89d44379c0bc2ae1acc216aa8ff5949e12ebeb478ba8d1efa772e688
data/README.md CHANGED
@@ -74,6 +74,8 @@ require 'pnap_ip_api'
74
74
  IpApi.configure do |config|
75
75
  # Configure OAuth2 access token for authorization: OAuth2
76
76
  config.access_token = 'YOUR ACCESS TOKEN'
77
+ # Configure a proc to get access tokens in lieu of the static access_token configuration
78
+ config.access_token_getter = -> { 'YOUR TOKEN GETTER PROC' }
77
79
  end
78
80
 
79
81
  api_instance = IpApi::IPBlocksApi.new
@@ -144,6 +146,7 @@ Class | Method | HTTP request | Description
144
146
  ## Documentation for Authorization
145
147
 
146
148
 
149
+ Authentication schemes defined for the API:
147
150
  ### OAuth2
148
151
 
149
152
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.5
1
+ 2.0.0
data/docs/IPBlocksApi.md CHANGED
@@ -223,7 +223,7 @@ end
223
223
 
224
224
  ## ip_blocks_ip_block_id_patch
225
225
 
226
- > <IpBlock> ip_blocks_ip_block_id_patch(ip_block_id, opts)
226
+ > <IpBlock> ip_blocks_ip_block_id_patch(ip_block_id, ip_block_patch)
227
227
 
228
228
  Update IP block.
229
229
 
@@ -242,13 +242,11 @@ end
242
242
 
243
243
  api_instance = IpApi::IPBlocksApi.new
244
244
  ip_block_id = '6047127fed34ecc3ba8402d2' # String | The IP Block identifier.
245
- opts = {
246
- ip_block_patch: IpApi::IpBlockPatch.new # IpBlockPatch |
247
- }
245
+ ip_block_patch = IpApi::IpBlockPatch.new # IpBlockPatch |
248
246
 
249
247
  begin
250
248
  # Update IP block.
251
- result = api_instance.ip_blocks_ip_block_id_patch(ip_block_id, opts)
249
+ result = api_instance.ip_blocks_ip_block_id_patch(ip_block_id, ip_block_patch)
252
250
  p result
253
251
  rescue IpApi::ApiError => e
254
252
  puts "Error when calling IPBlocksApi->ip_blocks_ip_block_id_patch: #{e}"
@@ -259,12 +257,12 @@ end
259
257
 
260
258
  This returns an Array which contains the response data, status code and headers.
261
259
 
262
- > <Array(<IpBlock>, Integer, Hash)> ip_blocks_ip_block_id_patch_with_http_info(ip_block_id, opts)
260
+ > <Array(<IpBlock>, Integer, Hash)> ip_blocks_ip_block_id_patch_with_http_info(ip_block_id, ip_block_patch)
263
261
 
264
262
  ```ruby
265
263
  begin
266
264
  # Update IP block.
267
- data, status_code, headers = api_instance.ip_blocks_ip_block_id_patch_with_http_info(ip_block_id, opts)
265
+ data, status_code, headers = api_instance.ip_blocks_ip_block_id_patch_with_http_info(ip_block_id, ip_block_patch)
268
266
  p status_code # => 2xx
269
267
  p headers # => { ... }
270
268
  p data # => <IpBlock>
@@ -278,7 +276,7 @@ end
278
276
  | Name | Type | Description | Notes |
279
277
  | ---- | ---- | ----------- | ----- |
280
278
  | **ip_block_id** | **String** | The IP Block identifier. | |
281
- | **ip_block_patch** | [**IpBlockPatch**](IpBlockPatch.md) | | [optional] |
279
+ | **ip_block_patch** | [**IpBlockPatch**](IpBlockPatch.md) | | |
282
280
 
283
281
  ### Return type
284
282
 
@@ -296,7 +294,7 @@ end
296
294
 
297
295
  ## ip_blocks_ip_block_id_tags_put
298
296
 
299
- > <IpBlock> ip_blocks_ip_block_id_tags_put(ip_block_id, opts)
297
+ > <IpBlock> ip_blocks_ip_block_id_tags_put(ip_block_id, tag_assignment_request)
300
298
 
301
299
  Overwrite tags assigned for IP Block.
302
300
 
@@ -315,13 +313,11 @@ end
315
313
 
316
314
  api_instance = IpApi::IPBlocksApi.new
317
315
  ip_block_id = '6047127fed34ecc3ba8402d2' # String | The IP Block identifier.
318
- opts = {
319
- tag_assignment_request: [IpApi::TagAssignmentRequest.new({name: 'Environment'})] # Array<TagAssignmentRequest> |
320
- }
316
+ tag_assignment_request = [IpApi::TagAssignmentRequest.new({name: 'Environment'})] # Array<TagAssignmentRequest> |
321
317
 
322
318
  begin
323
319
  # Overwrite tags assigned for IP Block.
324
- result = api_instance.ip_blocks_ip_block_id_tags_put(ip_block_id, opts)
320
+ result = api_instance.ip_blocks_ip_block_id_tags_put(ip_block_id, tag_assignment_request)
325
321
  p result
326
322
  rescue IpApi::ApiError => e
327
323
  puts "Error when calling IPBlocksApi->ip_blocks_ip_block_id_tags_put: #{e}"
@@ -332,12 +328,12 @@ end
332
328
 
333
329
  This returns an Array which contains the response data, status code and headers.
334
330
 
335
- > <Array(<IpBlock>, Integer, Hash)> ip_blocks_ip_block_id_tags_put_with_http_info(ip_block_id, opts)
331
+ > <Array(<IpBlock>, Integer, Hash)> ip_blocks_ip_block_id_tags_put_with_http_info(ip_block_id, tag_assignment_request)
336
332
 
337
333
  ```ruby
338
334
  begin
339
335
  # Overwrite tags assigned for IP Block.
340
- data, status_code, headers = api_instance.ip_blocks_ip_block_id_tags_put_with_http_info(ip_block_id, opts)
336
+ data, status_code, headers = api_instance.ip_blocks_ip_block_id_tags_put_with_http_info(ip_block_id, tag_assignment_request)
341
337
  p status_code # => 2xx
342
338
  p headers # => { ... }
343
339
  p data # => <IpBlock>
@@ -351,7 +347,7 @@ end
351
347
  | Name | Type | Description | Notes |
352
348
  | ---- | ---- | ----------- | ----- |
353
349
  | **ip_block_id** | **String** | The IP Block identifier. | |
354
- | **tag_assignment_request** | [**Array&lt;TagAssignmentRequest&gt;**](TagAssignmentRequest.md) | | [optional] |
350
+ | **tag_assignment_request** | [**Array&lt;TagAssignmentRequest&gt;**](TagAssignmentRequest.md) | | |
355
351
 
356
352
  ### Return type
357
353
 
@@ -369,7 +365,7 @@ end
369
365
 
370
366
  ## ip_blocks_post
371
367
 
372
- > <IpBlock> ip_blocks_post(opts)
368
+ > <IpBlock> ip_blocks_post(ip_block_create)
373
369
 
374
370
  Create an IP Block.
375
371
 
@@ -387,13 +383,11 @@ IpApi.configure do |config|
387
383
  end
388
384
 
389
385
  api_instance = IpApi::IPBlocksApi.new
390
- opts = {
391
- ip_block_create: IpApi::IpBlockCreate.new({location: 'PHX', cidr_block_size: '/30'}) # IpBlockCreate |
392
- }
386
+ ip_block_create = IpApi::IpBlockCreate.new({location: 'PHX', cidr_block_size: '/30'}) # IpBlockCreate |
393
387
 
394
388
  begin
395
389
  # Create an IP Block.
396
- result = api_instance.ip_blocks_post(opts)
390
+ result = api_instance.ip_blocks_post(ip_block_create)
397
391
  p result
398
392
  rescue IpApi::ApiError => e
399
393
  puts "Error when calling IPBlocksApi->ip_blocks_post: #{e}"
@@ -404,12 +398,12 @@ end
404
398
 
405
399
  This returns an Array which contains the response data, status code and headers.
406
400
 
407
- > <Array(<IpBlock>, Integer, Hash)> ip_blocks_post_with_http_info(opts)
401
+ > <Array(<IpBlock>, Integer, Hash)> ip_blocks_post_with_http_info(ip_block_create)
408
402
 
409
403
  ```ruby
410
404
  begin
411
405
  # Create an IP Block.
412
- data, status_code, headers = api_instance.ip_blocks_post_with_http_info(opts)
406
+ data, status_code, headers = api_instance.ip_blocks_post_with_http_info(ip_block_create)
413
407
  p status_code # => 2xx
414
408
  p headers # => { ... }
415
409
  p data # => <IpBlock>
@@ -422,7 +416,7 @@ end
422
416
 
423
417
  | Name | Type | Description | Notes |
424
418
  | ---- | ---- | ----------- | ----- |
425
- | **ip_block_create** | [**IpBlockCreate**](IpBlockCreate.md) | | [optional] |
419
+ | **ip_block_create** | [**IpBlockCreate**](IpBlockCreate.md) | | |
426
420
 
427
421
  ### Return type
428
422
 
data/docs/IpBlock.md CHANGED
@@ -8,7 +8,7 @@
8
8
  | **location** | **String** | IP Block location ID. Currently this field should be set to &#x60;PHX&#x60;, &#x60;ASH&#x60;, &#x60;SGP&#x60;, &#x60;NLD&#x60;, &#x60;CHI&#x60;, &#x60;SEA&#x60; or &#x60;AUS&#x60;. | |
9
9
  | **cidr_block_size** | **String** | CIDR IP Block Size. Currently this field should be set to either &#x60;/31&#x60;, &#x60;/30&#x60;, &#x60;/29&#x60;, &#x60;/28&#x60;, &#x60;/27&#x60;, &#x60;/26&#x60;, &#x60;/25&#x60;, &#x60;/24&#x60;, &#x60;/23&#x60; or &#x60;/22&#x60;. | |
10
10
  | **cidr** | **String** | The IP Block in CIDR notation. | |
11
- | **status** | **String** | The status of the IP Block. | |
11
+ | **status** | **String** | The status of the IP Block. Can have one of the following values: &#x60;creating&#x60; , &#x60;assigning&#x60; , &#x60;error assigning&#x60; , &#x60;assigned&#x60; , &#x60;unassigning&#x60; , &#x60;error unassigning&#x60; or &#x60;unassigned&#x60;. | |
12
12
  | **assigned_resource_id** | **String** | ID of the resource assigned to the IP Block. | [optional] |
13
13
  | **assigned_resource_type** | **String** | Type of the resource assigned to the IP Block. | [optional] |
14
14
  | **description** | **String** | The description of the IP Block. | [optional] |
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 1.0
7
7
  Contact: support@phoenixnap.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0
9
+ OpenAPI Generator version: 7.2.0
10
10
 
11
11
  =end
12
12
 
@@ -208,21 +208,21 @@ module IpApi
208
208
  # Update IP block.
209
209
  # Update IP Block's details.
210
210
  # @param ip_block_id [String] The IP Block identifier.
211
+ # @param ip_block_patch [IpBlockPatch]
211
212
  # @param [Hash] opts the optional parameters
212
- # @option opts [IpBlockPatch] :ip_block_patch
213
213
  # @return [IpBlock]
214
- def ip_blocks_ip_block_id_patch(ip_block_id, opts = {})
215
- data, _status_code, _headers = ip_blocks_ip_block_id_patch_with_http_info(ip_block_id, opts)
214
+ def ip_blocks_ip_block_id_patch(ip_block_id, ip_block_patch, opts = {})
215
+ data, _status_code, _headers = ip_blocks_ip_block_id_patch_with_http_info(ip_block_id, ip_block_patch, opts)
216
216
  data
217
217
  end
218
218
 
219
219
  # Update IP block.
220
220
  # Update IP Block&#39;s details.
221
221
  # @param ip_block_id [String] The IP Block identifier.
222
+ # @param ip_block_patch [IpBlockPatch]
222
223
  # @param [Hash] opts the optional parameters
223
- # @option opts [IpBlockPatch] :ip_block_patch
224
224
  # @return [Array<(IpBlock, Integer, Hash)>] IpBlock data, response status code and response headers
225
- def ip_blocks_ip_block_id_patch_with_http_info(ip_block_id, opts = {})
225
+ def ip_blocks_ip_block_id_patch_with_http_info(ip_block_id, ip_block_patch, opts = {})
226
226
  if @api_client.config.debugging
227
227
  @api_client.config.logger.debug 'Calling API: IPBlocksApi.ip_blocks_ip_block_id_patch ...'
228
228
  end
@@ -230,6 +230,10 @@ module IpApi
230
230
  if @api_client.config.client_side_validation && ip_block_id.nil?
231
231
  fail ArgumentError, "Missing the required parameter 'ip_block_id' when calling IPBlocksApi.ip_blocks_ip_block_id_patch"
232
232
  end
233
+ # verify the required parameter 'ip_block_patch' is set
234
+ if @api_client.config.client_side_validation && ip_block_patch.nil?
235
+ fail ArgumentError, "Missing the required parameter 'ip_block_patch' when calling IPBlocksApi.ip_blocks_ip_block_id_patch"
236
+ end
233
237
  # resource path
234
238
  local_var_path = '/ip-blocks/{ipBlockId}'.sub('{' + 'ipBlockId' + '}', CGI.escape(ip_block_id.to_s))
235
239
 
@@ -250,7 +254,7 @@ module IpApi
250
254
  form_params = opts[:form_params] || {}
251
255
 
252
256
  # http body (model)
253
- post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'ip_block_patch'])
257
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(ip_block_patch)
254
258
 
255
259
  # return_type
256
260
  return_type = opts[:debug_return_type] || 'IpBlock'
@@ -278,21 +282,21 @@ module IpApi
278
282
  # Overwrite tags assigned for IP Block.
279
283
  # Overwrites tags assigned for IP Block and unassigns any tags not part of the request.
280
284
  # @param ip_block_id [String] The IP Block identifier.
285
+ # @param tag_assignment_request [Array<TagAssignmentRequest>]
281
286
  # @param [Hash] opts the optional parameters
282
- # @option opts [Array<TagAssignmentRequest>] :tag_assignment_request
283
287
  # @return [IpBlock]
284
- def ip_blocks_ip_block_id_tags_put(ip_block_id, opts = {})
285
- data, _status_code, _headers = ip_blocks_ip_block_id_tags_put_with_http_info(ip_block_id, opts)
288
+ def ip_blocks_ip_block_id_tags_put(ip_block_id, tag_assignment_request, opts = {})
289
+ data, _status_code, _headers = ip_blocks_ip_block_id_tags_put_with_http_info(ip_block_id, tag_assignment_request, opts)
286
290
  data
287
291
  end
288
292
 
289
293
  # Overwrite tags assigned for IP Block.
290
294
  # Overwrites tags assigned for IP Block and unassigns any tags not part of the request.
291
295
  # @param ip_block_id [String] The IP Block identifier.
296
+ # @param tag_assignment_request [Array<TagAssignmentRequest>]
292
297
  # @param [Hash] opts the optional parameters
293
- # @option opts [Array<TagAssignmentRequest>] :tag_assignment_request
294
298
  # @return [Array<(IpBlock, Integer, Hash)>] IpBlock data, response status code and response headers
295
- def ip_blocks_ip_block_id_tags_put_with_http_info(ip_block_id, opts = {})
299
+ def ip_blocks_ip_block_id_tags_put_with_http_info(ip_block_id, tag_assignment_request, opts = {})
296
300
  if @api_client.config.debugging
297
301
  @api_client.config.logger.debug 'Calling API: IPBlocksApi.ip_blocks_ip_block_id_tags_put ...'
298
302
  end
@@ -300,6 +304,10 @@ module IpApi
300
304
  if @api_client.config.client_side_validation && ip_block_id.nil?
301
305
  fail ArgumentError, "Missing the required parameter 'ip_block_id' when calling IPBlocksApi.ip_blocks_ip_block_id_tags_put"
302
306
  end
307
+ # verify the required parameter 'tag_assignment_request' is set
308
+ if @api_client.config.client_side_validation && tag_assignment_request.nil?
309
+ fail ArgumentError, "Missing the required parameter 'tag_assignment_request' when calling IPBlocksApi.ip_blocks_ip_block_id_tags_put"
310
+ end
303
311
  # resource path
304
312
  local_var_path = '/ip-blocks/{ipBlockId}/tags'.sub('{' + 'ipBlockId' + '}', CGI.escape(ip_block_id.to_s))
305
313
 
@@ -320,7 +328,7 @@ module IpApi
320
328
  form_params = opts[:form_params] || {}
321
329
 
322
330
  # http body (model)
323
- post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'tag_assignment_request'])
331
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(tag_assignment_request)
324
332
 
325
333
  # return_type
326
334
  return_type = opts[:debug_return_type] || 'IpBlock'
@@ -347,23 +355,27 @@ module IpApi
347
355
 
348
356
  # Create an IP Block.
349
357
  # Request an IP Block. An IP Block is a set of contiguous IPs that can be assigned to other resources such as servers.
358
+ # @param ip_block_create [IpBlockCreate]
350
359
  # @param [Hash] opts the optional parameters
351
- # @option opts [IpBlockCreate] :ip_block_create
352
360
  # @return [IpBlock]
353
- def ip_blocks_post(opts = {})
354
- data, _status_code, _headers = ip_blocks_post_with_http_info(opts)
361
+ def ip_blocks_post(ip_block_create, opts = {})
362
+ data, _status_code, _headers = ip_blocks_post_with_http_info(ip_block_create, opts)
355
363
  data
356
364
  end
357
365
 
358
366
  # Create an IP Block.
359
367
  # Request an IP Block. An IP Block is a set of contiguous IPs that can be assigned to other resources such as servers.
368
+ # @param ip_block_create [IpBlockCreate]
360
369
  # @param [Hash] opts the optional parameters
361
- # @option opts [IpBlockCreate] :ip_block_create
362
370
  # @return [Array<(IpBlock, Integer, Hash)>] IpBlock data, response status code and response headers
363
- def ip_blocks_post_with_http_info(opts = {})
371
+ def ip_blocks_post_with_http_info(ip_block_create, opts = {})
364
372
  if @api_client.config.debugging
365
373
  @api_client.config.logger.debug 'Calling API: IPBlocksApi.ip_blocks_post ...'
366
374
  end
375
+ # verify the required parameter 'ip_block_create' is set
376
+ if @api_client.config.client_side_validation && ip_block_create.nil?
377
+ fail ArgumentError, "Missing the required parameter 'ip_block_create' when calling IPBlocksApi.ip_blocks_post"
378
+ end
367
379
  # resource path
368
380
  local_var_path = '/ip-blocks'
369
381
 
@@ -384,7 +396,7 @@ module IpApi
384
396
  form_params = opts[:form_params] || {}
385
397
 
386
398
  # http body (model)
387
- post_body = opts[:debug_body] || @api_client.object_to_http_body(opts[:'ip_block_create'])
399
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(ip_block_create)
388
400
 
389
401
  # return_type
390
402
  return_type = opts[:debug_return_type] || 'IpBlock'
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 1.0
7
7
  Contact: support@phoenixnap.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0
9
+ OpenAPI Generator version: 7.2.0
10
10
 
11
11
  =end
12
12
 
@@ -17,6 +17,7 @@ require 'tempfile'
17
17
  require 'time'
18
18
  require 'typhoeus'
19
19
 
20
+
20
21
  module IpApi
21
22
  class ApiClient
22
23
  # The Configuration object holding settings to be used in the API client.
@@ -31,6 +32,7 @@ module IpApi
31
32
  # @option config [Configuration] Configuration for initializing the object, default to Configuration.default
32
33
  def initialize(config = Configuration.default)
33
34
  @config = config
35
+ @config.params_encoding = :multi
34
36
  @user_agent = "PNAP-ruby-sdk-bmc/#{ IpApi::VERSION }"
35
37
  @powered_by = "PNAP-ruby-sdk-bmc/#{ IpApi::VERSION }"
36
38
  @default_headers = {
@@ -47,9 +49,10 @@ module IpApi
47
49
  # Call an API with given options.
48
50
  #
49
51
  # @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
50
- # the data deserialized from response body (could be nil), response status code and response headers.
52
+ # the data deserialized from response body (may be a Tempfile or nil), response status code and response headers.
51
53
  def call_api(http_method, path, opts = {})
52
54
  request = build_request(http_method, path, opts)
55
+ tempfile = download_file(request) if opts[:return_type] == 'File'
53
56
  response = request.run
54
57
 
55
58
  if @config.debugging
@@ -71,7 +74,9 @@ module IpApi
71
74
  end
72
75
  end
73
76
 
74
- if opts[:return_type]
77
+ if opts[:return_type] == 'File'
78
+ data = tempfile
79
+ elsif opts[:return_type]
75
80
  data = deserialize(response, opts[:return_type])
76
81
  else
77
82
  data = nil
@@ -127,9 +132,7 @@ module IpApi
127
132
  end
128
133
  end
129
134
 
130
- request = Typhoeus::Request.new(url, req_opts)
131
- download_file(request) if opts[:return_type] == 'File'
132
- request
135
+ Typhoeus::Request.new(url, req_opts)
133
136
  end
134
137
 
135
138
  # Builds the HTTP request body
@@ -167,6 +170,8 @@ module IpApi
167
170
  # process can use.
168
171
  #
169
172
  # @see Configuration#temp_folder_path
173
+ #
174
+ # @return [Tempfile] the tempfile generated
170
175
  def download_file(request)
171
176
  tempfile = nil
172
177
  encoding = nil
@@ -181,21 +186,24 @@ module IpApi
181
186
  prefix = prefix + '-' unless prefix.end_with?('-')
182
187
  encoding = response.body.encoding
183
188
  tempfile = Tempfile.open(prefix, @config.temp_folder_path, encoding: encoding)
184
- @tempfile = tempfile
185
189
  end
186
190
  request.on_body do |chunk|
187
191
  chunk.force_encoding(encoding)
188
192
  tempfile.write(chunk)
189
193
  end
190
- request.on_complete do |response|
191
- if tempfile
192
- tempfile.close
193
- @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
194
- "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
195
- "will be deleted automatically with GC. It's also recommended to delete the temp file "\
196
- "explicitly with `tempfile.delete`"
197
- end
194
+ # run the request to ensure the tempfile is created successfully before returning it
195
+ request.run
196
+ if tempfile
197
+ tempfile.close
198
+ @config.logger.info "Temp file written to #{tempfile.path}, please copy the file to a proper folder "\
199
+ "with e.g. `FileUtils.cp(tempfile.path, '/new/file/path')` otherwise the temp file "\
200
+ "will be deleted automatically with GC. It's also recommended to delete the temp file "\
201
+ "explicitly with `tempfile.delete`"
202
+ else
203
+ fail ApiError.new("Failed to create the tempfile based on the HTTP response from the server: #{request.inspect}")
198
204
  end
205
+
206
+ tempfile
199
207
  end
200
208
 
201
209
  # Check if the given MIME is a JSON MIME.
@@ -216,15 +224,10 @@ module IpApi
216
224
  # @param [String] return_type some examples: "User", "Array<User>", "Hash<String, Integer>"
217
225
  def deserialize(response, return_type)
218
226
  body = response.body
219
-
220
- # handle file downloading - return the File instance processed in request callbacks
221
- # note that response body is empty when the file is written in chunks in request on_body callback
222
- return @tempfile if return_type == 'File'
223
-
224
227
  return nil if body.nil? || body.empty?
225
228
 
226
229
  # return response body directly for String return type
227
- return body if return_type == 'String'
230
+ return body.to_s if return_type == 'String'
228
231
 
229
232
  # ensuring a default content type
230
233
  content_type = response.headers['Content-Type'] || 'application/json'
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 1.0
7
7
  Contact: support@phoenixnap.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0
9
+ OpenAPI Generator version: 7.2.0
10
10
 
11
11
  =end
12
12
 
@@ -32,6 +32,7 @@ module IpApi
32
32
  end
33
33
  else
34
34
  super arg
35
+ @message = arg
35
36
  end
36
37
  end
37
38
 
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 1.0
7
7
  Contact: support@phoenixnap.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0
9
+ OpenAPI Generator version: 7.2.0
10
10
 
11
11
  =end
12
12
 
@@ -62,6 +62,16 @@ module IpApi
62
62
  # Defines the access token (Bearer) used with OAuth2.
63
63
  attr_accessor :access_token
64
64
 
65
+ # Defines a Proc used to fetch or refresh access tokens (Bearer) used with OAuth2.
66
+ # Overrides the access_token if set
67
+ # @return [Proc]
68
+ attr_accessor :access_token_getter
69
+
70
+ # Set this to return data as binary instead of downloading a temp file. When enabled (set to true)
71
+ # HTTP responses with return type `File` will be returned as a stream of binary data.
72
+ # Default to false.
73
+ attr_accessor :return_binary_data
74
+
65
75
  # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
66
76
  # details will be logged with `logger.debug` (see the `logger` attribute).
67
77
  # Default to false.
@@ -142,7 +152,7 @@ module IpApi
142
152
  @scheme = 'https'
143
153
  @host = 'api.phoenixnap.com'
144
154
  @base_path = '/ips/v1'
145
- @server_index = 0
155
+ @server_index = nil
146
156
  @server_operation_index = {}
147
157
  @server_variables = {}
148
158
  @server_operation_variables = {}
@@ -190,10 +200,12 @@ module IpApi
190
200
 
191
201
  # Returns base URL for specified operation based on server settings
192
202
  def base_url(operation = nil)
193
- index = server_operation_index.fetch(operation, server_index)
194
- return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if index == nil
195
-
196
- server_url(index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
203
+ if operation_server_settings.key?(operation) then
204
+ index = server_operation_index.fetch(operation, server_index)
205
+ server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
206
+ else
207
+ server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil)
208
+ end
197
209
  end
198
210
 
199
211
  # Gets API key (with prefix if set).
@@ -208,6 +220,12 @@ module IpApi
208
220
  end
209
221
  end
210
222
 
223
+ # Gets access_token using access_token_getter or uses the static access_token
224
+ def access_token_with_refresh
225
+ return access_token if access_token_getter.nil?
226
+ access_token_getter.call
227
+ end
228
+
211
229
  # Gets Basic Auth token string
212
230
  def basic_auth_token
213
231
  'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
@@ -221,7 +239,7 @@ module IpApi
221
239
  type: 'oauth2',
222
240
  in: 'header',
223
241
  key: 'Authorization',
224
- value: "Bearer #{access_token}"
242
+ value: "Bearer #{access_token_with_refresh}"
225
243
  },
226
244
  }
227
245
  end
@@ -249,8 +267,8 @@ module IpApi
249
267
  servers = server_settings if servers == nil
250
268
 
251
269
  # check array index out of bound
252
- if (index < 0 || index >= servers.size)
253
- fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
270
+ if (index.nil? || index < 0 || index >= servers.size)
271
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}"
254
272
  end
255
273
 
256
274
  server = servers[index]
@@ -275,5 +293,6 @@ module IpApi
275
293
  url
276
294
  end
277
295
 
296
+
278
297
  end
279
298
  end
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: 1.0
7
7
  Contact: support@phoenixnap.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 6.1.0
9
+ OpenAPI Generator version: 7.2.0
10
10
 
11
11
  =end
12
12
 
@@ -66,16 +66,21 @@ module IpApi
66
66
 
67
67
  if attributes.key?(:'result')
68
68
  self.result = attributes[:'result']
69
+ else
70
+ self.result = nil
69
71
  end
70
72
 
71
73
  if attributes.key?(:'ip_block_id')
72
74
  self.ip_block_id = attributes[:'ip_block_id']
75
+ else
76
+ self.ip_block_id = nil
73
77
  end
74
78
  end
75
79
 
76
80
  # Show invalid properties with the reasons. Usually used together with valid?
77
81
  # @return Array for valid properties with the reasons
78
82
  def list_invalid_properties
83
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
79
84
  invalid_properties = Array.new
80
85
  if @result.nil?
81
86
  invalid_properties.push('invalid value for "result", result cannot be nil.')
@@ -91,6 +96,7 @@ module IpApi
91
96
  # Check to see if the all the properties in the model are valid
92
97
  # @return true if the model is valid
93
98
  def valid?
99
+ warn '[DEPRECATED] the `valid?` method is obsolete'
94
100
  return false if @result.nil?
95
101
  return false if @ip_block_id.nil?
96
102
  true
@@ -121,37 +127,30 @@ module IpApi
121
127
  # @param [Hash] attributes Model attributes in the form of hash
122
128
  # @return [Object] Returns the model itself
123
129
  def self.build_from_hash(attributes)
124
- new.build_from_hash(attributes)
125
- end
126
-
127
- # Builds the object from hash
128
- # @param [Hash] attributes Model attributes in the form of hash
129
- # @return [Object] Returns the model itself
130
- def build_from_hash(attributes)
131
130
  return nil unless attributes.is_a?(Hash)
132
131
  attributes = attributes.transform_keys(&:to_sym)
133
- self.class.openapi_types.each_pair do |key, type|
134
- if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
135
- self.send("#{key}=", nil)
132
+ transformed_hash = {}
133
+ openapi_types.each_pair do |key, type|
134
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
135
+ transformed_hash["#{key}"] = nil
136
136
  elsif type =~ /\AArray<(.*)>/i
137
137
  # check to ensure the input is an array given that the attribute
138
138
  # is documented as an array but the input is not
139
- if attributes[self.class.attribute_map[key]].is_a?(Array)
140
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
139
+ if attributes[attribute_map[key]].is_a?(Array)
140
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
141
141
  end
142
- elsif !attributes[self.class.attribute_map[key]].nil?
143
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
142
+ elsif !attributes[attribute_map[key]].nil?
143
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
144
144
  end
145
145
  end
146
-
147
- self
146
+ new(transformed_hash)
148
147
  end
149
148
 
150
149
  # Deserializes the data based on type
151
150
  # @param string type Data type
152
151
  # @param string value Value to be deserialized
153
152
  # @return [Object] Deserialized data
154
- def _deserialize(type, value)
153
+ def self._deserialize(type, value)
155
154
  case type.to_sym
156
155
  when :Time
157
156
  Time.parse(value)
@@ -186,7 +185,7 @@ module IpApi
186
185
  else # model
187
186
  # models (e.g. Pet) or oneOf
188
187
  klass = IpApi.const_get(type)
189
- klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
188
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
190
189
  end
191
190
  end
192
191