pulp_file_client 1.0.1 → 1.1.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 +6 -12
- data/docs/ContentFilesApi.md +2 -2
- data/docs/DistributionsFileApi.md +2 -2
- data/docs/{ExportRead.md → Export.md} +2 -2
- data/docs/ExportersFileExportsApi.md +2 -2
- data/docs/ExportersFilesystemApi.md +8 -8
- data/docs/{FileFileContentRead.md → FileFileContent.md} +2 -2
- data/docs/InlineResponse200.md +1 -1
- 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 +1 -1
- data/docs/InlineResponse2006.md +1 -1
- data/docs/InlineResponse2007.md +1 -1
- data/docs/PublicationsFileApi.md +2 -2
- data/docs/RemotesFileApi.md +4 -4
- data/docs/RepositoriesFileApi.md +4 -4
- data/docs/RepositoriesFileVersionsApi.md +6 -4
- data/lib/pulp_file_client/api/content_files_api.rb +3 -3
- data/lib/pulp_file_client/api/distributions_file_api.rb +3 -3
- data/lib/pulp_file_client/api/exporters_file_exports_api.rb +3 -3
- data/lib/pulp_file_client/api/exporters_filesystem_api.rb +12 -12
- data/lib/pulp_file_client/api/publications_file_api.rb +3 -3
- data/lib/pulp_file_client/api/remotes_file_api.rb +6 -6
- data/lib/pulp_file_client/api/repositories_file_api.rb +6 -6
- data/lib/pulp_file_client/api/repositories_file_versions_api.rb +9 -6
- data/lib/pulp_file_client/models/{export_read.rb → export.rb} +3 -3
- data/lib/pulp_file_client/models/{file_file_content_read.rb → file_file_content.rb} +3 -3
- data/lib/pulp_file_client/models/inline_response200.rb +1 -1
- data/lib/pulp_file_client/models/inline_response2001.rb +1 -1
- data/lib/pulp_file_client/models/inline_response2002.rb +1 -1
- data/lib/pulp_file_client/models/inline_response2003.rb +1 -1
- data/lib/pulp_file_client/models/inline_response2004.rb +1 -1
- data/lib/pulp_file_client/models/inline_response2005.rb +1 -1
- data/lib/pulp_file_client/models/inline_response2006.rb +1 -1
- data/lib/pulp_file_client/models/inline_response2007.rb +1 -1
- data/lib/pulp_file_client/version.rb +1 -1
- data/lib/pulp_file_client.rb +2 -8
- data/spec/api/content_files_api_spec.rb +1 -1
- data/spec/api/distributions_file_api_spec.rb +1 -1
- data/spec/api/exporters_file_exports_api_spec.rb +1 -1
- data/spec/api/exporters_filesystem_api_spec.rb +4 -4
- data/spec/api/publications_file_api_spec.rb +1 -1
- data/spec/api/remotes_file_api_spec.rb +2 -2
- data/spec/api/repositories_file_api_spec.rb +2 -2
- data/spec/api/repositories_file_versions_api_spec.rb +3 -2
- data/spec/models/{export_read_spec.rb → export_spec.rb} +6 -6
- data/spec/models/{file_file_content_read_spec.rb → file_file_content_spec.rb} +6 -6
- metadata +10 -34
- data/docs/FileFileDistributionRead.md +0 -29
- data/docs/FileFileFilesystemExporterRead.md +0 -23
- data/docs/FileFilePublicationRead.md +0 -27
- data/docs/FileFileRemoteRead.md +0 -43
- data/docs/FileFileRepositoryRead.md +0 -27
- data/docs/RepositoryVersionRead.md +0 -25
- data/lib/pulp_file_client/models/file_file_distribution_read.rb +0 -331
- data/lib/pulp_file_client/models/file_file_filesystem_exporter_read.rb +0 -284
- data/lib/pulp_file_client/models/file_file_publication_read.rb +0 -274
- data/lib/pulp_file_client/models/file_file_remote_read.rb +0 -531
- data/lib/pulp_file_client/models/file_file_repository_read.rb +0 -294
- data/lib/pulp_file_client/models/repository_version_read.rb +0 -244
- data/spec/models/file_file_distribution_read_spec.rb +0 -77
- data/spec/models/file_file_filesystem_exporter_read_spec.rb +0 -59
- data/spec/models/file_file_publication_read_spec.rb +0 -71
- data/spec/models/file_file_remote_read_spec.rb +0 -123
- data/spec/models/file_file_repository_read_spec.rb +0 -71
- data/spec/models/repository_version_read_spec.rb +0 -65
@@ -1,284 +0,0 @@
|
|
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 PulpFileClient
|
16
|
-
class FileFileFilesystemExporterRead
|
17
|
-
attr_accessor :pulp_href
|
18
|
-
|
19
|
-
# Timestamp of creation.
|
20
|
-
attr_accessor :pulp_created
|
21
|
-
|
22
|
-
# Unique name of the file system exporter.
|
23
|
-
attr_accessor :name
|
24
|
-
|
25
|
-
# File system location to export to.
|
26
|
-
attr_accessor :path
|
27
|
-
|
28
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
29
|
-
def self.attribute_map
|
30
|
-
{
|
31
|
-
:'pulp_href' => :'pulp_href',
|
32
|
-
:'pulp_created' => :'pulp_created',
|
33
|
-
:'name' => :'name',
|
34
|
-
:'path' => :'path'
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
# Attribute type mapping.
|
39
|
-
def self.openapi_types
|
40
|
-
{
|
41
|
-
:'pulp_href' => :'String',
|
42
|
-
:'pulp_created' => :'DateTime',
|
43
|
-
:'name' => :'String',
|
44
|
-
:'path' => :'String'
|
45
|
-
}
|
46
|
-
end
|
47
|
-
|
48
|
-
# List of attributes with nullable: true
|
49
|
-
def self.openapi_nullable
|
50
|
-
Set.new([
|
51
|
-
])
|
52
|
-
end
|
53
|
-
|
54
|
-
# Initializes the object
|
55
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
56
|
-
def initialize(attributes = {})
|
57
|
-
if (!attributes.is_a?(Hash))
|
58
|
-
fail ArgumentError, "The input argument (attributes) must be a hash in `PulpFileClient::FileFileFilesystemExporterRead` initialize method"
|
59
|
-
end
|
60
|
-
|
61
|
-
# check to see if the attribute exists and convert string to symbol for hash key
|
62
|
-
attributes = attributes.each_with_object({}) { |(k, v), h|
|
63
|
-
if (!self.class.attribute_map.key?(k.to_sym))
|
64
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `PulpFileClient::FileFileFilesystemExporterRead`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
65
|
-
end
|
66
|
-
h[k.to_sym] = v
|
67
|
-
}
|
68
|
-
|
69
|
-
if attributes.key?(:'pulp_href')
|
70
|
-
self.pulp_href = attributes[:'pulp_href']
|
71
|
-
end
|
72
|
-
|
73
|
-
if attributes.key?(:'pulp_created')
|
74
|
-
self.pulp_created = attributes[:'pulp_created']
|
75
|
-
end
|
76
|
-
|
77
|
-
if attributes.key?(:'name')
|
78
|
-
self.name = attributes[:'name']
|
79
|
-
end
|
80
|
-
|
81
|
-
if attributes.key?(:'path')
|
82
|
-
self.path = attributes[:'path']
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
87
|
-
# @return Array for valid properties with the reasons
|
88
|
-
def list_invalid_properties
|
89
|
-
invalid_properties = Array.new
|
90
|
-
if @name.nil?
|
91
|
-
invalid_properties.push('invalid value for "name", name cannot be nil.')
|
92
|
-
end
|
93
|
-
|
94
|
-
if @name.to_s.length < 1
|
95
|
-
invalid_properties.push('invalid value for "name", the character length must be great than or equal to 1.')
|
96
|
-
end
|
97
|
-
|
98
|
-
if @path.nil?
|
99
|
-
invalid_properties.push('invalid value for "path", path cannot be nil.')
|
100
|
-
end
|
101
|
-
|
102
|
-
if @path.to_s.length < 1
|
103
|
-
invalid_properties.push('invalid value for "path", the character length must be great than or equal to 1.')
|
104
|
-
end
|
105
|
-
|
106
|
-
invalid_properties
|
107
|
-
end
|
108
|
-
|
109
|
-
# Check to see if the all the properties in the model are valid
|
110
|
-
# @return true if the model is valid
|
111
|
-
def valid?
|
112
|
-
return false if @name.nil?
|
113
|
-
return false if @name.to_s.length < 1
|
114
|
-
return false if @path.nil?
|
115
|
-
return false if @path.to_s.length < 1
|
116
|
-
true
|
117
|
-
end
|
118
|
-
|
119
|
-
# Custom attribute writer method with validation
|
120
|
-
# @param [Object] name Value to be assigned
|
121
|
-
def name=(name)
|
122
|
-
if name.nil?
|
123
|
-
fail ArgumentError, 'name cannot be nil'
|
124
|
-
end
|
125
|
-
|
126
|
-
if name.to_s.length < 1
|
127
|
-
fail ArgumentError, 'invalid value for "name", the character length must be great than or equal to 1.'
|
128
|
-
end
|
129
|
-
|
130
|
-
@name = name
|
131
|
-
end
|
132
|
-
|
133
|
-
# Custom attribute writer method with validation
|
134
|
-
# @param [Object] path Value to be assigned
|
135
|
-
def path=(path)
|
136
|
-
if path.nil?
|
137
|
-
fail ArgumentError, 'path cannot be nil'
|
138
|
-
end
|
139
|
-
|
140
|
-
if path.to_s.length < 1
|
141
|
-
fail ArgumentError, 'invalid value for "path", the character length must be great than or equal to 1.'
|
142
|
-
end
|
143
|
-
|
144
|
-
@path = path
|
145
|
-
end
|
146
|
-
|
147
|
-
# Checks equality by comparing each attribute.
|
148
|
-
# @param [Object] Object to be compared
|
149
|
-
def ==(o)
|
150
|
-
return true if self.equal?(o)
|
151
|
-
self.class == o.class &&
|
152
|
-
pulp_href == o.pulp_href &&
|
153
|
-
pulp_created == o.pulp_created &&
|
154
|
-
name == o.name &&
|
155
|
-
path == o.path
|
156
|
-
end
|
157
|
-
|
158
|
-
# @see the `==` method
|
159
|
-
# @param [Object] Object to be compared
|
160
|
-
def eql?(o)
|
161
|
-
self == o
|
162
|
-
end
|
163
|
-
|
164
|
-
# Calculates hash code according to all attributes.
|
165
|
-
# @return [Integer] Hash code
|
166
|
-
def hash
|
167
|
-
[pulp_href, pulp_created, name, path].hash
|
168
|
-
end
|
169
|
-
|
170
|
-
# Builds the object from hash
|
171
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
172
|
-
# @return [Object] Returns the model itself
|
173
|
-
def self.build_from_hash(attributes)
|
174
|
-
new.build_from_hash(attributes)
|
175
|
-
end
|
176
|
-
|
177
|
-
# Builds the object from hash
|
178
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
179
|
-
# @return [Object] Returns the model itself
|
180
|
-
def build_from_hash(attributes)
|
181
|
-
return nil unless attributes.is_a?(Hash)
|
182
|
-
self.class.openapi_types.each_pair do |key, type|
|
183
|
-
if type =~ /\AArray<(.*)>/i
|
184
|
-
# check to ensure the input is an array given that the attribute
|
185
|
-
# is documented as an array but the input is not
|
186
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
187
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
188
|
-
end
|
189
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
190
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
191
|
-
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
192
|
-
end
|
193
|
-
|
194
|
-
self
|
195
|
-
end
|
196
|
-
|
197
|
-
# Deserializes the data based on type
|
198
|
-
# @param string type Data type
|
199
|
-
# @param string value Value to be deserialized
|
200
|
-
# @return [Object] Deserialized data
|
201
|
-
def _deserialize(type, value)
|
202
|
-
case type.to_sym
|
203
|
-
when :DateTime
|
204
|
-
DateTime.parse(value)
|
205
|
-
when :Date
|
206
|
-
Date.parse(value)
|
207
|
-
when :String
|
208
|
-
value.to_s
|
209
|
-
when :Integer
|
210
|
-
value.to_i
|
211
|
-
when :Float
|
212
|
-
value.to_f
|
213
|
-
when :Boolean
|
214
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
215
|
-
true
|
216
|
-
else
|
217
|
-
false
|
218
|
-
end
|
219
|
-
when :Object
|
220
|
-
# generic object (usually a Hash), return directly
|
221
|
-
value
|
222
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
223
|
-
inner_type = Regexp.last_match[:inner_type]
|
224
|
-
value.map { |v| _deserialize(inner_type, v) }
|
225
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
226
|
-
k_type = Regexp.last_match[:k_type]
|
227
|
-
v_type = Regexp.last_match[:v_type]
|
228
|
-
{}.tap do |hash|
|
229
|
-
value.each do |k, v|
|
230
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
231
|
-
end
|
232
|
-
end
|
233
|
-
else # model
|
234
|
-
PulpFileClient.const_get(type).build_from_hash(value)
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
# Returns the string representation of the object
|
239
|
-
# @return [String] String presentation of the object
|
240
|
-
def to_s
|
241
|
-
to_hash.to_s
|
242
|
-
end
|
243
|
-
|
244
|
-
# to_body is an alias to to_hash (backward compatibility)
|
245
|
-
# @return [Hash] Returns the object in the form of hash
|
246
|
-
def to_body
|
247
|
-
to_hash
|
248
|
-
end
|
249
|
-
|
250
|
-
# Returns the object in the form of hash
|
251
|
-
# @return [Hash] Returns the object in the form of hash
|
252
|
-
def to_hash
|
253
|
-
hash = {}
|
254
|
-
self.class.attribute_map.each_pair do |attr, param|
|
255
|
-
value = self.send(attr)
|
256
|
-
if value.nil?
|
257
|
-
is_nullable = self.class.openapi_nullable.include?(attr)
|
258
|
-
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
259
|
-
end
|
260
|
-
|
261
|
-
hash[param] = _to_hash(value)
|
262
|
-
end
|
263
|
-
hash
|
264
|
-
end
|
265
|
-
|
266
|
-
# Outputs non-array value in the form of hash
|
267
|
-
# For object, use to_hash. Otherwise, just return the value
|
268
|
-
# @param [Object] value Any valid value
|
269
|
-
# @return [Hash] Returns the value in the form of hash
|
270
|
-
def _to_hash(value)
|
271
|
-
if value.is_a?(Array)
|
272
|
-
value.compact.map { |v| _to_hash(v) }
|
273
|
-
elsif value.is_a?(Hash)
|
274
|
-
{}.tap do |hash|
|
275
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
276
|
-
end
|
277
|
-
elsif value.respond_to? :to_hash
|
278
|
-
value.to_hash
|
279
|
-
else
|
280
|
-
value
|
281
|
-
end
|
282
|
-
end
|
283
|
-
end
|
284
|
-
end
|
@@ -1,274 +0,0 @@
|
|
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 PulpFileClient
|
16
|
-
class FileFilePublicationRead
|
17
|
-
attr_accessor :pulp_href
|
18
|
-
|
19
|
-
# Timestamp of creation.
|
20
|
-
attr_accessor :pulp_created
|
21
|
-
|
22
|
-
attr_accessor :repository_version
|
23
|
-
|
24
|
-
# A URI of the repository to be published.
|
25
|
-
attr_accessor :repository
|
26
|
-
|
27
|
-
# This publication is currently hosted as defined by these distributions.
|
28
|
-
attr_accessor :distributions
|
29
|
-
|
30
|
-
# Filename to use for manifest file containing metadata for all the files.
|
31
|
-
attr_accessor :manifest
|
32
|
-
|
33
|
-
# Attribute mapping from ruby-style variable name to JSON key.
|
34
|
-
def self.attribute_map
|
35
|
-
{
|
36
|
-
:'pulp_href' => :'pulp_href',
|
37
|
-
:'pulp_created' => :'pulp_created',
|
38
|
-
:'repository_version' => :'repository_version',
|
39
|
-
:'repository' => :'repository',
|
40
|
-
:'distributions' => :'distributions',
|
41
|
-
:'manifest' => :'manifest'
|
42
|
-
}
|
43
|
-
end
|
44
|
-
|
45
|
-
# Attribute type mapping.
|
46
|
-
def self.openapi_types
|
47
|
-
{
|
48
|
-
:'pulp_href' => :'String',
|
49
|
-
:'pulp_created' => :'DateTime',
|
50
|
-
:'repository_version' => :'String',
|
51
|
-
:'repository' => :'String',
|
52
|
-
:'distributions' => :'Array<String>',
|
53
|
-
:'manifest' => :'String'
|
54
|
-
}
|
55
|
-
end
|
56
|
-
|
57
|
-
# List of attributes with nullable: true
|
58
|
-
def self.openapi_nullable
|
59
|
-
Set.new([
|
60
|
-
])
|
61
|
-
end
|
62
|
-
|
63
|
-
# Initializes the object
|
64
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
65
|
-
def initialize(attributes = {})
|
66
|
-
if (!attributes.is_a?(Hash))
|
67
|
-
fail ArgumentError, "The input argument (attributes) must be a hash in `PulpFileClient::FileFilePublicationRead` initialize method"
|
68
|
-
end
|
69
|
-
|
70
|
-
# check to see if the attribute exists and convert string to symbol for hash key
|
71
|
-
attributes = attributes.each_with_object({}) { |(k, v), h|
|
72
|
-
if (!self.class.attribute_map.key?(k.to_sym))
|
73
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `PulpFileClient::FileFilePublicationRead`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
74
|
-
end
|
75
|
-
h[k.to_sym] = v
|
76
|
-
}
|
77
|
-
|
78
|
-
if attributes.key?(:'pulp_href')
|
79
|
-
self.pulp_href = attributes[:'pulp_href']
|
80
|
-
end
|
81
|
-
|
82
|
-
if attributes.key?(:'pulp_created')
|
83
|
-
self.pulp_created = attributes[:'pulp_created']
|
84
|
-
end
|
85
|
-
|
86
|
-
if attributes.key?(:'repository_version')
|
87
|
-
self.repository_version = attributes[:'repository_version']
|
88
|
-
end
|
89
|
-
|
90
|
-
if attributes.key?(:'repository')
|
91
|
-
self.repository = attributes[:'repository']
|
92
|
-
end
|
93
|
-
|
94
|
-
if attributes.key?(:'distributions')
|
95
|
-
if (value = attributes[:'distributions']).is_a?(Array)
|
96
|
-
self.distributions = value
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
|
-
if attributes.key?(:'manifest')
|
101
|
-
self.manifest = attributes[:'manifest']
|
102
|
-
else
|
103
|
-
self.manifest = 'PULP_MANIFEST'
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
# Show invalid properties with the reasons. Usually used together with valid?
|
108
|
-
# @return Array for valid properties with the reasons
|
109
|
-
def list_invalid_properties
|
110
|
-
invalid_properties = Array.new
|
111
|
-
if !@manifest.nil? && @manifest.to_s.length < 1
|
112
|
-
invalid_properties.push('invalid value for "manifest", the character length must be great than or equal to 1.')
|
113
|
-
end
|
114
|
-
|
115
|
-
invalid_properties
|
116
|
-
end
|
117
|
-
|
118
|
-
# Check to see if the all the properties in the model are valid
|
119
|
-
# @return true if the model is valid
|
120
|
-
def valid?
|
121
|
-
return false if !@manifest.nil? && @manifest.to_s.length < 1
|
122
|
-
true
|
123
|
-
end
|
124
|
-
|
125
|
-
# Custom attribute writer method with validation
|
126
|
-
# @param [Object] manifest Value to be assigned
|
127
|
-
def manifest=(manifest)
|
128
|
-
if !manifest.nil? && manifest.to_s.length < 1
|
129
|
-
fail ArgumentError, 'invalid value for "manifest", the character length must be great than or equal to 1.'
|
130
|
-
end
|
131
|
-
|
132
|
-
@manifest = manifest
|
133
|
-
end
|
134
|
-
|
135
|
-
# Checks equality by comparing each attribute.
|
136
|
-
# @param [Object] Object to be compared
|
137
|
-
def ==(o)
|
138
|
-
return true if self.equal?(o)
|
139
|
-
self.class == o.class &&
|
140
|
-
pulp_href == o.pulp_href &&
|
141
|
-
pulp_created == o.pulp_created &&
|
142
|
-
repository_version == o.repository_version &&
|
143
|
-
repository == o.repository &&
|
144
|
-
distributions == o.distributions &&
|
145
|
-
manifest == o.manifest
|
146
|
-
end
|
147
|
-
|
148
|
-
# @see the `==` method
|
149
|
-
# @param [Object] Object to be compared
|
150
|
-
def eql?(o)
|
151
|
-
self == o
|
152
|
-
end
|
153
|
-
|
154
|
-
# Calculates hash code according to all attributes.
|
155
|
-
# @return [Integer] Hash code
|
156
|
-
def hash
|
157
|
-
[pulp_href, pulp_created, repository_version, repository, distributions, manifest].hash
|
158
|
-
end
|
159
|
-
|
160
|
-
# Builds the object from hash
|
161
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
162
|
-
# @return [Object] Returns the model itself
|
163
|
-
def self.build_from_hash(attributes)
|
164
|
-
new.build_from_hash(attributes)
|
165
|
-
end
|
166
|
-
|
167
|
-
# Builds the object from hash
|
168
|
-
# @param [Hash] attributes Model attributes in the form of hash
|
169
|
-
# @return [Object] Returns the model itself
|
170
|
-
def build_from_hash(attributes)
|
171
|
-
return nil unless attributes.is_a?(Hash)
|
172
|
-
self.class.openapi_types.each_pair do |key, type|
|
173
|
-
if type =~ /\AArray<(.*)>/i
|
174
|
-
# check to ensure the input is an array given that the attribute
|
175
|
-
# is documented as an array but the input is not
|
176
|
-
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
177
|
-
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
178
|
-
end
|
179
|
-
elsif !attributes[self.class.attribute_map[key]].nil?
|
180
|
-
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
181
|
-
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
182
|
-
end
|
183
|
-
|
184
|
-
self
|
185
|
-
end
|
186
|
-
|
187
|
-
# Deserializes the data based on type
|
188
|
-
# @param string type Data type
|
189
|
-
# @param string value Value to be deserialized
|
190
|
-
# @return [Object] Deserialized data
|
191
|
-
def _deserialize(type, value)
|
192
|
-
case type.to_sym
|
193
|
-
when :DateTime
|
194
|
-
DateTime.parse(value)
|
195
|
-
when :Date
|
196
|
-
Date.parse(value)
|
197
|
-
when :String
|
198
|
-
value.to_s
|
199
|
-
when :Integer
|
200
|
-
value.to_i
|
201
|
-
when :Float
|
202
|
-
value.to_f
|
203
|
-
when :Boolean
|
204
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
205
|
-
true
|
206
|
-
else
|
207
|
-
false
|
208
|
-
end
|
209
|
-
when :Object
|
210
|
-
# generic object (usually a Hash), return directly
|
211
|
-
value
|
212
|
-
when /\AArray<(?<inner_type>.+)>\z/
|
213
|
-
inner_type = Regexp.last_match[:inner_type]
|
214
|
-
value.map { |v| _deserialize(inner_type, v) }
|
215
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
216
|
-
k_type = Regexp.last_match[:k_type]
|
217
|
-
v_type = Regexp.last_match[:v_type]
|
218
|
-
{}.tap do |hash|
|
219
|
-
value.each do |k, v|
|
220
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
221
|
-
end
|
222
|
-
end
|
223
|
-
else # model
|
224
|
-
PulpFileClient.const_get(type).build_from_hash(value)
|
225
|
-
end
|
226
|
-
end
|
227
|
-
|
228
|
-
# Returns the string representation of the object
|
229
|
-
# @return [String] String presentation of the object
|
230
|
-
def to_s
|
231
|
-
to_hash.to_s
|
232
|
-
end
|
233
|
-
|
234
|
-
# to_body is an alias to to_hash (backward compatibility)
|
235
|
-
# @return [Hash] Returns the object in the form of hash
|
236
|
-
def to_body
|
237
|
-
to_hash
|
238
|
-
end
|
239
|
-
|
240
|
-
# Returns the object in the form of hash
|
241
|
-
# @return [Hash] Returns the object in the form of hash
|
242
|
-
def to_hash
|
243
|
-
hash = {}
|
244
|
-
self.class.attribute_map.each_pair do |attr, param|
|
245
|
-
value = self.send(attr)
|
246
|
-
if value.nil?
|
247
|
-
is_nullable = self.class.openapi_nullable.include?(attr)
|
248
|
-
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
249
|
-
end
|
250
|
-
|
251
|
-
hash[param] = _to_hash(value)
|
252
|
-
end
|
253
|
-
hash
|
254
|
-
end
|
255
|
-
|
256
|
-
# Outputs non-array value in the form of hash
|
257
|
-
# For object, use to_hash. Otherwise, just return the value
|
258
|
-
# @param [Object] value Any valid value
|
259
|
-
# @return [Hash] Returns the value in the form of hash
|
260
|
-
def _to_hash(value)
|
261
|
-
if value.is_a?(Array)
|
262
|
-
value.compact.map { |v| _to_hash(v) }
|
263
|
-
elsif value.is_a?(Hash)
|
264
|
-
{}.tap do |hash|
|
265
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
266
|
-
end
|
267
|
-
elsif value.respond_to? :to_hash
|
268
|
-
value.to_hash
|
269
|
-
else
|
270
|
-
value
|
271
|
-
end
|
272
|
-
end
|
273
|
-
end
|
274
|
-
end
|