daytona_api_client 0.134.0.alpha.1 → 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 (77) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +9 -0
  3. data/Gemfile.lock +101 -0
  4. data/daytona_api_client.gemspec +2 -2
  5. data/lib/daytona_api_client/api/audit_api.rb +66 -18
  6. data/lib/daytona_api_client/api/docker_registry_api.rb +0 -3
  7. data/lib/daytona_api_client/api/organizations_api.rb +29 -754
  8. data/lib/daytona_api_client/api/preview_api.rb +5 -74
  9. data/lib/daytona_api_client/api/runners_api.rb +20 -343
  10. data/lib/daytona_api_client/api/sandbox_api.rb +194 -558
  11. data/lib/daytona_api_client/api/snapshots_api.rb +0 -66
  12. data/lib/daytona_api_client/api/toolbox_api.rb +711 -711
  13. data/lib/daytona_api_client/api/workspace_api.rb +3 -3
  14. data/lib/daytona_api_client/models/build_info.rb +4 -31
  15. data/lib/daytona_api_client/models/{job.rb → create_audit_log.rb} +79 -166
  16. data/lib/daytona_api_client/models/create_organization.rb +4 -31
  17. data/lib/daytona_api_client/models/create_runner.rb +315 -31
  18. data/lib/daytona_api_client/models/create_sandbox.rb +1 -11
  19. data/lib/daytona_api_client/models/create_snapshot.rb +4 -14
  20. data/lib/daytona_api_client/models/create_user.rb +1 -10
  21. data/lib/daytona_api_client/models/daytona_configuration.rb +4 -41
  22. data/lib/daytona_api_client/models/organization.rb +85 -53
  23. data/lib/daytona_api_client/models/organization_usage_overview.rb +146 -18
  24. data/lib/daytona_api_client/models/paginated_audit_logs.rb +4 -14
  25. data/lib/daytona_api_client/models/{paginated_jobs.rb → paginated_snapshots_dto.rb} +4 -4
  26. data/lib/daytona_api_client/models/port_preview_url.rb +14 -31
  27. data/lib/daytona_api_client/models/region.rb +4 -178
  28. data/lib/daytona_api_client/models/runner.rb +117 -79
  29. data/lib/daytona_api_client/models/runner_snapshot_dto.rb +17 -0
  30. data/lib/daytona_api_client/models/sandbox.rb +14 -51
  31. data/lib/daytona_api_client/models/sandbox_volume.rb +4 -14
  32. data/lib/daytona_api_client/models/snapshot_dto.rb +4 -36
  33. data/lib/daytona_api_client/models/snapshot_state.rb +4 -1
  34. data/lib/daytona_api_client/models/ssh_access_dto.rb +4 -31
  35. data/lib/daytona_api_client/models/ssh_access_validation_dto.rb +24 -4
  36. data/lib/daytona_api_client/models/update_organization_quota.rb +41 -41
  37. data/lib/daytona_api_client/models/update_sandbox_state_dto.rb +4 -24
  38. data/lib/daytona_api_client/models/workspace.rb +35 -45
  39. data/lib/daytona_api_client/version.rb +1 -1
  40. data/lib/daytona_api_client.rb +1 -30
  41. data/project.json +6 -34
  42. metadata +5 -38
  43. data/.gitignore +0 -39
  44. data/.openapi-generator/FILES +0 -194
  45. data/.openapi-generator/VERSION +0 -1
  46. data/.openapi-generator-ignore +0 -31
  47. data/.rspec +0 -2
  48. data/.rubocop.yml +0 -148
  49. data/fix-gemspec.sh +0 -11
  50. data/lib/daytona_api_client/api/admin_api.rb +0 -325
  51. data/lib/daytona_api_client/api/jobs_api.rb +0 -299
  52. data/lib/daytona_api_client/api/regions_api.rb +0 -77
  53. data/lib/daytona_api_client/models/admin_create_runner.rb +0 -385
  54. data/lib/daytona_api_client/models/create_region.rb +0 -269
  55. data/lib/daytona_api_client/models/create_region_response.rb +0 -280
  56. data/lib/daytona_api_client/models/create_runner_response.rb +0 -263
  57. data/lib/daytona_api_client/models/job_status.rb +0 -42
  58. data/lib/daytona_api_client/models/job_type.rb +0 -49
  59. data/lib/daytona_api_client/models/poll_jobs_response.rb +0 -238
  60. data/lib/daytona_api_client/models/rate_limit_config.rb +0 -249
  61. data/lib/daytona_api_client/models/rate_limit_entry.rb +0 -229
  62. data/lib/daytona_api_client/models/regenerate_api_key_response.rb +0 -236
  63. data/lib/daytona_api_client/models/region_quota.rb +0 -339
  64. data/lib/daytona_api_client/models/region_type.rb +0 -41
  65. data/lib/daytona_api_client/models/region_usage_overview.rb +0 -391
  66. data/lib/daytona_api_client/models/runner_full.rb +0 -779
  67. data/lib/daytona_api_client/models/runner_health_metrics.rb +0 -533
  68. data/lib/daytona_api_client/models/runner_healthcheck.rb +0 -276
  69. data/lib/daytona_api_client/models/signed_port_preview_url.rb +0 -317
  70. data/lib/daytona_api_client/models/snapshot_manager_credentials.rb +0 -263
  71. data/lib/daytona_api_client/models/toolbox_proxy_url.rb +0 -236
  72. data/lib/daytona_api_client/models/update_job_status.rb +0 -278
  73. data/lib/daytona_api_client/models/update_organization_default_region.rb +0 -236
  74. data/lib/daytona_api_client/models/update_organization_region_quota.rb +0 -245
  75. data/lib/daytona_api_client/models/update_region.rb +0 -242
  76. data/lib/daytona_api_client/models/url.rb +0 -236
  77. data/lib/daytona_api_client/models/workspace_port_preview_url.rb +0 -263
@@ -1,385 +0,0 @@
1
- =begin
2
- #Daytona
3
-
4
- #Daytona AI platform API Docs
5
-
6
- The version of the OpenAPI document: 1.0
7
- Contact: support@daytona.com
8
- Generated by: https://openapi-generator.tech
9
- Generator version: 7.12.0
10
-
11
- =end
12
-
13
- require 'date'
14
- require 'time'
15
-
16
- module DaytonaApiClient
17
- class AdminCreateRunner
18
- attr_accessor :region_id
19
-
20
- attr_accessor :name
21
-
22
- attr_accessor :api_key
23
-
24
- # The api version of the runner to create
25
- attr_accessor :api_version
26
-
27
- # The domain of the runner
28
- attr_accessor :domain
29
-
30
- # The API URL of the runner
31
- attr_accessor :api_url
32
-
33
- # The proxy URL of the runner
34
- attr_accessor :proxy_url
35
-
36
- # The CPU capacity of the runner
37
- attr_accessor :cpu
38
-
39
- # The memory capacity of the runner in GiB
40
- attr_accessor :memory_gi_b
41
-
42
- # The disk capacity of the runner in GiB
43
- attr_accessor :disk_gi_b
44
-
45
- # Attribute mapping from ruby-style variable name to JSON key.
46
- def self.attribute_map
47
- {
48
- :'region_id' => :'regionId',
49
- :'name' => :'name',
50
- :'api_key' => :'apiKey',
51
- :'api_version' => :'apiVersion',
52
- :'domain' => :'domain',
53
- :'api_url' => :'apiUrl',
54
- :'proxy_url' => :'proxyUrl',
55
- :'cpu' => :'cpu',
56
- :'memory_gi_b' => :'memoryGiB',
57
- :'disk_gi_b' => :'diskGiB'
58
- }
59
- end
60
-
61
- # Returns attribute mapping this model knows about
62
- def self.acceptable_attribute_map
63
- attribute_map
64
- end
65
-
66
- # Returns all the JSON keys this model knows about
67
- def self.acceptable_attributes
68
- acceptable_attribute_map.values
69
- end
70
-
71
- # Attribute type mapping.
72
- def self.openapi_types
73
- {
74
- :'region_id' => :'String',
75
- :'name' => :'String',
76
- :'api_key' => :'String',
77
- :'api_version' => :'String',
78
- :'domain' => :'String',
79
- :'api_url' => :'String',
80
- :'proxy_url' => :'String',
81
- :'cpu' => :'Float',
82
- :'memory_gi_b' => :'Float',
83
- :'disk_gi_b' => :'Float'
84
- }
85
- end
86
-
87
- # List of attributes with nullable: true
88
- def self.openapi_nullable
89
- Set.new([
90
- ])
91
- end
92
-
93
- # Initializes the object
94
- # @param [Hash] attributes Model attributes in the form of hash
95
- def initialize(attributes = {})
96
- if (!attributes.is_a?(Hash))
97
- fail ArgumentError, "The input argument (attributes) must be a hash in `DaytonaApiClient::AdminCreateRunner` initialize method"
98
- end
99
-
100
- # check to see if the attribute exists and convert string to symbol for hash key
101
- acceptable_attribute_map = self.class.acceptable_attribute_map
102
- attributes = attributes.each_with_object({}) { |(k, v), h|
103
- if (!acceptable_attribute_map.key?(k.to_sym))
104
- fail ArgumentError, "`#{k}` is not a valid attribute in `DaytonaApiClient::AdminCreateRunner`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
105
- end
106
- h[k.to_sym] = v
107
- }
108
-
109
- if attributes.key?(:'region_id')
110
- self.region_id = attributes[:'region_id']
111
- else
112
- self.region_id = nil
113
- end
114
-
115
- if attributes.key?(:'name')
116
- self.name = attributes[:'name']
117
- else
118
- self.name = nil
119
- end
120
-
121
- if attributes.key?(:'api_key')
122
- self.api_key = attributes[:'api_key']
123
- else
124
- self.api_key = nil
125
- end
126
-
127
- if attributes.key?(:'api_version')
128
- self.api_version = attributes[:'api_version']
129
- else
130
- self.api_version = nil
131
- end
132
-
133
- if attributes.key?(:'domain')
134
- self.domain = attributes[:'domain']
135
- end
136
-
137
- if attributes.key?(:'api_url')
138
- self.api_url = attributes[:'api_url']
139
- end
140
-
141
- if attributes.key?(:'proxy_url')
142
- self.proxy_url = attributes[:'proxy_url']
143
- end
144
-
145
- if attributes.key?(:'cpu')
146
- self.cpu = attributes[:'cpu']
147
- end
148
-
149
- if attributes.key?(:'memory_gi_b')
150
- self.memory_gi_b = attributes[:'memory_gi_b']
151
- end
152
-
153
- if attributes.key?(:'disk_gi_b')
154
- self.disk_gi_b = attributes[:'disk_gi_b']
155
- end
156
- end
157
-
158
- # Show invalid properties with the reasons. Usually used together with valid?
159
- # @return Array for valid properties with the reasons
160
- def list_invalid_properties
161
- warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
162
- invalid_properties = Array.new
163
- if @region_id.nil?
164
- invalid_properties.push('invalid value for "region_id", region_id cannot be nil.')
165
- end
166
-
167
- if @name.nil?
168
- invalid_properties.push('invalid value for "name", name cannot be nil.')
169
- end
170
-
171
- if @api_key.nil?
172
- invalid_properties.push('invalid value for "api_key", api_key cannot be nil.')
173
- end
174
-
175
- if @api_version.nil?
176
- invalid_properties.push('invalid value for "api_version", api_version cannot be nil.')
177
- end
178
-
179
- pattern = Regexp.new(/^(0|2)$/)
180
- if @api_version !~ pattern
181
- invalid_properties.push("invalid value for \"api_version\", must conform to the pattern #{pattern}.")
182
- end
183
-
184
- invalid_properties
185
- end
186
-
187
- # Check to see if the all the properties in the model are valid
188
- # @return true if the model is valid
189
- def valid?
190
- warn '[DEPRECATED] the `valid?` method is obsolete'
191
- return false if @region_id.nil?
192
- return false if @name.nil?
193
- return false if @api_key.nil?
194
- return false if @api_version.nil?
195
- return false if @api_version !~ Regexp.new(/^(0|2)$/)
196
- true
197
- end
198
-
199
- # Custom attribute writer method with validation
200
- # @param [Object] region_id Value to be assigned
201
- def region_id=(region_id)
202
- if region_id.nil?
203
- fail ArgumentError, 'region_id cannot be nil'
204
- end
205
-
206
- @region_id = region_id
207
- end
208
-
209
- # Custom attribute writer method with validation
210
- # @param [Object] name Value to be assigned
211
- def name=(name)
212
- if name.nil?
213
- fail ArgumentError, 'name cannot be nil'
214
- end
215
-
216
- @name = name
217
- end
218
-
219
- # Custom attribute writer method with validation
220
- # @param [Object] api_key Value to be assigned
221
- def api_key=(api_key)
222
- if api_key.nil?
223
- fail ArgumentError, 'api_key cannot be nil'
224
- end
225
-
226
- @api_key = api_key
227
- end
228
-
229
- # Custom attribute writer method with validation
230
- # @param [Object] api_version Value to be assigned
231
- def api_version=(api_version)
232
- if api_version.nil?
233
- fail ArgumentError, 'api_version cannot be nil'
234
- end
235
-
236
- pattern = Regexp.new(/^(0|2)$/)
237
- if api_version !~ pattern
238
- fail ArgumentError, "invalid value for \"api_version\", must conform to the pattern #{pattern}."
239
- end
240
-
241
- @api_version = api_version
242
- end
243
-
244
- # Checks equality by comparing each attribute.
245
- # @param [Object] Object to be compared
246
- def ==(o)
247
- return true if self.equal?(o)
248
- self.class == o.class &&
249
- region_id == o.region_id &&
250
- name == o.name &&
251
- api_key == o.api_key &&
252
- api_version == o.api_version &&
253
- domain == o.domain &&
254
- api_url == o.api_url &&
255
- proxy_url == o.proxy_url &&
256
- cpu == o.cpu &&
257
- memory_gi_b == o.memory_gi_b &&
258
- disk_gi_b == o.disk_gi_b
259
- end
260
-
261
- # @see the `==` method
262
- # @param [Object] Object to be compared
263
- def eql?(o)
264
- self == o
265
- end
266
-
267
- # Calculates hash code according to all attributes.
268
- # @return [Integer] Hash code
269
- def hash
270
- [region_id, name, api_key, api_version, domain, api_url, proxy_url, cpu, memory_gi_b, disk_gi_b].hash
271
- end
272
-
273
- # Builds the object from hash
274
- # @param [Hash] attributes Model attributes in the form of hash
275
- # @return [Object] Returns the model itself
276
- def self.build_from_hash(attributes)
277
- return nil unless attributes.is_a?(Hash)
278
- attributes = attributes.transform_keys(&:to_sym)
279
- transformed_hash = {}
280
- openapi_types.each_pair do |key, type|
281
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
282
- transformed_hash["#{key}"] = nil
283
- elsif type =~ /\AArray<(.*)>/i
284
- # check to ensure the input is an array given that the attribute
285
- # is documented as an array but the input is not
286
- if attributes[attribute_map[key]].is_a?(Array)
287
- transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
288
- end
289
- elsif !attributes[attribute_map[key]].nil?
290
- transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
291
- end
292
- end
293
- new(transformed_hash)
294
- end
295
-
296
- # Deserializes the data based on type
297
- # @param string type Data type
298
- # @param string value Value to be deserialized
299
- # @return [Object] Deserialized data
300
- def self._deserialize(type, value)
301
- case type.to_sym
302
- when :Time
303
- Time.parse(value)
304
- when :Date
305
- Date.parse(value)
306
- when :String
307
- value.to_s
308
- when :Integer
309
- value.to_i
310
- when :Float
311
- value.to_f
312
- when :Boolean
313
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
314
- true
315
- else
316
- false
317
- end
318
- when :Object
319
- # generic object (usually a Hash), return directly
320
- value
321
- when /\AArray<(?<inner_type>.+)>\z/
322
- inner_type = Regexp.last_match[:inner_type]
323
- value.map { |v| _deserialize(inner_type, v) }
324
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
325
- k_type = Regexp.last_match[:k_type]
326
- v_type = Regexp.last_match[:v_type]
327
- {}.tap do |hash|
328
- value.each do |k, v|
329
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
330
- end
331
- end
332
- else # model
333
- # models (e.g. Pet) or oneOf
334
- klass = DaytonaApiClient.const_get(type)
335
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
336
- end
337
- end
338
-
339
- # Returns the string representation of the object
340
- # @return [String] String presentation of the object
341
- def to_s
342
- to_hash.to_s
343
- end
344
-
345
- # to_body is an alias to to_hash (backward compatibility)
346
- # @return [Hash] Returns the object in the form of hash
347
- def to_body
348
- to_hash
349
- end
350
-
351
- # Returns the object in the form of hash
352
- # @return [Hash] Returns the object in the form of hash
353
- def to_hash
354
- hash = {}
355
- self.class.attribute_map.each_pair do |attr, param|
356
- value = self.send(attr)
357
- if value.nil?
358
- is_nullable = self.class.openapi_nullable.include?(attr)
359
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
360
- end
361
-
362
- hash[param] = _to_hash(value)
363
- end
364
- hash
365
- end
366
-
367
- # Outputs non-array value in the form of hash
368
- # For object, use to_hash. Otherwise, just return the value
369
- # @param [Object] value Any valid value
370
- # @return [Hash] Returns the value in the form of hash
371
- def _to_hash(value)
372
- if value.is_a?(Array)
373
- value.compact.map { |v| _to_hash(v) }
374
- elsif value.is_a?(Hash)
375
- {}.tap do |hash|
376
- value.each { |k, v| hash[k] = _to_hash(v) }
377
- end
378
- elsif value.respond_to? :to_hash
379
- value.to_hash
380
- else
381
- value
382
- end
383
- end
384
- end
385
- end
@@ -1,269 +0,0 @@
1
- =begin
2
- #Daytona
3
-
4
- #Daytona AI platform API Docs
5
-
6
- The version of the OpenAPI document: 1.0
7
- Contact: support@daytona.com
8
- Generated by: https://openapi-generator.tech
9
- Generator version: 7.12.0
10
-
11
- =end
12
-
13
- require 'date'
14
- require 'time'
15
-
16
- module DaytonaApiClient
17
- class CreateRegion
18
- # Region name
19
- attr_accessor :name
20
-
21
- # Proxy URL for the region
22
- attr_accessor :proxy_url
23
-
24
- # SSH Gateway URL for the region
25
- attr_accessor :ssh_gateway_url
26
-
27
- # Snapshot Manager URL for the region
28
- attr_accessor :snapshot_manager_url
29
-
30
- # Attribute mapping from ruby-style variable name to JSON key.
31
- def self.attribute_map
32
- {
33
- :'name' => :'name',
34
- :'proxy_url' => :'proxyUrl',
35
- :'ssh_gateway_url' => :'sshGatewayUrl',
36
- :'snapshot_manager_url' => :'snapshotManagerUrl'
37
- }
38
- end
39
-
40
- # Returns attribute mapping this model knows about
41
- def self.acceptable_attribute_map
42
- attribute_map
43
- end
44
-
45
- # Returns all the JSON keys this model knows about
46
- def self.acceptable_attributes
47
- acceptable_attribute_map.values
48
- end
49
-
50
- # Attribute type mapping.
51
- def self.openapi_types
52
- {
53
- :'name' => :'String',
54
- :'proxy_url' => :'String',
55
- :'ssh_gateway_url' => :'String',
56
- :'snapshot_manager_url' => :'String'
57
- }
58
- end
59
-
60
- # List of attributes with nullable: true
61
- def self.openapi_nullable
62
- Set.new([
63
- :'proxy_url',
64
- :'ssh_gateway_url',
65
- :'snapshot_manager_url'
66
- ])
67
- end
68
-
69
- # Initializes the object
70
- # @param [Hash] attributes Model attributes in the form of hash
71
- def initialize(attributes = {})
72
- if (!attributes.is_a?(Hash))
73
- fail ArgumentError, "The input argument (attributes) must be a hash in `DaytonaApiClient::CreateRegion` initialize method"
74
- end
75
-
76
- # check to see if the attribute exists and convert string to symbol for hash key
77
- acceptable_attribute_map = self.class.acceptable_attribute_map
78
- attributes = attributes.each_with_object({}) { |(k, v), h|
79
- if (!acceptable_attribute_map.key?(k.to_sym))
80
- fail ArgumentError, "`#{k}` is not a valid attribute in `DaytonaApiClient::CreateRegion`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
81
- end
82
- h[k.to_sym] = v
83
- }
84
-
85
- if attributes.key?(:'name')
86
- self.name = attributes[:'name']
87
- else
88
- self.name = nil
89
- end
90
-
91
- if attributes.key?(:'proxy_url')
92
- self.proxy_url = attributes[:'proxy_url']
93
- end
94
-
95
- if attributes.key?(:'ssh_gateway_url')
96
- self.ssh_gateway_url = attributes[:'ssh_gateway_url']
97
- end
98
-
99
- if attributes.key?(:'snapshot_manager_url')
100
- self.snapshot_manager_url = attributes[:'snapshot_manager_url']
101
- end
102
- end
103
-
104
- # Show invalid properties with the reasons. Usually used together with valid?
105
- # @return Array for valid properties with the reasons
106
- def list_invalid_properties
107
- warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
108
- invalid_properties = Array.new
109
- if @name.nil?
110
- invalid_properties.push('invalid value for "name", name cannot be nil.')
111
- end
112
-
113
- invalid_properties
114
- end
115
-
116
- # Check to see if the all the properties in the model are valid
117
- # @return true if the model is valid
118
- def valid?
119
- warn '[DEPRECATED] the `valid?` method is obsolete'
120
- return false if @name.nil?
121
- true
122
- end
123
-
124
- # Custom attribute writer method with validation
125
- # @param [Object] name Value to be assigned
126
- def name=(name)
127
- if name.nil?
128
- fail ArgumentError, 'name cannot be nil'
129
- end
130
-
131
- @name = name
132
- end
133
-
134
- # Checks equality by comparing each attribute.
135
- # @param [Object] Object to be compared
136
- def ==(o)
137
- return true if self.equal?(o)
138
- self.class == o.class &&
139
- name == o.name &&
140
- proxy_url == o.proxy_url &&
141
- ssh_gateway_url == o.ssh_gateway_url &&
142
- snapshot_manager_url == o.snapshot_manager_url
143
- end
144
-
145
- # @see the `==` method
146
- # @param [Object] Object to be compared
147
- def eql?(o)
148
- self == o
149
- end
150
-
151
- # Calculates hash code according to all attributes.
152
- # @return [Integer] Hash code
153
- def hash
154
- [name, proxy_url, ssh_gateway_url, snapshot_manager_url].hash
155
- end
156
-
157
- # Builds the object from hash
158
- # @param [Hash] attributes Model attributes in the form of hash
159
- # @return [Object] Returns the model itself
160
- def self.build_from_hash(attributes)
161
- return nil unless attributes.is_a?(Hash)
162
- attributes = attributes.transform_keys(&:to_sym)
163
- transformed_hash = {}
164
- openapi_types.each_pair do |key, type|
165
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
166
- transformed_hash["#{key}"] = nil
167
- elsif type =~ /\AArray<(.*)>/i
168
- # check to ensure the input is an array given that the attribute
169
- # is documented as an array but the input is not
170
- if attributes[attribute_map[key]].is_a?(Array)
171
- transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
172
- end
173
- elsif !attributes[attribute_map[key]].nil?
174
- transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
175
- end
176
- end
177
- new(transformed_hash)
178
- end
179
-
180
- # Deserializes the data based on type
181
- # @param string type Data type
182
- # @param string value Value to be deserialized
183
- # @return [Object] Deserialized data
184
- def self._deserialize(type, value)
185
- case type.to_sym
186
- when :Time
187
- Time.parse(value)
188
- when :Date
189
- Date.parse(value)
190
- when :String
191
- value.to_s
192
- when :Integer
193
- value.to_i
194
- when :Float
195
- value.to_f
196
- when :Boolean
197
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
198
- true
199
- else
200
- false
201
- end
202
- when :Object
203
- # generic object (usually a Hash), return directly
204
- value
205
- when /\AArray<(?<inner_type>.+)>\z/
206
- inner_type = Regexp.last_match[:inner_type]
207
- value.map { |v| _deserialize(inner_type, v) }
208
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
209
- k_type = Regexp.last_match[:k_type]
210
- v_type = Regexp.last_match[:v_type]
211
- {}.tap do |hash|
212
- value.each do |k, v|
213
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
214
- end
215
- end
216
- else # model
217
- # models (e.g. Pet) or oneOf
218
- klass = DaytonaApiClient.const_get(type)
219
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
220
- end
221
- end
222
-
223
- # Returns the string representation of the object
224
- # @return [String] String presentation of the object
225
- def to_s
226
- to_hash.to_s
227
- end
228
-
229
- # to_body is an alias to to_hash (backward compatibility)
230
- # @return [Hash] Returns the object in the form of hash
231
- def to_body
232
- to_hash
233
- end
234
-
235
- # Returns the object in the form of hash
236
- # @return [Hash] Returns the object in the form of hash
237
- def to_hash
238
- hash = {}
239
- self.class.attribute_map.each_pair do |attr, param|
240
- value = self.send(attr)
241
- if value.nil?
242
- is_nullable = self.class.openapi_nullable.include?(attr)
243
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
244
- end
245
-
246
- hash[param] = _to_hash(value)
247
- end
248
- hash
249
- end
250
-
251
- # Outputs non-array value in the form of hash
252
- # For object, use to_hash. Otherwise, just return the value
253
- # @param [Object] value Any valid value
254
- # @return [Hash] Returns the value in the form of hash
255
- def _to_hash(value)
256
- if value.is_a?(Array)
257
- value.compact.map { |v| _to_hash(v) }
258
- elsif value.is_a?(Hash)
259
- {}.tap do |hash|
260
- value.each { |k, v| hash[k] = _to_hash(v) }
261
- end
262
- elsif value.respond_to? :to_hash
263
- value.to_hash
264
- else
265
- value
266
- end
267
- end
268
- end
269
- end