pulp_python_client 3.28.1 → 3.29.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.
@@ -0,0 +1,313 @@
1
+ =begin
2
+ #Pulp 3 API
3
+
4
+ #Fetch, Upload, Organize, and Distribute Software Packages
5
+
6
+ The version of the OpenAPI document: v3
7
+ Contact: pulp-list@redhat.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.10.0
10
+
11
+ =end
12
+
13
+ require 'cgi'
14
+
15
+ module PulpPythonClient
16
+ class RepositoriesPythonBlocklistEntriesApi
17
+ attr_accessor :api_client
18
+
19
+ def initialize(api_client = ApiClient.default)
20
+ @api_client = api_client
21
+ end
22
+ # Create a python blocklist entry
23
+ # ViewSet for managing blocklist entries on a PythonRepository. Blocklist entries prevent packages from being added to the repository. Entries can match by package `name` (all versions), package `name` + `version`, or exact `filename`. Exactly one of `name` or `filename` must be provided.
24
+ # @param python_python_repository_href [String]
25
+ # @param python_python_blocklist_entry [PythonPythonBlocklistEntry]
26
+ # @param [Hash] opts the optional parameters
27
+ # @option opts [Array<String>] :x_task_diagnostics List of profilers to use on tasks.
28
+ # @return [PythonPythonBlocklistEntryResponse]
29
+ def create(python_python_repository_href, python_python_blocklist_entry, opts = {})
30
+ data, _status_code, _headers = create_with_http_info(python_python_repository_href, python_python_blocklist_entry, opts)
31
+ data
32
+ end
33
+
34
+ # Create a python blocklist entry
35
+ # ViewSet for managing blocklist entries on a PythonRepository. Blocklist entries prevent packages from being added to the repository. Entries can match by package &#x60;name&#x60; (all versions), package &#x60;name&#x60; + &#x60;version&#x60;, or exact &#x60;filename&#x60;. Exactly one of &#x60;name&#x60; or &#x60;filename&#x60; must be provided.
36
+ # @param python_python_repository_href [String]
37
+ # @param python_python_blocklist_entry [PythonPythonBlocklistEntry]
38
+ # @param [Hash] opts the optional parameters
39
+ # @option opts [Array<String>] :x_task_diagnostics List of profilers to use on tasks.
40
+ # @return [Array<(PythonPythonBlocklistEntryResponse, Integer, Hash)>] PythonPythonBlocklistEntryResponse data, response status code and response headers
41
+ def create_with_http_info(python_python_repository_href, python_python_blocklist_entry, opts = {})
42
+ if @api_client.config.debugging
43
+ @api_client.config.logger.debug 'Calling API: RepositoriesPythonBlocklistEntriesApi.create ...'
44
+ end
45
+ # verify the required parameter 'python_python_repository_href' is set
46
+ if @api_client.config.client_side_validation && python_python_repository_href.nil?
47
+ fail ArgumentError, "Missing the required parameter 'python_python_repository_href' when calling RepositoriesPythonBlocklistEntriesApi.create"
48
+ end
49
+ # verify the required parameter 'python_python_blocklist_entry' is set
50
+ if @api_client.config.client_side_validation && python_python_blocklist_entry.nil?
51
+ fail ArgumentError, "Missing the required parameter 'python_python_blocklist_entry' when calling RepositoriesPythonBlocklistEntriesApi.create"
52
+ end
53
+ # resource path
54
+ local_var_path = '{python_python_repository_href}blocklist_entries/'.sub('{' + 'python_python_repository_href' + '}', CGI.escape(python_python_repository_href.to_s).gsub('%2F', '/'))
55
+
56
+ # query parameters
57
+ query_params = opts[:query_params] || {}
58
+
59
+ # header parameters
60
+ header_params = opts[:header_params] || {}
61
+ # HTTP header 'Accept' (if needed)
62
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
63
+ # HTTP header 'Content-Type'
64
+ content_type = @api_client.select_header_content_type(['application/json', 'application/x-www-form-urlencoded', 'multipart/form-data'])
65
+ if !content_type.nil?
66
+ header_params['Content-Type'] = content_type
67
+ end
68
+ header_params[:'X-Task-Diagnostics'] = @api_client.build_collection_param(opts[:'x_task_diagnostics'], :csv) if !opts[:'x_task_diagnostics'].nil?
69
+
70
+ # form parameters
71
+ form_params = opts[:form_params] || {}
72
+
73
+ # http body (model)
74
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(python_python_blocklist_entry)
75
+
76
+ # return_type
77
+ return_type = opts[:debug_return_type] || 'PythonPythonBlocklistEntryResponse'
78
+
79
+ # auth_names
80
+ auth_names = opts[:debug_auth_names] || ['basicAuth']
81
+
82
+ new_options = opts.merge(
83
+ :operation => :"RepositoriesPythonBlocklistEntriesApi.create",
84
+ :header_params => header_params,
85
+ :query_params => query_params,
86
+ :form_params => form_params,
87
+ :body => post_body,
88
+ :auth_names => auth_names,
89
+ :return_type => return_type
90
+ )
91
+
92
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
93
+ if @api_client.config.debugging
94
+ @api_client.config.logger.debug "API called: RepositoriesPythonBlocklistEntriesApi#create\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
95
+ end
96
+ return data, status_code, headers
97
+ end
98
+
99
+ # Delete a python blocklist entry
100
+ # ViewSet for managing blocklist entries on a PythonRepository. Blocklist entries prevent packages from being added to the repository. Entries can match by package `name` (all versions), package `name` + `version`, or exact `filename`. Exactly one of `name` or `filename` must be provided.
101
+ # @param python_python_python_blocklist_entry_href [String]
102
+ # @param [Hash] opts the optional parameters
103
+ # @option opts [Array<String>] :x_task_diagnostics List of profilers to use on tasks.
104
+ # @return [nil]
105
+ def delete(python_python_python_blocklist_entry_href, opts = {})
106
+ delete_with_http_info(python_python_python_blocklist_entry_href, opts)
107
+ nil
108
+ end
109
+
110
+ # Delete a python blocklist entry
111
+ # ViewSet for managing blocklist entries on a PythonRepository. Blocklist entries prevent packages from being added to the repository. Entries can match by package &#x60;name&#x60; (all versions), package &#x60;name&#x60; + &#x60;version&#x60;, or exact &#x60;filename&#x60;. Exactly one of &#x60;name&#x60; or &#x60;filename&#x60; must be provided.
112
+ # @param python_python_python_blocklist_entry_href [String]
113
+ # @param [Hash] opts the optional parameters
114
+ # @option opts [Array<String>] :x_task_diagnostics List of profilers to use on tasks.
115
+ # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
116
+ def delete_with_http_info(python_python_python_blocklist_entry_href, opts = {})
117
+ if @api_client.config.debugging
118
+ @api_client.config.logger.debug 'Calling API: RepositoriesPythonBlocklistEntriesApi.delete ...'
119
+ end
120
+ # verify the required parameter 'python_python_python_blocklist_entry_href' is set
121
+ if @api_client.config.client_side_validation && python_python_python_blocklist_entry_href.nil?
122
+ fail ArgumentError, "Missing the required parameter 'python_python_python_blocklist_entry_href' when calling RepositoriesPythonBlocklistEntriesApi.delete"
123
+ end
124
+ # resource path
125
+ local_var_path = '{python_python_python_blocklist_entry_href}'.sub('{' + 'python_python_python_blocklist_entry_href' + '}', CGI.escape(python_python_python_blocklist_entry_href.to_s).gsub('%2F', '/'))
126
+
127
+ # query parameters
128
+ query_params = opts[:query_params] || {}
129
+
130
+ # header parameters
131
+ header_params = opts[:header_params] || {}
132
+ header_params[:'X-Task-Diagnostics'] = @api_client.build_collection_param(opts[:'x_task_diagnostics'], :csv) if !opts[:'x_task_diagnostics'].nil?
133
+
134
+ # form parameters
135
+ form_params = opts[:form_params] || {}
136
+
137
+ # http body (model)
138
+ post_body = opts[:debug_body]
139
+
140
+ # return_type
141
+ return_type = opts[:debug_return_type]
142
+
143
+ # auth_names
144
+ auth_names = opts[:debug_auth_names] || ['basicAuth']
145
+
146
+ new_options = opts.merge(
147
+ :operation => :"RepositoriesPythonBlocklistEntriesApi.delete",
148
+ :header_params => header_params,
149
+ :query_params => query_params,
150
+ :form_params => form_params,
151
+ :body => post_body,
152
+ :auth_names => auth_names,
153
+ :return_type => return_type
154
+ )
155
+
156
+ data, status_code, headers = @api_client.call_api(:DELETE, local_var_path, new_options)
157
+ if @api_client.config.debugging
158
+ @api_client.config.logger.debug "API called: RepositoriesPythonBlocklistEntriesApi#delete\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
159
+ end
160
+ return data, status_code, headers
161
+ end
162
+
163
+ # List python blocklist entrys
164
+ # ViewSet for managing blocklist entries on a PythonRepository. Blocklist entries prevent packages from being added to the repository. Entries can match by package `name` (all versions), package `name` + `version`, or exact `filename`. Exactly one of `name` or `filename` must be provided.
165
+ # @param python_python_repository_href [String]
166
+ # @param [Hash] opts the optional parameters
167
+ # @option opts [Array<String>] :x_task_diagnostics List of profilers to use on tasks.
168
+ # @option opts [Integer] :limit Number of results to return per page.
169
+ # @option opts [Integer] :offset The initial index from which to return the results.
170
+ # @option opts [Array<String>] :fields A list of fields to include in the response.
171
+ # @option opts [Array<String>] :exclude_fields A list of fields to exclude from the response.
172
+ # @return [PaginatedpythonPythonBlocklistEntryResponseList]
173
+ def list(python_python_repository_href, opts = {})
174
+ data, _status_code, _headers = list_with_http_info(python_python_repository_href, opts)
175
+ data
176
+ end
177
+
178
+ # List python blocklist entrys
179
+ # ViewSet for managing blocklist entries on a PythonRepository. Blocklist entries prevent packages from being added to the repository. Entries can match by package &#x60;name&#x60; (all versions), package &#x60;name&#x60; + &#x60;version&#x60;, or exact &#x60;filename&#x60;. Exactly one of &#x60;name&#x60; or &#x60;filename&#x60; must be provided.
180
+ # @param python_python_repository_href [String]
181
+ # @param [Hash] opts the optional parameters
182
+ # @option opts [Array<String>] :x_task_diagnostics List of profilers to use on tasks.
183
+ # @option opts [Integer] :limit Number of results to return per page.
184
+ # @option opts [Integer] :offset The initial index from which to return the results.
185
+ # @option opts [Array<String>] :fields A list of fields to include in the response.
186
+ # @option opts [Array<String>] :exclude_fields A list of fields to exclude from the response.
187
+ # @return [Array<(PaginatedpythonPythonBlocklistEntryResponseList, Integer, Hash)>] PaginatedpythonPythonBlocklistEntryResponseList data, response status code and response headers
188
+ def list_with_http_info(python_python_repository_href, opts = {})
189
+ if @api_client.config.debugging
190
+ @api_client.config.logger.debug 'Calling API: RepositoriesPythonBlocklistEntriesApi.list ...'
191
+ end
192
+ # verify the required parameter 'python_python_repository_href' is set
193
+ if @api_client.config.client_side_validation && python_python_repository_href.nil?
194
+ fail ArgumentError, "Missing the required parameter 'python_python_repository_href' when calling RepositoriesPythonBlocklistEntriesApi.list"
195
+ end
196
+ # resource path
197
+ local_var_path = '{python_python_repository_href}blocklist_entries/'.sub('{' + 'python_python_repository_href' + '}', CGI.escape(python_python_repository_href.to_s).gsub('%2F', '/'))
198
+
199
+ # query parameters
200
+ query_params = opts[:query_params] || {}
201
+ query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
202
+ query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].nil?
203
+ query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :multi) if !opts[:'fields'].nil?
204
+ query_params[:'exclude_fields'] = @api_client.build_collection_param(opts[:'exclude_fields'], :multi) if !opts[:'exclude_fields'].nil?
205
+
206
+ # header parameters
207
+ header_params = opts[:header_params] || {}
208
+ # HTTP header 'Accept' (if needed)
209
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
210
+ header_params[:'X-Task-Diagnostics'] = @api_client.build_collection_param(opts[:'x_task_diagnostics'], :csv) if !opts[:'x_task_diagnostics'].nil?
211
+
212
+ # form parameters
213
+ form_params = opts[:form_params] || {}
214
+
215
+ # http body (model)
216
+ post_body = opts[:debug_body]
217
+
218
+ # return_type
219
+ return_type = opts[:debug_return_type] || 'PaginatedpythonPythonBlocklistEntryResponseList'
220
+
221
+ # auth_names
222
+ auth_names = opts[:debug_auth_names] || ['basicAuth']
223
+
224
+ new_options = opts.merge(
225
+ :operation => :"RepositoriesPythonBlocklistEntriesApi.list",
226
+ :header_params => header_params,
227
+ :query_params => query_params,
228
+ :form_params => form_params,
229
+ :body => post_body,
230
+ :auth_names => auth_names,
231
+ :return_type => return_type
232
+ )
233
+
234
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
235
+ if @api_client.config.debugging
236
+ @api_client.config.logger.debug "API called: RepositoriesPythonBlocklistEntriesApi#list\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
237
+ end
238
+ return data, status_code, headers
239
+ end
240
+
241
+ # Inspect a python blocklist entry
242
+ # ViewSet for managing blocklist entries on a PythonRepository. Blocklist entries prevent packages from being added to the repository. Entries can match by package `name` (all versions), package `name` + `version`, or exact `filename`. Exactly one of `name` or `filename` must be provided.
243
+ # @param python_python_python_blocklist_entry_href [String]
244
+ # @param [Hash] opts the optional parameters
245
+ # @option opts [Array<String>] :x_task_diagnostics List of profilers to use on tasks.
246
+ # @option opts [Array<String>] :fields A list of fields to include in the response.
247
+ # @option opts [Array<String>] :exclude_fields A list of fields to exclude from the response.
248
+ # @return [PythonPythonBlocklistEntryResponse]
249
+ def read(python_python_python_blocklist_entry_href, opts = {})
250
+ data, _status_code, _headers = read_with_http_info(python_python_python_blocklist_entry_href, opts)
251
+ data
252
+ end
253
+
254
+ # Inspect a python blocklist entry
255
+ # ViewSet for managing blocklist entries on a PythonRepository. Blocklist entries prevent packages from being added to the repository. Entries can match by package &#x60;name&#x60; (all versions), package &#x60;name&#x60; + &#x60;version&#x60;, or exact &#x60;filename&#x60;. Exactly one of &#x60;name&#x60; or &#x60;filename&#x60; must be provided.
256
+ # @param python_python_python_blocklist_entry_href [String]
257
+ # @param [Hash] opts the optional parameters
258
+ # @option opts [Array<String>] :x_task_diagnostics List of profilers to use on tasks.
259
+ # @option opts [Array<String>] :fields A list of fields to include in the response.
260
+ # @option opts [Array<String>] :exclude_fields A list of fields to exclude from the response.
261
+ # @return [Array<(PythonPythonBlocklistEntryResponse, Integer, Hash)>] PythonPythonBlocklistEntryResponse data, response status code and response headers
262
+ def read_with_http_info(python_python_python_blocklist_entry_href, opts = {})
263
+ if @api_client.config.debugging
264
+ @api_client.config.logger.debug 'Calling API: RepositoriesPythonBlocklistEntriesApi.read ...'
265
+ end
266
+ # verify the required parameter 'python_python_python_blocklist_entry_href' is set
267
+ if @api_client.config.client_side_validation && python_python_python_blocklist_entry_href.nil?
268
+ fail ArgumentError, "Missing the required parameter 'python_python_python_blocklist_entry_href' when calling RepositoriesPythonBlocklistEntriesApi.read"
269
+ end
270
+ # resource path
271
+ local_var_path = '{python_python_python_blocklist_entry_href}'.sub('{' + 'python_python_python_blocklist_entry_href' + '}', CGI.escape(python_python_python_blocklist_entry_href.to_s).gsub('%2F', '/'))
272
+
273
+ # query parameters
274
+ query_params = opts[:query_params] || {}
275
+ query_params[:'fields'] = @api_client.build_collection_param(opts[:'fields'], :multi) if !opts[:'fields'].nil?
276
+ query_params[:'exclude_fields'] = @api_client.build_collection_param(opts[:'exclude_fields'], :multi) if !opts[:'exclude_fields'].nil?
277
+
278
+ # header parameters
279
+ header_params = opts[:header_params] || {}
280
+ # HTTP header 'Accept' (if needed)
281
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
282
+ header_params[:'X-Task-Diagnostics'] = @api_client.build_collection_param(opts[:'x_task_diagnostics'], :csv) if !opts[:'x_task_diagnostics'].nil?
283
+
284
+ # form parameters
285
+ form_params = opts[:form_params] || {}
286
+
287
+ # http body (model)
288
+ post_body = opts[:debug_body]
289
+
290
+ # return_type
291
+ return_type = opts[:debug_return_type] || 'PythonPythonBlocklistEntryResponse'
292
+
293
+ # auth_names
294
+ auth_names = opts[:debug_auth_names] || ['basicAuth']
295
+
296
+ new_options = opts.merge(
297
+ :operation => :"RepositoriesPythonBlocklistEntriesApi.read",
298
+ :header_params => header_params,
299
+ :query_params => query_params,
300
+ :form_params => form_params,
301
+ :body => post_body,
302
+ :auth_names => auth_names,
303
+ :return_type => return_type
304
+ )
305
+
306
+ data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
307
+ if @api_client.config.debugging
308
+ @api_client.config.logger.debug "API called: RepositoriesPythonBlocklistEntriesApi#read\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
309
+ end
310
+ return data, status_code, headers
311
+ end
312
+ end
313
+ end
@@ -0,0 +1,257 @@
1
+ =begin
2
+ #Pulp 3 API
3
+
4
+ #Fetch, Upload, Organize, and Distribute Software Packages
5
+
6
+ The version of the OpenAPI document: v3
7
+ Contact: pulp-list@redhat.com
8
+ Generated by: https://openapi-generator.tech
9
+ Generator version: 7.10.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module PulpPythonClient
17
+ class PaginatedpythonPythonBlocklistEntryResponseList
18
+ attr_accessor :count
19
+
20
+ attr_accessor :_next
21
+
22
+ attr_accessor :previous
23
+
24
+ attr_accessor :results
25
+
26
+ # Attribute mapping from ruby-style variable name to JSON key.
27
+ def self.attribute_map
28
+ {
29
+ :'count' => :'count',
30
+ :'_next' => :'next',
31
+ :'previous' => :'previous',
32
+ :'results' => :'results'
33
+ }
34
+ end
35
+
36
+ # Returns all the JSON keys this model knows about
37
+ def self.acceptable_attributes
38
+ attribute_map.values
39
+ end
40
+
41
+ # Attribute type mapping.
42
+ def self.openapi_types
43
+ {
44
+ :'count' => :'Integer',
45
+ :'_next' => :'String',
46
+ :'previous' => :'String',
47
+ :'results' => :'Array<PythonPythonBlocklistEntryResponse>'
48
+ }
49
+ end
50
+
51
+ # List of attributes with nullable: true
52
+ def self.openapi_nullable
53
+ Set.new([
54
+ ])
55
+ end
56
+
57
+ # Initializes the object
58
+ # @param [Hash] attributes Model attributes in the form of hash
59
+ def initialize(attributes = {})
60
+ if (!attributes.is_a?(Hash))
61
+ fail ArgumentError, "The input argument (attributes) must be a hash in `PulpPythonClient::PaginatedpythonPythonBlocklistEntryResponseList` initialize method"
62
+ end
63
+
64
+ # check to see if the attribute exists and convert string to symbol for hash key
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!self.class.attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `PulpPythonClient::PaginatedpythonPythonBlocklistEntryResponseList`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'count')
73
+ self.count = attributes[:'count']
74
+ else
75
+ self.count = nil
76
+ end
77
+
78
+ if attributes.key?(:'_next')
79
+ self._next = attributes[:'_next']
80
+ end
81
+
82
+ if attributes.key?(:'previous')
83
+ self.previous = attributes[:'previous']
84
+ end
85
+
86
+ if attributes.key?(:'results')
87
+ if (value = attributes[:'results']).is_a?(Array)
88
+ self.results = value
89
+ end
90
+ else
91
+ self.results = nil
92
+ end
93
+ end
94
+
95
+ # Show invalid properties with the reasons. Usually used together with valid?
96
+ # @return Array for valid properties with the reasons
97
+ def list_invalid_properties
98
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
99
+ invalid_properties = Array.new
100
+ if @count.nil?
101
+ invalid_properties.push('invalid value for "count", count cannot be nil.')
102
+ end
103
+
104
+ if @results.nil?
105
+ invalid_properties.push('invalid value for "results", results cannot be nil.')
106
+ end
107
+
108
+ invalid_properties
109
+ end
110
+
111
+ # Check to see if the all the properties in the model are valid
112
+ # @return true if the model is valid
113
+ def valid?
114
+ warn '[DEPRECATED] the `valid?` method is obsolete'
115
+ return false if @count.nil?
116
+ return false if @results.nil?
117
+ true
118
+ end
119
+
120
+ # Checks equality by comparing each attribute.
121
+ # @param [Object] Object to be compared
122
+ def ==(o)
123
+ return true if self.equal?(o)
124
+ self.class == o.class &&
125
+ count == o.count &&
126
+ _next == o._next &&
127
+ previous == o.previous &&
128
+ results == o.results
129
+ end
130
+
131
+ # @see the `==` method
132
+ # @param [Object] Object to be compared
133
+ def eql?(o)
134
+ self == o
135
+ end
136
+
137
+ # Calculates hash code according to all attributes.
138
+ # @return [Integer] Hash code
139
+ def hash
140
+ [count, _next, previous, results].hash
141
+ end
142
+
143
+ # Builds the object from hash
144
+ # @param [Hash] attributes Model attributes in the form of hash
145
+ # @return [Object] Returns the model itself
146
+ def self.build_from_hash(attributes)
147
+ return nil unless attributes.is_a?(Hash)
148
+ attributes = attributes.transform_keys(&:to_sym)
149
+ transformed_hash = {}
150
+ openapi_types.each_pair do |key, type|
151
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
152
+ transformed_hash["#{key}"] = nil
153
+ elsif type =~ /\AArray<(.*)>/i
154
+ # check to ensure the input is an array given that the attribute
155
+ # is documented as an array but the input is not
156
+ if attributes[attribute_map[key]].is_a?(Array)
157
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
158
+ end
159
+ elsif !attributes[attribute_map[key]].nil?
160
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
161
+ end
162
+ end
163
+ new(transformed_hash)
164
+ end
165
+
166
+ # Deserializes the data based on type
167
+ # @param string type Data type
168
+ # @param string value Value to be deserialized
169
+ # @return [Object] Deserialized data
170
+ def self._deserialize(type, value)
171
+ case type.to_sym
172
+ when :Time
173
+ Time.parse(value)
174
+ when :Date
175
+ Date.parse(value)
176
+ when :String
177
+ value.to_s
178
+ when :Integer
179
+ value.to_i
180
+ when :Float
181
+ value.to_f
182
+ when :Boolean
183
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
184
+ true
185
+ else
186
+ false
187
+ end
188
+ when :Object
189
+ # generic object (usually a Hash), return directly
190
+ value
191
+ when /\AArray<(?<inner_type>.+)>\z/
192
+ inner_type = Regexp.last_match[:inner_type]
193
+ value.map { |v| _deserialize(inner_type, v) }
194
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
195
+ k_type = Regexp.last_match[:k_type]
196
+ v_type = Regexp.last_match[:v_type]
197
+ {}.tap do |hash|
198
+ value.each do |k, v|
199
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
200
+ end
201
+ end
202
+ else # model
203
+ # models (e.g. Pet) or oneOf
204
+ klass = PulpPythonClient.const_get(type)
205
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
206
+ end
207
+ end
208
+
209
+ # Returns the string representation of the object
210
+ # @return [String] String presentation of the object
211
+ def to_s
212
+ to_hash.to_s
213
+ end
214
+
215
+ # to_body is an alias to to_hash (backward compatibility)
216
+ # @return [Hash] Returns the object in the form of hash
217
+ def to_body
218
+ to_hash
219
+ end
220
+
221
+ # Returns the object in the form of hash
222
+ # @return [Hash] Returns the object in the form of hash
223
+ def to_hash
224
+ hash = {}
225
+ self.class.attribute_map.each_pair do |attr, param|
226
+ value = self.send(attr)
227
+ if value.nil?
228
+ is_nullable = self.class.openapi_nullable.include?(attr)
229
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
230
+ end
231
+
232
+ hash[param] = _to_hash(value)
233
+ end
234
+ hash
235
+ end
236
+
237
+ # Outputs non-array value in the form of hash
238
+ # For object, use to_hash. Otherwise, just return the value
239
+ # @param [Object] value Any valid value
240
+ # @return [Hash] Returns the value in the form of hash
241
+ def _to_hash(value)
242
+ if value.is_a?(Array)
243
+ value.compact.map { |v| _to_hash(v) }
244
+ elsif value.is_a?(Hash)
245
+ {}.tap do |hash|
246
+ value.each { |k, v| hash[k] = _to_hash(v) }
247
+ end
248
+ elsif value.respond_to? :to_hash
249
+ value.to_hash
250
+ else
251
+ value
252
+ end
253
+ end
254
+
255
+ end
256
+
257
+ end