daytona_api_client 0.144.0 → 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 (90) 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/health_api.rb +1 -52
  8. data/lib/daytona_api_client/api/organizations_api.rb +121 -973
  9. data/lib/daytona_api_client/api/preview_api.rb +5 -74
  10. data/lib/daytona_api_client/api/runners_api.rb +20 -407
  11. data/lib/daytona_api_client/api/sandbox_api.rb +189 -961
  12. data/lib/daytona_api_client/api/snapshots_api.rb +0 -66
  13. data/lib/daytona_api_client/api/toolbox_api.rb +711 -711
  14. data/lib/daytona_api_client/api/workspace_api.rb +3 -3
  15. data/lib/daytona_api_client/models/build_info.rb +4 -31
  16. data/lib/daytona_api_client/models/{job.rb → create_audit_log.rb} +79 -166
  17. data/lib/daytona_api_client/models/create_organization.rb +4 -31
  18. data/lib/daytona_api_client/models/create_runner.rb +315 -31
  19. data/lib/daytona_api_client/models/create_sandbox.rb +1 -11
  20. data/lib/daytona_api_client/models/create_snapshot.rb +4 -14
  21. data/lib/daytona_api_client/models/create_user.rb +1 -10
  22. data/lib/daytona_api_client/models/daytona_configuration.rb +4 -41
  23. data/lib/daytona_api_client/models/organization.rb +85 -119
  24. data/lib/daytona_api_client/models/organization_suspension.rb +5 -7
  25. data/lib/daytona_api_client/models/organization_usage_overview.rb +146 -18
  26. data/lib/daytona_api_client/models/paginated_audit_logs.rb +4 -14
  27. data/lib/daytona_api_client/models/{paginated_jobs.rb → paginated_snapshots_dto.rb} +4 -4
  28. data/lib/daytona_api_client/models/port_preview_url.rb +14 -31
  29. data/lib/daytona_api_client/models/region.rb +4 -178
  30. data/lib/daytona_api_client/models/runner.rb +117 -79
  31. data/lib/daytona_api_client/models/runner_snapshot_dto.rb +17 -0
  32. data/lib/daytona_api_client/models/sandbox.rb +14 -51
  33. data/lib/daytona_api_client/models/sandbox_state.rb +1 -2
  34. data/lib/daytona_api_client/models/sandbox_volume.rb +4 -14
  35. data/lib/daytona_api_client/models/snapshot_dto.rb +4 -36
  36. data/lib/daytona_api_client/models/snapshot_state.rb +4 -1
  37. data/lib/daytona_api_client/models/ssh_access_dto.rb +4 -31
  38. data/lib/daytona_api_client/models/ssh_access_validation_dto.rb +24 -4
  39. data/lib/daytona_api_client/models/update_organization_quota.rb +41 -77
  40. data/lib/daytona_api_client/models/update_sandbox_state_dto.rb +6 -26
  41. data/lib/daytona_api_client/models/workspace.rb +35 -45
  42. data/lib/daytona_api_client/version.rb +1 -1
  43. data/lib/daytona_api_client.rb +1 -40
  44. data/project.json +8 -56
  45. metadata +7 -53
  46. data/.gitignore +0 -39
  47. data/.openapi-generator/FILES +0 -204
  48. data/.openapi-generator/VERSION +0 -1
  49. data/.openapi-generator-ignore +0 -31
  50. data/.rspec +0 -2
  51. data/.rubocop.yml +0 -148
  52. data/fix-gemspec.sh +0 -11
  53. data/lib/daytona_api_client/api/admin_api.rb +0 -386
  54. data/lib/daytona_api_client/api/jobs_api.rb +0 -299
  55. data/lib/daytona_api_client/api/regions_api.rb +0 -77
  56. data/lib/daytona_api_client/models/admin_create_runner.rb +0 -385
  57. data/lib/daytona_api_client/models/create_region.rb +0 -269
  58. data/lib/daytona_api_client/models/create_region_response.rb +0 -280
  59. data/lib/daytona_api_client/models/create_runner_response.rb +0 -263
  60. data/lib/daytona_api_client/models/job_status.rb +0 -42
  61. data/lib/daytona_api_client/models/job_type.rb +0 -50
  62. data/lib/daytona_api_client/models/log_entry.rb +0 -405
  63. data/lib/daytona_api_client/models/metric_data_point.rb +0 -263
  64. data/lib/daytona_api_client/models/metric_series.rb +0 -265
  65. data/lib/daytona_api_client/models/metrics_response.rb +0 -238
  66. data/lib/daytona_api_client/models/otel_config.rb +0 -249
  67. data/lib/daytona_api_client/models/paginated_logs.rb +0 -319
  68. data/lib/daytona_api_client/models/paginated_traces.rb +0 -319
  69. data/lib/daytona_api_client/models/poll_jobs_response.rb +0 -238
  70. data/lib/daytona_api_client/models/rate_limit_config.rb +0 -249
  71. data/lib/daytona_api_client/models/rate_limit_entry.rb +0 -229
  72. data/lib/daytona_api_client/models/regenerate_api_key_response.rb +0 -236
  73. data/lib/daytona_api_client/models/region_quota.rb +0 -339
  74. data/lib/daytona_api_client/models/region_type.rb +0 -41
  75. data/lib/daytona_api_client/models/region_usage_overview.rb +0 -391
  76. data/lib/daytona_api_client/models/resize_sandbox.rb +0 -296
  77. data/lib/daytona_api_client/models/runner_full.rb +0 -779
  78. data/lib/daytona_api_client/models/runner_health_metrics.rb +0 -533
  79. data/lib/daytona_api_client/models/runner_healthcheck.rb +0 -276
  80. data/lib/daytona_api_client/models/signed_port_preview_url.rb +0 -317
  81. data/lib/daytona_api_client/models/snapshot_manager_credentials.rb +0 -263
  82. data/lib/daytona_api_client/models/toolbox_proxy_url.rb +0 -236
  83. data/lib/daytona_api_client/models/trace_span.rb +0 -403
  84. data/lib/daytona_api_client/models/trace_summary.rb +0 -381
  85. data/lib/daytona_api_client/models/update_job_status.rb +0 -278
  86. data/lib/daytona_api_client/models/update_organization_default_region.rb +0 -236
  87. data/lib/daytona_api_client/models/update_organization_region_quota.rb +0 -245
  88. data/lib/daytona_api_client/models/update_region.rb +0 -242
  89. data/lib/daytona_api_client/models/url.rb +0 -236
  90. data/lib/daytona_api_client/models/workspace_port_preview_url.rb +0 -263
@@ -1,276 +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 RunnerHealthcheck
18
- # Runner metrics
19
- attr_accessor :metrics
20
-
21
- # Runner domain
22
- attr_accessor :domain
23
-
24
- # Runner proxy URL
25
- attr_accessor :proxy_url
26
-
27
- # Runner API URL
28
- attr_accessor :api_url
29
-
30
- # Runner app version
31
- attr_accessor :app_version
32
-
33
- # Attribute mapping from ruby-style variable name to JSON key.
34
- def self.attribute_map
35
- {
36
- :'metrics' => :'metrics',
37
- :'domain' => :'domain',
38
- :'proxy_url' => :'proxyUrl',
39
- :'api_url' => :'apiUrl',
40
- :'app_version' => :'appVersion'
41
- }
42
- end
43
-
44
- # Returns attribute mapping this model knows about
45
- def self.acceptable_attribute_map
46
- attribute_map
47
- end
48
-
49
- # Returns all the JSON keys this model knows about
50
- def self.acceptable_attributes
51
- acceptable_attribute_map.values
52
- end
53
-
54
- # Attribute type mapping.
55
- def self.openapi_types
56
- {
57
- :'metrics' => :'RunnerHealthMetrics',
58
- :'domain' => :'String',
59
- :'proxy_url' => :'String',
60
- :'api_url' => :'String',
61
- :'app_version' => :'String'
62
- }
63
- end
64
-
65
- # List of attributes with nullable: true
66
- def self.openapi_nullable
67
- Set.new([
68
- ])
69
- end
70
-
71
- # Initializes the object
72
- # @param [Hash] attributes Model attributes in the form of hash
73
- def initialize(attributes = {})
74
- if (!attributes.is_a?(Hash))
75
- fail ArgumentError, "The input argument (attributes) must be a hash in `DaytonaApiClient::RunnerHealthcheck` initialize method"
76
- end
77
-
78
- # check to see if the attribute exists and convert string to symbol for hash key
79
- acceptable_attribute_map = self.class.acceptable_attribute_map
80
- attributes = attributes.each_with_object({}) { |(k, v), h|
81
- if (!acceptable_attribute_map.key?(k.to_sym))
82
- fail ArgumentError, "`#{k}` is not a valid attribute in `DaytonaApiClient::RunnerHealthcheck`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
83
- end
84
- h[k.to_sym] = v
85
- }
86
-
87
- if attributes.key?(:'metrics')
88
- self.metrics = attributes[:'metrics']
89
- end
90
-
91
- if attributes.key?(:'domain')
92
- self.domain = attributes[:'domain']
93
- end
94
-
95
- if attributes.key?(:'proxy_url')
96
- self.proxy_url = attributes[:'proxy_url']
97
- end
98
-
99
- if attributes.key?(:'api_url')
100
- self.api_url = attributes[:'api_url']
101
- end
102
-
103
- if attributes.key?(:'app_version')
104
- self.app_version = attributes[:'app_version']
105
- else
106
- self.app_version = nil
107
- end
108
- end
109
-
110
- # Show invalid properties with the reasons. Usually used together with valid?
111
- # @return Array for valid properties with the reasons
112
- def list_invalid_properties
113
- warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
114
- invalid_properties = Array.new
115
- if @app_version.nil?
116
- invalid_properties.push('invalid value for "app_version", app_version cannot be nil.')
117
- end
118
-
119
- invalid_properties
120
- end
121
-
122
- # Check to see if the all the properties in the model are valid
123
- # @return true if the model is valid
124
- def valid?
125
- warn '[DEPRECATED] the `valid?` method is obsolete'
126
- return false if @app_version.nil?
127
- true
128
- end
129
-
130
- # Custom attribute writer method with validation
131
- # @param [Object] app_version Value to be assigned
132
- def app_version=(app_version)
133
- if app_version.nil?
134
- fail ArgumentError, 'app_version cannot be nil'
135
- end
136
-
137
- @app_version = app_version
138
- end
139
-
140
- # Checks equality by comparing each attribute.
141
- # @param [Object] Object to be compared
142
- def ==(o)
143
- return true if self.equal?(o)
144
- self.class == o.class &&
145
- metrics == o.metrics &&
146
- domain == o.domain &&
147
- proxy_url == o.proxy_url &&
148
- api_url == o.api_url &&
149
- app_version == o.app_version
150
- end
151
-
152
- # @see the `==` method
153
- # @param [Object] Object to be compared
154
- def eql?(o)
155
- self == o
156
- end
157
-
158
- # Calculates hash code according to all attributes.
159
- # @return [Integer] Hash code
160
- def hash
161
- [metrics, domain, proxy_url, api_url, app_version].hash
162
- end
163
-
164
- # Builds the object from hash
165
- # @param [Hash] attributes Model attributes in the form of hash
166
- # @return [Object] Returns the model itself
167
- def self.build_from_hash(attributes)
168
- return nil unless attributes.is_a?(Hash)
169
- attributes = attributes.transform_keys(&:to_sym)
170
- transformed_hash = {}
171
- openapi_types.each_pair do |key, type|
172
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
173
- transformed_hash["#{key}"] = nil
174
- elsif type =~ /\AArray<(.*)>/i
175
- # check to ensure the input is an array given that the attribute
176
- # is documented as an array but the input is not
177
- if attributes[attribute_map[key]].is_a?(Array)
178
- transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
179
- end
180
- elsif !attributes[attribute_map[key]].nil?
181
- transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
182
- end
183
- end
184
- new(transformed_hash)
185
- end
186
-
187
- # Deserializes the data based on type
188
- # @param string type Data type
189
- # @param string value Value to be deserialized
190
- # @return [Object] Deserialized data
191
- def self._deserialize(type, value)
192
- case type.to_sym
193
- when :Time
194
- Time.parse(value)
195
- when :Date
196
- Date.parse(value)
197
- when :String
198
- value.to_s
199
- when :Integer
200
- value.to_i
201
- when :Float
202
- value.to_f
203
- when :Boolean
204
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
205
- true
206
- else
207
- false
208
- end
209
- when :Object
210
- # generic object (usually a Hash), return directly
211
- value
212
- when /\AArray<(?<inner_type>.+)>\z/
213
- inner_type = Regexp.last_match[:inner_type]
214
- value.map { |v| _deserialize(inner_type, v) }
215
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
216
- k_type = Regexp.last_match[:k_type]
217
- v_type = Regexp.last_match[:v_type]
218
- {}.tap do |hash|
219
- value.each do |k, v|
220
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
221
- end
222
- end
223
- else # model
224
- # models (e.g. Pet) or oneOf
225
- klass = DaytonaApiClient.const_get(type)
226
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
227
- end
228
- end
229
-
230
- # Returns the string representation of the object
231
- # @return [String] String presentation of the object
232
- def to_s
233
- to_hash.to_s
234
- end
235
-
236
- # to_body is an alias to to_hash (backward compatibility)
237
- # @return [Hash] Returns the object in the form of hash
238
- def to_body
239
- to_hash
240
- end
241
-
242
- # Returns the object in the form of hash
243
- # @return [Hash] Returns the object in the form of hash
244
- def to_hash
245
- hash = {}
246
- self.class.attribute_map.each_pair do |attr, param|
247
- value = self.send(attr)
248
- if value.nil?
249
- is_nullable = self.class.openapi_nullable.include?(attr)
250
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
251
- end
252
-
253
- hash[param] = _to_hash(value)
254
- end
255
- hash
256
- end
257
-
258
- # Outputs non-array value in the form of hash
259
- # For object, use to_hash. Otherwise, just return the value
260
- # @param [Object] value Any valid value
261
- # @return [Hash] Returns the value in the form of hash
262
- def _to_hash(value)
263
- if value.is_a?(Array)
264
- value.compact.map { |v| _to_hash(v) }
265
- elsif value.is_a?(Hash)
266
- {}.tap do |hash|
267
- value.each { |k, v| hash[k] = _to_hash(v) }
268
- end
269
- elsif value.respond_to? :to_hash
270
- value.to_hash
271
- else
272
- value
273
- end
274
- end
275
- end
276
- end
@@ -1,317 +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 SignedPortPreviewUrl
18
- # ID of the sandbox
19
- attr_accessor :sandbox_id
20
-
21
- # Port number of the signed preview URL
22
- attr_accessor :port
23
-
24
- # Token of the signed preview URL
25
- attr_accessor :token
26
-
27
- # Signed preview url
28
- attr_accessor :url
29
-
30
- # Attribute mapping from ruby-style variable name to JSON key.
31
- def self.attribute_map
32
- {
33
- :'sandbox_id' => :'sandboxId',
34
- :'port' => :'port',
35
- :'token' => :'token',
36
- :'url' => :'url'
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
- :'sandbox_id' => :'String',
54
- :'port' => :'Integer',
55
- :'token' => :'String',
56
- :'url' => :'String'
57
- }
58
- end
59
-
60
- # List of attributes with nullable: true
61
- def self.openapi_nullable
62
- Set.new([
63
- ])
64
- end
65
-
66
- # Initializes the object
67
- # @param [Hash] attributes Model attributes in the form of hash
68
- def initialize(attributes = {})
69
- if (!attributes.is_a?(Hash))
70
- fail ArgumentError, "The input argument (attributes) must be a hash in `DaytonaApiClient::SignedPortPreviewUrl` initialize method"
71
- end
72
-
73
- # check to see if the attribute exists and convert string to symbol for hash key
74
- acceptable_attribute_map = self.class.acceptable_attribute_map
75
- attributes = attributes.each_with_object({}) { |(k, v), h|
76
- if (!acceptable_attribute_map.key?(k.to_sym))
77
- fail ArgumentError, "`#{k}` is not a valid attribute in `DaytonaApiClient::SignedPortPreviewUrl`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
78
- end
79
- h[k.to_sym] = v
80
- }
81
-
82
- if attributes.key?(:'sandbox_id')
83
- self.sandbox_id = attributes[:'sandbox_id']
84
- else
85
- self.sandbox_id = nil
86
- end
87
-
88
- if attributes.key?(:'port')
89
- self.port = attributes[:'port']
90
- else
91
- self.port = nil
92
- end
93
-
94
- if attributes.key?(:'token')
95
- self.token = attributes[:'token']
96
- else
97
- self.token = nil
98
- end
99
-
100
- if attributes.key?(:'url')
101
- self.url = attributes[:'url']
102
- else
103
- self.url = nil
104
- end
105
- end
106
-
107
- # Show invalid properties with the reasons. Usually used together with valid?
108
- # @return Array for valid properties with the reasons
109
- def list_invalid_properties
110
- warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
111
- invalid_properties = Array.new
112
- if @sandbox_id.nil?
113
- invalid_properties.push('invalid value for "sandbox_id", sandbox_id cannot be nil.')
114
- end
115
-
116
- if @port.nil?
117
- invalid_properties.push('invalid value for "port", port cannot be nil.')
118
- end
119
-
120
- if @token.nil?
121
- invalid_properties.push('invalid value for "token", token cannot be nil.')
122
- end
123
-
124
- if @url.nil?
125
- invalid_properties.push('invalid value for "url", url cannot be nil.')
126
- end
127
-
128
- invalid_properties
129
- end
130
-
131
- # Check to see if the all the properties in the model are valid
132
- # @return true if the model is valid
133
- def valid?
134
- warn '[DEPRECATED] the `valid?` method is obsolete'
135
- return false if @sandbox_id.nil?
136
- return false if @port.nil?
137
- return false if @token.nil?
138
- return false if @url.nil?
139
- true
140
- end
141
-
142
- # Custom attribute writer method with validation
143
- # @param [Object] sandbox_id Value to be assigned
144
- def sandbox_id=(sandbox_id)
145
- if sandbox_id.nil?
146
- fail ArgumentError, 'sandbox_id cannot be nil'
147
- end
148
-
149
- @sandbox_id = sandbox_id
150
- end
151
-
152
- # Custom attribute writer method with validation
153
- # @param [Object] port Value to be assigned
154
- def port=(port)
155
- if port.nil?
156
- fail ArgumentError, 'port cannot be nil'
157
- end
158
-
159
- @port = port
160
- end
161
-
162
- # Custom attribute writer method with validation
163
- # @param [Object] token Value to be assigned
164
- def token=(token)
165
- if token.nil?
166
- fail ArgumentError, 'token cannot be nil'
167
- end
168
-
169
- @token = token
170
- end
171
-
172
- # Custom attribute writer method with validation
173
- # @param [Object] url Value to be assigned
174
- def url=(url)
175
- if url.nil?
176
- fail ArgumentError, 'url cannot be nil'
177
- end
178
-
179
- @url = url
180
- end
181
-
182
- # Checks equality by comparing each attribute.
183
- # @param [Object] Object to be compared
184
- def ==(o)
185
- return true if self.equal?(o)
186
- self.class == o.class &&
187
- sandbox_id == o.sandbox_id &&
188
- port == o.port &&
189
- token == o.token &&
190
- url == o.url
191
- end
192
-
193
- # @see the `==` method
194
- # @param [Object] Object to be compared
195
- def eql?(o)
196
- self == o
197
- end
198
-
199
- # Calculates hash code according to all attributes.
200
- # @return [Integer] Hash code
201
- def hash
202
- [sandbox_id, port, token, url].hash
203
- end
204
-
205
- # Builds the object from hash
206
- # @param [Hash] attributes Model attributes in the form of hash
207
- # @return [Object] Returns the model itself
208
- def self.build_from_hash(attributes)
209
- return nil unless attributes.is_a?(Hash)
210
- attributes = attributes.transform_keys(&:to_sym)
211
- transformed_hash = {}
212
- openapi_types.each_pair do |key, type|
213
- if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
214
- transformed_hash["#{key}"] = nil
215
- elsif type =~ /\AArray<(.*)>/i
216
- # check to ensure the input is an array given that the attribute
217
- # is documented as an array but the input is not
218
- if attributes[attribute_map[key]].is_a?(Array)
219
- transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
220
- end
221
- elsif !attributes[attribute_map[key]].nil?
222
- transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
223
- end
224
- end
225
- new(transformed_hash)
226
- end
227
-
228
- # Deserializes the data based on type
229
- # @param string type Data type
230
- # @param string value Value to be deserialized
231
- # @return [Object] Deserialized data
232
- def self._deserialize(type, value)
233
- case type.to_sym
234
- when :Time
235
- Time.parse(value)
236
- when :Date
237
- Date.parse(value)
238
- when :String
239
- value.to_s
240
- when :Integer
241
- value.to_i
242
- when :Float
243
- value.to_f
244
- when :Boolean
245
- if value.to_s =~ /\A(true|t|yes|y|1)\z/i
246
- true
247
- else
248
- false
249
- end
250
- when :Object
251
- # generic object (usually a Hash), return directly
252
- value
253
- when /\AArray<(?<inner_type>.+)>\z/
254
- inner_type = Regexp.last_match[:inner_type]
255
- value.map { |v| _deserialize(inner_type, v) }
256
- when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
257
- k_type = Regexp.last_match[:k_type]
258
- v_type = Regexp.last_match[:v_type]
259
- {}.tap do |hash|
260
- value.each do |k, v|
261
- hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
262
- end
263
- end
264
- else # model
265
- # models (e.g. Pet) or oneOf
266
- klass = DaytonaApiClient.const_get(type)
267
- klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
268
- end
269
- end
270
-
271
- # Returns the string representation of the object
272
- # @return [String] String presentation of the object
273
- def to_s
274
- to_hash.to_s
275
- end
276
-
277
- # to_body is an alias to to_hash (backward compatibility)
278
- # @return [Hash] Returns the object in the form of hash
279
- def to_body
280
- to_hash
281
- end
282
-
283
- # Returns the object in the form of hash
284
- # @return [Hash] Returns the object in the form of hash
285
- def to_hash
286
- hash = {}
287
- self.class.attribute_map.each_pair do |attr, param|
288
- value = self.send(attr)
289
- if value.nil?
290
- is_nullable = self.class.openapi_nullable.include?(attr)
291
- next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
292
- end
293
-
294
- hash[param] = _to_hash(value)
295
- end
296
- hash
297
- end
298
-
299
- # Outputs non-array value in the form of hash
300
- # For object, use to_hash. Otherwise, just return the value
301
- # @param [Object] value Any valid value
302
- # @return [Hash] Returns the value in the form of hash
303
- def _to_hash(value)
304
- if value.is_a?(Array)
305
- value.compact.map { |v| _to_hash(v) }
306
- elsif value.is_a?(Hash)
307
- {}.tap do |hash|
308
- value.each { |k, v| hash[k] = _to_hash(v) }
309
- end
310
- elsif value.respond_to? :to_hash
311
- value.to_hash
312
- else
313
- value
314
- end
315
- end
316
- end
317
- end