daytona_toolbox_api_client 0.162.0 → 0.163.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6ba9919dbbca9510a6493bf7b28be76d534f45caa62f89a3a9e0ac6c960e3181
4
- data.tar.gz: bcd70eee991da6187892a112a5ddda5374aacb8eecbef0ca036265a81d38d58e
3
+ metadata.gz: b6d5edb852db5be116890348bddc2206fa9524dcbd99eab86dc4302803411ca1
4
+ data.tar.gz: e2dbde87f611ccd8e61e14fee05bdf7c6d889dd3f64818e1edd7455649b72fa2
5
5
  SHA512:
6
- metadata.gz: 5edbd8e1c1c2b9d3170e9830353f792e91f6f98c46b6c06e993171e6f6145bd93b9e1fc28e82aa000c1eb8dbe8f4d8801ad6b23b72bcd0c0208c06d74327c99c
7
- data.tar.gz: 9e16f04db59fbd20dc478b5f402c8558680150a2c9874b6906b2af27ef6d15a73acaab163853aadb1b72e1dfac869fc972a5310782ca32f225194bf6f452e0e1
6
+ metadata.gz: fc63095997da260d004f20f84b4704c16f54997f3c9773586444f9dd1d0cffc5be7d24867e4806ebeedda0645a6f7eb10a469c49238904dd9fd6b1f2fe7627e4
7
+ data.tar.gz: '0314833a88f1147d4a1ec73b0d06cde55943d4a5bb1a4585e56740fc24c78ecc4aab41b92c8c8dd5797d62fa347545269c8848215ee8dcc35bfaeb2f98c5904a'
@@ -16,6 +16,11 @@ lib/daytona_toolbox_api_client/api/server_api.rb
16
16
  lib/daytona_toolbox_api_client/api_client.rb
17
17
  lib/daytona_toolbox_api_client/api_error.rb
18
18
  lib/daytona_toolbox_api_client/configuration.rb
19
+ lib/daytona_toolbox_api_client/models/chart.rb
20
+ lib/daytona_toolbox_api_client/models/chart_element.rb
21
+ lib/daytona_toolbox_api_client/models/code_run_artifacts.rb
22
+ lib/daytona_toolbox_api_client/models/code_run_request.rb
23
+ lib/daytona_toolbox_api_client/models/code_run_response.rb
19
24
  lib/daytona_toolbox_api_client/models/command.rb
20
25
  lib/daytona_toolbox_api_client/models/completion_context.rb
21
26
  lib/daytona_toolbox_api_client/models/completion_item.rb
@@ -39,7 +44,7 @@ lib/daytona_toolbox_api_client/models/git_clone_request.rb
39
44
  lib/daytona_toolbox_api_client/models/git_commit_info.rb
40
45
  lib/daytona_toolbox_api_client/models/git_commit_request.rb
41
46
  lib/daytona_toolbox_api_client/models/git_commit_response.rb
42
- lib/daytona_toolbox_api_client/models/git_git_delete_branch_request.rb
47
+ lib/daytona_toolbox_api_client/models/git_delete_branch_request.rb
43
48
  lib/daytona_toolbox_api_client/models/git_repo_request.rb
44
49
  lib/daytona_toolbox_api_client/models/git_status.rb
45
50
  lib/daytona_toolbox_api_client/models/initialize_request.rb
@@ -85,6 +90,7 @@ lib/daytona_toolbox_api_client/models/screenshot_response.rb
85
90
  lib/daytona_toolbox_api_client/models/scroll_response.rb
86
91
  lib/daytona_toolbox_api_client/models/search_files_response.rb
87
92
  lib/daytona_toolbox_api_client/models/session.rb
93
+ lib/daytona_toolbox_api_client/models/session_command_logs_response.rb
88
94
  lib/daytona_toolbox_api_client/models/session_execute_request.rb
89
95
  lib/daytona_toolbox_api_client/models/session_execute_response.rb
90
96
  lib/daytona_toolbox_api_client/models/session_send_input_request.rb
@@ -353,7 +353,7 @@ module DaytonaToolboxApiClient
353
353
 
354
354
  # Delete a branch
355
355
  # Delete a branch from the Git repository
356
- # @param request [GitGitDeleteBranchRequest] Delete branch request
356
+ # @param request [GitDeleteBranchRequest] Delete branch request
357
357
  # @param [Hash] opts the optional parameters
358
358
  # @return [nil]
359
359
  def delete_branch(request, opts = {})
@@ -363,7 +363,7 @@ module DaytonaToolboxApiClient
363
363
 
364
364
  # Delete a branch
365
365
  # Delete a branch from the Git repository
366
- # @param request [GitGitDeleteBranchRequest] Delete branch request
366
+ # @param request [GitDeleteBranchRequest] Delete branch request
367
367
  # @param [Hash] opts the optional parameters
368
368
  # @return [Array<(nil, Integer, Hash)>] nil, response status code and response headers
369
369
  def delete_branch_with_http_info(request, opts = {})
@@ -19,6 +19,74 @@ module DaytonaToolboxApiClient
19
19
  def initialize(api_client = ApiClient.default)
20
20
  @api_client = api_client
21
21
  end
22
+ # Execute code
23
+ # Execute Python, JavaScript, or TypeScript code and return output, exit code, and artifacts
24
+ # @param request [CodeRunRequest] Code execution request
25
+ # @param [Hash] opts the optional parameters
26
+ # @return [CodeRunResponse]
27
+ def code_run(request, opts = {})
28
+ data, _status_code, _headers = code_run_with_http_info(request, opts)
29
+ data
30
+ end
31
+
32
+ # Execute code
33
+ # Execute Python, JavaScript, or TypeScript code and return output, exit code, and artifacts
34
+ # @param request [CodeRunRequest] Code execution request
35
+ # @param [Hash] opts the optional parameters
36
+ # @return [Array<(CodeRunResponse, Integer, Hash)>] CodeRunResponse data, response status code and response headers
37
+ def code_run_with_http_info(request, opts = {})
38
+ if @api_client.config.debugging
39
+ @api_client.config.logger.debug 'Calling API: ProcessApi.code_run ...'
40
+ end
41
+ # verify the required parameter 'request' is set
42
+ if @api_client.config.client_side_validation && request.nil?
43
+ fail ArgumentError, "Missing the required parameter 'request' when calling ProcessApi.code_run"
44
+ end
45
+ # resource path
46
+ local_var_path = '/process/code-run'
47
+
48
+ # query parameters
49
+ query_params = opts[:query_params] || {}
50
+
51
+ # header parameters
52
+ header_params = opts[:header_params] || {}
53
+ # HTTP header 'Accept' (if needed)
54
+ header_params['Accept'] = @api_client.select_header_accept(['application/json']) unless header_params['Accept']
55
+ # HTTP header 'Content-Type'
56
+ content_type = @api_client.select_header_content_type(['application/json'])
57
+ if !content_type.nil?
58
+ header_params['Content-Type'] = content_type
59
+ end
60
+
61
+ # form parameters
62
+ form_params = opts[:form_params] || {}
63
+
64
+ # http body (model)
65
+ post_body = opts[:debug_body] || @api_client.object_to_http_body(request)
66
+
67
+ # return_type
68
+ return_type = opts[:debug_return_type] || 'CodeRunResponse'
69
+
70
+ # auth_names
71
+ auth_names = opts[:debug_auth_names] || []
72
+
73
+ new_options = opts.merge(
74
+ :operation => :"ProcessApi.code_run",
75
+ :header_params => header_params,
76
+ :query_params => query_params,
77
+ :form_params => form_params,
78
+ :body => post_body,
79
+ :auth_names => auth_names,
80
+ :return_type => return_type
81
+ )
82
+
83
+ data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
84
+ if @api_client.config.debugging
85
+ @api_client.config.logger.debug "API called: ProcessApi#code_run\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
86
+ end
87
+ return data, status_code, headers
88
+ end
89
+
22
90
  # Connect to PTY session via WebSocket
23
91
  # Establish a WebSocket connection to interact with a pseudo-terminal session
24
92
  # @param session_id [String] PTY session ID
@@ -407,20 +475,20 @@ module DaytonaToolboxApiClient
407
475
  end
408
476
 
409
477
  # Get entrypoint logs
410
- # Get logs for a sandbox entrypoint session. Supports both HTTP and WebSocket streaming.
478
+ # Get logs for a sandbox entrypoint session. Returns JSON with separated stdout/stderr for SDK >= 0.161.0, plain text otherwise. Supports WebSocket streaming.
411
479
  # @param [Hash] opts the optional parameters
412
480
  # @option opts [Boolean] :follow Follow logs in real-time (WebSocket only)
413
- # @return [String]
481
+ # @return [SessionCommandLogsResponse]
414
482
  def get_entrypoint_logs(opts = {})
415
483
  data, _status_code, _headers = get_entrypoint_logs_with_http_info(opts)
416
484
  data
417
485
  end
418
486
 
419
487
  # Get entrypoint logs
420
- # Get logs for a sandbox entrypoint session. Supports both HTTP and WebSocket streaming.
488
+ # Get logs for a sandbox entrypoint session. Returns JSON with separated stdout/stderr for SDK &gt;&#x3D; 0.161.0, plain text otherwise. Supports WebSocket streaming.
421
489
  # @param [Hash] opts the optional parameters
422
490
  # @option opts [Boolean] :follow Follow logs in real-time (WebSocket only)
423
- # @return [Array<(String, Integer, Hash)>] String data, response status code and response headers
491
+ # @return [Array<(SessionCommandLogsResponse, Integer, Hash)>] SessionCommandLogsResponse data, response status code and response headers
424
492
  def get_entrypoint_logs_with_http_info(opts = {})
425
493
  if @api_client.config.debugging
426
494
  @api_client.config.logger.debug 'Calling API: ProcessApi.get_entrypoint_logs ...'
@@ -435,7 +503,7 @@ module DaytonaToolboxApiClient
435
503
  # header parameters
436
504
  header_params = opts[:header_params] || {}
437
505
  # HTTP header 'Accept' (if needed)
438
- header_params['Accept'] = @api_client.select_header_accept(['text/plain']) unless header_params['Accept']
506
+ header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/plain']) unless header_params['Accept']
439
507
 
440
508
  # form parameters
441
509
  form_params = opts[:form_params] || {}
@@ -444,7 +512,7 @@ module DaytonaToolboxApiClient
444
512
  post_body = opts[:debug_body]
445
513
 
446
514
  # return_type
447
- return_type = opts[:debug_return_type] || 'String'
515
+ return_type = opts[:debug_return_type] || 'SessionCommandLogsResponse'
448
516
 
449
517
  # auth_names
450
518
  auth_names = opts[:debug_auth_names] || []
@@ -719,24 +787,24 @@ module DaytonaToolboxApiClient
719
787
  end
720
788
 
721
789
  # Get session command logs
722
- # Get logs for a specific command within a session. Supports both HTTP and WebSocket streaming.
790
+ # Get logs for a specific command within a session. Returns JSON with separated stdout/stderr for SDK >= 0.163.0, plain text otherwise. Supports WebSocket streaming.
723
791
  # @param session_id [String] Session ID
724
792
  # @param command_id [String] Command ID
725
793
  # @param [Hash] opts the optional parameters
726
794
  # @option opts [Boolean] :follow Follow logs in real-time (WebSocket only)
727
- # @return [String]
795
+ # @return [SessionCommandLogsResponse]
728
796
  def get_session_command_logs(session_id, command_id, opts = {})
729
797
  data, _status_code, _headers = get_session_command_logs_with_http_info(session_id, command_id, opts)
730
798
  data
731
799
  end
732
800
 
733
801
  # Get session command logs
734
- # Get logs for a specific command within a session. Supports both HTTP and WebSocket streaming.
802
+ # Get logs for a specific command within a session. Returns JSON with separated stdout/stderr for SDK &gt;&#x3D; 0.163.0, plain text otherwise. Supports WebSocket streaming.
735
803
  # @param session_id [String] Session ID
736
804
  # @param command_id [String] Command ID
737
805
  # @param [Hash] opts the optional parameters
738
806
  # @option opts [Boolean] :follow Follow logs in real-time (WebSocket only)
739
- # @return [Array<(String, Integer, Hash)>] String data, response status code and response headers
807
+ # @return [Array<(SessionCommandLogsResponse, Integer, Hash)>] SessionCommandLogsResponse data, response status code and response headers
740
808
  def get_session_command_logs_with_http_info(session_id, command_id, opts = {})
741
809
  if @api_client.config.debugging
742
810
  @api_client.config.logger.debug 'Calling API: ProcessApi.get_session_command_logs ...'
@@ -759,7 +827,7 @@ module DaytonaToolboxApiClient
759
827
  # header parameters
760
828
  header_params = opts[:header_params] || {}
761
829
  # HTTP header 'Accept' (if needed)
762
- header_params['Accept'] = @api_client.select_header_accept(['text/plain']) unless header_params['Accept']
830
+ header_params['Accept'] = @api_client.select_header_accept(['application/json', 'text/plain']) unless header_params['Accept']
763
831
 
764
832
  # form parameters
765
833
  form_params = opts[:form_params] || {}
@@ -768,7 +836,7 @@ module DaytonaToolboxApiClient
768
836
  post_body = opts[:debug_body]
769
837
 
770
838
  # return_type
771
- return_type = opts[:debug_return_type] || 'String'
839
+ return_type = opts[:debug_return_type] || 'SessionCommandLogsResponse'
772
840
 
773
841
  # auth_names
774
842
  auth_names = opts[:debug_auth_names] || []
@@ -0,0 +1,329 @@
1
+ =begin
2
+ #Daytona Toolbox API
3
+
4
+ #Daytona Toolbox API
5
+
6
+ The version of the OpenAPI document: v0.0.0-dev
7
+
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 DaytonaToolboxApiClient
17
+ class Chart
18
+ attr_accessor :elements
19
+
20
+ attr_accessor :png
21
+
22
+ attr_accessor :title
23
+
24
+ attr_accessor :type
25
+
26
+ attr_accessor :x_label
27
+
28
+ attr_accessor :x_scale
29
+
30
+ attr_accessor :x_tick_labels
31
+
32
+ attr_accessor :x_ticks
33
+
34
+ attr_accessor :y_label
35
+
36
+ attr_accessor :y_scale
37
+
38
+ attr_accessor :y_tick_labels
39
+
40
+ attr_accessor :y_ticks
41
+
42
+ # Attribute mapping from ruby-style variable name to JSON key.
43
+ def self.attribute_map
44
+ {
45
+ :'elements' => :'elements',
46
+ :'png' => :'png',
47
+ :'title' => :'title',
48
+ :'type' => :'type',
49
+ :'x_label' => :'x_label',
50
+ :'x_scale' => :'x_scale',
51
+ :'x_tick_labels' => :'x_tick_labels',
52
+ :'x_ticks' => :'x_ticks',
53
+ :'y_label' => :'y_label',
54
+ :'y_scale' => :'y_scale',
55
+ :'y_tick_labels' => :'y_tick_labels',
56
+ :'y_ticks' => :'y_ticks'
57
+ }
58
+ end
59
+
60
+ # Returns attribute mapping this model knows about
61
+ def self.acceptable_attribute_map
62
+ attribute_map
63
+ end
64
+
65
+ # Returns all the JSON keys this model knows about
66
+ def self.acceptable_attributes
67
+ acceptable_attribute_map.values
68
+ end
69
+
70
+ # Attribute type mapping.
71
+ def self.openapi_types
72
+ {
73
+ :'elements' => :'Array<ChartElement>',
74
+ :'png' => :'String',
75
+ :'title' => :'String',
76
+ :'type' => :'String',
77
+ :'x_label' => :'String',
78
+ :'x_scale' => :'String',
79
+ :'x_tick_labels' => :'Array<String>',
80
+ :'x_ticks' => :'Array<Float>',
81
+ :'y_label' => :'String',
82
+ :'y_scale' => :'String',
83
+ :'y_tick_labels' => :'Array<String>',
84
+ :'y_ticks' => :'Array<Float>'
85
+ }
86
+ end
87
+
88
+ # List of attributes with nullable: true
89
+ def self.openapi_nullable
90
+ Set.new([
91
+ ])
92
+ end
93
+
94
+ # Initializes the object
95
+ # @param [Hash] attributes Model attributes in the form of hash
96
+ def initialize(attributes = {})
97
+ if (!attributes.is_a?(Hash))
98
+ fail ArgumentError, "The input argument (attributes) must be a hash in `DaytonaToolboxApiClient::Chart` initialize method"
99
+ end
100
+
101
+ # check to see if the attribute exists and convert string to symbol for hash key
102
+ acceptable_attribute_map = self.class.acceptable_attribute_map
103
+ attributes = attributes.each_with_object({}) { |(k, v), h|
104
+ if (!acceptable_attribute_map.key?(k.to_sym))
105
+ fail ArgumentError, "`#{k}` is not a valid attribute in `DaytonaToolboxApiClient::Chart`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect
106
+ end
107
+ h[k.to_sym] = v
108
+ }
109
+
110
+ if attributes.key?(:'elements')
111
+ if (value = attributes[:'elements']).is_a?(Array)
112
+ self.elements = value
113
+ end
114
+ end
115
+
116
+ if attributes.key?(:'png')
117
+ self.png = attributes[:'png']
118
+ end
119
+
120
+ if attributes.key?(:'title')
121
+ self.title = attributes[:'title']
122
+ end
123
+
124
+ if attributes.key?(:'type')
125
+ self.type = attributes[:'type']
126
+ end
127
+
128
+ if attributes.key?(:'x_label')
129
+ self.x_label = attributes[:'x_label']
130
+ end
131
+
132
+ if attributes.key?(:'x_scale')
133
+ self.x_scale = attributes[:'x_scale']
134
+ end
135
+
136
+ if attributes.key?(:'x_tick_labels')
137
+ if (value = attributes[:'x_tick_labels']).is_a?(Array)
138
+ self.x_tick_labels = value
139
+ end
140
+ end
141
+
142
+ if attributes.key?(:'x_ticks')
143
+ if (value = attributes[:'x_ticks']).is_a?(Array)
144
+ self.x_ticks = value
145
+ end
146
+ end
147
+
148
+ if attributes.key?(:'y_label')
149
+ self.y_label = attributes[:'y_label']
150
+ end
151
+
152
+ if attributes.key?(:'y_scale')
153
+ self.y_scale = attributes[:'y_scale']
154
+ end
155
+
156
+ if attributes.key?(:'y_tick_labels')
157
+ if (value = attributes[:'y_tick_labels']).is_a?(Array)
158
+ self.y_tick_labels = value
159
+ end
160
+ end
161
+
162
+ if attributes.key?(:'y_ticks')
163
+ if (value = attributes[:'y_ticks']).is_a?(Array)
164
+ self.y_ticks = value
165
+ end
166
+ end
167
+ end
168
+
169
+ # Show invalid properties with the reasons. Usually used together with valid?
170
+ # @return Array for valid properties with the reasons
171
+ def list_invalid_properties
172
+ warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
173
+ invalid_properties = Array.new
174
+ invalid_properties
175
+ end
176
+
177
+ # Check to see if the all the properties in the model are valid
178
+ # @return true if the model is valid
179
+ def valid?
180
+ warn '[DEPRECATED] the `valid?` method is obsolete'
181
+ true
182
+ end
183
+
184
+ # Checks equality by comparing each attribute.
185
+ # @param [Object] Object to be compared
186
+ def ==(o)
187
+ return true if self.equal?(o)
188
+ self.class == o.class &&
189
+ elements == o.elements &&
190
+ png == o.png &&
191
+ title == o.title &&
192
+ type == o.type &&
193
+ x_label == o.x_label &&
194
+ x_scale == o.x_scale &&
195
+ x_tick_labels == o.x_tick_labels &&
196
+ x_ticks == o.x_ticks &&
197
+ y_label == o.y_label &&
198
+ y_scale == o.y_scale &&
199
+ y_tick_labels == o.y_tick_labels &&
200
+ y_ticks == o.y_ticks
201
+ end
202
+
203
+ # @see the `==` method
204
+ # @param [Object] Object to be compared
205
+ def eql?(o)
206
+ self == o
207
+ end
208
+
209
+ # Calculates hash code according to all attributes.
210
+ # @return [Integer] Hash code
211
+ def hash
212
+ [elements, png, title, type, x_label, x_scale, x_tick_labels, x_ticks, y_label, y_scale, y_tick_labels, y_ticks].hash
213
+ end
214
+
215
+ # Builds the object from hash
216
+ # @param [Hash] attributes Model attributes in the form of hash
217
+ # @return [Object] Returns the model itself
218
+ def self.build_from_hash(attributes)
219
+ return nil unless attributes.is_a?(Hash)
220
+ attributes = attributes.transform_keys(&:to_sym)
221
+ transformed_hash = {}
222
+ openapi_types.each_pair do |key, type|
223
+ if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
224
+ transformed_hash["#{key}"] = nil
225
+ elsif type =~ /\AArray<(.*)>/i
226
+ # check to ensure the input is an array given that the attribute
227
+ # is documented as an array but the input is not
228
+ if attributes[attribute_map[key]].is_a?(Array)
229
+ transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
230
+ end
231
+ elsif !attributes[attribute_map[key]].nil?
232
+ transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]])
233
+ end
234
+ end
235
+ new(transformed_hash)
236
+ end
237
+
238
+ # Deserializes the data based on type
239
+ # @param string type Data type
240
+ # @param string value Value to be deserialized
241
+ # @return [Object] Deserialized data
242
+ def self._deserialize(type, value)
243
+ case type.to_sym
244
+ when :Time
245
+ Time.parse(value)
246
+ when :Date
247
+ Date.parse(value)
248
+ when :String
249
+ value.to_s
250
+ when :Integer
251
+ value.to_i
252
+ when :Float
253
+ value.to_f
254
+ when :Boolean
255
+ if value.to_s =~ /\A(true|t|yes|y|1)\z/i
256
+ true
257
+ else
258
+ false
259
+ end
260
+ when :Object
261
+ # generic object (usually a Hash), return directly
262
+ value
263
+ when /\AArray<(?<inner_type>.+)>\z/
264
+ inner_type = Regexp.last_match[:inner_type]
265
+ value.map { |v| _deserialize(inner_type, v) }
266
+ when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/
267
+ k_type = Regexp.last_match[:k_type]
268
+ v_type = Regexp.last_match[:v_type]
269
+ {}.tap do |hash|
270
+ value.each do |k, v|
271
+ hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
272
+ end
273
+ end
274
+ else # model
275
+ # models (e.g. Pet) or oneOf
276
+ klass = DaytonaToolboxApiClient.const_get(type)
277
+ klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
278
+ end
279
+ end
280
+
281
+ # Returns the string representation of the object
282
+ # @return [String] String presentation of the object
283
+ def to_s
284
+ to_hash.to_s
285
+ end
286
+
287
+ # to_body is an alias to to_hash (backward compatibility)
288
+ # @return [Hash] Returns the object in the form of hash
289
+ def to_body
290
+ to_hash
291
+ end
292
+
293
+ # Returns the object in the form of hash
294
+ # @return [Hash] Returns the object in the form of hash
295
+ def to_hash
296
+ hash = {}
297
+ self.class.attribute_map.each_pair do |attr, param|
298
+ value = self.send(attr)
299
+ if value.nil?
300
+ is_nullable = self.class.openapi_nullable.include?(attr)
301
+ next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}"))
302
+ end
303
+
304
+ hash[param] = _to_hash(value)
305
+ end
306
+ hash
307
+ end
308
+
309
+ # Outputs non-array value in the form of hash
310
+ # For object, use to_hash. Otherwise, just return the value
311
+ # @param [Object] value Any valid value
312
+ # @return [Hash] Returns the value in the form of hash
313
+ def _to_hash(value)
314
+ if value.is_a?(Array)
315
+ value.compact.map { |v| _to_hash(v) }
316
+ elsif value.is_a?(Hash)
317
+ {}.tap do |hash|
318
+ value.each { |k, v| hash[k] = _to_hash(v) }
319
+ end
320
+ elsif value.respond_to? :to_hash
321
+ value.to_hash
322
+ else
323
+ value
324
+ end
325
+ end
326
+
327
+ end
328
+
329
+ end