daytona-sdk 0.125.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.
- checksums.yaml +7 -0
- data/.rubocop.yml +16 -0
- data/.ruby-version +1 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/README.md +39 -0
- data/Rakefile +12 -0
- data/lib/daytona/code_toolbox/sandbox_python_code_toolbox.rb +439 -0
- data/lib/daytona/code_toolbox/sandbox_ts_code_toolbox.rb +23 -0
- data/lib/daytona/common/charts.rb +298 -0
- data/lib/daytona/common/code_language.rb +11 -0
- data/lib/daytona/common/daytona.rb +206 -0
- data/lib/daytona/common/file_system.rb +23 -0
- data/lib/daytona/common/git.rb +16 -0
- data/lib/daytona/common/image.rb +493 -0
- data/lib/daytona/common/process.rb +141 -0
- data/lib/daytona/common/pty.rb +306 -0
- data/lib/daytona/common/resources.rb +31 -0
- data/lib/daytona/common/response.rb +28 -0
- data/lib/daytona/common/snapshot.rb +110 -0
- data/lib/daytona/computer_use.rb +549 -0
- data/lib/daytona/config.rb +53 -0
- data/lib/daytona/daytona.rb +278 -0
- data/lib/daytona/file_system.rb +359 -0
- data/lib/daytona/git.rb +287 -0
- data/lib/daytona/lsp_server.rb +130 -0
- data/lib/daytona/object_storage.rb +169 -0
- data/lib/daytona/process.rb +484 -0
- data/lib/daytona/sandbox.rb +376 -0
- data/lib/daytona/sdk/version.rb +7 -0
- data/lib/daytona/sdk.rb +45 -0
- data/lib/daytona/snapshot_service.rb +198 -0
- data/lib/daytona/util.rb +56 -0
- data/lib/daytona/volume.rb +43 -0
- data/lib/daytona/volume_service.rb +49 -0
- data/sig/daytona/sdk.rbs +6 -0
- metadata +149 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'base64'
|
|
4
|
+
|
|
5
|
+
module Daytona
|
|
6
|
+
class SandboxTsCodeToolbox
|
|
7
|
+
# Get the run command for executing TypeScript code
|
|
8
|
+
#
|
|
9
|
+
# @param code [String] The TypeScript code to execute
|
|
10
|
+
# @param params [Daytona::CodeRunParams, nil] Optional parameters for code execution
|
|
11
|
+
# @return [String] The command to run the TypeScript code
|
|
12
|
+
def get_run_command(code, params = nil)
|
|
13
|
+
encoded_code = Base64.encode64(code)
|
|
14
|
+
|
|
15
|
+
argv = params&.argv&.join(' ') || ''
|
|
16
|
+
|
|
17
|
+
# Execute TypeScript code using ts-node with ESM support
|
|
18
|
+
" sh -c 'echo #{encoded_code} | base64 --decode | npx ts-node -O " \
|
|
19
|
+
"\"{\\\"module\\\":\\\"CommonJS\\\"}\" -e \"$(cat)\" x #{argv} 2>&1 | grep -vE " \
|
|
20
|
+
"\"npm notice\"' "
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Daytona
|
|
4
|
+
module Charts
|
|
5
|
+
# @param data [Hash<Symbol, Object>]
|
|
6
|
+
# @return [Daytona::Charts::Chart]
|
|
7
|
+
def self.parse(data)
|
|
8
|
+
case data.fetch(:type, ChartType::UNKNOWN)
|
|
9
|
+
when ChartType::LINE then LineChart.new(data)
|
|
10
|
+
when ChartType::SCATTER then ScatterChart.new(data)
|
|
11
|
+
when ChartType::BAR then BarChart.new(data)
|
|
12
|
+
when ChartType::PIE then PieChart.new(data)
|
|
13
|
+
when ChartType::BOX_AND_WHISKER then BoxAndWhiskerChart.new(data)
|
|
14
|
+
when ChartType::COMPOSITE_CHART then CompositeChart.new(data)
|
|
15
|
+
else
|
|
16
|
+
Chart.new(data)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class Chart
|
|
21
|
+
# @return [String, Nil] The type of chart
|
|
22
|
+
attr_reader :type
|
|
23
|
+
|
|
24
|
+
# @return [String, Nil] The title of the chart
|
|
25
|
+
attr_reader :title
|
|
26
|
+
|
|
27
|
+
# @return [Array<Object>] The elements of the chart
|
|
28
|
+
attr_reader :elements
|
|
29
|
+
|
|
30
|
+
# @return [String, Nil] The PNG representation of the chart encoded in base64
|
|
31
|
+
attr_reader :png
|
|
32
|
+
|
|
33
|
+
# @param data [Hash<Symbol, Object>]
|
|
34
|
+
def initialize(data)
|
|
35
|
+
@type = data.fetch(:type, nil)
|
|
36
|
+
@title = data.fetch(:title, nil)
|
|
37
|
+
@elements = data.fetch(:elements, [])
|
|
38
|
+
@png = data.fetch(:png, nil)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
# @return [Hash<Symbol, Object>] original metadata
|
|
42
|
+
def to_h = { type:, title:, elements:, png: }
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
class Chart2D < Chart
|
|
46
|
+
# @return [String, Nil] The label of the x-axis
|
|
47
|
+
attr_reader :x_label
|
|
48
|
+
|
|
49
|
+
# @return [String, Nil] The label of the y-axis
|
|
50
|
+
attr_reader :y_label
|
|
51
|
+
|
|
52
|
+
# @param data [Hash<Symbol, Object>]
|
|
53
|
+
def initialize(data)
|
|
54
|
+
super
|
|
55
|
+
@x_label = data.fetch(:x_label, nil)
|
|
56
|
+
@y_label = data.fetch(:y_label, nil)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# @return [Hash<Symbol, Object>] original metadata
|
|
60
|
+
def to_h = super.merge(x_label:, y_label:)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
class PointData
|
|
64
|
+
# @return [String] The label of the point series
|
|
65
|
+
attr_reader :label
|
|
66
|
+
|
|
67
|
+
# @return [Array<Array<Object>>] Array of [x, y] points
|
|
68
|
+
attr_reader :points
|
|
69
|
+
|
|
70
|
+
# @param data [Hash<Symbol, Object>]
|
|
71
|
+
def initialize(data)
|
|
72
|
+
@label = data.fetch(:label)
|
|
73
|
+
@points = data.fetch(:points)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
# @return [Hash<Symbol, Object>] original data representation
|
|
77
|
+
def to_h = { label:, points: }
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
class PointChart < Chart2D
|
|
81
|
+
# @return [Array<Object>] The ticks of the x-axis
|
|
82
|
+
attr_reader :x_ticks
|
|
83
|
+
|
|
84
|
+
# @return [Array<String>] The labels of the x-axis
|
|
85
|
+
attr_reader :x_tick_labels
|
|
86
|
+
|
|
87
|
+
# @return [String, Nil] The scale of the x-axis
|
|
88
|
+
attr_reader :x_scale
|
|
89
|
+
|
|
90
|
+
# @return [Array<Object>] The ticks of the y-axis
|
|
91
|
+
attr_reader :y_ticks
|
|
92
|
+
|
|
93
|
+
# @return [Array<String>] The labels of the y-axis
|
|
94
|
+
attr_reader :y_tick_labels
|
|
95
|
+
|
|
96
|
+
# @return [String, Nil] The scale of the y-axis
|
|
97
|
+
attr_reader :y_scale
|
|
98
|
+
|
|
99
|
+
# @return [Array<Daytona::Charts::PointData>] The points of the chart
|
|
100
|
+
attr_reader :elements
|
|
101
|
+
|
|
102
|
+
# @param data [Hash<Symbol, Object>]
|
|
103
|
+
def initialize(data)
|
|
104
|
+
super
|
|
105
|
+
@x_scale = data.fetch(:x_scale, nil)
|
|
106
|
+
@x_ticks = data.fetch(:x_ticks, nil)
|
|
107
|
+
@x_tick_labels = data.fetch(:x_tick_labels, nil)
|
|
108
|
+
|
|
109
|
+
@y_scale = data.fetch(:y_scale, nil)
|
|
110
|
+
@y_ticks = data.fetch(:y_ticks, nil)
|
|
111
|
+
@y_tick_labels = data.fetch(:y_tick_labels, nil)
|
|
112
|
+
|
|
113
|
+
@elements = data.fetch(:elements, []).map { |e| PointData.new(e) }
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
# @return [Hash<Symbol, Object>] original metadata
|
|
117
|
+
def to_h
|
|
118
|
+
super.merge(
|
|
119
|
+
x_scale:,
|
|
120
|
+
x_ticks:,
|
|
121
|
+
x_tick_labels:,
|
|
122
|
+
y_scale:,
|
|
123
|
+
y_ticks:,
|
|
124
|
+
y_tick_labels:,
|
|
125
|
+
elements: elements.map(&:to_h)
|
|
126
|
+
)
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
class LineChart < PointChart
|
|
131
|
+
def initialize(data)
|
|
132
|
+
super
|
|
133
|
+
@type = ChartType::LINE
|
|
134
|
+
end
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
class ScatterChart < PointChart
|
|
138
|
+
def initialize(data)
|
|
139
|
+
super
|
|
140
|
+
@type = ChartType::SCATTER
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
|
|
144
|
+
class BarData
|
|
145
|
+
# @return [String] The label of the bar
|
|
146
|
+
attr_reader :label
|
|
147
|
+
|
|
148
|
+
# @return [String] The value of the bar
|
|
149
|
+
attr_reader :value
|
|
150
|
+
|
|
151
|
+
# @return [String] The group of the bar
|
|
152
|
+
attr_reader :group
|
|
153
|
+
|
|
154
|
+
# @param data [Hash<Symbol, Object>]
|
|
155
|
+
def initialize(data)
|
|
156
|
+
@label = data.fetch(:label)
|
|
157
|
+
@value = data.fetch(:value)
|
|
158
|
+
@group = data.fetch(:group)
|
|
159
|
+
end
|
|
160
|
+
|
|
161
|
+
# @return [Hash<Symbol, Object>]
|
|
162
|
+
def to_h = { label:, value:, group: }
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
class BarChart < Chart2D
|
|
166
|
+
# @return [Array<Daytona::Charts::BarData>] The bars of the chart
|
|
167
|
+
attr_reader :elements
|
|
168
|
+
|
|
169
|
+
# @param data [Hash<Symbol, Object>]
|
|
170
|
+
def initialize(data)
|
|
171
|
+
super
|
|
172
|
+
@type = ChartType::BAR
|
|
173
|
+
@elements = data.fetch(:elements, []).map { |e| BarData.new(e) }
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
# @return [Hash<Symbol, Object>]
|
|
177
|
+
def to_h = super.merge(elements: elements.map(&:to_h))
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
class PieData
|
|
181
|
+
# @return [String] The label of the pie slice
|
|
182
|
+
attr_reader :label
|
|
183
|
+
|
|
184
|
+
# @return [Float] The angle of the pie slice
|
|
185
|
+
attr_reader :angle
|
|
186
|
+
|
|
187
|
+
# @return [Float] The radius of the pie slice
|
|
188
|
+
attr_reader :radius
|
|
189
|
+
|
|
190
|
+
# @return [Float] The autopct value of the pie slice
|
|
191
|
+
attr_reader :autopct
|
|
192
|
+
|
|
193
|
+
# @param data [Hash<Symbol, Object>]
|
|
194
|
+
def initialize(data)
|
|
195
|
+
@label = data.fetch(:label)
|
|
196
|
+
@angle = data.fetch(:angle)
|
|
197
|
+
@radius = data.fetch(:radius)
|
|
198
|
+
@autopct = data.fetch(:autopct)
|
|
199
|
+
end
|
|
200
|
+
|
|
201
|
+
# @return [Hash<Symbol, Object>]
|
|
202
|
+
def to_h = { label:, angle:, radius:, autopct: }
|
|
203
|
+
end
|
|
204
|
+
|
|
205
|
+
class PieChart < Chart
|
|
206
|
+
# @return [Array<Daytona::Charts::PieData>] The pie slices of the chart
|
|
207
|
+
attr_reader :elements
|
|
208
|
+
|
|
209
|
+
# @param data [Hash<Symbol, Object>]
|
|
210
|
+
def initialize(data)
|
|
211
|
+
super
|
|
212
|
+
@type = ChartType::PIE
|
|
213
|
+
@elements = data.fetch(:elements, []).map { |e| PieData.new(e) }
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
# @return [Hash<Symbol, Object>]
|
|
217
|
+
def to_h = super.merge(elements: elements.map(&:to_h))
|
|
218
|
+
end
|
|
219
|
+
|
|
220
|
+
class BoxAndWhiskerData
|
|
221
|
+
# @return [String] The label of the box and whisker
|
|
222
|
+
attr_reader :label
|
|
223
|
+
|
|
224
|
+
# @return [Float] The minimum value of the box and whisker
|
|
225
|
+
attr_reader :min
|
|
226
|
+
|
|
227
|
+
# @return [Float] The first quartile of the box and whisker
|
|
228
|
+
attr_reader :first_quartile
|
|
229
|
+
|
|
230
|
+
# @return [Float] The median of the box and whisker
|
|
231
|
+
attr_reader :median
|
|
232
|
+
|
|
233
|
+
# @return [Float] The third quartile of the box and whisker
|
|
234
|
+
attr_reader :third_quartile
|
|
235
|
+
|
|
236
|
+
# @return [Float] The maximum value of the box and whisker
|
|
237
|
+
attr_reader :max
|
|
238
|
+
|
|
239
|
+
# @return [Array<Float>] The outliers of the box and whisker
|
|
240
|
+
attr_reader :outliers
|
|
241
|
+
|
|
242
|
+
# @param data [Hash<Symbol, Object>]
|
|
243
|
+
def initialize(data)
|
|
244
|
+
@label = data.fetch(:label)
|
|
245
|
+
@min = data.fetch(:min)
|
|
246
|
+
@first_quartile = data.fetch(:first_quartile)
|
|
247
|
+
@median = data.fetch(:median)
|
|
248
|
+
@third_quartile = data.fetch(:third_quartile)
|
|
249
|
+
@max = data.fetch(:max)
|
|
250
|
+
@outliers = data.fetch(:outliers, [])
|
|
251
|
+
end
|
|
252
|
+
|
|
253
|
+
# @return [Hash<Symbol, Object>]
|
|
254
|
+
def to_h = { label:, min:, first_quartile:, median:, third_quartile:, max:, outliers: }
|
|
255
|
+
end
|
|
256
|
+
|
|
257
|
+
class BoxAndWhiskerChart < Chart2D
|
|
258
|
+
# @return [Array<Daytona::Charts::BoxAndWhiskerData>] The box and whiskers of the chart
|
|
259
|
+
attr_reader :elements
|
|
260
|
+
|
|
261
|
+
# @param data [Hash<Symbol, Object>]
|
|
262
|
+
def initialize(data)
|
|
263
|
+
super
|
|
264
|
+
@type = ChartType::BOX_AND_WHISKER
|
|
265
|
+
@elements = data.fetch(:elements, []).map { |e| BoxAndWhiskerData.new(e) }
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
# @return [Hash<Symbol, Object>]
|
|
269
|
+
def to_h = super.merge(elements: elements.map(&:to_h))
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
class CompositeChart < Chart
|
|
273
|
+
# @return [Array<Daytona::Charts::Chart>] The charts of the composite chart
|
|
274
|
+
attr_reader :elements
|
|
275
|
+
|
|
276
|
+
# @param data [Hash<Symbol, Object>]
|
|
277
|
+
def initialize(data)
|
|
278
|
+
super
|
|
279
|
+
@type = ChartType::COMPOSITE_CHART
|
|
280
|
+
@elements = data.fetch(:elements, []).map { |e| Charts.parse(e) }
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
def to_h = super.merge(elements: elements.map(&:to_h))
|
|
284
|
+
end
|
|
285
|
+
|
|
286
|
+
module ChartType
|
|
287
|
+
ALL = [
|
|
288
|
+
LINE = 'line',
|
|
289
|
+
SCATTER = 'scatter',
|
|
290
|
+
BAR = 'bar',
|
|
291
|
+
PIE = 'pie',
|
|
292
|
+
BOX_AND_WHISKER = 'box_and_whisker',
|
|
293
|
+
COMPOSITE_CHART = 'composite_chart',
|
|
294
|
+
UNKNOWN = 'unknown'
|
|
295
|
+
].freeze
|
|
296
|
+
end
|
|
297
|
+
end
|
|
298
|
+
end
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Daytona
|
|
4
|
+
class CreateSandboxBaseParams
|
|
5
|
+
# @return [Symbol, nil] Programming language for the Sandbox
|
|
6
|
+
attr_accessor :language
|
|
7
|
+
|
|
8
|
+
# @return [String, nil] OS user for the Sandbox
|
|
9
|
+
attr_accessor :os_user
|
|
10
|
+
|
|
11
|
+
# @return [Hash<String, String>, nil] Environment variables to set in the Sandbox
|
|
12
|
+
attr_accessor :env_vars
|
|
13
|
+
|
|
14
|
+
# @return [Hash<String, String>, nil] Custom labels for the Sandbox
|
|
15
|
+
attr_accessor :labels
|
|
16
|
+
|
|
17
|
+
# @return [Boolean, nil] Whether the Sandbox should be public
|
|
18
|
+
attr_accessor :public
|
|
19
|
+
|
|
20
|
+
# @return [Float, nil] Timeout in seconds for Sandbox to be created and started
|
|
21
|
+
attr_accessor :timeout
|
|
22
|
+
|
|
23
|
+
# @return [Integer, nil] Auto-stop interval in minutes
|
|
24
|
+
attr_accessor :auto_stop_interval
|
|
25
|
+
|
|
26
|
+
# @return [Integer, nil] Auto-archive interval in minutes
|
|
27
|
+
attr_accessor :auto_archive_interval
|
|
28
|
+
|
|
29
|
+
# @return [Integer, nil] Auto-delete interval in minutes
|
|
30
|
+
attr_accessor :auto_delete_interval
|
|
31
|
+
|
|
32
|
+
# @return [Array<DaytonaApiClient::SandboxVolume>, nil] List of volumes mounts to attach to the Sandbox
|
|
33
|
+
attr_accessor :volumes
|
|
34
|
+
|
|
35
|
+
# @return [Boolean, nil] Whether to block all network access for the Sandbox
|
|
36
|
+
attr_accessor :network_block_all
|
|
37
|
+
|
|
38
|
+
# @return [String, nil] Comma-separated list of allowed CIDR network addresses for the Sandbox
|
|
39
|
+
attr_accessor :network_allow_list
|
|
40
|
+
|
|
41
|
+
# @return [Boolean, nil] Whether the Sandbox should be ephemeral
|
|
42
|
+
attr_accessor :ephemeral
|
|
43
|
+
|
|
44
|
+
# Initialize CreateSandboxBaseParams
|
|
45
|
+
#
|
|
46
|
+
# @param language [Symbol, nil] Programming language for the Sandbox
|
|
47
|
+
# @param os_user [String, nil] OS user for the Sandbox
|
|
48
|
+
# @param env_vars [Hash<String, String>, nil] Environment variables to set in the Sandbox
|
|
49
|
+
# @param labels [Hash<String, String>, nil] Custom labels for the Sandbox
|
|
50
|
+
# @param public [Boolean, nil] Whether the Sandbox should be public
|
|
51
|
+
# @param timeout [Float, nil] Timeout in seconds for Sandbox to be created and started
|
|
52
|
+
# @param auto_stop_interval [Integer, nil] Auto-stop interval in minutes
|
|
53
|
+
# @param auto_archive_interval [Integer, nil] Auto-archive interval in minutes
|
|
54
|
+
# @param auto_delete_interval [Integer, nil] Auto-delete interval in minutes
|
|
55
|
+
# @param volumes [Array<DaytonaApiClient::SandboxVolume>, nil] List of volumes mounts to attach to the Sandbox
|
|
56
|
+
# @param network_block_all [Boolean, nil] Whether to block all network access for the Sandbox
|
|
57
|
+
# @param network_allow_list [String, nil] Comma-separated list of allowed CIDR network addresses for the Sandbox
|
|
58
|
+
# @param ephemeral [Boolean, nil] Whether the Sandbox should be ephemeral
|
|
59
|
+
def initialize( # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists
|
|
60
|
+
language: nil,
|
|
61
|
+
os_user: nil,
|
|
62
|
+
env_vars: nil,
|
|
63
|
+
labels: nil,
|
|
64
|
+
public: nil,
|
|
65
|
+
timeout: nil,
|
|
66
|
+
auto_stop_interval: nil,
|
|
67
|
+
auto_archive_interval: nil,
|
|
68
|
+
auto_delete_interval: nil,
|
|
69
|
+
volumes: nil,
|
|
70
|
+
network_block_all: nil,
|
|
71
|
+
network_allow_list: nil,
|
|
72
|
+
ephemeral: nil
|
|
73
|
+
)
|
|
74
|
+
@language = language
|
|
75
|
+
@os_user = os_user
|
|
76
|
+
@env_vars = env_vars
|
|
77
|
+
@labels = labels
|
|
78
|
+
@public = public
|
|
79
|
+
@timeout = timeout
|
|
80
|
+
@auto_stop_interval = auto_stop_interval
|
|
81
|
+
@auto_archive_interval = auto_archive_interval
|
|
82
|
+
@auto_delete_interval = auto_delete_interval
|
|
83
|
+
@volumes = volumes
|
|
84
|
+
@network_block_all = network_block_all
|
|
85
|
+
@network_allow_list = network_allow_list
|
|
86
|
+
@ephemeral = ephemeral
|
|
87
|
+
|
|
88
|
+
# Handle ephemeral and auto_delete_interval conflict
|
|
89
|
+
handle_ephemeral_auto_delete_conflict
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
# Convert to hash representation
|
|
93
|
+
#
|
|
94
|
+
# @return [Hash<Symbol, Object>] Hash representation of the parameters
|
|
95
|
+
def to_h # rubocop:disable Metrics/MethodLength
|
|
96
|
+
{
|
|
97
|
+
language:,
|
|
98
|
+
os_user:,
|
|
99
|
+
env_vars:,
|
|
100
|
+
labels:,
|
|
101
|
+
public:,
|
|
102
|
+
timeout:,
|
|
103
|
+
auto_stop_interval:,
|
|
104
|
+
auto_archive_interval:,
|
|
105
|
+
auto_delete_interval:,
|
|
106
|
+
volumes:,
|
|
107
|
+
network_block_all:,
|
|
108
|
+
network_allow_list:,
|
|
109
|
+
ephemeral:
|
|
110
|
+
}.compact
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
private
|
|
114
|
+
|
|
115
|
+
# Handle the conflict between ephemeral and auto_delete_interval
|
|
116
|
+
#
|
|
117
|
+
# @return [void]
|
|
118
|
+
def handle_ephemeral_auto_delete_conflict
|
|
119
|
+
return unless ephemeral && auto_delete_interval && !auto_delete_interval.zero?
|
|
120
|
+
|
|
121
|
+
warn(
|
|
122
|
+
"'ephemeral' and 'auto_delete_interval' cannot be used together. " \
|
|
123
|
+
'If ephemeral is true, auto_delete_interval will be ignored and set to 0.'
|
|
124
|
+
)
|
|
125
|
+
@auto_delete_interval = 0
|
|
126
|
+
end
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
class CreateSandboxFromImageParams < CreateSandboxBaseParams
|
|
130
|
+
# @return [String, Image] Custom Docker image to use for the Sandbox. If an Image object is provided,
|
|
131
|
+
# the image will be dynamically built.
|
|
132
|
+
attr_accessor :image
|
|
133
|
+
|
|
134
|
+
# @return [Daytona::Resources, nil] Resource configuration for the Sandbox. If not provided, sandbox will
|
|
135
|
+
# have default resources.
|
|
136
|
+
attr_accessor :resources
|
|
137
|
+
|
|
138
|
+
# Initialize CreateSandboxFromImageParams
|
|
139
|
+
#
|
|
140
|
+
# @param image [String, Image] Custom Docker image to use for the Sandbox
|
|
141
|
+
# @param resources [Daytona::Resources, nil] Resource configuration for the Sandbox
|
|
142
|
+
# @param language [Symbol, nil] Programming language for the Sandbox
|
|
143
|
+
# @param os_user [String, nil] OS user for the Sandbox
|
|
144
|
+
# @param env_vars [Hash<String, String>, nil] Environment variables to set in the Sandbox
|
|
145
|
+
# @param labels [Hash<String, String>, nil] Custom labels for the Sandbox
|
|
146
|
+
# @param public [Boolean, nil] Whether the Sandbox should be public
|
|
147
|
+
# @param timeout [Float, nil] Timeout in seconds for Sandbox to be created and started
|
|
148
|
+
# @param auto_stop_interval [Integer, nil] Auto-stop interval in minutes
|
|
149
|
+
# @param auto_archive_interval [Integer, nil] Auto-archive interval in minutes
|
|
150
|
+
# @param auto_delete_interval [Integer, nil] Auto-delete interval in minutes
|
|
151
|
+
# @param volumes [Array<DaytonaApiClient::SandboxVolume>, nil] List of volumes mounts to attach to the Sandbox
|
|
152
|
+
# @param network_block_all [Boolean, nil] Whether to block all network access for the Sandbox
|
|
153
|
+
# @param network_allow_list [String, nil] Comma-separated list of allowed CIDR network addresses for the Sandbox
|
|
154
|
+
# @param ephemeral [Boolean, nil] Whether the Sandbox should be ephemeral
|
|
155
|
+
def initialize(image:, resources: nil, **args)
|
|
156
|
+
@image = image
|
|
157
|
+
@resources = resources
|
|
158
|
+
|
|
159
|
+
super(**args)
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
# Convert to hash representation
|
|
163
|
+
#
|
|
164
|
+
# @return [Hash<Symbol, Object>] Hash representation of the parameters
|
|
165
|
+
def to_h
|
|
166
|
+
super.merge(
|
|
167
|
+
image:,
|
|
168
|
+
resources: resources&.to_h
|
|
169
|
+
).compact
|
|
170
|
+
end
|
|
171
|
+
end
|
|
172
|
+
|
|
173
|
+
class CreateSandboxFromSnapshotParams < CreateSandboxBaseParams
|
|
174
|
+
# @return [String, nil] Name of the snapshot to use for the Sandbox
|
|
175
|
+
attr_accessor :snapshot
|
|
176
|
+
|
|
177
|
+
# Initialize CreateSandboxFromSnapshotParams
|
|
178
|
+
#
|
|
179
|
+
# @param snapshot [String, nil] Name of the snapshot to use for the Sandbox
|
|
180
|
+
# @param language [Symbol, nil] Programming language for the Sandbox
|
|
181
|
+
# @param os_user [String, nil] OS user for the Sandbox
|
|
182
|
+
# @param env_vars [Hash<String, String>, nil] Environment variables to set in the Sandbox
|
|
183
|
+
# @param labels [Hash<String, String>, nil] Custom labels for the Sandbox
|
|
184
|
+
# @param public [Boolean, nil] Whether the Sandbox should be public
|
|
185
|
+
# @param timeout [Float, nil] Timeout in seconds for Sandbox to be created and started
|
|
186
|
+
# @param auto_stop_interval [Integer, nil] Auto-stop interval in minutes
|
|
187
|
+
# @param auto_archive_interval [Integer, nil] Auto-archive interval in minutes
|
|
188
|
+
# @param auto_delete_interval [Integer, nil] Auto-delete interval in minutes
|
|
189
|
+
# @param volumes [Array<DaytonaApiClient::SandboxVolume>, nil] List of volumes mounts to attach to the Sandbox
|
|
190
|
+
# @param network_block_all [Boolean, nil] Whether to block all network access for the Sandbox
|
|
191
|
+
# @param network_allow_list [String, nil] Comma-separated list of allowed CIDR network addresses for the Sandbox
|
|
192
|
+
# @param ephemeral [Boolean, nil] Whether the Sandbox should be ephemeral
|
|
193
|
+
def initialize(snapshot: nil, **args)
|
|
194
|
+
@snapshot = snapshot
|
|
195
|
+
|
|
196
|
+
super(**args)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# Convert to hash representation
|
|
200
|
+
#
|
|
201
|
+
# @return [Hash<Symbol, Object>] Hash representation of the parameters
|
|
202
|
+
def to_h
|
|
203
|
+
super.merge(snapshot:).compact
|
|
204
|
+
end
|
|
205
|
+
end
|
|
206
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Daytona
|
|
4
|
+
class FileUpload
|
|
5
|
+
# @return [String, IO] File contents as a string/bytes object or a local file path or IO object.
|
|
6
|
+
# If a string path is provided, the file content will be read from disk.
|
|
7
|
+
# If a string content is provided, make sure it fits into memory.
|
|
8
|
+
attr_reader :source
|
|
9
|
+
|
|
10
|
+
# @return [String] Absolute destination path in the Sandbox. Relative paths are resolved based on
|
|
11
|
+
# the sandbox working directory.
|
|
12
|
+
attr_reader :destination
|
|
13
|
+
|
|
14
|
+
# Initializes a new FileUpload instance.
|
|
15
|
+
#
|
|
16
|
+
# @param source [String, IO] File contents as a string/bytes object or a local file path or IO object.
|
|
17
|
+
# @param destination [String] Absolute destination path in the Sandbox.
|
|
18
|
+
def initialize(source, destination)
|
|
19
|
+
@source = source
|
|
20
|
+
@destination = destination
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Daytona
|
|
4
|
+
# Response from the git commit.
|
|
5
|
+
class GitCommitResponse
|
|
6
|
+
# @return [String] The SHA of the commit
|
|
7
|
+
attr_reader :sha
|
|
8
|
+
|
|
9
|
+
# Initialize a new GitCommitResponse
|
|
10
|
+
#
|
|
11
|
+
# @param sha [String] The SHA of the commit
|
|
12
|
+
def initialize(sha:)
|
|
13
|
+
@sha = sha
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|