pulp_npm_client 0.1.0a4 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +24 -10
  3. data/docs/AsyncOperationResponse.md +8 -7
  4. data/docs/ContentPackagesApi.md +126 -64
  5. data/docs/ContentSummaryResponse.md +12 -11
  6. data/docs/DistributionsNpmApi.md +362 -93
  7. data/docs/NpmNpmDistribution.md +18 -15
  8. data/docs/NpmNpmDistributionResponse.md +30 -21
  9. data/docs/NpmNpmRemote.md +48 -47
  10. data/docs/NpmNpmRemoteResponse.md +48 -43
  11. data/docs/NpmNpmRemoteResponseHiddenFieldsInner.md +20 -0
  12. data/docs/NpmNpmRepository.md +16 -15
  13. data/docs/NpmNpmRepositoryResponse.md +28 -23
  14. data/docs/NpmPackageResponse.md +22 -17
  15. data/docs/PaginatedRepositoryVersionResponseList.md +14 -13
  16. data/docs/PaginatednpmNpmDistributionResponseList.md +14 -13
  17. data/docs/PaginatednpmNpmRemoteResponseList.md +14 -13
  18. data/docs/PaginatednpmNpmRepositoryResponseList.md +14 -13
  19. data/docs/PaginatednpmPackageResponseList.md +14 -13
  20. data/docs/PatchednpmNpmDistribution.md +18 -15
  21. data/docs/PatchednpmNpmRemote.md +48 -47
  22. data/docs/PatchednpmNpmRepository.md +16 -15
  23. data/docs/PolicyEnum.md +4 -5
  24. data/docs/RemotesNpmApi.md +364 -99
  25. data/docs/Repair.md +8 -7
  26. data/docs/RepositoriesNpmApi.md +429 -110
  27. data/docs/RepositoriesNpmVersionsApi.md +156 -80
  28. data/docs/RepositoryAddRemoveContent.md +12 -11
  29. data/docs/RepositorySyncURL.md +10 -9
  30. data/docs/RepositoryVersionResponse.md +22 -17
  31. data/docs/SetLabel.md +20 -0
  32. data/docs/SetLabelResponse.md +20 -0
  33. data/docs/UnsetLabel.md +18 -0
  34. data/docs/UnsetLabelResponse.md +20 -0
  35. data/lib/pulp_npm_client/api/content_packages_api.rb +72 -44
  36. data/lib/pulp_npm_client/api/distributions_npm_api.rb +243 -47
  37. data/lib/pulp_npm_client/api/remotes_npm_api.rb +247 -57
  38. data/lib/pulp_npm_client/api/repositories_npm_api.rb +283 -55
  39. data/lib/pulp_npm_client/api/repositories_npm_versions_api.rb +71 -52
  40. data/lib/pulp_npm_client/api_client.rb +137 -102
  41. data/lib/pulp_npm_client/api_error.rb +2 -1
  42. data/lib/pulp_npm_client/configuration.rb +163 -22
  43. data/lib/pulp_npm_client/models/async_operation_response.rb +32 -22
  44. data/lib/pulp_npm_client/models/content_summary_response.rb +36 -22
  45. data/lib/pulp_npm_client/models/npm_npm_distribution.rb +51 -25
  46. data/lib/pulp_npm_client/models/npm_npm_distribution_response.rb +83 -27
  47. data/lib/pulp_npm_client/models/npm_npm_remote.rb +61 -25
  48. data/lib/pulp_npm_client/models/npm_npm_remote_response.rb +99 -41
  49. data/lib/pulp_npm_client/models/npm_npm_remote_response_hidden_fields_inner.rb +237 -0
  50. data/lib/pulp_npm_client/models/npm_npm_repository.rb +37 -25
  51. data/lib/pulp_npm_client/models/npm_npm_repository_response.rb +59 -27
  52. data/lib/pulp_npm_client/models/npm_package_response.rb +58 -24
  53. data/lib/pulp_npm_client/models/paginated_repository_version_response_list.rb +44 -22
  54. data/lib/pulp_npm_client/models/paginatednpm_npm_distribution_response_list.rb +44 -22
  55. data/lib/pulp_npm_client/models/paginatednpm_npm_remote_response_list.rb +44 -22
  56. data/lib/pulp_npm_client/models/paginatednpm_npm_repository_response_list.rb +44 -22
  57. data/lib/pulp_npm_client/models/paginatednpm_package_response_list.rb +44 -22
  58. data/lib/pulp_npm_client/models/patchednpm_npm_distribution.rb +57 -27
  59. data/lib/pulp_npm_client/models/patchednpm_npm_remote.rb +67 -27
  60. data/lib/pulp_npm_client/models/patchednpm_npm_repository.rb +40 -26
  61. data/lib/pulp_npm_client/models/policy_enum.rb +8 -4
  62. data/lib/pulp_npm_client/models/repair.rb +30 -22
  63. data/lib/pulp_npm_client/models/repository_add_remove_content.rb +33 -25
  64. data/lib/pulp_npm_client/models/repository_sync_url.rb +30 -22
  65. data/lib/pulp_npm_client/models/repository_version_response.rb +53 -25
  66. data/lib/pulp_npm_client/models/set_label.rb +264 -0
  67. data/lib/pulp_npm_client/models/set_label_response.rb +255 -0
  68. data/lib/pulp_npm_client/models/unset_label.rb +252 -0
  69. data/lib/pulp_npm_client/models/unset_label_response.rb +252 -0
  70. data/lib/pulp_npm_client/version.rb +2 -2
  71. data/lib/pulp_npm_client.rb +6 -3
  72. data/pulp_npm_client.gemspec +10 -7
  73. data/spec/api/content_packages_api_spec.rb +22 -16
  74. data/spec/api/distributions_npm_api_spec.rb +51 -14
  75. data/spec/api/remotes_npm_api_spec.rb +54 -19
  76. data/spec/api/repositories_npm_api_spec.rb +60 -15
  77. data/spec/api/repositories_npm_versions_api_spec.rb +23 -19
  78. data/spec/models/async_operation_response_spec.rb +7 -12
  79. data/spec/models/content_summary_response_spec.rb +9 -14
  80. data/spec/models/npm_npm_distribution_response_spec.rb +38 -19
  81. data/spec/models/npm_npm_distribution_spec.rb +17 -16
  82. data/spec/models/npm_npm_remote_response_hidden_fields_inner_spec.rb +42 -0
  83. data/spec/models/npm_npm_remote_response_spec.rb +42 -35
  84. data/spec/models/npm_npm_remote_spec.rb +27 -32
  85. data/spec/models/npm_npm_repository_response_spec.rb +27 -20
  86. data/spec/models/npm_npm_repository_spec.rb +11 -16
  87. data/spec/models/npm_package_response_spec.rb +24 -17
  88. data/spec/models/paginated_repository_version_response_list_spec.rb +10 -15
  89. data/spec/models/paginatednpm_npm_distribution_response_list_spec.rb +10 -15
  90. data/spec/models/paginatednpm_npm_remote_response_list_spec.rb +10 -15
  91. data/spec/models/paginatednpm_npm_repository_response_list_spec.rb +10 -15
  92. data/spec/models/paginatednpm_package_response_list_spec.rb +10 -15
  93. data/spec/models/patchednpm_npm_distribution_spec.rb +17 -16
  94. data/spec/models/patchednpm_npm_remote_spec.rb +27 -32
  95. data/spec/models/patchednpm_npm_repository_spec.rb +11 -16
  96. data/spec/models/policy_enum_spec.rb +6 -11
  97. data/spec/models/repair_spec.rb +7 -12
  98. data/spec/models/repository_add_remove_content_spec.rb +9 -14
  99. data/spec/models/repository_sync_url_spec.rb +8 -13
  100. data/spec/models/repository_version_response_spec.rb +24 -17
  101. data/spec/models/set_label_response_spec.rb +42 -0
  102. data/spec/models/set_label_spec.rb +42 -0
  103. data/spec/models/unset_label_response_spec.rb +42 -0
  104. data/spec/models/unset_label_spec.rb +36 -0
  105. data/spec/spec_helper.rb +1 -1
  106. metadata +94 -59
  107. data/docs/NpmPackage.md +0 -29
  108. data/docs/PulpNpmPackagesApi.md +0 -60
  109. data/git_push.sh +0 -58
  110. data/lib/pulp_npm_client/api/pulp_npm_packages_api.rb +0 -86
  111. data/lib/pulp_npm_client/models/npm_package.rb +0 -337
  112. data/spec/api/pulp_npm_packages_api_spec.rb +0 -48
  113. data/spec/api_client_spec.rb +0 -188
  114. data/spec/configuration_spec.rb +0 -42
  115. data/spec/models/npm_package_spec.rb +0 -77
@@ -6,7 +6,7 @@
6
6
  The version of the OpenAPI document: v3
7
7
  Contact: pulp-list@redhat.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ Generator version: 7.10.0
10
10
 
11
11
  =end
12
12
 
@@ -32,6 +32,7 @@ module PulpNpmClient
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: v3
7
7
  Contact: pulp-list@redhat.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ Generator version: 7.10.0
10
10
 
11
11
  =end
12
12
 
@@ -21,6 +21,18 @@ module PulpNpmClient
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)
@@ -50,6 +62,16 @@ module PulpNpmClient
50
62
  # Defines the access token (Bearer) used with OAuth2.
51
63
  attr_accessor :access_token
52
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
+
53
75
  # Set this to enable/disable debugging. When enabled (set to true), HTTP request/response
54
76
  # details will be logged with `logger.debug` (see the `logger` attribute).
55
77
  # Default to false.
@@ -57,6 +79,14 @@ module PulpNpmClient
57
79
  # @return [true, false]
58
80
  attr_accessor :debugging
59
81
 
82
+ # Set this to ignore operation servers for the API client. This is useful when you need to
83
+ # send requests to a different server than the one specified in the OpenAPI document.
84
+ # Will default to the base url defined in the spec but can be overridden by setting
85
+ # `scheme`, `host`, `base_path` directly.
86
+ # Default to false.
87
+ # @return [true, false]
88
+ attr_accessor :ignore_operation_servers
89
+
60
90
  # Defines the logger used for debugging.
61
91
  # Default to `Rails.logger` (when in Rails) or logging to STDOUT.
62
92
  #
@@ -109,39 +139,46 @@ module PulpNpmClient
109
139
  # Client private key file (for client certificate)
110
140
  attr_accessor :ssl_client_key
111
141
 
142
+ ### Proxy setting
143
+ # HTTP Proxy settings
144
+ attr_accessor :proxy
145
+
112
146
  # Set this to customize parameters encoder of array parameter.
113
147
  # Default to nil. Faraday uses NestedParamsEncoder when nil.
114
148
  #
115
149
  # @see The params_encoder option of Faraday. Related source code:
116
150
  # https://github.com/lostisland/faraday/tree/main/lib/faraday/encoders
117
151
  attr_accessor :params_encoder
118
- # Set this to customize parameters encoding of array parameter with multi collectionFormat.
119
- # Default to nil.
120
- #
121
- # @see The params_encoding option of Ethon. Related source code:
122
- # https://github.com/typhoeus/ethon/blob/master/lib/ethon/easy/queryable.rb#L96
123
- attr_accessor :params_encoding
152
+
124
153
 
125
154
  attr_accessor :inject_format
126
155
 
127
156
  attr_accessor :force_ending_format
128
157
 
129
158
  def initialize
130
- @scheme = 'https'
131
- @host = 'pulp'
159
+ @scheme = 'http'
160
+ @host = 'localhost:24817'
132
161
  @base_path = ''
162
+ @server_index = nil
163
+ @server_operation_index = {}
164
+ @server_variables = {}
165
+ @server_operation_variables = {}
133
166
  @api_key = {}
134
167
  @api_key_prefix = {}
135
- @timeout = 0
136
168
  @client_side_validation = true
137
169
  @ssl_verify = true
138
170
  @ssl_verify_mode = nil
139
171
  @ssl_ca_file = nil
140
172
  @ssl_client_cert = nil
141
173
  @ssl_client_key = nil
142
- @params_encoder = nil
174
+ @middlewares = Hash.new { |h, k| h[k] = [] }
175
+ @configure_connection_blocks = []
143
176
  @timeout = 60
177
+ # return data as binary instead of file
178
+ @return_binary_data = false
179
+ @params_encoder = nil
144
180
  @debugging = false
181
+ @ignore_operation_servers = false
145
182
  @inject_format = false
146
183
  @force_ending_format = false
147
184
  @logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
@@ -174,20 +211,35 @@ module PulpNpmClient
174
211
  @base_path = '' if @base_path == '/'
175
212
  end
176
213
 
177
- def base_url
178
- "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '')
214
+ # Returns base URL for specified operation based on server settings
215
+ def base_url(operation = nil)
216
+ return "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') if ignore_operation_servers
217
+ if operation_server_settings.key?(operation) then
218
+ index = server_operation_index.fetch(operation, server_index)
219
+ server_url(index.nil? ? 0 : index, server_operation_variables.fetch(operation, server_variables), operation_server_settings[operation])
220
+ else
221
+ server_index.nil? ? "#{scheme}://#{[host, base_path].join('/').gsub(/\/+/, '/')}".sub(/\/+\z/, '') : server_url(server_index, server_variables, nil)
222
+ end
179
223
  end
180
224
 
181
225
  # Gets API key (with prefix if set).
182
226
  # @param [String] param_name the parameter name of API key auth
183
- def api_key_with_prefix(param_name)
227
+ def api_key_with_prefix(param_name, param_alias = nil)
228
+ key = @api_key[param_name]
229
+ key = @api_key.fetch(param_alias, key) unless param_alias.nil?
184
230
  if @api_key_prefix[param_name]
185
- "#{@api_key_prefix[param_name]} #{@api_key[param_name]}"
231
+ "#{@api_key_prefix[param_name]} #{key}"
186
232
  else
187
- @api_key[param_name]
233
+ key
188
234
  end
189
235
  end
190
236
 
237
+ # Gets access_token using access_token_getter or uses the static access_token
238
+ def access_token_with_refresh
239
+ return access_token if access_token_getter.nil?
240
+ access_token_getter.call
241
+ end
242
+
191
243
  # Gets Basic Auth token string
192
244
  def basic_auth_token
193
245
  'Basic ' + ["#{username}:#{password}"].pack('m').delete("\r\n")
@@ -210,31 +262,38 @@ module PulpNpmClient
210
262
  def server_settings
211
263
  [
212
264
  {
213
- url: "https://pulp/",
265
+ url: "http://localhost:24817",
214
266
  description: "No description provided",
215
267
  }
216
268
  ]
217
269
  end
218
270
 
271
+ def operation_server_settings
272
+ {
273
+ }
274
+ end
275
+
219
276
  # Returns URL based on server settings
220
277
  #
221
278
  # @param index array index of the server settings
222
279
  # @param variables hash of variable and the corresponding value
223
- def server_url(index, variables = {})
224
- servers = server_settings
280
+ def server_url(index, variables = {}, servers = nil)
281
+ servers = server_settings if servers == nil
225
282
 
226
283
  # check array index out of bound
227
- if (index < 0 || index >= servers.size)
228
- fail ArgumentError, "Invalid index #{index} when selecting the server. Must be less than #{servers.size}"
284
+ if (index.nil? || index < 0 || index >= servers.size)
285
+ fail ArgumentError, "Invalid index #{index} when selecting the server. Must not be nil and must be less than #{servers.size}"
229
286
  end
230
287
 
231
288
  server = servers[index]
232
289
  url = server[:url]
233
290
 
291
+ return url unless server.key? :variables
292
+
234
293
  # go through variable and assign a value
235
294
  server[:variables].each do |name, variable|
236
295
  if variables.key?(name)
237
- if (server[:variables][name][:enum_values].include? variables[name])
296
+ if (!server[:variables][name].key?(:enum_values) || server[:variables][name][:enum_values].include?(variables[name]))
238
297
  url.gsub! "{" + name.to_s + "}", variables[name]
239
298
  else
240
299
  fail ArgumentError, "The variable `#{name}` in the server URL has invalid value #{variables[name]}. Must be #{server[:variables][name][:enum_values]}."
@@ -247,5 +306,87 @@ module PulpNpmClient
247
306
 
248
307
  url
249
308
  end
309
+
310
+ # Configure Faraday connection directly.
311
+ #
312
+ # ```
313
+ # c.configure_faraday_connection do |conn|
314
+ # conn.use Faraday::HttpCache, shared_cache: false, logger: logger
315
+ # conn.response :logger, nil, headers: true, bodies: true, log_level: :debug do |logger|
316
+ # logger.filter(/(Authorization: )(.*)/, '\1[REDACTED]')
317
+ # end
318
+ # end
319
+ #
320
+ # c.configure_faraday_connection do |conn|
321
+ # conn.adapter :typhoeus
322
+ # end
323
+ # ```
324
+ #
325
+ # @param block [Proc] `#call`able object that takes one arg, the connection
326
+ def configure_faraday_connection(&block)
327
+ @configure_connection_blocks << block
328
+ end
329
+
330
+ def configure_connection(conn)
331
+ @configure_connection_blocks.each do |block|
332
+ block.call(conn)
333
+ end
334
+ end
335
+
336
+ # Adds middleware to the stack
337
+ def use(*middleware)
338
+ set_faraday_middleware(:use, *middleware)
339
+ end
340
+
341
+ # Adds request middleware to the stack
342
+ def request(*middleware)
343
+ set_faraday_middleware(:request, *middleware)
344
+ end
345
+
346
+ # Adds response middleware to the stack
347
+ def response(*middleware)
348
+ set_faraday_middleware(:response, *middleware)
349
+ end
350
+
351
+ # Adds Faraday middleware setting information to the stack
352
+ #
353
+ # @example Use the `set_faraday_middleware` method to set middleware information
354
+ # config.set_faraday_middleware(:request, :retry, max: 3, methods: [:get, :post], retry_statuses: [503])
355
+ # config.set_faraday_middleware(:response, :logger, nil, { bodies: true, log_level: :debug })
356
+ # config.set_faraday_middleware(:use, Faraday::HttpCache, store: Rails.cache, shared_cache: false)
357
+ # config.set_faraday_middleware(:insert, 0, FaradayMiddleware::FollowRedirects, { standards_compliant: true, limit: 1 })
358
+ # config.set_faraday_middleware(:swap, 0, Faraday::Response::Logger)
359
+ # config.set_faraday_middleware(:delete, Faraday::Multipart::Middleware)
360
+ #
361
+ # @see https://github.com/lostisland/faraday/blob/v2.3.0/lib/faraday/rack_builder.rb#L92-L143
362
+ def set_faraday_middleware(operation, key, *args, &block)
363
+ unless [:request, :response, :use, :insert, :insert_before, :insert_after, :swap, :delete].include?(operation)
364
+ fail ArgumentError, "Invalid faraday middleware operation #{operation}. Must be" \
365
+ " :request, :response, :use, :insert, :insert_before, :insert_after, :swap or :delete."
366
+ end
367
+
368
+ @middlewares[operation] << [key, args, block]
369
+ end
370
+ ruby2_keywords(:set_faraday_middleware) if respond_to?(:ruby2_keywords, true)
371
+
372
+ # Set up middleware on the connection
373
+ def configure_middleware(connection)
374
+ return if @middlewares.empty?
375
+
376
+ [:request, :response, :use, :insert, :insert_before, :insert_after, :swap].each do |operation|
377
+ next unless @middlewares.key?(operation)
378
+
379
+ @middlewares[operation].each do |key, args, block|
380
+ connection.builder.send(operation, key, *args, &block)
381
+ end
382
+ end
383
+
384
+ if @middlewares.key?(:delete)
385
+ @middlewares[:delete].each do |key, _args, _block|
386
+ connection.builder.delete(key)
387
+ end
388
+ end
389
+ end
390
+
250
391
  end
251
392
  end
@@ -6,11 +6,12 @@
6
6
  The version of the OpenAPI document: v3
7
7
  Contact: pulp-list@redhat.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ Generator version: 7.10.0
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
+ require 'time'
14
15
 
15
16
  module PulpNpmClient
16
17
  # Serializer for asynchronous operations.
@@ -25,6 +26,11 @@ module PulpNpmClient
25
26
  }
26
27
  end
27
28
 
29
+ # Returns all the JSON keys this model knows about
30
+ def self.acceptable_attributes
31
+ attribute_map.values
32
+ end
33
+
28
34
  # Attribute type mapping.
29
35
  def self.openapi_types
30
36
  {
@@ -55,12 +61,15 @@ module PulpNpmClient
55
61
 
56
62
  if attributes.key?(:'task')
57
63
  self.task = attributes[:'task']
64
+ else
65
+ self.task = nil
58
66
  end
59
67
  end
60
68
 
61
69
  # Show invalid properties with the reasons. Usually used together with valid?
62
70
  # @return Array for valid properties with the reasons
63
71
  def list_invalid_properties
72
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
64
73
  invalid_properties = Array.new
65
74
  if @task.nil?
66
75
  invalid_properties.push('invalid value for "task", task cannot be nil.')
@@ -72,6 +81,7 @@ module PulpNpmClient
72
81
  # Check to see if the all the properties in the model are valid
73
82
  # @return true if the model is valid
74
83
  def valid?
84
+ warn '[DEPRECATED] the `valid?` method is obsolete'
75
85
  return false if @task.nil?
76
86
  true
77
87
  end
@@ -100,37 +110,33 @@ module PulpNpmClient
100
110
  # @param [Hash] attributes Model attributes in the form of hash
101
111
  # @return [Object] Returns the model itself
102
112
  def self.build_from_hash(attributes)
103
- new.build_from_hash(attributes)
104
- end
105
-
106
- # Builds the object from hash
107
- # @param [Hash] attributes Model attributes in the form of hash
108
- # @return [Object] Returns the model itself
109
- def build_from_hash(attributes)
110
113
  return nil unless attributes.is_a?(Hash)
111
- self.class.openapi_types.each_pair do |key, type|
112
- if type =~ /\AArray<(.*)>/i
114
+ attributes = attributes.transform_keys(&:to_sym)
115
+ transformed_hash = {}
116
+ openapi_types.each_pair do |key, type|
117
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
118
+ transformed_hash["#{key}"] = nil
119
+ elsif type =~ /\AArray<(.*)>/i
113
120
  # check to ensure the input is an array given that the attribute
114
121
  # is documented as an array but the input is not
115
- if attributes[self.class.attribute_map[key]].is_a?(Array)
116
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
122
+ if attributes[attribute_map[key]].is_a?(Array)
123
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
117
124
  end
118
- elsif !attributes[self.class.attribute_map[key]].nil?
119
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
120
- end # or else data not found in attributes(hash), not an issue as the data can be optional
125
+ elsif !attributes[attribute_map[key]].nil?
126
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
127
+ end
121
128
  end
122
-
123
- self
129
+ new(transformed_hash)
124
130
  end
125
131
 
126
132
  # Deserializes the data based on type
127
133
  # @param string type Data type
128
134
  # @param string value Value to be deserialized
129
135
  # @return [Object] Deserialized data
130
- def _deserialize(type, value)
136
+ def self._deserialize(type, value)
131
137
  case type.to_sym
132
- when :DateTime
133
- DateTime.parse(value)
138
+ when :Time
139
+ Time.parse(value)
134
140
  when :Date
135
141
  Date.parse(value)
136
142
  when :String
@@ -160,7 +166,9 @@ module PulpNpmClient
160
166
  end
161
167
  end
162
168
  else # model
163
- PulpNpmClient.const_get(type).build_from_hash(value)
169
+ # models (e.g. Pet) or oneOf
170
+ klass = PulpNpmClient.const_get(type)
171
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
164
172
  end
165
173
  end
166
174
 
@@ -186,7 +194,7 @@ module PulpNpmClient
186
194
  is_nullable = self.class.openapi_nullable.include?(attr)
187
195
  next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
188
196
  end
189
-
197
+
190
198
  hash[param] = _to_hash(value)
191
199
  end
192
200
  hash
@@ -209,5 +217,7 @@ module PulpNpmClient
209
217
  value
210
218
  end
211
219
  end
220
+
212
221
  end
222
+
213
223
  end
@@ -6,11 +6,12 @@
6
6
  The version of the OpenAPI document: v3
7
7
  Contact: pulp-list@redhat.com
8
8
  Generated by: https://openapi-generator.tech
9
- OpenAPI Generator version: 4.3.1
9
+ Generator version: 7.10.0
10
10
 
11
11
  =end
12
12
 
13
13
  require 'date'
14
+ require 'time'
14
15
 
15
16
  module PulpNpmClient
16
17
  # Serializer for the RepositoryVersion content summary
@@ -30,6 +31,11 @@ module PulpNpmClient
30
31
  }
31
32
  end
32
33
 
34
+ # Returns all the JSON keys this model knows about
35
+ def self.acceptable_attributes
36
+ attribute_map.values
37
+ end
38
+
33
39
  # Attribute type mapping.
34
40
  def self.openapi_types
35
41
  {
@@ -64,24 +70,31 @@ module PulpNpmClient
64
70
  if (value = attributes[:'added']).is_a?(Hash)
65
71
  self.added = value
66
72
  end
73
+ else
74
+ self.added = nil
67
75
  end
68
76
 
69
77
  if attributes.key?(:'removed')
70
78
  if (value = attributes[:'removed']).is_a?(Hash)
71
79
  self.removed = value
72
80
  end
81
+ else
82
+ self.removed = nil
73
83
  end
74
84
 
75
85
  if attributes.key?(:'present')
76
86
  if (value = attributes[:'present']).is_a?(Hash)
77
87
  self.present = value
78
88
  end
89
+ else
90
+ self.present = nil
79
91
  end
80
92
  end
81
93
 
82
94
  # Show invalid properties with the reasons. Usually used together with valid?
83
95
  # @return Array for valid properties with the reasons
84
96
  def list_invalid_properties
97
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
85
98
  invalid_properties = Array.new
86
99
  if @added.nil?
87
100
  invalid_properties.push('invalid value for "added", added cannot be nil.')
@@ -101,6 +114,7 @@ module PulpNpmClient
101
114
  # Check to see if the all the properties in the model are valid
102
115
  # @return true if the model is valid
103
116
  def valid?
117
+ warn '[DEPRECATED] the `valid?` method is obsolete'
104
118
  return false if @added.nil?
105
119
  return false if @removed.nil?
106
120
  return false if @present.nil?
@@ -133,37 +147,33 @@ module PulpNpmClient
133
147
  # @param [Hash] attributes Model attributes in the form of hash
134
148
  # @return [Object] Returns the model itself
135
149
  def self.build_from_hash(attributes)
136
- new.build_from_hash(attributes)
137
- end
138
-
139
- # Builds the object from hash
140
- # @param [Hash] attributes Model attributes in the form of hash
141
- # @return [Object] Returns the model itself
142
- def build_from_hash(attributes)
143
150
  return nil unless attributes.is_a?(Hash)
144
- self.class.openapi_types.each_pair do |key, type|
145
- if type =~ /\AArray<(.*)>/i
151
+ attributes = attributes.transform_keys(&:to_sym)
152
+ transformed_hash = {}
153
+ openapi_types.each_pair do |key, type|
154
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
155
+ transformed_hash["#{key}"] = nil
156
+ elsif type =~ /\AArray<(.*)>/i
146
157
  # check to ensure the input is an array given that the attribute
147
158
  # is documented as an array but the input is not
148
- if attributes[self.class.attribute_map[key]].is_a?(Array)
149
- self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
159
+ if attributes[attribute_map[key]].is_a?(Array)
160
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
150
161
  end
151
- elsif !attributes[self.class.attribute_map[key]].nil?
152
- self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
153
- end # or else data not found in attributes(hash), not an issue as the data can be optional
162
+ elsif !attributes[attribute_map[key]].nil?
163
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
164
+ end
154
165
  end
155
-
156
- self
166
+ new(transformed_hash)
157
167
  end
158
168
 
159
169
  # Deserializes the data based on type
160
170
  # @param string type Data type
161
171
  # @param string value Value to be deserialized
162
172
  # @return [Object] Deserialized data
163
- def _deserialize(type, value)
173
+ def self._deserialize(type, value)
164
174
  case type.to_sym
165
- when :DateTime
166
- DateTime.parse(value)
175
+ when :Time
176
+ Time.parse(value)
167
177
  when :Date
168
178
  Date.parse(value)
169
179
  when :String
@@ -193,7 +203,9 @@ module PulpNpmClient
193
203
  end
194
204
  end
195
205
  else # model
196
- PulpNpmClient.const_get(type).build_from_hash(value)
206
+ # models (e.g. Pet) or oneOf
207
+ klass = PulpNpmClient.const_get(type)
208
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
197
209
  end
198
210
  end
199
211
 
@@ -219,7 +231,7 @@ module PulpNpmClient
219
231
  is_nullable = self.class.openapi_nullable.include?(attr)
220
232
  next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
221
233
  end
222
-
234
+
223
235
  hash[param] = _to_hash(value)
224
236
  end
225
237
  hash
@@ -242,5 +254,7 @@ module PulpNpmClient
242
254
  value
243
255
  end
244
256
  end
257
+
245
258
  end
259
+
246
260
  end