pulp_ansible_client 0.5.2 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -4
- data/docs/AnsibleCollectionRemote.md +8 -0
- data/docs/AnsibleCollectionRemoteResponse.md +8 -0
- data/docs/AnsibleCollectionVersionResponse.md +3 -3
- data/docs/AnsibleRoleRemote.md +9 -1
- data/docs/AnsibleRoleRemoteResponse.md +9 -1
- data/docs/AnsibleRoleResponse.md +3 -3
- data/docs/ArtifactRefResponse.md +21 -0
- data/docs/CollectionResponse.md +2 -2
- data/docs/CollectionVersionResponse.md +1 -1
- data/docs/PaginatedCollectionResponseList.md +2 -2
- data/docs/PaginatedCollectionResponseListLinks.md +23 -0
- data/docs/PaginatedCollectionResponseListMeta.md +17 -0
- data/docs/PaginatedCollectionVersionResponseList.md +2 -2
- data/docs/PatchedansibleCollectionRemote.md +8 -0
- data/docs/PatchedansibleRoleRemote.md +9 -1
- data/docs/RepositoriesAnsibleVersionsApi.md +2 -2
- data/lib/pulp_ansible_client.rb +3 -0
- data/lib/pulp_ansible_client/api/repositories_ansible_versions_api.rb +4 -4
- data/lib/pulp_ansible_client/models/ansible_collection_remote.rb +105 -1
- data/lib/pulp_ansible_client/models/ansible_collection_remote_response.rb +105 -1
- data/lib/pulp_ansible_client/models/ansible_collection_version_response.rb +11 -11
- data/lib/pulp_ansible_client/models/ansible_role_remote.rb +108 -4
- data/lib/pulp_ansible_client/models/ansible_role_remote_response.rb +108 -4
- data/lib/pulp_ansible_client/models/ansible_role_response.rb +11 -11
- data/lib/pulp_ansible_client/models/artifact_ref_response.rb +240 -0
- data/lib/pulp_ansible_client/models/collection_response.rb +2 -2
- data/lib/pulp_ansible_client/models/collection_version_response.rb +1 -1
- data/lib/pulp_ansible_client/models/paginated_collection_response_list.rb +2 -2
- data/lib/pulp_ansible_client/models/paginated_collection_response_list_links.rb +237 -0
- data/lib/pulp_ansible_client/models/paginated_collection_response_list_meta.rb +206 -0
- data/lib/pulp_ansible_client/models/paginated_collection_version_response_list.rb +2 -2
- data/lib/pulp_ansible_client/models/patchedansible_collection_remote.rb +105 -1
- data/lib/pulp_ansible_client/models/patchedansible_role_remote.rb +108 -4
- data/lib/pulp_ansible_client/version.rb +1 -1
- data/spec/api/repositories_ansible_versions_api_spec.rb +2 -2
- data/spec/models/ansible_collection_remote_response_spec.rb +24 -0
- data/spec/models/ansible_collection_remote_spec.rb +24 -0
- data/spec/models/ansible_collection_version_response_spec.rb +3 -3
- data/spec/models/ansible_role_remote_response_spec.rb +24 -0
- data/spec/models/ansible_role_remote_spec.rb +24 -0
- data/spec/models/ansible_role_response_spec.rb +3 -3
- data/spec/models/artifact_ref_response_spec.rb +53 -0
- data/spec/models/paginated_collection_response_list_links_spec.rb +59 -0
- data/spec/models/paginated_collection_response_list_meta_spec.rb +41 -0
- data/spec/models/patchedansible_collection_remote_spec.rb +24 -0
- data/spec/models/patchedansible_role_remote_spec.rb +24 -0
- metadata +74 -62
@@ -15,14 +15,14 @@ require 'date'
|
|
15
15
|
module PulpAnsibleClient
|
16
16
|
# A serializer for Role versions.
|
17
17
|
class AnsibleRoleResponse
|
18
|
-
# Timestamp of creation.
|
19
|
-
attr_accessor :pulp_created
|
20
|
-
|
21
18
|
attr_accessor :pulp_href
|
22
19
|
|
23
20
|
# Artifact file representing the physical content
|
24
21
|
attr_accessor :artifact
|
25
22
|
|
23
|
+
# Timestamp of creation.
|
24
|
+
attr_accessor :pulp_created
|
25
|
+
|
26
26
|
attr_accessor :version
|
27
27
|
|
28
28
|
attr_accessor :name
|
@@ -32,9 +32,9 @@ module PulpAnsibleClient
|
|
32
32
|
# Attribute mapping from ruby-style variable name to JSON key.
|
33
33
|
def self.attribute_map
|
34
34
|
{
|
35
|
-
:'pulp_created' => :'pulp_created',
|
36
35
|
:'pulp_href' => :'pulp_href',
|
37
36
|
:'artifact' => :'artifact',
|
37
|
+
:'pulp_created' => :'pulp_created',
|
38
38
|
:'version' => :'version',
|
39
39
|
:'name' => :'name',
|
40
40
|
:'namespace' => :'namespace'
|
@@ -44,9 +44,9 @@ module PulpAnsibleClient
|
|
44
44
|
# Attribute type mapping.
|
45
45
|
def self.openapi_types
|
46
46
|
{
|
47
|
-
:'pulp_created' => :'DateTime',
|
48
47
|
:'pulp_href' => :'String',
|
49
48
|
:'artifact' => :'String',
|
49
|
+
:'pulp_created' => :'DateTime',
|
50
50
|
:'version' => :'String',
|
51
51
|
:'name' => :'String',
|
52
52
|
:'namespace' => :'String'
|
@@ -74,10 +74,6 @@ module PulpAnsibleClient
|
|
74
74
|
h[k.to_sym] = v
|
75
75
|
}
|
76
76
|
|
77
|
-
if attributes.key?(:'pulp_created')
|
78
|
-
self.pulp_created = attributes[:'pulp_created']
|
79
|
-
end
|
80
|
-
|
81
77
|
if attributes.key?(:'pulp_href')
|
82
78
|
self.pulp_href = attributes[:'pulp_href']
|
83
79
|
end
|
@@ -86,6 +82,10 @@ module PulpAnsibleClient
|
|
86
82
|
self.artifact = attributes[:'artifact']
|
87
83
|
end
|
88
84
|
|
85
|
+
if attributes.key?(:'pulp_created')
|
86
|
+
self.pulp_created = attributes[:'pulp_created']
|
87
|
+
end
|
88
|
+
|
89
89
|
if attributes.key?(:'version')
|
90
90
|
self.version = attributes[:'version']
|
91
91
|
end
|
@@ -137,9 +137,9 @@ module PulpAnsibleClient
|
|
137
137
|
def ==(o)
|
138
138
|
return true if self.equal?(o)
|
139
139
|
self.class == o.class &&
|
140
|
-
pulp_created == o.pulp_created &&
|
141
140
|
pulp_href == o.pulp_href &&
|
142
141
|
artifact == o.artifact &&
|
142
|
+
pulp_created == o.pulp_created &&
|
143
143
|
version == o.version &&
|
144
144
|
name == o.name &&
|
145
145
|
namespace == o.namespace
|
@@ -154,7 +154,7 @@ module PulpAnsibleClient
|
|
154
154
|
# Calculates hash code according to all attributes.
|
155
155
|
# @return [Integer] Hash code
|
156
156
|
def hash
|
157
|
-
[
|
157
|
+
[pulp_href, artifact, pulp_created, version, name, namespace].hash
|
158
158
|
end
|
159
159
|
|
160
160
|
# Builds the object from hash
|
@@ -0,0 +1,240 @@
|
|
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.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module PulpAnsibleClient
|
16
|
+
# A serializer for an Artifact reference.
|
17
|
+
class ArtifactRefResponse
|
18
|
+
attr_accessor :filename
|
19
|
+
|
20
|
+
attr_accessor :sha256
|
21
|
+
|
22
|
+
attr_accessor :size
|
23
|
+
|
24
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
25
|
+
def self.attribute_map
|
26
|
+
{
|
27
|
+
:'filename' => :'filename',
|
28
|
+
:'sha256' => :'sha256',
|
29
|
+
:'size' => :'size'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# Attribute type mapping.
|
34
|
+
def self.openapi_types
|
35
|
+
{
|
36
|
+
:'filename' => :'String',
|
37
|
+
:'sha256' => :'String',
|
38
|
+
:'size' => :'Integer'
|
39
|
+
}
|
40
|
+
end
|
41
|
+
|
42
|
+
# List of attributes with nullable: true
|
43
|
+
def self.openapi_nullable
|
44
|
+
Set.new([
|
45
|
+
])
|
46
|
+
end
|
47
|
+
|
48
|
+
# Initializes the object
|
49
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
50
|
+
def initialize(attributes = {})
|
51
|
+
if (!attributes.is_a?(Hash))
|
52
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `PulpAnsibleClient::ArtifactRefResponse` initialize method"
|
53
|
+
end
|
54
|
+
|
55
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
56
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
57
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
58
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `PulpAnsibleClient::ArtifactRefResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
59
|
+
end
|
60
|
+
h[k.to_sym] = v
|
61
|
+
}
|
62
|
+
|
63
|
+
if attributes.key?(:'filename')
|
64
|
+
self.filename = attributes[:'filename']
|
65
|
+
end
|
66
|
+
|
67
|
+
if attributes.key?(:'sha256')
|
68
|
+
self.sha256 = attributes[:'sha256']
|
69
|
+
end
|
70
|
+
|
71
|
+
if attributes.key?(:'size')
|
72
|
+
self.size = attributes[:'size']
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
77
|
+
# @return Array for valid properties with the reasons
|
78
|
+
def list_invalid_properties
|
79
|
+
invalid_properties = Array.new
|
80
|
+
if @filename.nil?
|
81
|
+
invalid_properties.push('invalid value for "filename", filename cannot be nil.')
|
82
|
+
end
|
83
|
+
|
84
|
+
if @sha256.nil?
|
85
|
+
invalid_properties.push('invalid value for "sha256", sha256 cannot be nil.')
|
86
|
+
end
|
87
|
+
|
88
|
+
if @size.nil?
|
89
|
+
invalid_properties.push('invalid value for "size", size cannot be nil.')
|
90
|
+
end
|
91
|
+
|
92
|
+
invalid_properties
|
93
|
+
end
|
94
|
+
|
95
|
+
# Check to see if the all the properties in the model are valid
|
96
|
+
# @return true if the model is valid
|
97
|
+
def valid?
|
98
|
+
return false if @filename.nil?
|
99
|
+
return false if @sha256.nil?
|
100
|
+
return false if @size.nil?
|
101
|
+
true
|
102
|
+
end
|
103
|
+
|
104
|
+
# Checks equality by comparing each attribute.
|
105
|
+
# @param [Object] Object to be compared
|
106
|
+
def ==(o)
|
107
|
+
return true if self.equal?(o)
|
108
|
+
self.class == o.class &&
|
109
|
+
filename == o.filename &&
|
110
|
+
sha256 == o.sha256 &&
|
111
|
+
size == o.size
|
112
|
+
end
|
113
|
+
|
114
|
+
# @see the `==` method
|
115
|
+
# @param [Object] Object to be compared
|
116
|
+
def eql?(o)
|
117
|
+
self == o
|
118
|
+
end
|
119
|
+
|
120
|
+
# Calculates hash code according to all attributes.
|
121
|
+
# @return [Integer] Hash code
|
122
|
+
def hash
|
123
|
+
[filename, sha256, size].hash
|
124
|
+
end
|
125
|
+
|
126
|
+
# Builds the object from hash
|
127
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
128
|
+
# @return [Object] Returns the model itself
|
129
|
+
def self.build_from_hash(attributes)
|
130
|
+
new.build_from_hash(attributes)
|
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 build_from_hash(attributes)
|
137
|
+
return nil unless attributes.is_a?(Hash)
|
138
|
+
self.class.openapi_types.each_pair do |key, type|
|
139
|
+
if type =~ /\AArray<(.*)>/i
|
140
|
+
# check to ensure the input is an array given that the attribute
|
141
|
+
# is documented as an array but the input is not
|
142
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
143
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
144
|
+
end
|
145
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
146
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
147
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
148
|
+
end
|
149
|
+
|
150
|
+
self
|
151
|
+
end
|
152
|
+
|
153
|
+
# Deserializes the data based on type
|
154
|
+
# @param string type Data type
|
155
|
+
# @param string value Value to be deserialized
|
156
|
+
# @return [Object] Deserialized data
|
157
|
+
def _deserialize(type, value)
|
158
|
+
case type.to_sym
|
159
|
+
when :DateTime
|
160
|
+
DateTime.parse(value)
|
161
|
+
when :Date
|
162
|
+
Date.parse(value)
|
163
|
+
when :String
|
164
|
+
value.to_s
|
165
|
+
when :Integer
|
166
|
+
value.to_i
|
167
|
+
when :Float
|
168
|
+
value.to_f
|
169
|
+
when :Boolean
|
170
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
171
|
+
true
|
172
|
+
else
|
173
|
+
false
|
174
|
+
end
|
175
|
+
when :Object
|
176
|
+
# generic object (usually a Hash), return directly
|
177
|
+
value
|
178
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
179
|
+
inner_type = Regexp.last_match[:inner_type]
|
180
|
+
value.map { |v| _deserialize(inner_type, v) }
|
181
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
182
|
+
k_type = Regexp.last_match[:k_type]
|
183
|
+
v_type = Regexp.last_match[:v_type]
|
184
|
+
{}.tap do |hash|
|
185
|
+
value.each do |k, v|
|
186
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
else # model
|
190
|
+
PulpAnsibleClient.const_get(type).build_from_hash(value)
|
191
|
+
end
|
192
|
+
end
|
193
|
+
|
194
|
+
# Returns the string representation of the object
|
195
|
+
# @return [String] String presentation of the object
|
196
|
+
def to_s
|
197
|
+
to_hash.to_s
|
198
|
+
end
|
199
|
+
|
200
|
+
# to_body is an alias to to_hash (backward compatibility)
|
201
|
+
# @return [Hash] Returns the object in the form of hash
|
202
|
+
def to_body
|
203
|
+
to_hash
|
204
|
+
end
|
205
|
+
|
206
|
+
# Returns the object in the form of hash
|
207
|
+
# @return [Hash] Returns the object in the form of hash
|
208
|
+
def to_hash
|
209
|
+
hash = {}
|
210
|
+
self.class.attribute_map.each_pair do |attr, param|
|
211
|
+
value = self.send(attr)
|
212
|
+
if value.nil?
|
213
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
214
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
215
|
+
end
|
216
|
+
|
217
|
+
hash[param] = _to_hash(value)
|
218
|
+
end
|
219
|
+
hash
|
220
|
+
end
|
221
|
+
|
222
|
+
# Outputs non-array value in the form of hash
|
223
|
+
# For object, use to_hash. Otherwise, just return the value
|
224
|
+
# @param [Object] value Any valid value
|
225
|
+
# @return [Hash] Returns the value in the form of hash
|
226
|
+
def _to_hash(value)
|
227
|
+
if value.is_a?(Array)
|
228
|
+
value.compact.map { |v| _to_hash(v) }
|
229
|
+
elsif value.is_a?(Hash)
|
230
|
+
{}.tap do |hash|
|
231
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
232
|
+
end
|
233
|
+
elsif value.respond_to? :to_hash
|
234
|
+
value.to_hash
|
235
|
+
else
|
236
|
+
value
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
end
|
@@ -54,8 +54,8 @@ module PulpAnsibleClient
|
|
54
54
|
:'deprecated' => :'Boolean',
|
55
55
|
:'versions_url' => :'String',
|
56
56
|
:'highest_version' => :'Object',
|
57
|
-
:'created_at' => :'
|
58
|
-
:'updated_at' => :'
|
57
|
+
:'created_at' => :'DateTime',
|
58
|
+
:'updated_at' => :'DateTime'
|
59
59
|
}
|
60
60
|
end
|
61
61
|
|
@@ -58,7 +58,7 @@ module PulpAnsibleClient
|
|
58
58
|
:'href' => :'String',
|
59
59
|
:'created_at' => :'DateTime',
|
60
60
|
:'updated_at' => :'DateTime',
|
61
|
-
:'artifact' => :'
|
61
|
+
:'artifact' => :'ArtifactRefResponse',
|
62
62
|
:'collection' => :'CollectionRefResponse',
|
63
63
|
:'download_url' => :'String',
|
64
64
|
:'name' => :'String',
|
@@ -32,8 +32,8 @@ module PulpAnsibleClient
|
|
32
32
|
# Attribute type mapping.
|
33
33
|
def self.openapi_types
|
34
34
|
{
|
35
|
-
:'meta' => :'
|
36
|
-
:'links' => :'
|
35
|
+
:'meta' => :'PaginatedCollectionResponseListMeta',
|
36
|
+
:'links' => :'PaginatedCollectionResponseListLinks',
|
37
37
|
:'data' => :'Array<CollectionResponse>'
|
38
38
|
}
|
39
39
|
end
|
@@ -0,0 +1,237 @@
|
|
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.2.3
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module PulpAnsibleClient
|
16
|
+
class PaginatedCollectionResponseListLinks
|
17
|
+
attr_accessor :first
|
18
|
+
|
19
|
+
attr_accessor :previous
|
20
|
+
|
21
|
+
attr_accessor :_next
|
22
|
+
|
23
|
+
attr_accessor :last
|
24
|
+
|
25
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
26
|
+
def self.attribute_map
|
27
|
+
{
|
28
|
+
:'first' => :'first',
|
29
|
+
:'previous' => :'previous',
|
30
|
+
:'_next' => :'next',
|
31
|
+
:'last' => :'last'
|
32
|
+
}
|
33
|
+
end
|
34
|
+
|
35
|
+
# Attribute type mapping.
|
36
|
+
def self.openapi_types
|
37
|
+
{
|
38
|
+
:'first' => :'String',
|
39
|
+
:'previous' => :'String',
|
40
|
+
:'_next' => :'String',
|
41
|
+
:'last' => :'String'
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
# List of attributes with nullable: true
|
46
|
+
def self.openapi_nullable
|
47
|
+
Set.new([
|
48
|
+
:'first',
|
49
|
+
:'previous',
|
50
|
+
:'_next',
|
51
|
+
:'last'
|
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 `PulpAnsibleClient::PaginatedCollectionResponseListLinks` 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 `PulpAnsibleClient::PaginatedCollectionResponseListLinks`. 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?(:'first')
|
71
|
+
self.first = attributes[:'first']
|
72
|
+
end
|
73
|
+
|
74
|
+
if attributes.key?(:'previous')
|
75
|
+
self.previous = attributes[:'previous']
|
76
|
+
end
|
77
|
+
|
78
|
+
if attributes.key?(:'_next')
|
79
|
+
self._next = attributes[:'_next']
|
80
|
+
end
|
81
|
+
|
82
|
+
if attributes.key?(:'last')
|
83
|
+
self.last = attributes[:'last']
|
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
|
+
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
|
+
true
|
98
|
+
end
|
99
|
+
|
100
|
+
# Checks equality by comparing each attribute.
|
101
|
+
# @param [Object] Object to be compared
|
102
|
+
def ==(o)
|
103
|
+
return true if self.equal?(o)
|
104
|
+
self.class == o.class &&
|
105
|
+
first == o.first &&
|
106
|
+
previous == o.previous &&
|
107
|
+
_next == o._next &&
|
108
|
+
last == o.last
|
109
|
+
end
|
110
|
+
|
111
|
+
# @see the `==` method
|
112
|
+
# @param [Object] Object to be compared
|
113
|
+
def eql?(o)
|
114
|
+
self == o
|
115
|
+
end
|
116
|
+
|
117
|
+
# Calculates hash code according to all attributes.
|
118
|
+
# @return [Integer] Hash code
|
119
|
+
def hash
|
120
|
+
[first, previous, _next, last].hash
|
121
|
+
end
|
122
|
+
|
123
|
+
# Builds the object from hash
|
124
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
125
|
+
# @return [Object] Returns the model itself
|
126
|
+
def self.build_from_hash(attributes)
|
127
|
+
new.build_from_hash(attributes)
|
128
|
+
end
|
129
|
+
|
130
|
+
# Builds the object from hash
|
131
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
132
|
+
# @return [Object] Returns the model itself
|
133
|
+
def build_from_hash(attributes)
|
134
|
+
return nil unless attributes.is_a?(Hash)
|
135
|
+
self.class.openapi_types.each_pair do |key, type|
|
136
|
+
if type =~ /\AArray<(.*)>/i
|
137
|
+
# check to ensure the input is an array given that the attribute
|
138
|
+
# is documented as an array but the input is not
|
139
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
140
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
141
|
+
end
|
142
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
143
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
144
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
145
|
+
end
|
146
|
+
|
147
|
+
self
|
148
|
+
end
|
149
|
+
|
150
|
+
# Deserializes the data based on type
|
151
|
+
# @param string type Data type
|
152
|
+
# @param string value Value to be deserialized
|
153
|
+
# @return [Object] Deserialized data
|
154
|
+
def _deserialize(type, value)
|
155
|
+
case type.to_sym
|
156
|
+
when :DateTime
|
157
|
+
DateTime.parse(value)
|
158
|
+
when :Date
|
159
|
+
Date.parse(value)
|
160
|
+
when :String
|
161
|
+
value.to_s
|
162
|
+
when :Integer
|
163
|
+
value.to_i
|
164
|
+
when :Float
|
165
|
+
value.to_f
|
166
|
+
when :Boolean
|
167
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
168
|
+
true
|
169
|
+
else
|
170
|
+
false
|
171
|
+
end
|
172
|
+
when :Object
|
173
|
+
# generic object (usually a Hash), return directly
|
174
|
+
value
|
175
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
176
|
+
inner_type = Regexp.last_match[:inner_type]
|
177
|
+
value.map { |v| _deserialize(inner_type, v) }
|
178
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
179
|
+
k_type = Regexp.last_match[:k_type]
|
180
|
+
v_type = Regexp.last_match[:v_type]
|
181
|
+
{}.tap do |hash|
|
182
|
+
value.each do |k, v|
|
183
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
184
|
+
end
|
185
|
+
end
|
186
|
+
else # model
|
187
|
+
PulpAnsibleClient.const_get(type).build_from_hash(value)
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
# Returns the string representation of the object
|
192
|
+
# @return [String] String presentation of the object
|
193
|
+
def to_s
|
194
|
+
to_hash.to_s
|
195
|
+
end
|
196
|
+
|
197
|
+
# to_body is an alias to to_hash (backward compatibility)
|
198
|
+
# @return [Hash] Returns the object in the form of hash
|
199
|
+
def to_body
|
200
|
+
to_hash
|
201
|
+
end
|
202
|
+
|
203
|
+
# Returns the object in the form of hash
|
204
|
+
# @return [Hash] Returns the object in the form of hash
|
205
|
+
def to_hash
|
206
|
+
hash = {}
|
207
|
+
self.class.attribute_map.each_pair do |attr, param|
|
208
|
+
value = self.send(attr)
|
209
|
+
if value.nil?
|
210
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
211
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
212
|
+
end
|
213
|
+
|
214
|
+
hash[param] = _to_hash(value)
|
215
|
+
end
|
216
|
+
hash
|
217
|
+
end
|
218
|
+
|
219
|
+
# Outputs non-array value in the form of hash
|
220
|
+
# For object, use to_hash. Otherwise, just return the value
|
221
|
+
# @param [Object] value Any valid value
|
222
|
+
# @return [Hash] Returns the value in the form of hash
|
223
|
+
def _to_hash(value)
|
224
|
+
if value.is_a?(Array)
|
225
|
+
value.compact.map { |v| _to_hash(v) }
|
226
|
+
elsif value.is_a?(Hash)
|
227
|
+
{}.tap do |hash|
|
228
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
229
|
+
end
|
230
|
+
elsif value.respond_to? :to_hash
|
231
|
+
value.to_hash
|
232
|
+
else
|
233
|
+
value
|
234
|
+
end
|
235
|
+
end
|
236
|
+
end
|
237
|
+
end
|