pulp_deb_client 3.0.0 → 3.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +35 -7
- data/docs/ContentGenericContentsApi.md +7 -5
- data/docs/ContentInstallerFileIndicesApi.md +3 -1
- data/docs/ContentInstallerPackagesApi.md +7 -5
- data/docs/ContentPackageIndicesApi.md +3 -1
- data/docs/ContentPackageReleaseComponentsApi.md +3 -1
- data/docs/ContentPackagesApi.md +23 -5
- data/docs/ContentReleaseArchitecturesApi.md +3 -1
- data/docs/ContentReleaseComponentsApi.md +3 -1
- data/docs/ContentReleaseFilesApi.md +3 -1
- data/docs/ContentReleasesApi.md +3 -1
- data/docs/ContentSourceIndicesApi.md +204 -0
- data/docs/ContentSourcePackagesApi.md +258 -0
- data/docs/ContentSourceReleaseComponentsApi.md +202 -0
- data/docs/DebCopyApi.md +1 -1
- data/docs/DebGenericContent.md +2 -2
- data/docs/DebInstallerPackage.md +2 -2
- data/docs/DebPackage.md +2 -2
- data/docs/DebSourceIndex.md +25 -0
- data/docs/DebSourceIndexResponse.md +27 -0
- data/docs/DebSourcePackage.md +21 -0
- data/docs/DebSourcePackageReleaseComponent.md +21 -0
- data/docs/DebSourcePackageReleaseComponentResponse.md +23 -0
- data/docs/DebSourcePackageResponse.md +77 -0
- data/docs/DistributionsAptApi.md +123 -1
- data/docs/PaginateddebSourceIndexResponseList.md +23 -0
- data/docs/PaginateddebSourcePackageReleaseComponentResponseList.md +23 -0
- data/docs/PaginateddebSourcePackageResponseList.md +23 -0
- data/docs/PublicationsAptApi.md +3 -1
- data/docs/PublicationsVerbatimApi.md +3 -1
- data/docs/RemotesAptApi.md +123 -1
- data/docs/RepositoriesAptApi.md +123 -1
- data/docs/RepositoriesAptVersionsApi.md +3 -1
- data/docs/SetLabel.md +19 -0
- data/docs/SetLabelResponse.md +19 -0
- data/docs/UnsetLabel.md +17 -0
- data/docs/UnsetLabelResponse.md +19 -0
- data/lib/pulp_deb_client/api/content_generic_contents_api.rb +7 -4
- data/lib/pulp_deb_client/api/content_installer_file_indices_api.rb +3 -0
- data/lib/pulp_deb_client/api/content_installer_packages_api.rb +7 -4
- data/lib/pulp_deb_client/api/content_package_indices_api.rb +3 -0
- data/lib/pulp_deb_client/api/content_package_release_components_api.rb +3 -0
- data/lib/pulp_deb_client/api/content_packages_api.rb +31 -4
- data/lib/pulp_deb_client/api/content_release_architectures_api.rb +3 -0
- data/lib/pulp_deb_client/api/content_release_components_api.rb +3 -0
- data/lib/pulp_deb_client/api/content_release_files_api.rb +3 -0
- data/lib/pulp_deb_client/api/content_releases_api.rb +3 -0
- data/lib/pulp_deb_client/api/content_source_indices_api.rb +256 -0
- data/lib/pulp_deb_client/api/content_source_packages_api.rb +337 -0
- data/lib/pulp_deb_client/api/content_source_release_components_api.rb +253 -0
- data/lib/pulp_deb_client/api/distributions_apt_api.rb +155 -0
- data/lib/pulp_deb_client/api/publications_apt_api.rb +3 -0
- data/lib/pulp_deb_client/api/publications_verbatim_api.rb +3 -0
- data/lib/pulp_deb_client/api/remotes_apt_api.rb +155 -0
- data/lib/pulp_deb_client/api/repositories_apt_api.rb +155 -0
- data/lib/pulp_deb_client/api/repositories_apt_versions_api.rb +3 -0
- data/lib/pulp_deb_client/configuration.rb +2 -2
- data/lib/pulp_deb_client/models/deb_generic_content.rb +2 -2
- data/lib/pulp_deb_client/models/deb_installer_package.rb +2 -2
- data/lib/pulp_deb_client/models/deb_package.rb +2 -2
- data/lib/pulp_deb_client/models/deb_source_index.rb +297 -0
- data/lib/pulp_deb_client/models/deb_source_index_response.rb +272 -0
- data/lib/pulp_deb_client/models/deb_source_package.rb +248 -0
- data/lib/pulp_deb_client/models/deb_source_package_release_component.rb +238 -0
- data/lib/pulp_deb_client/models/deb_source_package_release_component_response.rb +247 -0
- data/lib/pulp_deb_client/models/deb_source_package_response.rb +485 -0
- data/lib/pulp_deb_client/models/paginateddeb_source_index_response_list.rb +237 -0
- data/lib/pulp_deb_client/models/paginateddeb_source_package_release_component_response_list.rb +237 -0
- data/lib/pulp_deb_client/models/paginateddeb_source_package_response_list.rb +237 -0
- data/lib/pulp_deb_client/models/set_label.rb +252 -0
- data/lib/pulp_deb_client/models/set_label_response.rb +243 -0
- data/lib/pulp_deb_client/models/unset_label.rb +242 -0
- data/lib/pulp_deb_client/models/unset_label_response.rb +242 -0
- data/lib/pulp_deb_client/version.rb +1 -1
- data/lib/pulp_deb_client.rb +16 -0
- data/spec/api/content_generic_contents_api_spec.rb +3 -2
- data/spec/api/content_installer_file_indices_api_spec.rb +1 -0
- data/spec/api/content_installer_packages_api_spec.rb +3 -2
- data/spec/api/content_package_indices_api_spec.rb +1 -0
- data/spec/api/content_package_release_components_api_spec.rb +1 -0
- data/spec/api/content_packages_api_spec.rb +11 -2
- data/spec/api/content_release_architectures_api_spec.rb +1 -0
- data/spec/api/content_release_components_api_spec.rb +1 -0
- data/spec/api/content_release_files_api_spec.rb +1 -0
- data/spec/api/content_releases_api_spec.rb +1 -0
- data/spec/api/content_source_indices_api_spec.rb +86 -0
- data/spec/api/content_source_packages_api_spec.rb +113 -0
- data/spec/api/content_source_release_components_api_spec.rb +85 -0
- data/spec/api/distributions_apt_api_spec.rb +31 -0
- data/spec/api/publications_apt_api_spec.rb +1 -0
- data/spec/api/publications_verbatim_api_spec.rb +1 -0
- data/spec/api/remotes_apt_api_spec.rb +31 -0
- data/spec/api/repositories_apt_api_spec.rb +31 -0
- data/spec/api/repositories_apt_versions_api_spec.rb +1 -0
- data/spec/configuration_spec.rb +3 -3
- data/spec/models/deb_source_index_response_spec.rb +71 -0
- data/spec/models/deb_source_index_spec.rb +65 -0
- data/spec/models/deb_source_package_release_component_response_spec.rb +59 -0
- data/spec/models/deb_source_package_release_component_spec.rb +53 -0
- data/spec/models/deb_source_package_response_spec.rb +221 -0
- data/spec/models/deb_source_package_spec.rb +53 -0
- data/spec/models/paginateddeb_source_index_response_list_spec.rb +59 -0
- data/spec/models/paginateddeb_source_package_release_component_response_list_spec.rb +59 -0
- data/spec/models/paginateddeb_source_package_response_list_spec.rb +59 -0
- data/spec/models/set_label_response_spec.rb +47 -0
- data/spec/models/set_label_spec.rb +47 -0
- data/spec/models/unset_label_response_spec.rb +47 -0
- data/spec/models/unset_label_spec.rb +41 -0
- metadata +120 -56
@@ -0,0 +1,238 @@
|
|
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
|
+
OpenAPI Generator version: 4.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module PulpDebClient
|
16
|
+
# A Serializer for SourcePackageReleaseComponent.
|
17
|
+
class DebSourcePackageReleaseComponent
|
18
|
+
# A URI of a repository the new content unit should be associated with.
|
19
|
+
attr_accessor :repository
|
20
|
+
|
21
|
+
# Source package that is contained in release_component.
|
22
|
+
attr_accessor :source_package
|
23
|
+
|
24
|
+
# ReleaseComponent this source package is contained in.
|
25
|
+
attr_accessor :release_component
|
26
|
+
|
27
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
28
|
+
def self.attribute_map
|
29
|
+
{
|
30
|
+
:'repository' => :'repository',
|
31
|
+
:'source_package' => :'source_package',
|
32
|
+
:'release_component' => :'release_component'
|
33
|
+
}
|
34
|
+
end
|
35
|
+
|
36
|
+
# Attribute type mapping.
|
37
|
+
def self.openapi_types
|
38
|
+
{
|
39
|
+
:'repository' => :'String',
|
40
|
+
:'source_package' => :'String',
|
41
|
+
:'release_component' => :'String'
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
# List of attributes with nullable: true
|
46
|
+
def self.openapi_nullable
|
47
|
+
Set.new([
|
48
|
+
])
|
49
|
+
end
|
50
|
+
|
51
|
+
# Initializes the object
|
52
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
53
|
+
def initialize(attributes = {})
|
54
|
+
if (!attributes.is_a?(Hash))
|
55
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `PulpDebClient::DebSourcePackageReleaseComponent` initialize method"
|
56
|
+
end
|
57
|
+
|
58
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
59
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
60
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
61
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `PulpDebClient::DebSourcePackageReleaseComponent`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
62
|
+
end
|
63
|
+
h[k.to_sym] = v
|
64
|
+
}
|
65
|
+
|
66
|
+
if attributes.key?(:'repository')
|
67
|
+
self.repository = attributes[:'repository']
|
68
|
+
end
|
69
|
+
|
70
|
+
if attributes.key?(:'source_package')
|
71
|
+
self.source_package = attributes[:'source_package']
|
72
|
+
end
|
73
|
+
|
74
|
+
if attributes.key?(:'release_component')
|
75
|
+
self.release_component = attributes[:'release_component']
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
80
|
+
# @return Array for valid properties with the reasons
|
81
|
+
def list_invalid_properties
|
82
|
+
invalid_properties = Array.new
|
83
|
+
if @source_package.nil?
|
84
|
+
invalid_properties.push('invalid value for "source_package", source_package cannot be nil.')
|
85
|
+
end
|
86
|
+
|
87
|
+
if @release_component.nil?
|
88
|
+
invalid_properties.push('invalid value for "release_component", release_component cannot be nil.')
|
89
|
+
end
|
90
|
+
|
91
|
+
invalid_properties
|
92
|
+
end
|
93
|
+
|
94
|
+
# Check to see if the all the properties in the model are valid
|
95
|
+
# @return true if the model is valid
|
96
|
+
def valid?
|
97
|
+
return false if @source_package.nil?
|
98
|
+
return false if @release_component.nil?
|
99
|
+
true
|
100
|
+
end
|
101
|
+
|
102
|
+
# Checks equality by comparing each attribute.
|
103
|
+
# @param [Object] Object to be compared
|
104
|
+
def ==(o)
|
105
|
+
return true if self.equal?(o)
|
106
|
+
self.class == o.class &&
|
107
|
+
repository == o.repository &&
|
108
|
+
source_package == o.source_package &&
|
109
|
+
release_component == o.release_component
|
110
|
+
end
|
111
|
+
|
112
|
+
# @see the `==` method
|
113
|
+
# @param [Object] Object to be compared
|
114
|
+
def eql?(o)
|
115
|
+
self == o
|
116
|
+
end
|
117
|
+
|
118
|
+
# Calculates hash code according to all attributes.
|
119
|
+
# @return [Integer] Hash code
|
120
|
+
def hash
|
121
|
+
[repository, source_package, release_component].hash
|
122
|
+
end
|
123
|
+
|
124
|
+
# Builds the object from hash
|
125
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
126
|
+
# @return [Object] Returns the model itself
|
127
|
+
def self.build_from_hash(attributes)
|
128
|
+
new.build_from_hash(attributes)
|
129
|
+
end
|
130
|
+
|
131
|
+
# Builds the object from hash
|
132
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
133
|
+
# @return [Object] Returns the model itself
|
134
|
+
def build_from_hash(attributes)
|
135
|
+
return nil unless attributes.is_a?(Hash)
|
136
|
+
self.class.openapi_types.each_pair do |key, type|
|
137
|
+
if type =~ /\AArray<(.*)>/i
|
138
|
+
# check to ensure the input is an array given that the attribute
|
139
|
+
# is documented as an array but the input is not
|
140
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
141
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
142
|
+
end
|
143
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
144
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
145
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
146
|
+
end
|
147
|
+
|
148
|
+
self
|
149
|
+
end
|
150
|
+
|
151
|
+
# Deserializes the data based on type
|
152
|
+
# @param string type Data type
|
153
|
+
# @param string value Value to be deserialized
|
154
|
+
# @return [Object] Deserialized data
|
155
|
+
def _deserialize(type, value)
|
156
|
+
case type.to_sym
|
157
|
+
when :DateTime
|
158
|
+
DateTime.parse(value)
|
159
|
+
when :Date
|
160
|
+
Date.parse(value)
|
161
|
+
when :String
|
162
|
+
value.to_s
|
163
|
+
when :Integer
|
164
|
+
value.to_i
|
165
|
+
when :Float
|
166
|
+
value.to_f
|
167
|
+
when :Boolean
|
168
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
169
|
+
true
|
170
|
+
else
|
171
|
+
false
|
172
|
+
end
|
173
|
+
when :Object
|
174
|
+
# generic object (usually a Hash), return directly
|
175
|
+
value
|
176
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
177
|
+
inner_type = Regexp.last_match[:inner_type]
|
178
|
+
value.map { |v| _deserialize(inner_type, v) }
|
179
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
180
|
+
k_type = Regexp.last_match[:k_type]
|
181
|
+
v_type = Regexp.last_match[:v_type]
|
182
|
+
{}.tap do |hash|
|
183
|
+
value.each do |k, v|
|
184
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
185
|
+
end
|
186
|
+
end
|
187
|
+
else # model
|
188
|
+
PulpDebClient.const_get(type).build_from_hash(value)
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
# Returns the string representation of the object
|
193
|
+
# @return [String] String presentation of the object
|
194
|
+
def to_s
|
195
|
+
to_hash.to_s
|
196
|
+
end
|
197
|
+
|
198
|
+
# to_body is an alias to to_hash (backward compatibility)
|
199
|
+
# @return [Hash] Returns the object in the form of hash
|
200
|
+
def to_body
|
201
|
+
to_hash
|
202
|
+
end
|
203
|
+
|
204
|
+
# Returns the object in the form of hash
|
205
|
+
# @return [Hash] Returns the object in the form of hash
|
206
|
+
def to_hash
|
207
|
+
hash = {}
|
208
|
+
self.class.attribute_map.each_pair do |attr, param|
|
209
|
+
value = self.send(attr)
|
210
|
+
if value.nil?
|
211
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
212
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
213
|
+
end
|
214
|
+
|
215
|
+
hash[param] = _to_hash(value)
|
216
|
+
end
|
217
|
+
hash
|
218
|
+
end
|
219
|
+
|
220
|
+
# Outputs non-array value in the form of hash
|
221
|
+
# For object, use to_hash. Otherwise, just return the value
|
222
|
+
# @param [Object] value Any valid value
|
223
|
+
# @return [Hash] Returns the value in the form of hash
|
224
|
+
def _to_hash(value)
|
225
|
+
if value.is_a?(Array)
|
226
|
+
value.compact.map { |v| _to_hash(v) }
|
227
|
+
elsif value.is_a?(Hash)
|
228
|
+
{}.tap do |hash|
|
229
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
230
|
+
end
|
231
|
+
elsif value.respond_to? :to_hash
|
232
|
+
value.to_hash
|
233
|
+
else
|
234
|
+
value
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
@@ -0,0 +1,247 @@
|
|
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
|
+
OpenAPI Generator version: 4.3.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module PulpDebClient
|
16
|
+
# A Serializer for SourcePackageReleaseComponent.
|
17
|
+
class DebSourcePackageReleaseComponentResponse
|
18
|
+
attr_accessor :pulp_href
|
19
|
+
|
20
|
+
# Timestamp of creation.
|
21
|
+
attr_accessor :pulp_created
|
22
|
+
|
23
|
+
# Source package that is contained in release_component.
|
24
|
+
attr_accessor :source_package
|
25
|
+
|
26
|
+
# ReleaseComponent this source package is contained in.
|
27
|
+
attr_accessor :release_component
|
28
|
+
|
29
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
30
|
+
def self.attribute_map
|
31
|
+
{
|
32
|
+
:'pulp_href' => :'pulp_href',
|
33
|
+
:'pulp_created' => :'pulp_created',
|
34
|
+
:'source_package' => :'source_package',
|
35
|
+
:'release_component' => :'release_component'
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
# Attribute type mapping.
|
40
|
+
def self.openapi_types
|
41
|
+
{
|
42
|
+
:'pulp_href' => :'String',
|
43
|
+
:'pulp_created' => :'DateTime',
|
44
|
+
:'source_package' => :'String',
|
45
|
+
:'release_component' => :'String'
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
# List of attributes with nullable: true
|
50
|
+
def self.openapi_nullable
|
51
|
+
Set.new([
|
52
|
+
])
|
53
|
+
end
|
54
|
+
|
55
|
+
# Initializes the object
|
56
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
57
|
+
def initialize(attributes = {})
|
58
|
+
if (!attributes.is_a?(Hash))
|
59
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `PulpDebClient::DebSourcePackageReleaseComponentResponse` initialize method"
|
60
|
+
end
|
61
|
+
|
62
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
63
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
64
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
65
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `PulpDebClient::DebSourcePackageReleaseComponentResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
66
|
+
end
|
67
|
+
h[k.to_sym] = v
|
68
|
+
}
|
69
|
+
|
70
|
+
if attributes.key?(:'pulp_href')
|
71
|
+
self.pulp_href = attributes[:'pulp_href']
|
72
|
+
end
|
73
|
+
|
74
|
+
if attributes.key?(:'pulp_created')
|
75
|
+
self.pulp_created = attributes[:'pulp_created']
|
76
|
+
end
|
77
|
+
|
78
|
+
if attributes.key?(:'source_package')
|
79
|
+
self.source_package = attributes[:'source_package']
|
80
|
+
end
|
81
|
+
|
82
|
+
if attributes.key?(:'release_component')
|
83
|
+
self.release_component = attributes[:'release_component']
|
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 @source_package.nil?
|
92
|
+
invalid_properties.push('invalid value for "source_package", source_package cannot be nil.')
|
93
|
+
end
|
94
|
+
|
95
|
+
if @release_component.nil?
|
96
|
+
invalid_properties.push('invalid value for "release_component", release_component 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 @source_package.nil?
|
106
|
+
return false if @release_component.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
|
+
pulp_href == o.pulp_href &&
|
116
|
+
pulp_created == o.pulp_created &&
|
117
|
+
source_package == o.source_package &&
|
118
|
+
release_component == o.release_component
|
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
|
+
[pulp_href, pulp_created, source_package, release_component].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
|
+
PulpDebClient.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
|