pulp_gem_client 0.6.0 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (136) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -8
  3. data/docs/AsyncOperationResponse.md +8 -7
  4. data/docs/ContentGemApi.md +118 -66
  5. data/docs/ContentSummaryResponse.md +12 -11
  6. data/docs/DistributionsGemApi.md +388 -183
  7. data/docs/GemGemContentResponse.md +32 -29
  8. data/docs/GemGemDistribution.md +22 -21
  9. data/docs/GemGemDistributionResponse.md +34 -29
  10. data/docs/GemGemPublication.md +10 -9
  11. data/docs/GemGemPublicationResponse.md +18 -15
  12. data/docs/GemGemRemote.md +54 -53
  13. data/docs/GemGemRemoteResponse.md +54 -51
  14. data/docs/GemGemRemoteResponseHiddenFieldsInner.md +20 -0
  15. data/docs/GemGemRepository.md +16 -15
  16. data/docs/GemGemRepositoryResponse.md +28 -25
  17. data/docs/MyPermissionsResponse.md +8 -7
  18. data/docs/NestedRole.md +12 -11
  19. data/docs/NestedRoleResponse.md +12 -11
  20. data/docs/ObjectRolesResponse.md +8 -7
  21. data/docs/PaginatedRepositoryVersionResponseList.md +14 -13
  22. data/docs/PaginatedgemGemContentResponseList.md +14 -13
  23. data/docs/PaginatedgemGemDistributionResponseList.md +14 -13
  24. data/docs/PaginatedgemGemPublicationResponseList.md +14 -13
  25. data/docs/PaginatedgemGemRemoteResponseList.md +14 -13
  26. data/docs/PaginatedgemGemRepositoryResponseList.md +14 -13
  27. data/docs/PatchedgemGemDistribution.md +22 -21
  28. data/docs/PatchedgemGemRemote.md +54 -53
  29. data/docs/PatchedgemGemRepository.md +16 -15
  30. data/docs/PolicyEnum.md +4 -5
  31. data/docs/PublicationsGemApi.md +271 -132
  32. data/docs/RemotesGemApi.md +392 -185
  33. data/docs/Repair.md +8 -7
  34. data/docs/RepositoriesGemApi.md +449 -210
  35. data/docs/RepositoriesGemVersionsApi.md +155 -83
  36. data/docs/RepositoryAddRemoveContent.md +12 -11
  37. data/docs/RepositorySyncURL.md +10 -9
  38. data/docs/RepositoryVersionResponse.md +22 -19
  39. data/docs/SetLabel.md +10 -9
  40. data/docs/SetLabelResponse.md +10 -9
  41. data/docs/UnsetLabel.md +8 -7
  42. data/docs/UnsetLabelResponse.md +10 -9
  43. data/lib/pulp_gem_client/api/content_gem_api.rb +31 -22
  44. data/lib/pulp_gem_client/api/distributions_gem_api.rb +94 -58
  45. data/lib/pulp_gem_client/api/publications_gem_api.rb +81 -58
  46. data/lib/pulp_gem_client/api/remotes_gem_api.rb +109 -70
  47. data/lib/pulp_gem_client/api/repositories_gem_api.rb +116 -72
  48. data/lib/pulp_gem_client/api/repositories_gem_versions_api.rb +50 -37
  49. data/lib/pulp_gem_client/api_client.rb +137 -102
  50. data/lib/pulp_gem_client/api_error.rb +2 -1
  51. data/lib/pulp_gem_client/configuration.rb +162 -21
  52. data/lib/pulp_gem_client/models/async_operation_response.rb +32 -22
  53. data/lib/pulp_gem_client/models/content_summary_response.rb +36 -22
  54. data/lib/pulp_gem_client/models/gem_gem_content_response.rb +45 -25
  55. data/lib/pulp_gem_client/models/gem_gem_distribution.rb +34 -22
  56. data/lib/pulp_gem_client/models/gem_gem_distribution_response.rb +57 -25
  57. data/lib/pulp_gem_client/models/gem_gem_publication.rb +30 -22
  58. data/lib/pulp_gem_client/models/gem_gem_publication_response.rb +43 -25
  59. data/lib/pulp_gem_client/models/gem_gem_remote.rb +56 -22
  60. data/lib/pulp_gem_client/models/gem_gem_remote_response.rb +70 -26
  61. data/lib/pulp_gem_client/models/{gem_gem_remote_response_hidden_fields.rb → gem_gem_remote_response_hidden_fields_inner.rb} +37 -25
  62. data/lib/pulp_gem_client/models/gem_gem_repository.rb +32 -22
  63. data/lib/pulp_gem_client/models/gem_gem_repository_response.rb +45 -25
  64. data/lib/pulp_gem_client/models/my_permissions_response.rb +32 -22
  65. data/lib/pulp_gem_client/models/nested_role.rb +32 -22
  66. data/lib/pulp_gem_client/models/nested_role_response.rb +32 -22
  67. data/lib/pulp_gem_client/models/object_roles_response.rb +32 -22
  68. data/lib/pulp_gem_client/models/paginated_repository_version_response_list.rb +34 -22
  69. data/lib/pulp_gem_client/models/paginatedgem_gem_content_response_list.rb +34 -22
  70. data/lib/pulp_gem_client/models/paginatedgem_gem_distribution_response_list.rb +34 -22
  71. data/lib/pulp_gem_client/models/paginatedgem_gem_publication_response_list.rb +34 -22
  72. data/lib/pulp_gem_client/models/paginatedgem_gem_remote_response_list.rb +34 -22
  73. data/lib/pulp_gem_client/models/paginatedgem_gem_repository_response_list.rb +34 -22
  74. data/lib/pulp_gem_client/models/patchedgem_gem_distribution.rb +40 -24
  75. data/lib/pulp_gem_client/models/patchedgem_gem_remote.rb +62 -24
  76. data/lib/pulp_gem_client/models/patchedgem_gem_repository.rb +35 -23
  77. data/lib/pulp_gem_client/models/policy_enum.rb +8 -4
  78. data/lib/pulp_gem_client/models/repair.rb +30 -22
  79. data/lib/pulp_gem_client/models/repository_add_remove_content.rb +31 -23
  80. data/lib/pulp_gem_client/models/repository_sync_url.rb +30 -22
  81. data/lib/pulp_gem_client/models/repository_version_response.rb +44 -26
  82. data/lib/pulp_gem_client/models/set_label.rb +34 -22
  83. data/lib/pulp_gem_client/models/set_label_response.rb +34 -22
  84. data/lib/pulp_gem_client/models/unset_label.rb +32 -22
  85. data/lib/pulp_gem_client/models/unset_label_response.rb +32 -22
  86. data/lib/pulp_gem_client/version.rb +2 -2
  87. data/lib/pulp_gem_client.rb +2 -3
  88. data/pulp_gem_client.gemspec +9 -6
  89. data/spec/api/content_gem_api_spec.rb +9 -8
  90. data/spec/api/distributions_gem_api_spec.rb +15 -14
  91. data/spec/api/publications_gem_api_spec.rb +22 -20
  92. data/spec/api/remotes_gem_api_spec.rb +22 -20
  93. data/spec/api/repositories_gem_api_spec.rb +19 -18
  94. data/spec/api/repositories_gem_versions_api_spec.rb +16 -14
  95. data/spec/models/async_operation_response_spec.rb +7 -12
  96. data/spec/models/content_summary_response_spec.rb +9 -14
  97. data/spec/models/gem_gem_content_response_spec.rb +24 -23
  98. data/spec/models/gem_gem_distribution_response_spec.rb +30 -23
  99. data/spec/models/gem_gem_distribution_spec.rb +14 -19
  100. data/spec/models/gem_gem_publication_response_spec.rb +17 -16
  101. data/spec/models/gem_gem_publication_spec.rb +8 -13
  102. data/spec/models/{gem_gem_remote_response_hidden_fields_spec.rb → gem_gem_remote_response_hidden_fields_inner_spec.rb} +11 -16
  103. data/spec/models/gem_gem_remote_response_spec.rb +35 -34
  104. data/spec/models/gem_gem_remote_spec.rb +30 -35
  105. data/spec/models/gem_gem_repository_response_spec.rb +22 -21
  106. data/spec/models/gem_gem_repository_spec.rb +11 -16
  107. data/spec/models/my_permissions_response_spec.rb +7 -12
  108. data/spec/models/nested_role_response_spec.rb +9 -14
  109. data/spec/models/nested_role_spec.rb +9 -14
  110. data/spec/models/object_roles_response_spec.rb +7 -12
  111. data/spec/models/paginated_repository_version_response_list_spec.rb +10 -15
  112. data/spec/models/paginatedgem_gem_content_response_list_spec.rb +10 -15
  113. data/spec/models/paginatedgem_gem_distribution_response_list_spec.rb +10 -15
  114. data/spec/models/paginatedgem_gem_publication_response_list_spec.rb +10 -15
  115. data/spec/models/paginatedgem_gem_remote_response_list_spec.rb +10 -15
  116. data/spec/models/paginatedgem_gem_repository_response_list_spec.rb +10 -15
  117. data/spec/models/patchedgem_gem_distribution_spec.rb +14 -19
  118. data/spec/models/patchedgem_gem_remote_spec.rb +30 -35
  119. data/spec/models/patchedgem_gem_repository_spec.rb +11 -16
  120. data/spec/models/policy_enum_spec.rb +6 -11
  121. data/spec/models/repair_spec.rb +7 -12
  122. data/spec/models/repository_add_remove_content_spec.rb +9 -14
  123. data/spec/models/repository_sync_url_spec.rb +8 -13
  124. data/spec/models/repository_version_response_spec.rb +19 -18
  125. data/spec/models/set_label_response_spec.rb +8 -13
  126. data/spec/models/set_label_spec.rb +8 -13
  127. data/spec/models/unset_label_response_spec.rb +8 -13
  128. data/spec/models/unset_label_spec.rb +7 -12
  129. data/spec/spec_helper.rb +1 -1
  130. metadata +80 -60
  131. data/docs/GemGemContent.md +0 -21
  132. data/docs/GemGemRemoteResponseHiddenFields.md +0 -19
  133. data/lib/pulp_gem_client/models/gem_gem_content.rb +0 -228
  134. data/spec/api_client_spec.rb +0 -188
  135. data/spec/configuration_spec.rb +0 -42
  136. data/spec/models/gem_gem_content_spec.rb +0 -53
@@ -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 PulpGemClient
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 PulpGemClient
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 PulpGemClient
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,18 +139,17 @@ module PulpGemClient
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
 
@@ -128,20 +157,28 @@ module PulpGemClient
128
157
 
129
158
  def initialize
130
159
  @scheme = 'http'
131
- @host = 'pulp'
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 PulpGemClient
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 PulpGemClient
210
262
  def server_settings
211
263
  [
212
264
  {
213
- url: "http://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 PulpGemClient
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 PulpGemClient
16
17
  # Serializer for asynchronous operations.
@@ -25,6 +26,11 @@ module PulpGemClient
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 PulpGemClient
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 PulpGemClient
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 PulpGemClient
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 PulpGemClient
160
166
  end
161
167
  end
162
168
  else # model
163
- PulpGemClient.const_get(type).build_from_hash(value)
169
+ # models (e.g. Pet) or oneOf
170
+ klass = PulpGemClient.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 PulpGemClient
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 PulpGemClient
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 PulpGemClient
16
17
  # Serializer for the RepositoryVersion content summary
@@ -30,6 +31,11 @@ module PulpGemClient
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 PulpGemClient
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 PulpGemClient
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 PulpGemClient
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 PulpGemClient
193
203
  end
194
204
  end
195
205
  else # model
196
- PulpGemClient.const_get(type).build_from_hash(value)
206
+ # models (e.g. Pet) or oneOf
207
+ klass = PulpGemClient.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 PulpGemClient
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 PulpGemClient
242
254
  value
243
255
  end
244
256
  end
257
+
245
258
  end
259
+
246
260
  end