pnap_bmc_api 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (114) hide show
  1. checksums.yaml +7 -0
  2. data/Gemfile +9 -0
  3. data/README.md +196 -0
  4. data/Rakefile +10 -0
  5. data/VERSION +1 -0
  6. data/docs/ActionResult.md +18 -0
  7. data/docs/DeleteResult.md +20 -0
  8. data/docs/DeleteSshKeyResult.md +20 -0
  9. data/docs/Error.md +20 -0
  10. data/docs/IpBlocksConfiguration.md +20 -0
  11. data/docs/NetworkConfiguration.md +20 -0
  12. data/docs/OsConfiguration.md +24 -0
  13. data/docs/OsConfigurationMap.md +22 -0
  14. data/docs/OsConfigurationMapEsxi.md +22 -0
  15. data/docs/OsConfigurationMapProxmox.md +22 -0
  16. data/docs/OsConfigurationWindows.md +18 -0
  17. data/docs/PrivateNetworkConfiguration.md +22 -0
  18. data/docs/Quota.md +32 -0
  19. data/docs/QuotaEditLimitRequest.md +20 -0
  20. data/docs/QuotaEditLimitRequestDetails.md +22 -0
  21. data/docs/QuotaEditLimitRequestDetailsAllOf.md +18 -0
  22. data/docs/QuotasApi.md +217 -0
  23. data/docs/RelinquishIpBlock.md +18 -0
  24. data/docs/ResetResult.md +22 -0
  25. data/docs/SSHKeysApi.md +360 -0
  26. data/docs/Server.md +64 -0
  27. data/docs/ServerCreate.md +44 -0
  28. data/docs/ServerIpBlock.md +20 -0
  29. data/docs/ServerPatch.md +20 -0
  30. data/docs/ServerPrivateNetwork.md +24 -0
  31. data/docs/ServerReserve.md +18 -0
  32. data/docs/ServerReset.md +24 -0
  33. data/docs/ServersApi.md +1237 -0
  34. data/docs/SshKey.md +30 -0
  35. data/docs/SshKeyCreate.md +22 -0
  36. data/docs/SshKeyUpdate.md +20 -0
  37. data/docs/TagAssignment.md +26 -0
  38. data/docs/TagAssignmentRequest.md +20 -0
  39. data/lib/pnap_bmc_api/api/quotas_api.rb +212 -0
  40. data/lib/pnap_bmc_api/api/servers_api.rb +1159 -0
  41. data/lib/pnap_bmc_api/api/ssh_keys_api.rb +339 -0
  42. data/lib/pnap_bmc_api/api_client.rb +392 -0
  43. data/lib/pnap_bmc_api/api_error.rb +57 -0
  44. data/lib/pnap_bmc_api/configuration.rb +278 -0
  45. data/lib/pnap_bmc_api/models/action_result.rb +225 -0
  46. data/lib/pnap_bmc_api/models/delete_result.rb +240 -0
  47. data/lib/pnap_bmc_api/models/delete_ssh_key_result.rb +240 -0
  48. data/lib/pnap_bmc_api/models/error.rb +236 -0
  49. data/lib/pnap_bmc_api/models/ip_blocks_configuration.rb +283 -0
  50. data/lib/pnap_bmc_api/models/network_configuration.rb +228 -0
  51. data/lib/pnap_bmc_api/models/os_configuration.rb +266 -0
  52. data/lib/pnap_bmc_api/models/os_configuration_map.rb +237 -0
  53. data/lib/pnap_bmc_api/models/os_configuration_map_esxi.rb +257 -0
  54. data/lib/pnap_bmc_api/models/os_configuration_map_proxmox.rb +257 -0
  55. data/lib/pnap_bmc_api/models/os_configuration_windows.rb +237 -0
  56. data/lib/pnap_bmc_api/models/private_network_configuration.rb +244 -0
  57. data/lib/pnap_bmc_api/models/quota.rb +415 -0
  58. data/lib/pnap_bmc_api/models/quota_edit_limit_request.rb +259 -0
  59. data/lib/pnap_bmc_api/models/quota_edit_limit_request_details.rb +281 -0
  60. data/lib/pnap_bmc_api/models/quota_edit_limit_request_details_all_of.rb +225 -0
  61. data/lib/pnap_bmc_api/models/relinquish_ip_block.rb +222 -0
  62. data/lib/pnap_bmc_api/models/reset_result.rb +244 -0
  63. data/lib/pnap_bmc_api/models/server.rb +687 -0
  64. data/lib/pnap_bmc_api/models/server_create.rb +434 -0
  65. data/lib/pnap_bmc_api/models/server_ip_block.rb +235 -0
  66. data/lib/pnap_bmc_api/models/server_patch.rb +280 -0
  67. data/lib/pnap_bmc_api/models/server_private_network.rb +274 -0
  68. data/lib/pnap_bmc_api/models/server_reserve.rb +225 -0
  69. data/lib/pnap_bmc_api/models/server_reset.rb +255 -0
  70. data/lib/pnap_bmc_api/models/ssh_key.rb +315 -0
  71. data/lib/pnap_bmc_api/models/ssh_key_create.rb +283 -0
  72. data/lib/pnap_bmc_api/models/ssh_key_update.rb +268 -0
  73. data/lib/pnap_bmc_api/models/tag_assignment.rb +309 -0
  74. data/lib/pnap_bmc_api/models/tag_assignment_request.rb +235 -0
  75. data/lib/pnap_bmc_api/version.rb +19 -0
  76. data/lib/pnap_bmc_api.rb +72 -0
  77. data/pnap_bmc_api.gemspec +39 -0
  78. data/spec/api/quotas_api_spec.rb +71 -0
  79. data/spec/api/servers_api_spec.rb +249 -0
  80. data/spec/api/ssh_keys_api_spec.rb +95 -0
  81. data/spec/api_client_spec.rb +226 -0
  82. data/spec/configuration_spec.rb +42 -0
  83. data/spec/models/action_result_spec.rb +34 -0
  84. data/spec/models/delete_result_spec.rb +40 -0
  85. data/spec/models/delete_ssh_key_result_spec.rb +40 -0
  86. data/spec/models/error_spec.rb +40 -0
  87. data/spec/models/ip_blocks_configuration_spec.rb +44 -0
  88. data/spec/models/network_configuration_spec.rb +40 -0
  89. data/spec/models/os_configuration_map_esxi_spec.rb +46 -0
  90. data/spec/models/os_configuration_map_proxmox_spec.rb +46 -0
  91. data/spec/models/os_configuration_map_spec.rb +46 -0
  92. data/spec/models/os_configuration_spec.rb +52 -0
  93. data/spec/models/os_configuration_windows_spec.rb +34 -0
  94. data/spec/models/private_network_configuration_spec.rb +46 -0
  95. data/spec/models/quota_edit_limit_request_details_all_of_spec.rb +34 -0
  96. data/spec/models/quota_edit_limit_request_details_spec.rb +46 -0
  97. data/spec/models/quota_edit_limit_request_spec.rb +40 -0
  98. data/spec/models/quota_spec.rb +84 -0
  99. data/spec/models/relinquish_ip_block_spec.rb +34 -0
  100. data/spec/models/reset_result_spec.rb +46 -0
  101. data/spec/models/server_create_spec.rb +112 -0
  102. data/spec/models/server_ip_block_spec.rb +40 -0
  103. data/spec/models/server_patch_spec.rb +40 -0
  104. data/spec/models/server_private_network_spec.rb +52 -0
  105. data/spec/models/server_reserve_spec.rb +34 -0
  106. data/spec/models/server_reset_spec.rb +52 -0
  107. data/spec/models/server_spec.rb +172 -0
  108. data/spec/models/ssh_key_create_spec.rb +46 -0
  109. data/spec/models/ssh_key_spec.rb +70 -0
  110. data/spec/models/ssh_key_update_spec.rb +40 -0
  111. data/spec/models/tag_assignment_request_spec.rb +40 -0
  112. data/spec/models/tag_assignment_spec.rb +62 -0
  113. data/spec/spec_helper.rb +111 -0
  114. metadata +232 -0
@@ -0,0 +1,415 @@
1
+ =begin
2
+ #Bare Metal Cloud API
3
+
4
+ #Create, power off, power on, reset, reboot, or shut down your server with the Bare Metal Cloud API. Deprovision servers, get or edit SSH key details, and a lot more. Manage your infrastructure more efficiently using just a few simple api calls.<br> <br> <span class='pnap-api-knowledge-base-link'> Knowledge base articles to help you can be found <a href='https://phoenixnap.com/kb/how-to-deploy-bare-metal-cloud-server' target='_blank'>here</a> </span><br> <br> <b>All URLs are relative to (https://api.phoenixnap.com/bmc/v1/)</b>
5
+
6
+ The version of the OpenAPI document: 0.1
7
+ Contact: support@phoenixnap.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module BmcApi
17
+ # Quota.
18
+ class Quota
19
+ # The ID of the Quota.
20
+ attr_accessor :id
21
+
22
+ # The name of the Quota.
23
+ attr_accessor :name
24
+
25
+ # The Quota description.
26
+ attr_accessor :description
27
+
28
+ # The status of the quota resource usage.
29
+ attr_accessor :status
30
+
31
+ # The limit set for the quota.
32
+ attr_accessor :limit
33
+
34
+ # An enum field describing what the limit is measured in.
35
+ attr_accessor :unit
36
+
37
+ # The quota used expressed as a number.
38
+ attr_accessor :used
39
+
40
+ attr_accessor :quota_edit_limit_request_details
41
+
42
+ class EnumAttributeValidator
43
+ attr_reader :datatype
44
+ attr_reader :allowable_values
45
+
46
+ def initialize(datatype, allowable_values)
47
+ @allowable_values = allowable_values.map do |value|
48
+ case datatype.to_s
49
+ when /Integer/i
50
+ value.to_i
51
+ when /Float/i
52
+ value.to_f
53
+ else
54
+ value
55
+ end
56
+ end
57
+ end
58
+
59
+ def valid?(value)
60
+ !value || allowable_values.include?(value)
61
+ end
62
+ end
63
+
64
+ # Attribute mapping from ruby-style variable name to JSON key.
65
+ def self.attribute_map
66
+ {
67
+ :'id' => :'id',
68
+ :'name' => :'name',
69
+ :'description' => :'description',
70
+ :'status' => :'status',
71
+ :'limit' => :'limit',
72
+ :'unit' => :'unit',
73
+ :'used' => :'used',
74
+ :'quota_edit_limit_request_details' => :'quotaEditLimitRequestDetails'
75
+ }
76
+ end
77
+
78
+ # Returns all the JSON keys this model knows about
79
+ def self.acceptable_attributes
80
+ attribute_map.values
81
+ end
82
+
83
+ # Attribute type mapping.
84
+ def self.openapi_types
85
+ {
86
+ :'id' => :'String',
87
+ :'name' => :'String',
88
+ :'description' => :'String',
89
+ :'status' => :'String',
90
+ :'limit' => :'Integer',
91
+ :'unit' => :'String',
92
+ :'used' => :'Integer',
93
+ :'quota_edit_limit_request_details' => :'Array<QuotaEditLimitRequestDetails>'
94
+ }
95
+ end
96
+
97
+ # List of attributes with nullable: true
98
+ def self.openapi_nullable
99
+ Set.new([
100
+ ])
101
+ end
102
+
103
+ # Initializes the object
104
+ # @param [Hash] attributes Model attributes in the form of hash
105
+ def initialize(attributes = {})
106
+ if (!attributes.is_a?(Hash))
107
+ fail ArgumentError, "The input argument (attributes) must be a hash in `BmcApi::Quota` initialize method"
108
+ end
109
+
110
+ # check to see if the attribute exists and convert string to symbol for hash key
111
+ attributes = attributes.each_with_object({}) { |(k, v), h|
112
+ if (!self.class.attribute_map.key?(k.to_sym))
113
+ fail ArgumentError, "`#{k}` is not a valid attribute in `BmcApi::Quota`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
114
+ end
115
+ h[k.to_sym] = v
116
+ }
117
+
118
+ if attributes.key?(:'id')
119
+ self.id = attributes[:'id']
120
+ end
121
+
122
+ if attributes.key?(:'name')
123
+ self.name = attributes[:'name']
124
+ end
125
+
126
+ if attributes.key?(:'description')
127
+ self.description = attributes[:'description']
128
+ end
129
+
130
+ if attributes.key?(:'status')
131
+ self.status = attributes[:'status']
132
+ end
133
+
134
+ if attributes.key?(:'limit')
135
+ self.limit = attributes[:'limit']
136
+ end
137
+
138
+ if attributes.key?(:'unit')
139
+ self.unit = attributes[:'unit']
140
+ end
141
+
142
+ if attributes.key?(:'used')
143
+ self.used = attributes[:'used']
144
+ end
145
+
146
+ if attributes.key?(:'quota_edit_limit_request_details')
147
+ if (value = attributes[:'quota_edit_limit_request_details']).is_a?(Array)
148
+ self.quota_edit_limit_request_details = value
149
+ end
150
+ end
151
+ end
152
+
153
+ # Show invalid properties with the reasons. Usually used together with valid?
154
+ # @return Array for valid properties with the reasons
155
+ def list_invalid_properties
156
+ invalid_properties = Array.new
157
+ if @id.nil?
158
+ invalid_properties.push('invalid value for "id", id cannot be nil.')
159
+ end
160
+
161
+ if @name.nil?
162
+ invalid_properties.push('invalid value for "name", name cannot be nil.')
163
+ end
164
+
165
+ if @description.nil?
166
+ invalid_properties.push('invalid value for "description", description cannot be nil.')
167
+ end
168
+
169
+ if @status.nil?
170
+ invalid_properties.push('invalid value for "status", status cannot be nil.')
171
+ end
172
+
173
+ if @limit.nil?
174
+ invalid_properties.push('invalid value for "limit", limit cannot be nil.')
175
+ end
176
+
177
+ if @limit < 0
178
+ invalid_properties.push('invalid value for "limit", must be greater than or equal to 0.')
179
+ end
180
+
181
+ if @unit.nil?
182
+ invalid_properties.push('invalid value for "unit", unit cannot be nil.')
183
+ end
184
+
185
+ if @used.nil?
186
+ invalid_properties.push('invalid value for "used", used cannot be nil.')
187
+ end
188
+
189
+ if @used < 0
190
+ invalid_properties.push('invalid value for "used", must be greater than or equal to 0.')
191
+ end
192
+
193
+ if @quota_edit_limit_request_details.nil?
194
+ invalid_properties.push('invalid value for "quota_edit_limit_request_details", quota_edit_limit_request_details cannot be nil.')
195
+ end
196
+
197
+ invalid_properties
198
+ end
199
+
200
+ # Check to see if the all the properties in the model are valid
201
+ # @return true if the model is valid
202
+ def valid?
203
+ return false if @id.nil?
204
+ return false if @name.nil?
205
+ return false if @description.nil?
206
+ return false if @status.nil?
207
+ status_validator = EnumAttributeValidator.new('String', ["WITHIN_LIMIT", "OVER_LIMIT", "ON_LIMIT"])
208
+ return false unless status_validator.valid?(@status)
209
+ return false if @limit.nil?
210
+ return false if @limit < 0
211
+ return false if @unit.nil?
212
+ unit_validator = EnumAttributeValidator.new('String', ["COUNT"])
213
+ return false unless unit_validator.valid?(@unit)
214
+ return false if @used.nil?
215
+ return false if @used < 0
216
+ return false if @quota_edit_limit_request_details.nil?
217
+ true
218
+ end
219
+
220
+ # Custom attribute writer method checking allowed values (enum).
221
+ # @param [Object] status Object to be assigned
222
+ def status=(status)
223
+ validator = EnumAttributeValidator.new('String', ["WITHIN_LIMIT", "OVER_LIMIT", "ON_LIMIT"])
224
+ unless validator.valid?(status)
225
+ fail ArgumentError, "invalid value for \"status\", must be one of #{validator.allowable_values}."
226
+ end
227
+ @status = status
228
+ end
229
+
230
+ # Custom attribute writer method with validation
231
+ # @param [Object] limit Value to be assigned
232
+ def limit=(limit)
233
+ if limit.nil?
234
+ fail ArgumentError, 'limit cannot be nil'
235
+ end
236
+
237
+ if limit < 0
238
+ fail ArgumentError, 'invalid value for "limit", must be greater than or equal to 0.'
239
+ end
240
+
241
+ @limit = limit
242
+ end
243
+
244
+ # Custom attribute writer method checking allowed values (enum).
245
+ # @param [Object] unit Object to be assigned
246
+ def unit=(unit)
247
+ validator = EnumAttributeValidator.new('String', ["COUNT"])
248
+ unless validator.valid?(unit)
249
+ fail ArgumentError, "invalid value for \"unit\", must be one of #{validator.allowable_values}."
250
+ end
251
+ @unit = unit
252
+ end
253
+
254
+ # Custom attribute writer method with validation
255
+ # @param [Object] used Value to be assigned
256
+ def used=(used)
257
+ if used.nil?
258
+ fail ArgumentError, 'used cannot be nil'
259
+ end
260
+
261
+ if used < 0
262
+ fail ArgumentError, 'invalid value for "used", must be greater than or equal to 0.'
263
+ end
264
+
265
+ @used = used
266
+ end
267
+
268
+ # Checks equality by comparing each attribute.
269
+ # @param [Object] Object to be compared
270
+ def ==(o)
271
+ return true if self.equal?(o)
272
+ self.class == o.class &&
273
+ id == o.id &&
274
+ name == o.name &&
275
+ description == o.description &&
276
+ status == o.status &&
277
+ limit == o.limit &&
278
+ unit == o.unit &&
279
+ used == o.used &&
280
+ quota_edit_limit_request_details == o.quota_edit_limit_request_details
281
+ end
282
+
283
+ # @see the `==` method
284
+ # @param [Object] Object to be compared
285
+ def eql?(o)
286
+ self == o
287
+ end
288
+
289
+ # Calculates hash code according to all attributes.
290
+ # @return [Integer] Hash code
291
+ def hash
292
+ [id, name, description, status, limit, unit, used, quota_edit_limit_request_details].hash
293
+ end
294
+
295
+ # Builds the object from hash
296
+ # @param [Hash] attributes Model attributes in the form of hash
297
+ # @return [Object] Returns the model itself
298
+ def self.build_from_hash(attributes)
299
+ new.build_from_hash(attributes)
300
+ end
301
+
302
+ # Builds the object from hash
303
+ # @param [Hash] attributes Model attributes in the form of hash
304
+ # @return [Object] Returns the model itself
305
+ def build_from_hash(attributes)
306
+ return nil unless attributes.is_a?(Hash)
307
+ self.class.openapi_types.each_pair do |key, type|
308
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
309
+ self.send("#{key}=", nil)
310
+ elsif type =~ /\AArray<(.*)>/i
311
+ # check to ensure the input is an array given that the attribute
312
+ # is documented as an array but the input is not
313
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
314
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
315
+ end
316
+ elsif !attributes[self.class.attribute_map[key]].nil?
317
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
318
+ end
319
+ end
320
+
321
+ self
322
+ end
323
+
324
+ # Deserializes the data based on type
325
+ # @param string type Data type
326
+ # @param string value Value to be deserialized
327
+ # @return [Object] Deserialized data
328
+ def _deserialize(type, value)
329
+ case type.to_sym
330
+ when :Time
331
+ Time.parse(value)
332
+ when :Date
333
+ Date.parse(value)
334
+ when :String
335
+ value.to_s
336
+ when :Integer
337
+ value.to_i
338
+ when :Float
339
+ value.to_f
340
+ when :Boolean
341
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
342
+ true
343
+ else
344
+ false
345
+ end
346
+ when :Object
347
+ # generic object (usually a Hash), return directly
348
+ value
349
+ when /\AArray<(?<inner_type>.+)>\z/
350
+ inner_type = Regexp.last_match[:inner_type]
351
+ value.map { |v| _deserialize(inner_type, v) }
352
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
353
+ k_type = Regexp.last_match[:k_type]
354
+ v_type = Regexp.last_match[:v_type]
355
+ {}.tap do |hash|
356
+ value.each do |k, v|
357
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
358
+ end
359
+ end
360
+ else # model
361
+ # models (e.g. Pet) or oneOf
362
+ klass = BmcApi.const_get(type)
363
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
364
+ end
365
+ end
366
+
367
+ # Returns the string representation of the object
368
+ # @return [String] String presentation of the object
369
+ def to_s
370
+ to_hash.to_s
371
+ end
372
+
373
+ # to_body is an alias to to_hash (backward compatibility)
374
+ # @return [Hash] Returns the object in the form of hash
375
+ def to_body
376
+ to_hash
377
+ end
378
+
379
+ # Returns the object in the form of hash
380
+ # @return [Hash] Returns the object in the form of hash
381
+ def to_hash
382
+ hash = {}
383
+ self.class.attribute_map.each_pair do |attr, param|
384
+ value = self.send(attr)
385
+ if value.nil?
386
+ is_nullable = self.class.openapi_nullable.include?(attr)
387
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
388
+ end
389
+
390
+ hash[param] = _to_hash(value)
391
+ end
392
+ hash
393
+ end
394
+
395
+ # Outputs non-array value in the form of hash
396
+ # For object, use to_hash. Otherwise, just return the value
397
+ # @param [Object] value Any valid value
398
+ # @return [Hash] Returns the value in the form of hash
399
+ def _to_hash(value)
400
+ if value.is_a?(Array)
401
+ value.compact.map { |v| _to_hash(v) }
402
+ elsif value.is_a?(Hash)
403
+ {}.tap do |hash|
404
+ value.each { |k, v| hash[k] = _to_hash(v) }
405
+ end
406
+ elsif value.respond_to? :to_hash
407
+ value.to_hash
408
+ else
409
+ value
410
+ end
411
+ end
412
+
413
+ end
414
+
415
+ end
@@ -0,0 +1,259 @@
1
+ =begin
2
+ #Bare Metal Cloud API
3
+
4
+ #Create, power off, power on, reset, reboot, or shut down your server with the Bare Metal Cloud API. Deprovision servers, get or edit SSH key details, and a lot more. Manage your infrastructure more efficiently using just a few simple api calls.<br> <br> <span class='pnap-api-knowledge-base-link'> Knowledge base articles to help you can be found <a href='https://phoenixnap.com/kb/how-to-deploy-bare-metal-cloud-server' target='_blank'>here</a> </span><br> <br> <b>All URLs are relative to (https://api.phoenixnap.com/bmc/v1/)</b>
5
+
6
+ The version of the OpenAPI document: 0.1
7
+ Contact: support@phoenixnap.com
8
+ Generated by: https://openapi-generator.tech
9
+ OpenAPI Generator version: 5.4.0
10
+
11
+ =end
12
+
13
+ require 'date'
14
+ require 'time'
15
+
16
+ module BmcApi
17
+ # A request to change the limit on a quota.
18
+ class QuotaEditLimitRequest
19
+ # The new limit that is requested.
20
+ attr_accessor :limit
21
+
22
+ # The reason for changing the limit.
23
+ attr_accessor :reason
24
+
25
+ # Attribute mapping from ruby-style variable name to JSON key.
26
+ def self.attribute_map
27
+ {
28
+ :'limit' => :'limit',
29
+ :'reason' => :'reason'
30
+ }
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'limit' => :'Integer',
42
+ :'reason' => :'String'
43
+ }
44
+ end
45
+
46
+ # List of attributes with nullable: true
47
+ def self.openapi_nullable
48
+ Set.new([
49
+ ])
50
+ end
51
+
52
+ # Initializes the object
53
+ # @param [Hash] attributes Model attributes in the form of hash
54
+ def initialize(attributes = {})
55
+ if (!attributes.is_a?(Hash))
56
+ fail ArgumentError, "The input argument (attributes) must be a hash in `BmcApi::QuotaEditLimitRequest` initialize method"
57
+ end
58
+
59
+ # check to see if the attribute exists and convert string to symbol for hash key
60
+ attributes = attributes.each_with_object({}) { |(k, v), h|
61
+ if (!self.class.attribute_map.key?(k.to_sym))
62
+ fail ArgumentError, "`#{k}` is not a valid attribute in `BmcApi::QuotaEditLimitRequest`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
63
+ end
64
+ h[k.to_sym] = v
65
+ }
66
+
67
+ if attributes.key?(:'limit')
68
+ self.limit = attributes[:'limit']
69
+ end
70
+
71
+ if attributes.key?(:'reason')
72
+ self.reason = attributes[:'reason']
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 @limit.nil?
81
+ invalid_properties.push('invalid value for "limit", limit cannot be nil.')
82
+ end
83
+
84
+ if @limit < 0
85
+ invalid_properties.push('invalid value for "limit", must be greater than or equal to 0.')
86
+ end
87
+
88
+ if @reason.nil?
89
+ invalid_properties.push('invalid value for "reason", reason 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 @limit.nil?
99
+ return false if @limit < 0
100
+ return false if @reason.nil?
101
+ true
102
+ end
103
+
104
+ # Custom attribute writer method with validation
105
+ # @param [Object] limit Value to be assigned
106
+ def limit=(limit)
107
+ if limit.nil?
108
+ fail ArgumentError, 'limit cannot be nil'
109
+ end
110
+
111
+ if limit < 0
112
+ fail ArgumentError, 'invalid value for "limit", must be greater than or equal to 0.'
113
+ end
114
+
115
+ @limit = limit
116
+ end
117
+
118
+ # Checks equality by comparing each attribute.
119
+ # @param [Object] Object to be compared
120
+ def ==(o)
121
+ return true if self.equal?(o)
122
+ self.class == o.class &&
123
+ limit == o.limit &&
124
+ reason == o.reason
125
+ end
126
+
127
+ # @see the `==` method
128
+ # @param [Object] Object to be compared
129
+ def eql?(o)
130
+ self == o
131
+ end
132
+
133
+ # Calculates hash code according to all attributes.
134
+ # @return [Integer] Hash code
135
+ def hash
136
+ [limit, reason].hash
137
+ end
138
+
139
+ # Builds the object from hash
140
+ # @param [Hash] attributes Model attributes in the form of hash
141
+ # @return [Object] Returns the model itself
142
+ def self.build_from_hash(attributes)
143
+ new.build_from_hash(attributes)
144
+ end
145
+
146
+ # Builds the object from hash
147
+ # @param [Hash] attributes Model attributes in the form of hash
148
+ # @return [Object] Returns the model itself
149
+ def build_from_hash(attributes)
150
+ return nil unless attributes.is_a?(Hash)
151
+ self.class.openapi_types.each_pair do |key, type|
152
+ if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
153
+ self.send("#{key}=", nil)
154
+ elsif type =~ /\AArray<(.*)>/i
155
+ # check to ensure the input is an array given that the attribute
156
+ # is documented as an array but the input is not
157
+ if attributes[self.class.attribute_map[key]].is_a?(Array)
158
+ self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
159
+ end
160
+ elsif !attributes[self.class.attribute_map[key]].nil?
161
+ self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
162
+ end
163
+ end
164
+
165
+ self
166
+ end
167
+
168
+ # Deserializes the data based on type
169
+ # @param string type Data type
170
+ # @param string value Value to be deserialized
171
+ # @return [Object] Deserialized data
172
+ def _deserialize(type, value)
173
+ case type.to_sym
174
+ when :Time
175
+ Time.parse(value)
176
+ when :Date
177
+ Date.parse(value)
178
+ when :String
179
+ value.to_s
180
+ when :Integer
181
+ value.to_i
182
+ when :Float
183
+ value.to_f
184
+ when :Boolean
185
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
186
+ true
187
+ else
188
+ false
189
+ end
190
+ when :Object
191
+ # generic object (usually a Hash), return directly
192
+ value
193
+ when /\AArray<(?<inner_type>.+)>\z/
194
+ inner_type = Regexp.last_match[:inner_type]
195
+ value.map { |v| _deserialize(inner_type, v) }
196
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
197
+ k_type = Regexp.last_match[:k_type]
198
+ v_type = Regexp.last_match[:v_type]
199
+ {}.tap do |hash|
200
+ value.each do |k, v|
201
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
202
+ end
203
+ end
204
+ else # model
205
+ # models (e.g. Pet) or oneOf
206
+ klass = BmcApi.const_get(type)
207
+ klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
208
+ end
209
+ end
210
+
211
+ # Returns the string representation of the object
212
+ # @return [String] String presentation of the object
213
+ def to_s
214
+ to_hash.to_s
215
+ end
216
+
217
+ # to_body is an alias to to_hash (backward compatibility)
218
+ # @return [Hash] Returns the object in the form of hash
219
+ def to_body
220
+ to_hash
221
+ end
222
+
223
+ # Returns the object in the form of hash
224
+ # @return [Hash] Returns the object in the form of hash
225
+ def to_hash
226
+ hash = {}
227
+ self.class.attribute_map.each_pair do |attr, param|
228
+ value = self.send(attr)
229
+ if value.nil?
230
+ is_nullable = self.class.openapi_nullable.include?(attr)
231
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
232
+ end
233
+
234
+ hash[param] = _to_hash(value)
235
+ end
236
+ hash
237
+ end
238
+
239
+ # Outputs non-array value in the form of hash
240
+ # For object, use to_hash. Otherwise, just return the value
241
+ # @param [Object] value Any valid value
242
+ # @return [Hash] Returns the value in the form of hash
243
+ def _to_hash(value)
244
+ if value.is_a?(Array)
245
+ value.compact.map { |v| _to_hash(v) }
246
+ elsif value.is_a?(Hash)
247
+ {}.tap do |hash|
248
+ value.each { |k, v| hash[k] = _to_hash(v) }
249
+ end
250
+ elsif value.respond_to? :to_hash
251
+ value.to_hash
252
+ else
253
+ value
254
+ end
255
+ end
256
+
257
+ end
258
+
259
+ end