daytona_api_client 0.126.0.pre.alpha.4 → 0.134.0.alpha.1

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 (51) hide show
  1. checksums.yaml +4 -4
  2. data/.openapi-generator/FILES +23 -0
  3. data/.openapi-generator-ignore +0 -2
  4. data/daytona_api_client.gemspec +1 -1
  5. data/fix-gemspec.sh +1 -1
  6. data/lib/daytona_api_client/api/admin_api.rb +325 -0
  7. data/lib/daytona_api_client/api/docker_registry_api.rb +3 -0
  8. data/lib/daytona_api_client/api/jobs_api.rb +299 -0
  9. data/lib/daytona_api_client/api/organizations_api.rb +518 -0
  10. data/lib/daytona_api_client/api/preview_api.rb +67 -0
  11. data/lib/daytona_api_client/api/regions_api.rb +9 -15
  12. data/lib/daytona_api_client/api/runners_api.rb +291 -23
  13. data/lib/daytona_api_client/api/sandbox_api.rb +277 -0
  14. data/lib/daytona_api_client/api/snapshots_api.rb +66 -0
  15. data/lib/daytona_api_client/models/admin_create_runner.rb +385 -0
  16. data/lib/daytona_api_client/models/build_info.rb +31 -4
  17. data/lib/daytona_api_client/models/create_region.rb +269 -0
  18. data/lib/daytona_api_client/models/create_region_response.rb +280 -0
  19. data/lib/daytona_api_client/models/create_runner.rb +31 -315
  20. data/lib/daytona_api_client/models/create_runner_response.rb +263 -0
  21. data/lib/daytona_api_client/models/create_snapshot.rb +14 -4
  22. data/lib/daytona_api_client/models/{create_audit_log.rb → job.rb} +166 -79
  23. data/lib/daytona_api_client/models/job_status.rb +42 -0
  24. data/lib/daytona_api_client/models/job_type.rb +49 -0
  25. data/lib/daytona_api_client/models/{paginated_snapshots_dto.rb → paginated_jobs.rb} +4 -4
  26. data/lib/daytona_api_client/models/poll_jobs_response.rb +238 -0
  27. data/lib/daytona_api_client/models/regenerate_api_key_response.rb +236 -0
  28. data/lib/daytona_api_client/models/region.rb +86 -4
  29. data/lib/daytona_api_client/models/region_type.rb +41 -0
  30. data/lib/daytona_api_client/models/runner.rb +79 -117
  31. data/lib/daytona_api_client/models/runner_full.rb +779 -0
  32. data/lib/daytona_api_client/models/runner_health_metrics.rb +533 -0
  33. data/lib/daytona_api_client/models/runner_healthcheck.rb +276 -0
  34. data/lib/daytona_api_client/models/runner_snapshot_dto.rb +0 -17
  35. data/lib/daytona_api_client/models/sandbox.rb +14 -4
  36. data/lib/daytona_api_client/models/signed_port_preview_url.rb +317 -0
  37. data/lib/daytona_api_client/models/snapshot_dto.rb +36 -4
  38. data/lib/daytona_api_client/models/snapshot_manager_credentials.rb +263 -0
  39. data/lib/daytona_api_client/models/ssh_access_dto.rb +31 -4
  40. data/lib/daytona_api_client/models/toolbox_proxy_url.rb +236 -0
  41. data/lib/daytona_api_client/models/update_job_status.rb +278 -0
  42. data/lib/daytona_api_client/models/update_region.rb +242 -0
  43. data/lib/daytona_api_client/models/update_sandbox_state_dto.rb +14 -4
  44. data/lib/daytona_api_client/models/url.rb +236 -0
  45. data/lib/daytona_api_client/models/workspace.rb +11 -1
  46. data/lib/daytona_api_client/version.rb +1 -1
  47. data/lib/daytona_api_client.rb +22 -0
  48. data/project.json +10 -4
  49. metadata +23 -5
  50. data/Gemfile +0 -9
  51. data/Gemfile.lock +0 -101
@@ -50,6 +50,15 @@ module DaytonaApiClient
50
50
  # Build information for the snapshot
51
51
  attr_accessor :build_info
52
52
 
53
+ # IDs of regions where the snapshot is available
54
+ attr_accessor :region_ids
55
+
56
+ # The initial runner ID of the snapshot
57
+ attr_accessor :initial_runner_id
58
+
59
+ # The snapshot reference
60
+ attr_accessor :ref
61
+
53
62
  class EnumAttributeValidator
54
63
  attr_reader :datatype
55
64
  attr_reader :allowable_values
@@ -91,7 +100,10 @@ module DaytonaApiClient
91
100
  :'created_at' => :'createdAt',
92
101
  :'updated_at' => :'updatedAt',
93
102
  :'last_used_at' => :'lastUsedAt',
94
- :'build_info' => :'buildInfo'
103
+ :'build_info' => :'buildInfo',
104
+ :'region_ids' => :'regionIds',
105
+ :'initial_runner_id' => :'initialRunnerId',
106
+ :'ref' => :'ref'
95
107
  }
96
108
  end
97
109
 
@@ -124,7 +136,10 @@ module DaytonaApiClient
124
136
  :'created_at' => :'Time',
125
137
  :'updated_at' => :'Time',
126
138
  :'last_used_at' => :'Time',
127
- :'build_info' => :'BuildInfo'
139
+ :'build_info' => :'BuildInfo',
140
+ :'region_ids' => :'Array<String>',
141
+ :'initial_runner_id' => :'String',
142
+ :'ref' => :'String'
128
143
  }
129
144
  end
130
145
 
@@ -251,6 +266,20 @@ module DaytonaApiClient
251
266
  if attributes.key?(:'build_info')
252
267
  self.build_info = attributes[:'build_info']
253
268
  end
269
+
270
+ if attributes.key?(:'region_ids')
271
+ if (value = attributes[:'region_ids']).is_a?(Array)
272
+ self.region_ids = value
273
+ end
274
+ end
275
+
276
+ if attributes.key?(:'initial_runner_id')
277
+ self.initial_runner_id = attributes[:'initial_runner_id']
278
+ end
279
+
280
+ if attributes.key?(:'ref')
281
+ self.ref = attributes[:'ref']
282
+ end
254
283
  end
255
284
 
256
285
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -439,7 +468,10 @@ module DaytonaApiClient
439
468
  created_at == o.created_at &&
440
469
  updated_at == o.updated_at &&
441
470
  last_used_at == o.last_used_at &&
442
- build_info == o.build_info
471
+ build_info == o.build_info &&
472
+ region_ids == o.region_ids &&
473
+ initial_runner_id == o.initial_runner_id &&
474
+ ref == o.ref
443
475
  end
444
476
 
445
477
  # @see the `==` method
@@ -451,7 +483,7 @@ module DaytonaApiClient
451
483
  # Calculates hash code according to all attributes.
452
484
  # @return [Integer] Hash code
453
485
  def hash
454
- [id, organization_id, general, name, image_name, state, size, entrypoint, cpu, gpu, mem, disk, error_reason, created_at, updated_at, last_used_at, build_info].hash
486
+ [id, organization_id, general, name, image_name, state, size, entrypoint, cpu, gpu, mem, disk, error_reason, created_at, updated_at, last_used_at, build_info, region_ids, initial_runner_id, ref].hash
455
487
  end
456
488
 
457
489
  # Builds the object from hash
@@ -0,0 +1,263 @@
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 SnapshotManagerCredentials
18
+ # Snapshot Manager username for the region
19
+ attr_accessor :username
20
+
21
+ # Snapshot Manager password for the region
22
+ attr_accessor :password
23
+
24
+ # Attribute mapping from ruby-style variable name to JSON key.
25
+ def self.attribute_map
26
+ {
27
+ :'username' => :'username',
28
+ :'password' => :'password'
29
+ }
30
+ end
31
+
32
+ # Returns attribute mapping this model knows about
33
+ def self.acceptable_attribute_map
34
+ attribute_map
35
+ end
36
+
37
+ # Returns all the JSON keys this model knows about
38
+ def self.acceptable_attributes
39
+ acceptable_attribute_map.values
40
+ end
41
+
42
+ # Attribute type mapping.
43
+ def self.openapi_types
44
+ {
45
+ :'username' => :'String',
46
+ :'password' => :'String'
47
+ }
48
+ end
49
+
50
+ # List of attributes with nullable: true
51
+ def self.openapi_nullable
52
+ Set.new([
53
+ ])
54
+ end
55
+
56
+ # Initializes the object
57
+ # @param [Hash] attributes Model attributes in the form of hash
58
+ def initialize(attributes = {})
59
+ if (!attributes.is_a?(Hash))
60
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DaytonaApiClient::SnapshotManagerCredentials` initialize method"
61
+ end
62
+
63
+ # check to see if the attribute exists and convert string to symbol for hash key
64
+ acceptable_attribute_map = self.class.acceptable_attribute_map
65
+ attributes = attributes.each_with_object({}) { |(k, v), h|
66
+ if (!acceptable_attribute_map.key?(k.to_sym))
67
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DaytonaApiClient::SnapshotManagerCredentials`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
68
+ end
69
+ h[k.to_sym] = v
70
+ }
71
+
72
+ if attributes.key?(:'username')
73
+ self.username = attributes[:'username']
74
+ else
75
+ self.username = nil
76
+ end
77
+
78
+ if attributes.key?(:'password')
79
+ self.password = attributes[:'password']
80
+ else
81
+ self.password = nil
82
+ end
83
+ end
84
+
85
+ # Show invalid properties with the reasons. Usually used together with valid?
86
+ # @return Array for valid properties with the reasons
87
+ def list_invalid_properties
88
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
89
+ invalid_properties = Array.new
90
+ if @username.nil?
91
+ invalid_properties.push('invalid value for "username", username cannot be nil.')
92
+ end
93
+
94
+ if @password.nil?
95
+ invalid_properties.push('invalid value for "password", password cannot be nil.')
96
+ end
97
+
98
+ invalid_properties
99
+ end
100
+
101
+ # Check to see if the all the properties in the model are valid
102
+ # @return true if the model is valid
103
+ def valid?
104
+ warn '[DEPRECATED] the `valid?` method is obsolete'
105
+ return false if @username.nil?
106
+ return false if @password.nil?
107
+ true
108
+ end
109
+
110
+ # Custom attribute writer method with validation
111
+ # @param [Object] username Value to be assigned
112
+ def username=(username)
113
+ if username.nil?
114
+ fail ArgumentError, 'username cannot be nil'
115
+ end
116
+
117
+ @username = username
118
+ end
119
+
120
+ # Custom attribute writer method with validation
121
+ # @param [Object] password Value to be assigned
122
+ def password=(password)
123
+ if password.nil?
124
+ fail ArgumentError, 'password cannot be nil'
125
+ end
126
+
127
+ @password = password
128
+ end
129
+
130
+ # Checks equality by comparing each attribute.
131
+ # @param [Object] Object to be compared
132
+ def ==(o)
133
+ return true if self.equal?(o)
134
+ self.class == o.class &&
135
+ username == o.username &&
136
+ password == o.password
137
+ end
138
+
139
+ # @see the `==` method
140
+ # @param [Object] Object to be compared
141
+ def eql?(o)
142
+ self == o
143
+ end
144
+
145
+ # Calculates hash code according to all attributes.
146
+ # @return [Integer] Hash code
147
+ def hash
148
+ [username, password].hash
149
+ end
150
+
151
+ # Builds the object from hash
152
+ # @param [Hash] attributes Model attributes in the form of hash
153
+ # @return [Object] Returns the model itself
154
+ def self.build_from_hash(attributes)
155
+ return nil unless attributes.is_a?(Hash)
156
+ attributes = attributes.transform_keys(&:to_sym)
157
+ transformed_hash = {}
158
+ openapi_types.each_pair do |key, type|
159
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
160
+ transformed_hash["#{key}"] = nil
161
+ elsif type =~ /\AArray<(.*)>/i
162
+ # check to ensure the input is an array given that the attribute
163
+ # is documented as an array but the input is not
164
+ if attributes[attribute_map[key]].is_a?(Array)
165
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
166
+ end
167
+ elsif !attributes[attribute_map[key]].nil?
168
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
169
+ end
170
+ end
171
+ new(transformed_hash)
172
+ end
173
+
174
+ # Deserializes the data based on type
175
+ # @param string type Data type
176
+ # @param string value Value to be deserialized
177
+ # @return [Object] Deserialized data
178
+ def self._deserialize(type, value)
179
+ case type.to_sym
180
+ when :Time
181
+ Time.parse(value)
182
+ when :Date
183
+ Date.parse(value)
184
+ when :String
185
+ value.to_s
186
+ when :Integer
187
+ value.to_i
188
+ when :Float
189
+ value.to_f
190
+ when :Boolean
191
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
192
+ true
193
+ else
194
+ false
195
+ end
196
+ when :Object
197
+ # generic object (usually a Hash), return directly
198
+ value
199
+ when /\AArray<(?<inner_type>.+)>\z/
200
+ inner_type = Regexp.last_match[:inner_type]
201
+ value.map { |v| _deserialize(inner_type, v) }
202
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
203
+ k_type = Regexp.last_match[:k_type]
204
+ v_type = Regexp.last_match[:v_type]
205
+ {}.tap do |hash|
206
+ value.each do |k, v|
207
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
208
+ end
209
+ end
210
+ else # model
211
+ # models (e.g. Pet) or oneOf
212
+ klass = DaytonaApiClient.const_get(type)
213
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
214
+ end
215
+ end
216
+
217
+ # Returns the string representation of the object
218
+ # @return [String] String presentation of the object
219
+ def to_s
220
+ to_hash.to_s
221
+ end
222
+
223
+ # to_body is an alias to to_hash (backward compatibility)
224
+ # @return [Hash] Returns the object in the form of hash
225
+ def to_body
226
+ to_hash
227
+ end
228
+
229
+ # Returns the object in the form of hash
230
+ # @return [Hash] Returns the object in the form of hash
231
+ def to_hash
232
+ hash = {}
233
+ self.class.attribute_map.each_pair do |attr, param|
234
+ value = self.send(attr)
235
+ if value.nil?
236
+ is_nullable = self.class.openapi_nullable.include?(attr)
237
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
238
+ end
239
+
240
+ hash[param] = _to_hash(value)
241
+ end
242
+ hash
243
+ end
244
+
245
+ # Outputs non-array value in the form of hash
246
+ # For object, use to_hash. Otherwise, just return the value
247
+ # @param [Object] value Any valid value
248
+ # @return [Hash] Returns the value in the form of hash
249
+ def _to_hash(value)
250
+ if value.is_a?(Array)
251
+ value.compact.map { |v| _to_hash(v) }
252
+ elsif value.is_a?(Hash)
253
+ {}.tap do |hash|
254
+ value.each { |k, v| hash[k] = _to_hash(v) }
255
+ end
256
+ elsif value.respond_to? :to_hash
257
+ value.to_hash
258
+ else
259
+ value
260
+ end
261
+ end
262
+ end
263
+ end
@@ -33,6 +33,9 @@ module DaytonaApiClient
33
33
  # When the SSH access was last updated
34
34
  attr_accessor :updated_at
35
35
 
36
+ # SSH command to connect to the sandbox
37
+ attr_accessor :ssh_command
38
+
36
39
  # Attribute mapping from ruby-style variable name to JSON key.
37
40
  def self.attribute_map
38
41
  {
@@ -41,7 +44,8 @@ module DaytonaApiClient
41
44
  :'token' => :'token',
42
45
  :'expires_at' => :'expiresAt',
43
46
  :'created_at' => :'createdAt',
44
- :'updated_at' => :'updatedAt'
47
+ :'updated_at' => :'updatedAt',
48
+ :'ssh_command' => :'sshCommand'
45
49
  }
46
50
  end
47
51
 
@@ -63,7 +67,8 @@ module DaytonaApiClient
63
67
  :'token' => :'String',
64
68
  :'expires_at' => :'Time',
65
69
  :'created_at' => :'Time',
66
- :'updated_at' => :'Time'
70
+ :'updated_at' => :'Time',
71
+ :'ssh_command' => :'String'
67
72
  }
68
73
  end
69
74
 
@@ -124,6 +129,12 @@ module DaytonaApiClient
124
129
  else
125
130
  self.updated_at = nil
126
131
  end
132
+
133
+ if attributes.key?(:'ssh_command')
134
+ self.ssh_command = attributes[:'ssh_command']
135
+ else
136
+ self.ssh_command = nil
137
+ end
127
138
  end
128
139
 
129
140
  # Show invalid properties with the reasons. Usually used together with valid?
@@ -155,6 +166,10 @@ module DaytonaApiClient
155
166
  invalid_properties.push('invalid value for "updated_at", updated_at cannot be nil.')
156
167
  end
157
168
 
169
+ if @ssh_command.nil?
170
+ invalid_properties.push('invalid value for "ssh_command", ssh_command cannot be nil.')
171
+ end
172
+
158
173
  invalid_properties
159
174
  end
160
175
 
@@ -168,6 +183,7 @@ module DaytonaApiClient
168
183
  return false if @expires_at.nil?
169
184
  return false if @created_at.nil?
170
185
  return false if @updated_at.nil?
186
+ return false if @ssh_command.nil?
171
187
  true
172
188
  end
173
189
 
@@ -231,6 +247,16 @@ module DaytonaApiClient
231
247
  @updated_at = updated_at
232
248
  end
233
249
 
250
+ # Custom attribute writer method with validation
251
+ # @param [Object] ssh_command Value to be assigned
252
+ def ssh_command=(ssh_command)
253
+ if ssh_command.nil?
254
+ fail ArgumentError, 'ssh_command cannot be nil'
255
+ end
256
+
257
+ @ssh_command = ssh_command
258
+ end
259
+
234
260
  # Checks equality by comparing each attribute.
235
261
  # @param [Object] Object to be compared
236
262
  def ==(o)
@@ -241,7 +267,8 @@ module DaytonaApiClient
241
267
  token == o.token &&
242
268
  expires_at == o.expires_at &&
243
269
  created_at == o.created_at &&
244
- updated_at == o.updated_at
270
+ updated_at == o.updated_at &&
271
+ ssh_command == o.ssh_command
245
272
  end
246
273
 
247
274
  # @see the `==` method
@@ -253,7 +280,7 @@ module DaytonaApiClient
253
280
  # Calculates hash code according to all attributes.
254
281
  # @return [Integer] Hash code
255
282
  def hash
256
- [id, sandbox_id, token, expires_at, created_at, updated_at].hash
283
+ [id, sandbox_id, token, expires_at, created_at, updated_at, ssh_command].hash
257
284
  end
258
285
 
259
286
  # Builds the object from hash
@@ -0,0 +1,236 @@
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 ToolboxProxyUrl
18
+ # The toolbox proxy URL for the sandbox
19
+ attr_accessor :url
20
+
21
+ # Attribute mapping from ruby-style variable name to JSON key.
22
+ def self.attribute_map
23
+ {
24
+ :'url' => :'url'
25
+ }
26
+ end
27
+
28
+ # Returns attribute mapping this model knows about
29
+ def self.acceptable_attribute_map
30
+ attribute_map
31
+ end
32
+
33
+ # Returns all the JSON keys this model knows about
34
+ def self.acceptable_attributes
35
+ acceptable_attribute_map.values
36
+ end
37
+
38
+ # Attribute type mapping.
39
+ def self.openapi_types
40
+ {
41
+ :'url' => :'String'
42
+ }
43
+ end
44
+
45
+ # List of attributes with nullable: true
46
+ def self.openapi_nullable
47
+ Set.new([
48
+ ])
49
+ end
50
+
51
+ # Initializes the object
52
+ # @param [Hash] attributes Model attributes in the form of hash
53
+ def initialize(attributes = {})
54
+ if (!attributes.is_a?(Hash))
55
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DaytonaApiClient::ToolboxProxyUrl` initialize method"
56
+ end
57
+
58
+ # check to see if the attribute exists and convert string to symbol for hash key
59
+ acceptable_attribute_map = self.class.acceptable_attribute_map
60
+ attributes = attributes.each_with_object({}) { |(k, v), h|
61
+ if (!acceptable_attribute_map.key?(k.to_sym))
62
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DaytonaApiClient::ToolboxProxyUrl`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
63
+ end
64
+ h[k.to_sym] = v
65
+ }
66
+
67
+ if attributes.key?(:'url')
68
+ self.url = attributes[:'url']
69
+ else
70
+ self.url = nil
71
+ end
72
+ end
73
+
74
+ # Show invalid properties with the reasons. Usually used together with valid?
75
+ # @return Array for valid properties with the reasons
76
+ def list_invalid_properties
77
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
78
+ invalid_properties = Array.new
79
+ if @url.nil?
80
+ invalid_properties.push('invalid value for "url", url cannot be nil.')
81
+ end
82
+
83
+ invalid_properties
84
+ end
85
+
86
+ # Check to see if the all the properties in the model are valid
87
+ # @return true if the model is valid
88
+ def valid?
89
+ warn '[DEPRECATED] the `valid?` method is obsolete'
90
+ return false if @url.nil?
91
+ true
92
+ end
93
+
94
+ # Custom attribute writer method with validation
95
+ # @param [Object] url Value to be assigned
96
+ def url=(url)
97
+ if url.nil?
98
+ fail ArgumentError, 'url cannot be nil'
99
+ end
100
+
101
+ @url = url
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
+ url == o.url
110
+ end
111
+
112
+ # @see the `==` method
113
+ # @param [Object] Object to be compared
114
+ def eql?(o)
115
+ self == o
116
+ end
117
+
118
+ # Calculates hash code according to all attributes.
119
+ # @return [Integer] Hash code
120
+ def hash
121
+ [url].hash
122
+ end
123
+
124
+ # Builds the object from hash
125
+ # @param [Hash] attributes Model attributes in the form of hash
126
+ # @return [Object] Returns the model itself
127
+ def self.build_from_hash(attributes)
128
+ return nil unless attributes.is_a?(Hash)
129
+ attributes = attributes.transform_keys(&:to_sym)
130
+ transformed_hash = {}
131
+ openapi_types.each_pair do |key, type|
132
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
133
+ transformed_hash["#{key}"] = nil
134
+ elsif type =~ /\AArray<(.*)>/i
135
+ # check to ensure the input is an array given that the attribute
136
+ # is documented as an array but the input is not
137
+ if attributes[attribute_map[key]].is_a?(Array)
138
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
139
+ end
140
+ elsif !attributes[attribute_map[key]].nil?
141
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
142
+ end
143
+ end
144
+ new(transformed_hash)
145
+ end
146
+
147
+ # Deserializes the data based on type
148
+ # @param string type Data type
149
+ # @param string value Value to be deserialized
150
+ # @return [Object] Deserialized data
151
+ def self._deserialize(type, value)
152
+ case type.to_sym
153
+ when :Time
154
+ Time.parse(value)
155
+ when :Date
156
+ Date.parse(value)
157
+ when :String
158
+ value.to_s
159
+ when :Integer
160
+ value.to_i
161
+ when :Float
162
+ value.to_f
163
+ when :Boolean
164
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
165
+ true
166
+ else
167
+ false
168
+ end
169
+ when :Object
170
+ # generic object (usually a Hash), return directly
171
+ value
172
+ when /\AArray<(?<inner_type>.+)>\z/
173
+ inner_type = Regexp.last_match[:inner_type]
174
+ value.map { |v| _deserialize(inner_type, v) }
175
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
176
+ k_type = Regexp.last_match[:k_type]
177
+ v_type = Regexp.last_match[:v_type]
178
+ {}.tap do |hash|
179
+ value.each do |k, v|
180
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
181
+ end
182
+ end
183
+ else # model
184
+ # models (e.g. Pet) or oneOf
185
+ klass = DaytonaApiClient.const_get(type)
186
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
187
+ end
188
+ end
189
+
190
+ # Returns the string representation of the object
191
+ # @return [String] String presentation of the object
192
+ def to_s
193
+ to_hash.to_s
194
+ end
195
+
196
+ # to_body is an alias to to_hash (backward compatibility)
197
+ # @return [Hash] Returns the object in the form of hash
198
+ def to_body
199
+ to_hash
200
+ end
201
+
202
+ # Returns the object in the form of hash
203
+ # @return [Hash] Returns the object in the form of hash
204
+ def to_hash
205
+ hash = {}
206
+ self.class.attribute_map.each_pair do |attr, param|
207
+ value = self.send(attr)
208
+ if value.nil?
209
+ is_nullable = self.class.openapi_nullable.include?(attr)
210
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
211
+ end
212
+
213
+ hash[param] = _to_hash(value)
214
+ end
215
+ hash
216
+ end
217
+
218
+ # Outputs non-array value in the form of hash
219
+ # For object, use to_hash. Otherwise, just return the value
220
+ # @param [Object] value Any valid value
221
+ # @return [Hash] Returns the value in the form of hash
222
+ def _to_hash(value)
223
+ if value.is_a?(Array)
224
+ value.compact.map { |v| _to_hash(v) }
225
+ elsif value.is_a?(Hash)
226
+ {}.tap do |hash|
227
+ value.each { |k, v| hash[k] = _to_hash(v) }
228
+ end
229
+ elsif value.respond_to? :to_hash
230
+ value.to_hash
231
+ else
232
+ value
233
+ end
234
+ end
235
+ end
236
+ end