pulp_docker_client 4.0.0b5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Gemfile +9 -0
- data/Gemfile.lock +79 -0
- data/README.md +131 -0
- data/Rakefile +10 -0
- data/docs/AsyncOperationResponse.md +17 -0
- data/docs/Blob.md +29 -0
- data/docs/ContentBlobsApi.md +182 -0
- data/docs/ContentManifestTagsApi.md +182 -0
- data/docs/ContentManifestsApi.md +180 -0
- data/docs/DistributionsDockerApi.md +352 -0
- data/docs/DockerDistribution.md +31 -0
- data/docs/DockerRemote.md +49 -0
- data/docs/InlineResponse200.md +23 -0
- data/docs/InlineResponse2001.md +23 -0
- data/docs/InlineResponse2002.md +23 -0
- data/docs/InlineResponse2003.md +23 -0
- data/docs/InlineResponse2004.md +23 -0
- data/docs/Manifest.md +37 -0
- data/docs/ManifestTag.md +29 -0
- data/docs/RemotesDockerApi.md +411 -0
- data/docs/RepositorySyncURL.md +19 -0
- data/git_push.sh +55 -0
- data/lib/pulp_docker_client/api/content_blobs_api.rb +222 -0
- data/lib/pulp_docker_client/api/content_manifest_tags_api.rb +222 -0
- data/lib/pulp_docker_client/api/content_manifests_api.rb +219 -0
- data/lib/pulp_docker_client/api/distributions_docker_api.rb +430 -0
- data/lib/pulp_docker_client/api/remotes_docker_api.rb +504 -0
- data/lib/pulp_docker_client/api_client.rb +387 -0
- data/lib/pulp_docker_client/api_error.rb +57 -0
- data/lib/pulp_docker_client/configuration.rb +251 -0
- data/lib/pulp_docker_client/models/async_operation_response.rb +202 -0
- data/lib/pulp_docker_client/models/blob.rb +347 -0
- data/lib/pulp_docker_client/models/docker_distribution.rb +347 -0
- data/lib/pulp_docker_client/models/docker_remote.rb +598 -0
- data/lib/pulp_docker_client/models/inline_response200.rb +235 -0
- data/lib/pulp_docker_client/models/inline_response2001.rb +235 -0
- data/lib/pulp_docker_client/models/inline_response2002.rb +235 -0
- data/lib/pulp_docker_client/models/inline_response2003.rb +235 -0
- data/lib/pulp_docker_client/models/inline_response2004.rb +235 -0
- data/lib/pulp_docker_client/models/manifest.rb +411 -0
- data/lib/pulp_docker_client/models/manifest_tag.rb +328 -0
- data/lib/pulp_docker_client/models/repository_sync_url.rb +214 -0
- data/lib/pulp_docker_client/version.rb +15 -0
- data/lib/pulp_docker_client.rb +56 -0
- data/pulp_docker_client.gemspec +45 -0
- data/spec/api/content_blobs_api_spec.rb +76 -0
- data/spec/api/content_manifest_tags_api_spec.rb +76 -0
- data/spec/api/content_manifests_api_spec.rb +75 -0
- data/spec/api/distributions_docker_api_spec.rb +116 -0
- data/spec/api/remotes_docker_api_spec.rb +130 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/async_operation_response_spec.rb +41 -0
- data/spec/models/blob_spec.rb +77 -0
- data/spec/models/docker_distribution_spec.rb +83 -0
- data/spec/models/docker_remote_spec.rb +141 -0
- data/spec/models/inline_response2001_spec.rb +59 -0
- data/spec/models/inline_response2002_spec.rb +59 -0
- data/spec/models/inline_response2003_spec.rb +59 -0
- data/spec/models/inline_response2004_spec.rb +59 -0
- data/spec/models/inline_response200_spec.rb +59 -0
- data/spec/models/manifest_spec.rb +101 -0
- data/spec/models/manifest_tag_spec.rb +77 -0
- data/spec/models/repository_sync_url_spec.rb +47 -0
- data/spec/spec_helper.rb +111 -0
- metadata +309 -0
@@ -0,0 +1,202 @@
|
|
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.0.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module PulpDockerClient
|
16
|
+
class AsyncOperationResponse
|
17
|
+
# The href of the task.
|
18
|
+
attr_accessor :task
|
19
|
+
|
20
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
21
|
+
def self.attribute_map
|
22
|
+
{
|
23
|
+
:'task' => :'task'
|
24
|
+
}
|
25
|
+
end
|
26
|
+
|
27
|
+
# Attribute type mapping.
|
28
|
+
def self.openapi_types
|
29
|
+
{
|
30
|
+
:'task' => :'String'
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
# Initializes the object
|
35
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
36
|
+
def initialize(attributes = {})
|
37
|
+
if (!attributes.is_a?(Hash))
|
38
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `PulpDockerClient::AsyncOperationResponse` initialize method"
|
39
|
+
end
|
40
|
+
|
41
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
42
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
43
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
44
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `PulpDockerClient::AsyncOperationResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
45
|
+
end
|
46
|
+
h[k.to_sym] = v
|
47
|
+
}
|
48
|
+
|
49
|
+
if attributes.key?(:'task')
|
50
|
+
self.task = attributes[:'task']
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
55
|
+
# @return Array for valid properties with the reasons
|
56
|
+
def list_invalid_properties
|
57
|
+
invalid_properties = Array.new
|
58
|
+
if @task.nil?
|
59
|
+
invalid_properties.push('invalid value for "task", task cannot be nil.')
|
60
|
+
end
|
61
|
+
|
62
|
+
invalid_properties
|
63
|
+
end
|
64
|
+
|
65
|
+
# Check to see if the all the properties in the model are valid
|
66
|
+
# @return true if the model is valid
|
67
|
+
def valid?
|
68
|
+
return false if @task.nil?
|
69
|
+
true
|
70
|
+
end
|
71
|
+
|
72
|
+
# Checks equality by comparing each attribute.
|
73
|
+
# @param [Object] Object to be compared
|
74
|
+
def ==(o)
|
75
|
+
return true if self.equal?(o)
|
76
|
+
self.class == o.class &&
|
77
|
+
task == o.task
|
78
|
+
end
|
79
|
+
|
80
|
+
# @see the `==` method
|
81
|
+
# @param [Object] Object to be compared
|
82
|
+
def eql?(o)
|
83
|
+
self == o
|
84
|
+
end
|
85
|
+
|
86
|
+
# Calculates hash code according to all attributes.
|
87
|
+
# @return [Integer] Hash code
|
88
|
+
def hash
|
89
|
+
[task].hash
|
90
|
+
end
|
91
|
+
|
92
|
+
# Builds the object from hash
|
93
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
94
|
+
# @return [Object] Returns the model itself
|
95
|
+
def self.build_from_hash(attributes)
|
96
|
+
new.build_from_hash(attributes)
|
97
|
+
end
|
98
|
+
|
99
|
+
# Builds the object from hash
|
100
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
101
|
+
# @return [Object] Returns the model itself
|
102
|
+
def build_from_hash(attributes)
|
103
|
+
return nil unless attributes.is_a?(Hash)
|
104
|
+
self.class.openapi_types.each_pair do |key, type|
|
105
|
+
if type =~ /\AArray<(.*)>/i
|
106
|
+
# check to ensure the input is an array given that the attribute
|
107
|
+
# is documented as an array but the input is not
|
108
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
109
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
110
|
+
end
|
111
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
112
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
113
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
114
|
+
end
|
115
|
+
|
116
|
+
self
|
117
|
+
end
|
118
|
+
|
119
|
+
# Deserializes the data based on type
|
120
|
+
# @param string type Data type
|
121
|
+
# @param string value Value to be deserialized
|
122
|
+
# @return [Object] Deserialized data
|
123
|
+
def _deserialize(type, value)
|
124
|
+
case type.to_sym
|
125
|
+
when :DateTime
|
126
|
+
DateTime.parse(value)
|
127
|
+
when :Date
|
128
|
+
Date.parse(value)
|
129
|
+
when :String
|
130
|
+
value.to_s
|
131
|
+
when :Integer
|
132
|
+
value.to_i
|
133
|
+
when :Float
|
134
|
+
value.to_f
|
135
|
+
when :Boolean
|
136
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
137
|
+
true
|
138
|
+
else
|
139
|
+
false
|
140
|
+
end
|
141
|
+
when :Object
|
142
|
+
# generic object (usually a Hash), return directly
|
143
|
+
value
|
144
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
145
|
+
inner_type = Regexp.last_match[:inner_type]
|
146
|
+
value.map { |v| _deserialize(inner_type, v) }
|
147
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
148
|
+
k_type = Regexp.last_match[:k_type]
|
149
|
+
v_type = Regexp.last_match[:v_type]
|
150
|
+
{}.tap do |hash|
|
151
|
+
value.each do |k, v|
|
152
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
else # model
|
156
|
+
PulpDockerClient.const_get(type).build_from_hash(value)
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
# Returns the string representation of the object
|
161
|
+
# @return [String] String presentation of the object
|
162
|
+
def to_s
|
163
|
+
to_hash.to_s
|
164
|
+
end
|
165
|
+
|
166
|
+
# to_body is an alias to to_hash (backward compatibility)
|
167
|
+
# @return [Hash] Returns the object in the form of hash
|
168
|
+
def to_body
|
169
|
+
to_hash
|
170
|
+
end
|
171
|
+
|
172
|
+
# Returns the object in the form of hash
|
173
|
+
# @return [Hash] Returns the object in the form of hash
|
174
|
+
def to_hash
|
175
|
+
hash = {}
|
176
|
+
self.class.attribute_map.each_pair do |attr, param|
|
177
|
+
value = self.send(attr)
|
178
|
+
next if value.nil?
|
179
|
+
hash[param] = _to_hash(value)
|
180
|
+
end
|
181
|
+
hash
|
182
|
+
end
|
183
|
+
|
184
|
+
# Outputs non-array value in the form of hash
|
185
|
+
# For object, use to_hash. Otherwise, just return the value
|
186
|
+
# @param [Object] value Any valid value
|
187
|
+
# @return [Hash] Returns the value in the form of hash
|
188
|
+
def _to_hash(value)
|
189
|
+
if value.is_a?(Array)
|
190
|
+
value.compact.map { |v| _to_hash(v) }
|
191
|
+
elsif value.is_a?(Hash)
|
192
|
+
{}.tap do |hash|
|
193
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
194
|
+
end
|
195
|
+
elsif value.respond_to? :to_hash
|
196
|
+
value.to_hash
|
197
|
+
else
|
198
|
+
value
|
199
|
+
end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
@@ -0,0 +1,347 @@
|
|
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.0.0
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module PulpDockerClient
|
16
|
+
class Blob
|
17
|
+
attr_accessor :_href
|
18
|
+
|
19
|
+
# Timestamp of creation.
|
20
|
+
attr_accessor :_created
|
21
|
+
|
22
|
+
attr_accessor :_type
|
23
|
+
|
24
|
+
# Artifact file representing the physical content
|
25
|
+
attr_accessor :_artifact
|
26
|
+
|
27
|
+
# Path where the artifact is located relative to distributions base_path
|
28
|
+
attr_accessor :_relative_path
|
29
|
+
|
30
|
+
# sha256 of the Blob file
|
31
|
+
attr_accessor :digest
|
32
|
+
|
33
|
+
# Docker media type of the file
|
34
|
+
attr_accessor :media_type
|
35
|
+
|
36
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
37
|
+
def self.attribute_map
|
38
|
+
{
|
39
|
+
:'_href' => :'_href',
|
40
|
+
:'_created' => :'_created',
|
41
|
+
:'_type' => :'_type',
|
42
|
+
:'_artifact' => :'_artifact',
|
43
|
+
:'_relative_path' => :'_relative_path',
|
44
|
+
:'digest' => :'digest',
|
45
|
+
:'media_type' => :'media_type'
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
# Attribute type mapping.
|
50
|
+
def self.openapi_types
|
51
|
+
{
|
52
|
+
:'_href' => :'String',
|
53
|
+
:'_created' => :'DateTime',
|
54
|
+
:'_type' => :'String',
|
55
|
+
:'_artifact' => :'String',
|
56
|
+
:'_relative_path' => :'String',
|
57
|
+
:'digest' => :'String',
|
58
|
+
:'media_type' => :'String'
|
59
|
+
}
|
60
|
+
end
|
61
|
+
|
62
|
+
# Initializes the object
|
63
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
64
|
+
def initialize(attributes = {})
|
65
|
+
if (!attributes.is_a?(Hash))
|
66
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `PulpDockerClient::Blob` initialize method"
|
67
|
+
end
|
68
|
+
|
69
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
70
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
71
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
72
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `PulpDockerClient::Blob`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
73
|
+
end
|
74
|
+
h[k.to_sym] = v
|
75
|
+
}
|
76
|
+
|
77
|
+
if attributes.key?(:'_href')
|
78
|
+
self._href = attributes[:'_href']
|
79
|
+
end
|
80
|
+
|
81
|
+
if attributes.key?(:'_created')
|
82
|
+
self._created = attributes[:'_created']
|
83
|
+
end
|
84
|
+
|
85
|
+
if attributes.key?(:'_type')
|
86
|
+
self._type = attributes[:'_type']
|
87
|
+
end
|
88
|
+
|
89
|
+
if attributes.key?(:'_artifact')
|
90
|
+
self._artifact = attributes[:'_artifact']
|
91
|
+
end
|
92
|
+
|
93
|
+
if attributes.key?(:'_relative_path')
|
94
|
+
self._relative_path = attributes[:'_relative_path']
|
95
|
+
end
|
96
|
+
|
97
|
+
if attributes.key?(:'digest')
|
98
|
+
self.digest = attributes[:'digest']
|
99
|
+
end
|
100
|
+
|
101
|
+
if attributes.key?(:'media_type')
|
102
|
+
self.media_type = attributes[:'media_type']
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
107
|
+
# @return Array for valid properties with the reasons
|
108
|
+
def list_invalid_properties
|
109
|
+
invalid_properties = Array.new
|
110
|
+
if !@_type.nil? && @_type.to_s.length < 1
|
111
|
+
invalid_properties.push('invalid value for "_type", the character length must be great than or equal to 1.')
|
112
|
+
end
|
113
|
+
|
114
|
+
if @_artifact.nil?
|
115
|
+
invalid_properties.push('invalid value for "_artifact", _artifact cannot be nil.')
|
116
|
+
end
|
117
|
+
|
118
|
+
if @_relative_path.nil?
|
119
|
+
invalid_properties.push('invalid value for "_relative_path", _relative_path cannot be nil.')
|
120
|
+
end
|
121
|
+
|
122
|
+
if @_relative_path.to_s.length < 1
|
123
|
+
invalid_properties.push('invalid value for "_relative_path", the character length must be great than or equal to 1.')
|
124
|
+
end
|
125
|
+
|
126
|
+
if @digest.nil?
|
127
|
+
invalid_properties.push('invalid value for "digest", digest cannot be nil.')
|
128
|
+
end
|
129
|
+
|
130
|
+
if @digest.to_s.length < 1
|
131
|
+
invalid_properties.push('invalid value for "digest", the character length must be great than or equal to 1.')
|
132
|
+
end
|
133
|
+
|
134
|
+
if @media_type.nil?
|
135
|
+
invalid_properties.push('invalid value for "media_type", media_type cannot be nil.')
|
136
|
+
end
|
137
|
+
|
138
|
+
if @media_type.to_s.length < 1
|
139
|
+
invalid_properties.push('invalid value for "media_type", the character length must be great than or equal to 1.')
|
140
|
+
end
|
141
|
+
|
142
|
+
invalid_properties
|
143
|
+
end
|
144
|
+
|
145
|
+
# Check to see if the all the properties in the model are valid
|
146
|
+
# @return true if the model is valid
|
147
|
+
def valid?
|
148
|
+
return false if !@_type.nil? && @_type.to_s.length < 1
|
149
|
+
return false if @_artifact.nil?
|
150
|
+
return false if @_relative_path.nil?
|
151
|
+
return false if @_relative_path.to_s.length < 1
|
152
|
+
return false if @digest.nil?
|
153
|
+
return false if @digest.to_s.length < 1
|
154
|
+
return false if @media_type.nil?
|
155
|
+
return false if @media_type.to_s.length < 1
|
156
|
+
true
|
157
|
+
end
|
158
|
+
|
159
|
+
# Custom attribute writer method with validation
|
160
|
+
# @param [Object] _type Value to be assigned
|
161
|
+
def _type=(_type)
|
162
|
+
if !_type.nil? && _type.to_s.length < 1
|
163
|
+
fail ArgumentError, 'invalid value for "_type", the character length must be great than or equal to 1.'
|
164
|
+
end
|
165
|
+
|
166
|
+
@_type = _type
|
167
|
+
end
|
168
|
+
|
169
|
+
# Custom attribute writer method with validation
|
170
|
+
# @param [Object] _relative_path Value to be assigned
|
171
|
+
def _relative_path=(_relative_path)
|
172
|
+
if _relative_path.nil?
|
173
|
+
fail ArgumentError, '_relative_path cannot be nil'
|
174
|
+
end
|
175
|
+
|
176
|
+
if _relative_path.to_s.length < 1
|
177
|
+
fail ArgumentError, 'invalid value for "_relative_path", the character length must be great than or equal to 1.'
|
178
|
+
end
|
179
|
+
|
180
|
+
@_relative_path = _relative_path
|
181
|
+
end
|
182
|
+
|
183
|
+
# Custom attribute writer method with validation
|
184
|
+
# @param [Object] digest Value to be assigned
|
185
|
+
def digest=(digest)
|
186
|
+
if digest.nil?
|
187
|
+
fail ArgumentError, 'digest cannot be nil'
|
188
|
+
end
|
189
|
+
|
190
|
+
if digest.to_s.length < 1
|
191
|
+
fail ArgumentError, 'invalid value for "digest", the character length must be great than or equal to 1.'
|
192
|
+
end
|
193
|
+
|
194
|
+
@digest = digest
|
195
|
+
end
|
196
|
+
|
197
|
+
# Custom attribute writer method with validation
|
198
|
+
# @param [Object] media_type Value to be assigned
|
199
|
+
def media_type=(media_type)
|
200
|
+
if media_type.nil?
|
201
|
+
fail ArgumentError, 'media_type cannot be nil'
|
202
|
+
end
|
203
|
+
|
204
|
+
if media_type.to_s.length < 1
|
205
|
+
fail ArgumentError, 'invalid value for "media_type", the character length must be great than or equal to 1.'
|
206
|
+
end
|
207
|
+
|
208
|
+
@media_type = media_type
|
209
|
+
end
|
210
|
+
|
211
|
+
# Checks equality by comparing each attribute.
|
212
|
+
# @param [Object] Object to be compared
|
213
|
+
def ==(o)
|
214
|
+
return true if self.equal?(o)
|
215
|
+
self.class == o.class &&
|
216
|
+
_href == o._href &&
|
217
|
+
_created == o._created &&
|
218
|
+
_type == o._type &&
|
219
|
+
_artifact == o._artifact &&
|
220
|
+
_relative_path == o._relative_path &&
|
221
|
+
digest == o.digest &&
|
222
|
+
media_type == o.media_type
|
223
|
+
end
|
224
|
+
|
225
|
+
# @see the `==` method
|
226
|
+
# @param [Object] Object to be compared
|
227
|
+
def eql?(o)
|
228
|
+
self == o
|
229
|
+
end
|
230
|
+
|
231
|
+
# Calculates hash code according to all attributes.
|
232
|
+
# @return [Integer] Hash code
|
233
|
+
def hash
|
234
|
+
[_href, _created, _type, _artifact, _relative_path, digest, media_type].hash
|
235
|
+
end
|
236
|
+
|
237
|
+
# Builds the object from hash
|
238
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
239
|
+
# @return [Object] Returns the model itself
|
240
|
+
def self.build_from_hash(attributes)
|
241
|
+
new.build_from_hash(attributes)
|
242
|
+
end
|
243
|
+
|
244
|
+
# Builds the object from hash
|
245
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
246
|
+
# @return [Object] Returns the model itself
|
247
|
+
def build_from_hash(attributes)
|
248
|
+
return nil unless attributes.is_a?(Hash)
|
249
|
+
self.class.openapi_types.each_pair do |key, type|
|
250
|
+
if type =~ /\AArray<(.*)>/i
|
251
|
+
# check to ensure the input is an array given that the attribute
|
252
|
+
# is documented as an array but the input is not
|
253
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
254
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
255
|
+
end
|
256
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
257
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
258
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
259
|
+
end
|
260
|
+
|
261
|
+
self
|
262
|
+
end
|
263
|
+
|
264
|
+
# Deserializes the data based on type
|
265
|
+
# @param string type Data type
|
266
|
+
# @param string value Value to be deserialized
|
267
|
+
# @return [Object] Deserialized data
|
268
|
+
def _deserialize(type, value)
|
269
|
+
case type.to_sym
|
270
|
+
when :DateTime
|
271
|
+
DateTime.parse(value)
|
272
|
+
when :Date
|
273
|
+
Date.parse(value)
|
274
|
+
when :String
|
275
|
+
value.to_s
|
276
|
+
when :Integer
|
277
|
+
value.to_i
|
278
|
+
when :Float
|
279
|
+
value.to_f
|
280
|
+
when :Boolean
|
281
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
282
|
+
true
|
283
|
+
else
|
284
|
+
false
|
285
|
+
end
|
286
|
+
when :Object
|
287
|
+
# generic object (usually a Hash), return directly
|
288
|
+
value
|
289
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
290
|
+
inner_type = Regexp.last_match[:inner_type]
|
291
|
+
value.map { |v| _deserialize(inner_type, v) }
|
292
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
293
|
+
k_type = Regexp.last_match[:k_type]
|
294
|
+
v_type = Regexp.last_match[:v_type]
|
295
|
+
{}.tap do |hash|
|
296
|
+
value.each do |k, v|
|
297
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
298
|
+
end
|
299
|
+
end
|
300
|
+
else # model
|
301
|
+
PulpDockerClient.const_get(type).build_from_hash(value)
|
302
|
+
end
|
303
|
+
end
|
304
|
+
|
305
|
+
# Returns the string representation of the object
|
306
|
+
# @return [String] String presentation of the object
|
307
|
+
def to_s
|
308
|
+
to_hash.to_s
|
309
|
+
end
|
310
|
+
|
311
|
+
# to_body is an alias to to_hash (backward compatibility)
|
312
|
+
# @return [Hash] Returns the object in the form of hash
|
313
|
+
def to_body
|
314
|
+
to_hash
|
315
|
+
end
|
316
|
+
|
317
|
+
# Returns the object in the form of hash
|
318
|
+
# @return [Hash] Returns the object in the form of hash
|
319
|
+
def to_hash
|
320
|
+
hash = {}
|
321
|
+
self.class.attribute_map.each_pair do |attr, param|
|
322
|
+
value = self.send(attr)
|
323
|
+
next if value.nil?
|
324
|
+
hash[param] = _to_hash(value)
|
325
|
+
end
|
326
|
+
hash
|
327
|
+
end
|
328
|
+
|
329
|
+
# Outputs non-array value in the form of hash
|
330
|
+
# For object, use to_hash. Otherwise, just return the value
|
331
|
+
# @param [Object] value Any valid value
|
332
|
+
# @return [Hash] Returns the value in the form of hash
|
333
|
+
def _to_hash(value)
|
334
|
+
if value.is_a?(Array)
|
335
|
+
value.compact.map { |v| _to_hash(v) }
|
336
|
+
elsif value.is_a?(Hash)
|
337
|
+
{}.tap do |hash|
|
338
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
339
|
+
end
|
340
|
+
elsif value.respond_to? :to_hash
|
341
|
+
value.to_hash
|
342
|
+
else
|
343
|
+
value
|
344
|
+
end
|
345
|
+
end
|
346
|
+
end
|
347
|
+
end
|