pulpcore_client 3.2.1 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -4
- data/docs/ArtifactsApi.md +2 -0
- data/docs/ExportersCoreExportsApi.md +243 -0
- data/docs/ExportersPulpApi.md +355 -0
- data/docs/Import.md +23 -0
- data/docs/ImportersCoreImportsApi.md +243 -0
- data/docs/ImportersPulpApi.md +355 -0
- data/docs/InlineResponse2001.md +1 -1
- data/docs/InlineResponse2002.md +1 -1
- data/docs/InlineResponse2003.md +1 -1
- data/docs/InlineResponse2004.md +1 -1
- data/docs/InlineResponse2005.md +23 -0
- data/docs/InlineResponse2006.md +23 -0
- data/docs/InlineResponse2007.md +23 -0
- data/docs/InlineResponse2008.md +23 -0
- data/docs/InlineResponse2009.md +23 -0
- data/docs/PulpExport.md +29 -0
- data/docs/PulpExporter.md +27 -0
- data/docs/PulpImport.md +17 -0
- data/docs/PulpImporter.md +23 -0
- data/docs/SigningServicesApi.md +6 -2
- data/docs/Task.md +6 -0
- data/docs/TaskGroup.md +29 -0
- data/docs/TaskGroupsApi.md +128 -0
- data/docs/TasksApi.md +10 -6
- data/docs/UploadsApi.md +4 -2
- data/docs/WorkersApi.md +4 -2
- data/lib/pulpcore_client/api/artifacts_api.rb +3 -0
- data/lib/pulpcore_client/api/exporters_core_exports_api.rb +297 -0
- data/lib/pulpcore_client/api/exporters_pulp_api.rb +431 -0
- data/lib/pulpcore_client/api/importers_core_imports_api.rb +297 -0
- data/lib/pulpcore_client/api/importers_pulp_api.rb +431 -0
- data/lib/pulpcore_client/api/signing_services_api.rb +9 -3
- data/lib/pulpcore_client/api/task_groups_api.rb +157 -0
- data/lib/pulpcore_client/api/tasks_api.rb +15 -9
- data/lib/pulpcore_client/api/uploads_api.rb +6 -3
- data/lib/pulpcore_client/api/workers_api.rb +6 -3
- data/lib/pulpcore_client/models/import.rb +246 -0
- data/lib/pulpcore_client/models/inline_response2001.rb +1 -1
- data/lib/pulpcore_client/models/inline_response2002.rb +1 -1
- data/lib/pulpcore_client/models/inline_response2003.rb +1 -1
- data/lib/pulpcore_client/models/inline_response2004.rb +1 -1
- data/lib/pulpcore_client/models/inline_response2005.rb +247 -0
- data/lib/pulpcore_client/models/inline_response2006.rb +247 -0
- data/lib/pulpcore_client/models/inline_response2007.rb +247 -0
- data/lib/pulpcore_client/models/inline_response2008.rb +247 -0
- data/lib/pulpcore_client/models/inline_response2009.rb +247 -0
- data/lib/pulpcore_client/models/pulp_export.rb +310 -0
- data/lib/pulpcore_client/models/pulp_exporter.rb +310 -0
- data/lib/pulpcore_client/models/pulp_import.rb +231 -0
- data/lib/pulpcore_client/models/pulp_importer.rb +262 -0
- data/lib/pulpcore_client/models/task.rb +33 -1
- data/lib/pulpcore_client/models/task_group.rb +291 -0
- data/lib/pulpcore_client/version.rb +1 -1
- data/lib/pulpcore_client.rb +16 -0
- data/spec/api/artifacts_api_spec.rb +1 -0
- data/spec/api/exporters_core_exports_api_spec.rb +91 -0
- data/spec/api/exporters_pulp_api_spec.rb +117 -0
- data/spec/api/importers_core_imports_api_spec.rb +91 -0
- data/spec/api/importers_pulp_api_spec.rb +117 -0
- data/spec/api/signing_services_api_spec.rb +3 -1
- data/spec/api/task_groups_api_spec.rb +63 -0
- data/spec/api/tasks_api_spec.rb +5 -3
- data/spec/api/uploads_api_spec.rb +2 -1
- data/spec/api/workers_api_spec.rb +2 -1
- data/spec/models/import_spec.rb +59 -0
- data/spec/models/inline_response2005_spec.rb +59 -0
- data/spec/models/inline_response2006_spec.rb +59 -0
- data/spec/models/inline_response2007_spec.rb +59 -0
- data/spec/models/inline_response2008_spec.rb +59 -0
- data/spec/models/inline_response2009_spec.rb +59 -0
- data/spec/models/pulp_export_spec.rb +77 -0
- data/spec/models/pulp_exporter_spec.rb +71 -0
- data/spec/models/pulp_import_spec.rb +41 -0
- data/spec/models/pulp_importer_spec.rb +59 -0
- data/spec/models/task_group_spec.rb +77 -0
- data/spec/models/task_spec.rb +18 -0
- metadata +66 -2
@@ -0,0 +1,247 @@
|
|
1
|
+
=begin
|
2
|
+
#Pulp 3 API
|
3
|
+
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
|
+
|
6
|
+
The version of the OpenAPI document: v3
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module PulpcoreClient
|
16
|
+
class InlineResponse2009
|
17
|
+
attr_accessor :count
|
18
|
+
|
19
|
+
attr_accessor :_next
|
20
|
+
|
21
|
+
attr_accessor :previous
|
22
|
+
|
23
|
+
attr_accessor :results
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
:'count' => :'count',
|
29
|
+
:'_next' => :'next',
|
30
|
+
:'previous' => :'previous',
|
31
|
+
:'results' => :'results'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# Attribute type mapping.
|
36
|
+
def self.openapi_types
|
37
|
+
{
|
38
|
+
:'count' => :'Integer',
|
39
|
+
:'_next' => :'String',
|
40
|
+
:'previous' => :'String',
|
41
|
+
:'results' => :'Array<Worker>'
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
# List of attributes with nullable: true
|
46
|
+
def self.openapi_nullable
|
47
|
+
Set.new([
|
48
|
+
:'_next',
|
49
|
+
:'previous',
|
50
|
+
])
|
51
|
+
end
|
52
|
+
|
53
|
+
# Initializes the object
|
54
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
55
|
+
def initialize(attributes = {})
|
56
|
+
if (!attributes.is_a?(Hash))
|
57
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `PulpcoreClient::InlineResponse2009` initialize method"
|
58
|
+
end
|
59
|
+
|
60
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
61
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
62
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
63
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `PulpcoreClient::InlineResponse2009`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
64
|
+
end
|
65
|
+
h[k.to_sym] = v
|
66
|
+
}
|
67
|
+
|
68
|
+
if attributes.key?(:'count')
|
69
|
+
self.count = attributes[:'count']
|
70
|
+
end
|
71
|
+
|
72
|
+
if attributes.key?(:'_next')
|
73
|
+
self._next = attributes[:'_next']
|
74
|
+
end
|
75
|
+
|
76
|
+
if attributes.key?(:'previous')
|
77
|
+
self.previous = attributes[:'previous']
|
78
|
+
end
|
79
|
+
|
80
|
+
if attributes.key?(:'results')
|
81
|
+
if (value = attributes[:'results']).is_a?(Array)
|
82
|
+
self.results = value
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
88
|
+
# @return Array for valid properties with the reasons
|
89
|
+
def list_invalid_properties
|
90
|
+
invalid_properties = Array.new
|
91
|
+
if @count.nil?
|
92
|
+
invalid_properties.push('invalid value for "count", count cannot be nil.')
|
93
|
+
end
|
94
|
+
|
95
|
+
if @results.nil?
|
96
|
+
invalid_properties.push('invalid value for "results", results cannot be nil.')
|
97
|
+
end
|
98
|
+
|
99
|
+
invalid_properties
|
100
|
+
end
|
101
|
+
|
102
|
+
# Check to see if the all the properties in the model are valid
|
103
|
+
# @return true if the model is valid
|
104
|
+
def valid?
|
105
|
+
return false if @count.nil?
|
106
|
+
return false if @results.nil?
|
107
|
+
true
|
108
|
+
end
|
109
|
+
|
110
|
+
# Checks equality by comparing each attribute.
|
111
|
+
# @param [Object] Object to be compared
|
112
|
+
def ==(o)
|
113
|
+
return true if self.equal?(o)
|
114
|
+
self.class == o.class &&
|
115
|
+
count == o.count &&
|
116
|
+
_next == o._next &&
|
117
|
+
previous == o.previous &&
|
118
|
+
results == o.results
|
119
|
+
end
|
120
|
+
|
121
|
+
# @see the `==` method
|
122
|
+
# @param [Object] Object to be compared
|
123
|
+
def eql?(o)
|
124
|
+
self == o
|
125
|
+
end
|
126
|
+
|
127
|
+
# Calculates hash code according to all attributes.
|
128
|
+
# @return [Integer] Hash code
|
129
|
+
def hash
|
130
|
+
[count, _next, previous, results].hash
|
131
|
+
end
|
132
|
+
|
133
|
+
# Builds the object from hash
|
134
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
135
|
+
# @return [Object] Returns the model itself
|
136
|
+
def self.build_from_hash(attributes)
|
137
|
+
new.build_from_hash(attributes)
|
138
|
+
end
|
139
|
+
|
140
|
+
# Builds the object from hash
|
141
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
142
|
+
# @return [Object] Returns the model itself
|
143
|
+
def build_from_hash(attributes)
|
144
|
+
return nil unless attributes.is_a?(Hash)
|
145
|
+
self.class.openapi_types.each_pair do |key, type|
|
146
|
+
if type =~ /\AArray<(.*)>/i
|
147
|
+
# check to ensure the input is an array given that the attribute
|
148
|
+
# is documented as an array but the input is not
|
149
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
150
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
151
|
+
end
|
152
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
153
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
154
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
155
|
+
end
|
156
|
+
|
157
|
+
self
|
158
|
+
end
|
159
|
+
|
160
|
+
# Deserializes the data based on type
|
161
|
+
# @param string type Data type
|
162
|
+
# @param string value Value to be deserialized
|
163
|
+
# @return [Object] Deserialized data
|
164
|
+
def _deserialize(type, value)
|
165
|
+
case type.to_sym
|
166
|
+
when :DateTime
|
167
|
+
DateTime.parse(value)
|
168
|
+
when :Date
|
169
|
+
Date.parse(value)
|
170
|
+
when :String
|
171
|
+
value.to_s
|
172
|
+
when :Integer
|
173
|
+
value.to_i
|
174
|
+
when :Float
|
175
|
+
value.to_f
|
176
|
+
when :Boolean
|
177
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
178
|
+
true
|
179
|
+
else
|
180
|
+
false
|
181
|
+
end
|
182
|
+
when :Object
|
183
|
+
# generic object (usually a Hash), return directly
|
184
|
+
value
|
185
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
186
|
+
inner_type = Regexp.last_match[:inner_type]
|
187
|
+
value.map { |v| _deserialize(inner_type, v) }
|
188
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
189
|
+
k_type = Regexp.last_match[:k_type]
|
190
|
+
v_type = Regexp.last_match[:v_type]
|
191
|
+
{}.tap do |hash|
|
192
|
+
value.each do |k, v|
|
193
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
else # model
|
197
|
+
PulpcoreClient.const_get(type).build_from_hash(value)
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
# Returns the string representation of the object
|
202
|
+
# @return [String] String presentation of the object
|
203
|
+
def to_s
|
204
|
+
to_hash.to_s
|
205
|
+
end
|
206
|
+
|
207
|
+
# to_body is an alias to to_hash (backward compatibility)
|
208
|
+
# @return [Hash] Returns the object in the form of hash
|
209
|
+
def to_body
|
210
|
+
to_hash
|
211
|
+
end
|
212
|
+
|
213
|
+
# Returns the object in the form of hash
|
214
|
+
# @return [Hash] Returns the object in the form of hash
|
215
|
+
def to_hash
|
216
|
+
hash = {}
|
217
|
+
self.class.attribute_map.each_pair do |attr, param|
|
218
|
+
value = self.send(attr)
|
219
|
+
if value.nil?
|
220
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
221
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
222
|
+
end
|
223
|
+
|
224
|
+
hash[param] = _to_hash(value)
|
225
|
+
end
|
226
|
+
hash
|
227
|
+
end
|
228
|
+
|
229
|
+
# Outputs non-array value in the form of hash
|
230
|
+
# For object, use to_hash. Otherwise, just return the value
|
231
|
+
# @param [Object] value Any valid value
|
232
|
+
# @return [Hash] Returns the value in the form of hash
|
233
|
+
def _to_hash(value)
|
234
|
+
if value.is_a?(Array)
|
235
|
+
value.compact.map { |v| _to_hash(v) }
|
236
|
+
elsif value.is_a?(Hash)
|
237
|
+
{}.tap do |hash|
|
238
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
239
|
+
end
|
240
|
+
elsif value.respond_to? :to_hash
|
241
|
+
value.to_hash
|
242
|
+
else
|
243
|
+
value
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|
@@ -0,0 +1,310 @@
|
|
1
|
+
=begin
|
2
|
+
#Pulp 3 API
|
3
|
+
|
4
|
+
#No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
|
5
|
+
|
6
|
+
The version of the OpenAPI document: v3
|
7
|
+
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module PulpcoreClient
|
16
|
+
class PulpExport
|
17
|
+
attr_accessor :pulp_href
|
18
|
+
|
19
|
+
# Timestamp of creation.
|
20
|
+
attr_accessor :pulp_created
|
21
|
+
|
22
|
+
# A URI of the task that ran the Export.
|
23
|
+
attr_accessor :task
|
24
|
+
|
25
|
+
# Resources that were exported.
|
26
|
+
attr_accessor :exported_resources
|
27
|
+
|
28
|
+
# Any additional parameters that were used to create the export.
|
29
|
+
attr_accessor :params
|
30
|
+
|
31
|
+
# The SHA-256 checksum of the exported .tar.gz.
|
32
|
+
attr_accessor :sha256
|
33
|
+
|
34
|
+
# The full-path filename of the exported .tar.gz.
|
35
|
+
attr_accessor :filename
|
36
|
+
|
37
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
38
|
+
def self.attribute_map
|
39
|
+
{
|
40
|
+
:'pulp_href' => :'pulp_href',
|
41
|
+
:'pulp_created' => :'pulp_created',
|
42
|
+
:'task' => :'task',
|
43
|
+
:'exported_resources' => :'exported_resources',
|
44
|
+
:'params' => :'params',
|
45
|
+
:'sha256' => :'sha256',
|
46
|
+
:'filename' => :'filename'
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
# Attribute type mapping.
|
51
|
+
def self.openapi_types
|
52
|
+
{
|
53
|
+
:'pulp_href' => :'String',
|
54
|
+
:'pulp_created' => :'DateTime',
|
55
|
+
:'task' => :'String',
|
56
|
+
:'exported_resources' => :'Array<Object>',
|
57
|
+
:'params' => :'Object',
|
58
|
+
:'sha256' => :'String',
|
59
|
+
:'filename' => :'String'
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
# List of attributes with nullable: true
|
64
|
+
def self.openapi_nullable
|
65
|
+
Set.new([
|
66
|
+
:'sha256',
|
67
|
+
:'filename'
|
68
|
+
])
|
69
|
+
end
|
70
|
+
|
71
|
+
# Initializes the object
|
72
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
73
|
+
def initialize(attributes = {})
|
74
|
+
if (!attributes.is_a?(Hash))
|
75
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `PulpcoreClient::PulpExport` initialize method"
|
76
|
+
end
|
77
|
+
|
78
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
79
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
80
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
81
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `PulpcoreClient::PulpExport`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
82
|
+
end
|
83
|
+
h[k.to_sym] = v
|
84
|
+
}
|
85
|
+
|
86
|
+
if attributes.key?(:'pulp_href')
|
87
|
+
self.pulp_href = attributes[:'pulp_href']
|
88
|
+
end
|
89
|
+
|
90
|
+
if attributes.key?(:'pulp_created')
|
91
|
+
self.pulp_created = attributes[:'pulp_created']
|
92
|
+
end
|
93
|
+
|
94
|
+
if attributes.key?(:'task')
|
95
|
+
self.task = attributes[:'task']
|
96
|
+
end
|
97
|
+
|
98
|
+
if attributes.key?(:'exported_resources')
|
99
|
+
if (value = attributes[:'exported_resources']).is_a?(Array)
|
100
|
+
self.exported_resources = value
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
if attributes.key?(:'params')
|
105
|
+
self.params = attributes[:'params']
|
106
|
+
end
|
107
|
+
|
108
|
+
if attributes.key?(:'sha256')
|
109
|
+
self.sha256 = attributes[:'sha256']
|
110
|
+
end
|
111
|
+
|
112
|
+
if attributes.key?(:'filename')
|
113
|
+
self.filename = attributes[:'filename']
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
118
|
+
# @return Array for valid properties with the reasons
|
119
|
+
def list_invalid_properties
|
120
|
+
invalid_properties = Array.new
|
121
|
+
if @task.nil?
|
122
|
+
invalid_properties.push('invalid value for "task", task cannot be nil.')
|
123
|
+
end
|
124
|
+
|
125
|
+
if @params.nil?
|
126
|
+
invalid_properties.push('invalid value for "params", params cannot be nil.')
|
127
|
+
end
|
128
|
+
|
129
|
+
if !@sha256.nil? && @sha256.to_s.length < 1
|
130
|
+
invalid_properties.push('invalid value for "sha256", the character length must be great than or equal to 1.')
|
131
|
+
end
|
132
|
+
|
133
|
+
if !@filename.nil? && @filename.to_s.length < 1
|
134
|
+
invalid_properties.push('invalid value for "filename", the character length must be great than or equal to 1.')
|
135
|
+
end
|
136
|
+
|
137
|
+
invalid_properties
|
138
|
+
end
|
139
|
+
|
140
|
+
# Check to see if the all the properties in the model are valid
|
141
|
+
# @return true if the model is valid
|
142
|
+
def valid?
|
143
|
+
return false if @task.nil?
|
144
|
+
return false if @params.nil?
|
145
|
+
return false if !@sha256.nil? && @sha256.to_s.length < 1
|
146
|
+
return false if !@filename.nil? && @filename.to_s.length < 1
|
147
|
+
true
|
148
|
+
end
|
149
|
+
|
150
|
+
# Custom attribute writer method with validation
|
151
|
+
# @param [Object] sha256 Value to be assigned
|
152
|
+
def sha256=(sha256)
|
153
|
+
if !sha256.nil? && sha256.to_s.length < 1
|
154
|
+
fail ArgumentError, 'invalid value for "sha256", the character length must be great than or equal to 1.'
|
155
|
+
end
|
156
|
+
|
157
|
+
@sha256 = sha256
|
158
|
+
end
|
159
|
+
|
160
|
+
# Custom attribute writer method with validation
|
161
|
+
# @param [Object] filename Value to be assigned
|
162
|
+
def filename=(filename)
|
163
|
+
if !filename.nil? && filename.to_s.length < 1
|
164
|
+
fail ArgumentError, 'invalid value for "filename", the character length must be great than or equal to 1.'
|
165
|
+
end
|
166
|
+
|
167
|
+
@filename = filename
|
168
|
+
end
|
169
|
+
|
170
|
+
# Checks equality by comparing each attribute.
|
171
|
+
# @param [Object] Object to be compared
|
172
|
+
def ==(o)
|
173
|
+
return true if self.equal?(o)
|
174
|
+
self.class == o.class &&
|
175
|
+
pulp_href == o.pulp_href &&
|
176
|
+
pulp_created == o.pulp_created &&
|
177
|
+
task == o.task &&
|
178
|
+
exported_resources == o.exported_resources &&
|
179
|
+
params == o.params &&
|
180
|
+
sha256 == o.sha256 &&
|
181
|
+
filename == o.filename
|
182
|
+
end
|
183
|
+
|
184
|
+
# @see the `==` method
|
185
|
+
# @param [Object] Object to be compared
|
186
|
+
def eql?(o)
|
187
|
+
self == o
|
188
|
+
end
|
189
|
+
|
190
|
+
# Calculates hash code according to all attributes.
|
191
|
+
# @return [Integer] Hash code
|
192
|
+
def hash
|
193
|
+
[pulp_href, pulp_created, task, exported_resources, params, sha256, filename].hash
|
194
|
+
end
|
195
|
+
|
196
|
+
# Builds the object from hash
|
197
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
198
|
+
# @return [Object] Returns the model itself
|
199
|
+
def self.build_from_hash(attributes)
|
200
|
+
new.build_from_hash(attributes)
|
201
|
+
end
|
202
|
+
|
203
|
+
# Builds the object from hash
|
204
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
205
|
+
# @return [Object] Returns the model itself
|
206
|
+
def build_from_hash(attributes)
|
207
|
+
return nil unless attributes.is_a?(Hash)
|
208
|
+
self.class.openapi_types.each_pair do |key, type|
|
209
|
+
if type =~ /\AArray<(.*)>/i
|
210
|
+
# check to ensure the input is an array given that the attribute
|
211
|
+
# is documented as an array but the input is not
|
212
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
213
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
214
|
+
end
|
215
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
216
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
217
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
218
|
+
end
|
219
|
+
|
220
|
+
self
|
221
|
+
end
|
222
|
+
|
223
|
+
# Deserializes the data based on type
|
224
|
+
# @param string type Data type
|
225
|
+
# @param string value Value to be deserialized
|
226
|
+
# @return [Object] Deserialized data
|
227
|
+
def _deserialize(type, value)
|
228
|
+
case type.to_sym
|
229
|
+
when :DateTime
|
230
|
+
DateTime.parse(value)
|
231
|
+
when :Date
|
232
|
+
Date.parse(value)
|
233
|
+
when :String
|
234
|
+
value.to_s
|
235
|
+
when :Integer
|
236
|
+
value.to_i
|
237
|
+
when :Float
|
238
|
+
value.to_f
|
239
|
+
when :Boolean
|
240
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
241
|
+
true
|
242
|
+
else
|
243
|
+
false
|
244
|
+
end
|
245
|
+
when :Object
|
246
|
+
# generic object (usually a Hash), return directly
|
247
|
+
value
|
248
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
249
|
+
inner_type = Regexp.last_match[:inner_type]
|
250
|
+
value.map { |v| _deserialize(inner_type, v) }
|
251
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
252
|
+
k_type = Regexp.last_match[:k_type]
|
253
|
+
v_type = Regexp.last_match[:v_type]
|
254
|
+
{}.tap do |hash|
|
255
|
+
value.each do |k, v|
|
256
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
257
|
+
end
|
258
|
+
end
|
259
|
+
else # model
|
260
|
+
PulpcoreClient.const_get(type).build_from_hash(value)
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
# Returns the string representation of the object
|
265
|
+
# @return [String] String presentation of the object
|
266
|
+
def to_s
|
267
|
+
to_hash.to_s
|
268
|
+
end
|
269
|
+
|
270
|
+
# to_body is an alias to to_hash (backward compatibility)
|
271
|
+
# @return [Hash] Returns the object in the form of hash
|
272
|
+
def to_body
|
273
|
+
to_hash
|
274
|
+
end
|
275
|
+
|
276
|
+
# Returns the object in the form of hash
|
277
|
+
# @return [Hash] Returns the object in the form of hash
|
278
|
+
def to_hash
|
279
|
+
hash = {}
|
280
|
+
self.class.attribute_map.each_pair do |attr, param|
|
281
|
+
value = self.send(attr)
|
282
|
+
if value.nil?
|
283
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
284
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
285
|
+
end
|
286
|
+
|
287
|
+
hash[param] = _to_hash(value)
|
288
|
+
end
|
289
|
+
hash
|
290
|
+
end
|
291
|
+
|
292
|
+
# Outputs non-array value in the form of hash
|
293
|
+
# For object, use to_hash. Otherwise, just return the value
|
294
|
+
# @param [Object] value Any valid value
|
295
|
+
# @return [Hash] Returns the value in the form of hash
|
296
|
+
def _to_hash(value)
|
297
|
+
if value.is_a?(Array)
|
298
|
+
value.compact.map { |v| _to_hash(v) }
|
299
|
+
elsif value.is_a?(Hash)
|
300
|
+
{}.tap do |hash|
|
301
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
302
|
+
end
|
303
|
+
elsif value.respond_to? :to_hash
|
304
|
+
value.to_hash
|
305
|
+
else
|
306
|
+
value
|
307
|
+
end
|
308
|
+
end
|
309
|
+
end
|
310
|
+
end
|