sources-api-client 1.0.0
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 +70 -0
- data/LICENSE.txt +202 -0
- data/README.md +151 -0
- data/Rakefile +10 -0
- data/docs/Application.md +31 -0
- data/docs/ApplicationType.md +31 -0
- data/docs/ApplicationTypesCollection.md +21 -0
- data/docs/ApplicationsCollection.md +21 -0
- data/docs/Authentication.md +41 -0
- data/docs/AuthenticationExtra.md +17 -0
- data/docs/AuthenticationExtraAzure.md +17 -0
- data/docs/AuthenticationsCollection.md +21 -0
- data/docs/CollectionLinks.md +23 -0
- data/docs/CollectionMetadata.md +21 -0
- data/docs/DefaultApi.md +1945 -0
- data/docs/Endpoint.md +47 -0
- data/docs/EndpointsCollection.md +21 -0
- data/docs/ErrorNotFound.md +17 -0
- data/docs/ErrorNotFoundErrors.md +19 -0
- data/docs/GraphQLRequest.md +21 -0
- data/docs/GraphQLResponse.md +19 -0
- data/docs/Source.md +37 -0
- data/docs/SourceType.md +31 -0
- data/docs/SourceTypesCollection.md +21 -0
- data/docs/SourcesCollection.md +21 -0
- data/docs/Tenant.md +21 -0
- data/git_push.sh +58 -0
- data/lib/sources-api-client.rb +61 -0
- data/lib/sources-api-client/api/default_api.rb +2523 -0
- data/lib/sources-api-client/api_client.rb +386 -0
- data/lib/sources-api-client/api_error.rb +57 -0
- data/lib/sources-api-client/configuration.rb +268 -0
- data/lib/sources-api-client/models/application.rb +323 -0
- data/lib/sources-api-client/models/application_type.rb +287 -0
- data/lib/sources-api-client/models/application_types_collection.rb +226 -0
- data/lib/sources-api-client/models/applications_collection.rb +226 -0
- data/lib/sources-api-client/models/authentication.rb +350 -0
- data/lib/sources-api-client/models/authentication_extra.rb +206 -0
- data/lib/sources-api-client/models/authentication_extra_azure.rb +206 -0
- data/lib/sources-api-client/models/authentications_collection.rb +226 -0
- data/lib/sources-api-client/models/collection_links.rb +233 -0
- data/lib/sources-api-client/models/collection_metadata.rb +224 -0
- data/lib/sources-api-client/models/endpoint.rb +384 -0
- data/lib/sources-api-client/models/endpoints_collection.rb +226 -0
- data/lib/sources-api-client/models/error_not_found.rb +208 -0
- data/lib/sources-api-client/models/error_not_found_errors.rb +215 -0
- data/lib/sources-api-client/models/graph_ql_request.rb +237 -0
- data/lib/sources-api-client/models/graph_ql_response.rb +219 -0
- data/lib/sources-api-client/models/source.rb +332 -0
- data/lib/sources-api-client/models/source_type.rb +287 -0
- data/lib/sources-api-client/models/source_types_collection.rb +226 -0
- data/lib/sources-api-client/models/sources_collection.rb +226 -0
- data/lib/sources-api-client/models/tenant.rb +224 -0
- data/lib/sources-api-client/version.rb +15 -0
- data/pkg/sources-api-client-1.0.0.gem +0 -0
- data/sources-api-client.gemspec +39 -0
- data/spec/api/default_api_spec.rb +487 -0
- data/spec/api_client_spec.rb +226 -0
- data/spec/configuration_spec.rb +42 -0
- data/spec/models/application_spec.rb +83 -0
- data/spec/models/application_type_spec.rb +83 -0
- data/spec/models/application_types_collection_spec.rb +53 -0
- data/spec/models/applications_collection_spec.rb +53 -0
- data/spec/models/authentication_extra_azure_spec.rb +41 -0
- data/spec/models/authentication_extra_spec.rb +41 -0
- data/spec/models/authentication_spec.rb +113 -0
- data/spec/models/authentications_collection_spec.rb +53 -0
- data/spec/models/collection_links_spec.rb +59 -0
- data/spec/models/collection_metadata_spec.rb +53 -0
- data/spec/models/endpoint_spec.rb +131 -0
- data/spec/models/endpoints_collection_spec.rb +53 -0
- data/spec/models/error_not_found_errors_spec.rb +47 -0
- data/spec/models/error_not_found_spec.rb +41 -0
- data/spec/models/graph_ql_request_spec.rb +53 -0
- data/spec/models/graph_ql_response_spec.rb +47 -0
- data/spec/models/source_spec.rb +101 -0
- data/spec/models/source_type_spec.rb +83 -0
- data/spec/models/source_types_collection_spec.rb +53 -0
- data/spec/models/sources_collection_spec.rb +53 -0
- data/spec/models/tenant_spec.rb +53 -0
- data/spec/spec_helper.rb +111 -0
- metadata +210 -0
@@ -0,0 +1,350 @@
|
|
1
|
+
=begin
|
2
|
+
#Sources
|
3
|
+
|
4
|
+
#Sources
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
Contact: support@redhat.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.2.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module SourcesApiClient
|
16
|
+
class Authentication
|
17
|
+
attr_accessor :authtype
|
18
|
+
|
19
|
+
attr_accessor :availability_status
|
20
|
+
|
21
|
+
attr_accessor :availability_status_error
|
22
|
+
|
23
|
+
attr_accessor :extra
|
24
|
+
|
25
|
+
# ID of the resource
|
26
|
+
attr_accessor :id
|
27
|
+
|
28
|
+
attr_accessor :name
|
29
|
+
|
30
|
+
attr_accessor :password
|
31
|
+
|
32
|
+
# ID of the resource
|
33
|
+
attr_accessor :resource_id
|
34
|
+
|
35
|
+
attr_accessor :resource_type
|
36
|
+
|
37
|
+
attr_accessor :status
|
38
|
+
|
39
|
+
attr_accessor :status_details
|
40
|
+
|
41
|
+
attr_accessor :tenant
|
42
|
+
|
43
|
+
attr_accessor :username
|
44
|
+
|
45
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
46
|
+
def self.attribute_map
|
47
|
+
{
|
48
|
+
:'authtype' => :'authtype',
|
49
|
+
:'availability_status' => :'availability_status',
|
50
|
+
:'availability_status_error' => :'availability_status_error',
|
51
|
+
:'extra' => :'extra',
|
52
|
+
:'id' => :'id',
|
53
|
+
:'name' => :'name',
|
54
|
+
:'password' => :'password',
|
55
|
+
:'resource_id' => :'resource_id',
|
56
|
+
:'resource_type' => :'resource_type',
|
57
|
+
:'status' => :'status',
|
58
|
+
:'status_details' => :'status_details',
|
59
|
+
:'tenant' => :'tenant',
|
60
|
+
:'username' => :'username'
|
61
|
+
}
|
62
|
+
end
|
63
|
+
|
64
|
+
# Attribute type mapping.
|
65
|
+
def self.openapi_types
|
66
|
+
{
|
67
|
+
:'authtype' => :'String',
|
68
|
+
:'availability_status' => :'String',
|
69
|
+
:'availability_status_error' => :'String',
|
70
|
+
:'extra' => :'AuthenticationExtra',
|
71
|
+
:'id' => :'String',
|
72
|
+
:'name' => :'String',
|
73
|
+
:'password' => :'String',
|
74
|
+
:'resource_id' => :'String',
|
75
|
+
:'resource_type' => :'String',
|
76
|
+
:'status' => :'String',
|
77
|
+
:'status_details' => :'String',
|
78
|
+
:'tenant' => :'String',
|
79
|
+
:'username' => :'String'
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
# List of attributes with nullable: true
|
84
|
+
def self.openapi_nullable
|
85
|
+
Set.new([
|
86
|
+
])
|
87
|
+
end
|
88
|
+
|
89
|
+
# Initializes the object
|
90
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
91
|
+
def initialize(attributes = {})
|
92
|
+
if (!attributes.is_a?(Hash))
|
93
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `SourcesApiClient::Authentication` initialize method"
|
94
|
+
end
|
95
|
+
|
96
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
97
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
98
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
99
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `SourcesApiClient::Authentication`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
100
|
+
end
|
101
|
+
h[k.to_sym] = v
|
102
|
+
}
|
103
|
+
|
104
|
+
if attributes.key?(:'authtype')
|
105
|
+
self.authtype = attributes[:'authtype']
|
106
|
+
end
|
107
|
+
|
108
|
+
if attributes.key?(:'availability_status')
|
109
|
+
self.availability_status = attributes[:'availability_status']
|
110
|
+
end
|
111
|
+
|
112
|
+
if attributes.key?(:'availability_status_error')
|
113
|
+
self.availability_status_error = attributes[:'availability_status_error']
|
114
|
+
end
|
115
|
+
|
116
|
+
if attributes.key?(:'extra')
|
117
|
+
self.extra = attributes[:'extra']
|
118
|
+
end
|
119
|
+
|
120
|
+
if attributes.key?(:'id')
|
121
|
+
self.id = attributes[:'id']
|
122
|
+
end
|
123
|
+
|
124
|
+
if attributes.key?(:'name')
|
125
|
+
self.name = attributes[:'name']
|
126
|
+
end
|
127
|
+
|
128
|
+
if attributes.key?(:'password')
|
129
|
+
self.password = attributes[:'password']
|
130
|
+
end
|
131
|
+
|
132
|
+
if attributes.key?(:'resource_id')
|
133
|
+
self.resource_id = attributes[:'resource_id']
|
134
|
+
end
|
135
|
+
|
136
|
+
if attributes.key?(:'resource_type')
|
137
|
+
self.resource_type = attributes[:'resource_type']
|
138
|
+
end
|
139
|
+
|
140
|
+
if attributes.key?(:'status')
|
141
|
+
self.status = attributes[:'status']
|
142
|
+
end
|
143
|
+
|
144
|
+
if attributes.key?(:'status_details')
|
145
|
+
self.status_details = attributes[:'status_details']
|
146
|
+
end
|
147
|
+
|
148
|
+
if attributes.key?(:'tenant')
|
149
|
+
self.tenant = attributes[:'tenant']
|
150
|
+
end
|
151
|
+
|
152
|
+
if attributes.key?(:'username')
|
153
|
+
self.username = attributes[:'username']
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
158
|
+
# @return Array for valid properties with the reasons
|
159
|
+
def list_invalid_properties
|
160
|
+
invalid_properties = Array.new
|
161
|
+
pattern = Regexp.new(/^\d+$/)
|
162
|
+
if !@id.nil? && @id !~ pattern
|
163
|
+
invalid_properties.push("invalid value for \"id\", must conform to the pattern #{pattern}.")
|
164
|
+
end
|
165
|
+
|
166
|
+
pattern = Regexp.new(/^\d+$/)
|
167
|
+
if !@resource_id.nil? && @resource_id !~ pattern
|
168
|
+
invalid_properties.push("invalid value for \"resource_id\", must conform to the pattern #{pattern}.")
|
169
|
+
end
|
170
|
+
|
171
|
+
invalid_properties
|
172
|
+
end
|
173
|
+
|
174
|
+
# Check to see if the all the properties in the model are valid
|
175
|
+
# @return true if the model is valid
|
176
|
+
def valid?
|
177
|
+
return false if !@id.nil? && @id !~ Regexp.new(/^\d+$/)
|
178
|
+
return false if !@resource_id.nil? && @resource_id !~ Regexp.new(/^\d+$/)
|
179
|
+
true
|
180
|
+
end
|
181
|
+
|
182
|
+
# Custom attribute writer method with validation
|
183
|
+
# @param [Object] id Value to be assigned
|
184
|
+
def id=(id)
|
185
|
+
pattern = Regexp.new(/^\d+$/)
|
186
|
+
if !id.nil? && id !~ pattern
|
187
|
+
fail ArgumentError, "invalid value for \"id\", must conform to the pattern #{pattern}."
|
188
|
+
end
|
189
|
+
|
190
|
+
@id = id
|
191
|
+
end
|
192
|
+
|
193
|
+
# Custom attribute writer method with validation
|
194
|
+
# @param [Object] resource_id Value to be assigned
|
195
|
+
def resource_id=(resource_id)
|
196
|
+
pattern = Regexp.new(/^\d+$/)
|
197
|
+
if !resource_id.nil? && resource_id !~ pattern
|
198
|
+
fail ArgumentError, "invalid value for \"resource_id\", must conform to the pattern #{pattern}."
|
199
|
+
end
|
200
|
+
|
201
|
+
@resource_id = resource_id
|
202
|
+
end
|
203
|
+
|
204
|
+
# Checks equality by comparing each attribute.
|
205
|
+
# @param [Object] Object to be compared
|
206
|
+
def ==(o)
|
207
|
+
return true if self.equal?(o)
|
208
|
+
self.class == o.class &&
|
209
|
+
authtype == o.authtype &&
|
210
|
+
availability_status == o.availability_status &&
|
211
|
+
availability_status_error == o.availability_status_error &&
|
212
|
+
extra == o.extra &&
|
213
|
+
id == o.id &&
|
214
|
+
name == o.name &&
|
215
|
+
password == o.password &&
|
216
|
+
resource_id == o.resource_id &&
|
217
|
+
resource_type == o.resource_type &&
|
218
|
+
status == o.status &&
|
219
|
+
status_details == o.status_details &&
|
220
|
+
tenant == o.tenant &&
|
221
|
+
username == o.username
|
222
|
+
end
|
223
|
+
|
224
|
+
# @see the `==` method
|
225
|
+
# @param [Object] Object to be compared
|
226
|
+
def eql?(o)
|
227
|
+
self == o
|
228
|
+
end
|
229
|
+
|
230
|
+
# Calculates hash code according to all attributes.
|
231
|
+
# @return [Integer] Hash code
|
232
|
+
def hash
|
233
|
+
[authtype, availability_status, availability_status_error, extra, id, name, password, resource_id, resource_type, status, status_details, tenant, username].hash
|
234
|
+
end
|
235
|
+
|
236
|
+
# Builds the object from hash
|
237
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
238
|
+
# @return [Object] Returns the model itself
|
239
|
+
def self.build_from_hash(attributes)
|
240
|
+
new.build_from_hash(attributes)
|
241
|
+
end
|
242
|
+
|
243
|
+
# Builds the object from hash
|
244
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
245
|
+
# @return [Object] Returns the model itself
|
246
|
+
def build_from_hash(attributes)
|
247
|
+
return nil unless attributes.is_a?(Hash)
|
248
|
+
self.class.openapi_types.each_pair do |key, type|
|
249
|
+
if type =~ /\AArray<(.*)>/i
|
250
|
+
# check to ensure the input is an array given that the attribute
|
251
|
+
# is documented as an array but the input is not
|
252
|
+
if attributes[self.class.attribute_map[key]].is_a?(Array)
|
253
|
+
self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
|
254
|
+
end
|
255
|
+
elsif !attributes[self.class.attribute_map[key]].nil?
|
256
|
+
self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
|
257
|
+
end # or else data not found in attributes(hash), not an issue as the data can be optional
|
258
|
+
end
|
259
|
+
|
260
|
+
self
|
261
|
+
end
|
262
|
+
|
263
|
+
# Deserializes the data based on type
|
264
|
+
# @param string type Data type
|
265
|
+
# @param string value Value to be deserialized
|
266
|
+
# @return [Object] Deserialized data
|
267
|
+
def _deserialize(type, value)
|
268
|
+
case type.to_sym
|
269
|
+
when :DateTime
|
270
|
+
DateTime.parse(value)
|
271
|
+
when :Date
|
272
|
+
Date.parse(value)
|
273
|
+
when :String
|
274
|
+
value.to_s
|
275
|
+
when :Integer
|
276
|
+
value.to_i
|
277
|
+
when :Float
|
278
|
+
value.to_f
|
279
|
+
when :Boolean
|
280
|
+
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
281
|
+
true
|
282
|
+
else
|
283
|
+
false
|
284
|
+
end
|
285
|
+
when :Object
|
286
|
+
# generic object (usually a Hash), return directly
|
287
|
+
value
|
288
|
+
when /\AArray<(?<inner_type>.+)>\z/
|
289
|
+
inner_type = Regexp.last_match[:inner_type]
|
290
|
+
value.map { |v| _deserialize(inner_type, v) }
|
291
|
+
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
|
292
|
+
k_type = Regexp.last_match[:k_type]
|
293
|
+
v_type = Regexp.last_match[:v_type]
|
294
|
+
{}.tap do |hash|
|
295
|
+
value.each do |k, v|
|
296
|
+
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
297
|
+
end
|
298
|
+
end
|
299
|
+
else # model
|
300
|
+
SourcesApiClient.const_get(type).build_from_hash(value)
|
301
|
+
end
|
302
|
+
end
|
303
|
+
|
304
|
+
# Returns the string representation of the object
|
305
|
+
# @return [String] String presentation of the object
|
306
|
+
def to_s
|
307
|
+
to_hash.to_s
|
308
|
+
end
|
309
|
+
|
310
|
+
# to_body is an alias to to_hash (backward compatibility)
|
311
|
+
# @return [Hash] Returns the object in the form of hash
|
312
|
+
def to_body
|
313
|
+
to_hash
|
314
|
+
end
|
315
|
+
|
316
|
+
# Returns the object in the form of hash
|
317
|
+
# @return [Hash] Returns the object in the form of hash
|
318
|
+
def to_hash
|
319
|
+
hash = {}
|
320
|
+
self.class.attribute_map.each_pair do |attr, param|
|
321
|
+
value = self.send(attr)
|
322
|
+
if value.nil?
|
323
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
324
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
325
|
+
end
|
326
|
+
|
327
|
+
hash[param] = _to_hash(value)
|
328
|
+
end
|
329
|
+
hash
|
330
|
+
end
|
331
|
+
|
332
|
+
# Outputs non-array value in the form of hash
|
333
|
+
# For object, use to_hash. Otherwise, just return the value
|
334
|
+
# @param [Object] value Any valid value
|
335
|
+
# @return [Hash] Returns the value in the form of hash
|
336
|
+
def _to_hash(value)
|
337
|
+
if value.is_a?(Array)
|
338
|
+
value.compact.map { |v| _to_hash(v) }
|
339
|
+
elsif value.is_a?(Hash)
|
340
|
+
{}.tap do |hash|
|
341
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
342
|
+
end
|
343
|
+
elsif value.respond_to? :to_hash
|
344
|
+
value.to_hash
|
345
|
+
else
|
346
|
+
value
|
347
|
+
end
|
348
|
+
end
|
349
|
+
end
|
350
|
+
end
|
@@ -0,0 +1,206 @@
|
|
1
|
+
=begin
|
2
|
+
#Sources
|
3
|
+
|
4
|
+
#Sources
|
5
|
+
|
6
|
+
The version of the OpenAPI document: 1.0.0
|
7
|
+
Contact: support@redhat.com
|
8
|
+
Generated by: https://openapi-generator.tech
|
9
|
+
OpenAPI Generator version: 4.2.1
|
10
|
+
|
11
|
+
=end
|
12
|
+
|
13
|
+
require 'date'
|
14
|
+
|
15
|
+
module SourcesApiClient
|
16
|
+
class AuthenticationExtra
|
17
|
+
attr_accessor :azure
|
18
|
+
|
19
|
+
# Attribute mapping from ruby-style variable name to JSON key.
|
20
|
+
def self.attribute_map
|
21
|
+
{
|
22
|
+
:'azure' => :'azure'
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
# Attribute type mapping.
|
27
|
+
def self.openapi_types
|
28
|
+
{
|
29
|
+
:'azure' => :'AuthenticationExtraAzure'
|
30
|
+
}
|
31
|
+
end
|
32
|
+
|
33
|
+
# List of attributes with nullable: true
|
34
|
+
def self.openapi_nullable
|
35
|
+
Set.new([
|
36
|
+
])
|
37
|
+
end
|
38
|
+
|
39
|
+
# Initializes the object
|
40
|
+
# @param [Hash] attributes Model attributes in the form of hash
|
41
|
+
def initialize(attributes = {})
|
42
|
+
if (!attributes.is_a?(Hash))
|
43
|
+
fail ArgumentError, "The input argument (attributes) must be a hash in `SourcesApiClient::AuthenticationExtra` initialize method"
|
44
|
+
end
|
45
|
+
|
46
|
+
# check to see if the attribute exists and convert string to symbol for hash key
|
47
|
+
attributes = attributes.each_with_object({}) { |(k, v), h|
|
48
|
+
if (!self.class.attribute_map.key?(k.to_sym))
|
49
|
+
fail ArgumentError, "`#{k}` is not a valid attribute in `SourcesApiClient::AuthenticationExtra`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
50
|
+
end
|
51
|
+
h[k.to_sym] = v
|
52
|
+
}
|
53
|
+
|
54
|
+
if attributes.key?(:'azure')
|
55
|
+
self.azure = attributes[:'azure']
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# Show invalid properties with the reasons. Usually used together with valid?
|
60
|
+
# @return Array for valid properties with the reasons
|
61
|
+
def list_invalid_properties
|
62
|
+
invalid_properties = Array.new
|
63
|
+
invalid_properties
|
64
|
+
end
|
65
|
+
|
66
|
+
# Check to see if the all the properties in the model are valid
|
67
|
+
# @return true if the model is valid
|
68
|
+
def valid?
|
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
|
+
azure == o.azure
|
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
|
+
[azure].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
|
+
SourcesApiClient.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
|
+
if value.nil?
|
179
|
+
is_nullable = self.class.openapi_nullable.include?(attr)
|
180
|
+
next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
|
181
|
+
end
|
182
|
+
|
183
|
+
hash[param] = _to_hash(value)
|
184
|
+
end
|
185
|
+
hash
|
186
|
+
end
|
187
|
+
|
188
|
+
# Outputs non-array value in the form of hash
|
189
|
+
# For object, use to_hash. Otherwise, just return the value
|
190
|
+
# @param [Object] value Any valid value
|
191
|
+
# @return [Hash] Returns the value in the form of hash
|
192
|
+
def _to_hash(value)
|
193
|
+
if value.is_a?(Array)
|
194
|
+
value.compact.map { |v| _to_hash(v) }
|
195
|
+
elsif value.is_a?(Hash)
|
196
|
+
{}.tap do |hash|
|
197
|
+
value.each { |k, v| hash[k] = _to_hash(v) }
|
198
|
+
end
|
199
|
+
elsif value.respond_to? :to_hash
|
200
|
+
value.to_hash
|
201
|
+
else
|
202
|
+
value
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|