autosde_openapi_client 1.1.9 → 1.1.10

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,395 @@
1
+ =begin
2
+ #Site Manager API
3
+
4
+ #Site Manager API
5
+
6
+ The version of the OpenAPI document: 1.0.0
7
+ Contact: autosde@il.ibm.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.0.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module AutosdeOpenapiClient
17
+ # User
18
+ class User
19
+ # date_joined
20
+ attr_accessor :date_joined
21
+
22
+ # email
23
+ attr_accessor :email
24
+
25
+ # first_name
26
+ attr_accessor :first_name
27
+
28
+ # is_active
29
+ attr_accessor :is_active
30
+
31
+ # is_staff
32
+ attr_accessor :is_staff
33
+
34
+ # is_superuser
35
+ attr_accessor :is_superuser
36
+
37
+ # last_login
38
+ attr_accessor :last_login
39
+
40
+ # last_name
41
+ attr_accessor :last_name
42
+
43
+ # password
44
+ attr_accessor :password
45
+
46
+ # username
47
+ attr_accessor :username
48
+
49
+ # uuid
50
+ attr_accessor :uuid
51
+
52
+ # Attribute mapping from ruby-style variable name to JSON key.
53
+ def self.attribute_map
54
+ {
55
+ :'date_joined' => :'date_joined',
56
+ :'email' => :'email',
57
+ :'first_name' => :'first_name',
58
+ :'is_active' => :'is_active',
59
+ :'is_staff' => :'is_staff',
60
+ :'is_superuser' => :'is_superuser',
61
+ :'last_login' => :'last_login',
62
+ :'last_name' => :'last_name',
63
+ :'password' => :'password',
64
+ :'username' => :'username',
65
+ :'uuid' => :'uuid'
66
+ }
67
+ end
68
+
69
+ # Returns all the JSON keys this model knows about
70
+ def self.acceptable_attributes
71
+ attribute_map.values
72
+ end
73
+
74
+ # Attribute type mapping.
75
+ def self.openapi_types
76
+ {
77
+ :'date_joined' => :'Time',
78
+ :'email' => :'String',
79
+ :'first_name' => :'String',
80
+ :'is_active' => :'Boolean',
81
+ :'is_staff' => :'Boolean',
82
+ :'is_superuser' => :'Boolean',
83
+ :'last_login' => :'Time',
84
+ :'last_name' => :'String',
85
+ :'password' => :'String',
86
+ :'username' => :'String',
87
+ :'uuid' => :'String'
88
+ }
89
+ end
90
+
91
+ # List of attributes with nullable: true
92
+ def self.openapi_nullable
93
+ Set.new([
94
+ ])
95
+ end
96
+
97
+ # Initializes the object
98
+ # @param [Hash] attributes Model attributes in the form of hash
99
+ def initialize(attributes = {})
100
+ if (!attributes.is_a?(Hash))
101
+ fail ArgumentError, "The input argument (attributes) must be a hash in `AutosdeOpenapiClient::User` initialize method"
102
+ end
103
+
104
+ # check to see if the attribute exists and convert string to symbol for hash key
105
+ attributes = attributes.each_with_object({}) { |(k, v), h|
106
+ if (!self.class.attribute_map.key?(k.to_sym))
107
+ fail ArgumentError, "`#{k}` is not a valid attribute in `AutosdeOpenapiClient::User`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
108
+ end
109
+ h[k.to_sym] = v
110
+ }
111
+
112
+ if attributes.key?(:'date_joined')
113
+ self.date_joined = attributes[:'date_joined']
114
+ end
115
+
116
+ if attributes.key?(:'email')
117
+ self.email = attributes[:'email']
118
+ end
119
+
120
+ if attributes.key?(:'first_name')
121
+ self.first_name = attributes[:'first_name']
122
+ end
123
+
124
+ if attributes.key?(:'is_active')
125
+ self.is_active = attributes[:'is_active']
126
+ end
127
+
128
+ if attributes.key?(:'is_staff')
129
+ self.is_staff = attributes[:'is_staff']
130
+ end
131
+
132
+ if attributes.key?(:'is_superuser')
133
+ self.is_superuser = attributes[:'is_superuser']
134
+ end
135
+
136
+ if attributes.key?(:'last_login')
137
+ self.last_login = attributes[:'last_login']
138
+ end
139
+
140
+ if attributes.key?(:'last_name')
141
+ self.last_name = attributes[:'last_name']
142
+ end
143
+
144
+ if attributes.key?(:'password')
145
+ self.password = attributes[:'password']
146
+ end
147
+
148
+ if attributes.key?(:'username')
149
+ self.username = attributes[:'username']
150
+ end
151
+
152
+ if attributes.key?(:'uuid')
153
+ self.uuid = attributes[:'uuid']
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
+ if !@email.nil? && @email.to_s.length > 254
162
+ invalid_properties.push('invalid value for "email", the character length must be smaller than or equal to 254.')
163
+ end
164
+
165
+ if !@first_name.nil? && @first_name.to_s.length > 150
166
+ invalid_properties.push('invalid value for "first_name", the character length must be smaller than or equal to 150.')
167
+ end
168
+
169
+ if !@last_name.nil? && @last_name.to_s.length > 150
170
+ invalid_properties.push('invalid value for "last_name", the character length must be smaller than or equal to 150.')
171
+ end
172
+
173
+ if !@password.nil? && @password.to_s.length > 128
174
+ invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 128.')
175
+ end
176
+
177
+ if !@username.nil? && @username.to_s.length > 150
178
+ invalid_properties.push('invalid value for "username", the character length must be smaller than or equal to 150.')
179
+ end
180
+
181
+ invalid_properties
182
+ end
183
+
184
+ # Check to see if the all the properties in the model are valid
185
+ # @return true if the model is valid
186
+ def valid?
187
+ return false if !@email.nil? && @email.to_s.length > 254
188
+ return false if !@first_name.nil? && @first_name.to_s.length > 150
189
+ return false if !@last_name.nil? && @last_name.to_s.length > 150
190
+ return false if !@password.nil? && @password.to_s.length > 128
191
+ return false if !@username.nil? && @username.to_s.length > 150
192
+ true
193
+ end
194
+
195
+ # Custom attribute writer method with validation
196
+ # @param [Object] email Value to be assigned
197
+ def email=(email)
198
+ if !email.nil? && email.to_s.length > 254
199
+ fail ArgumentError, 'invalid value for "email", the character length must be smaller than or equal to 254.'
200
+ end
201
+
202
+ @email = email
203
+ end
204
+
205
+ # Custom attribute writer method with validation
206
+ # @param [Object] first_name Value to be assigned
207
+ def first_name=(first_name)
208
+ if !first_name.nil? && first_name.to_s.length > 150
209
+ fail ArgumentError, 'invalid value for "first_name", the character length must be smaller than or equal to 150.'
210
+ end
211
+
212
+ @first_name = first_name
213
+ end
214
+
215
+ # Custom attribute writer method with validation
216
+ # @param [Object] last_name Value to be assigned
217
+ def last_name=(last_name)
218
+ if !last_name.nil? && last_name.to_s.length > 150
219
+ fail ArgumentError, 'invalid value for "last_name", the character length must be smaller than or equal to 150.'
220
+ end
221
+
222
+ @last_name = last_name
223
+ end
224
+
225
+ # Custom attribute writer method with validation
226
+ # @param [Object] password Value to be assigned
227
+ def password=(password)
228
+ if !password.nil? && password.to_s.length > 128
229
+ fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 128.'
230
+ end
231
+
232
+ @password = password
233
+ end
234
+
235
+ # Custom attribute writer method with validation
236
+ # @param [Object] username Value to be assigned
237
+ def username=(username)
238
+ if !username.nil? && username.to_s.length > 150
239
+ fail ArgumentError, 'invalid value for "username", the character length must be smaller than or equal to 150.'
240
+ end
241
+
242
+ @username = username
243
+ end
244
+
245
+ # Checks equality by comparing each attribute.
246
+ # @param [Object] Object to be compared
247
+ def ==(o)
248
+ return true if self.equal?(o)
249
+ self.class == o.class &&
250
+ date_joined == o.date_joined &&
251
+ email == o.email &&
252
+ first_name == o.first_name &&
253
+ is_active == o.is_active &&
254
+ is_staff == o.is_staff &&
255
+ is_superuser == o.is_superuser &&
256
+ last_login == o.last_login &&
257
+ last_name == o.last_name &&
258
+ password == o.password &&
259
+ username == o.username &&
260
+ uuid == o.uuid
261
+ end
262
+
263
+ # @see the `==` method
264
+ # @param [Object] Object to be compared
265
+ def eql?(o)
266
+ self == o
267
+ end
268
+
269
+ # Calculates hash code according to all attributes.
270
+ # @return [Integer] Hash code
271
+ def hash
272
+ [date_joined, email, first_name, is_active, is_staff, is_superuser, last_login, last_name, password, username, uuid].hash
273
+ end
274
+
275
+ # Builds the object from hash
276
+ # @param [Hash] attributes Model attributes in the form of hash
277
+ # @return [Object] Returns the model itself
278
+ def self.build_from_hash(attributes)
279
+ new.build_from_hash(attributes)
280
+ end
281
+
282
+ # Builds the object from hash
283
+ # @param [Hash] attributes Model attributes in the form of hash
284
+ # @return [Object] Returns the model itself
285
+ def build_from_hash(attributes)
286
+ return nil unless attributes.is_a?(Hash)
287
+ self.class.openapi_types.each_pair do |key, type|
288
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
289
+ self.send("#{key}=", nil)
290
+ elsif type =~ /\AArray<(.*)>/i
291
+ # check to ensure the input is an array given that the attribute
292
+ # is documented as an array but the input is not
293
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
294
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
295
+ end
296
+ elsif !attributes[self.class.attribute_map[key]].nil?
297
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
298
+ end
299
+ end
300
+
301
+ self
302
+ end
303
+
304
+ # Deserializes the data based on type
305
+ # @param string type Data type
306
+ # @param string value Value to be deserialized
307
+ # @return [Object] Deserialized data
308
+ def _deserialize(type, value)
309
+ case type.to_sym
310
+ when :Time
311
+ Time.parse(value)
312
+ when :Date
313
+ Date.parse(value)
314
+ when :String
315
+ value.to_s
316
+ when :Integer
317
+ value.to_i
318
+ when :Float
319
+ value.to_f
320
+ when :Boolean
321
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
322
+ true
323
+ else
324
+ false
325
+ end
326
+ when :Object
327
+ # generic object (usually a Hash), return directly
328
+ value
329
+ when /\AArray<(?<inner_type>.+)>\z/
330
+ inner_type = Regexp.last_match[:inner_type]
331
+ value.map { |v| _deserialize(inner_type, v) }
332
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
333
+ k_type = Regexp.last_match[:k_type]
334
+ v_type = Regexp.last_match[:v_type]
335
+ {}.tap do |hash|
336
+ value.each do |k, v|
337
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
338
+ end
339
+ end
340
+ else # model
341
+ # models (e.g. Pet) or oneOf
342
+ klass = AutosdeOpenapiClient.const_get(type)
343
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
344
+ end
345
+ end
346
+
347
+ # Returns the string representation of the object
348
+ # @return [String] String presentation of the object
349
+ def to_s
350
+ to_hash.to_s
351
+ end
352
+
353
+ # to_body is an alias to to_hash (backward compatibility)
354
+ # @return [Hash] Returns the object in the form of hash
355
+ def to_body
356
+ to_hash
357
+ end
358
+
359
+ # Returns the object in the form of hash
360
+ # @return [Hash] Returns the object in the form of hash
361
+ def to_hash
362
+ hash = {}
363
+ self.class.attribute_map.each_pair do |attr, param|
364
+ value = self.send(attr)
365
+ if value.nil?
366
+ is_nullable = self.class.openapi_nullable.include?(attr)
367
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
368
+ end
369
+
370
+ hash[param] = _to_hash(value)
371
+ end
372
+ hash
373
+ end
374
+
375
+ # Outputs non-array value in the form of hash
376
+ # For object, use to_hash. Otherwise, just return the value
377
+ # @param [Object] value Any valid value
378
+ # @return [Hash] Returns the value in the form of hash
379
+ def _to_hash(value)
380
+ if value.is_a?(Array)
381
+ value.compact.map { |v| _to_hash(v) }
382
+ elsif value.is_a?(Hash)
383
+ {}.tap do |hash|
384
+ value.each { |k, v| hash[k] = _to_hash(v) }
385
+ end
386
+ elsif value.respond_to? :to_hash
387
+ value.to_hash
388
+ else
389
+ value
390
+ end
391
+ end
392
+
393
+ end
394
+
395
+ end