daytona 0.223.0 → 0.224.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 +4 -4
- data/README.md +15 -1
- data/lib/daytona/common/daytona.rb +12 -2
- data/lib/daytona/common/snapshot.rb +2 -1
- data/lib/daytona/config.rb +4 -2
- data/lib/daytona/daytona.rb +1 -1
- data/lib/daytona/process.rb +20 -3
- data/lib/daytona/sandbox.rb +36 -3
- data/lib/daytona/sdk/version.rb +1 -1
- data/lib/daytona/snapshot_service.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9073174dfdaf41ddfeeff8c273346f9802806c7e39025f7efdf07eb5aaf32395
|
|
4
|
+
data.tar.gz: 27dcffd7cbeba0eabb88148108c5467995f16abb709820511c43a17a5568d8d5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 958b391e87200ff87e0f643f3ddd66901b82d47528aaa2ec6986ea3726ac64e26474b3456a07146adb496c857daf3ca978c5a0793d954891cf350314ed0761fa
|
|
7
|
+
data.tar.gz: 381ecfdc0266799593abc3dc3aebbce9c077e41102852456c089f32e81f7992e4bad86231300378d6da5953edf78432f83d214cb288ebff0343fab755e274c25
|
data/README.md
CHANGED
|
@@ -30,7 +30,7 @@ Configure the SDK using [environment variables](https://www.daytona.io/docs/en/c
|
|
|
30
30
|
|
|
31
31
|
- `DAYTONA_API_KEY`: Your Daytona [API key](https://www.daytona.io/docs/en/api-keys/)
|
|
32
32
|
- `DAYTONA_API_URL`: The Daytona [API URL](https://www.daytona.io/docs/en/tools/api/)
|
|
33
|
-
- `DAYTONA_TARGET`:
|
|
33
|
+
- `DAYTONA_TARGET`: Default [region](https://www.daytona.io/docs/en/regions/) for sandboxes and snapshots (e.g. `us`, `eu`); a per-call `target:` / `region_id:` overrides it
|
|
34
34
|
|
|
35
35
|
```ruby
|
|
36
36
|
require 'daytona'
|
|
@@ -62,6 +62,20 @@ sandbox = daytona.create
|
|
|
62
62
|
|
|
63
63
|
Daytona provides [examples](https://www.daytona.io/docs/en/getting-started/#examples) and [guides](https://www.daytona.io/docs/en/guides/) for common sandbox operations, best practices, and a wide range of topics, from basic usage to advanced topics, showcasing various types of integrations between Daytona and other tools.
|
|
64
64
|
|
|
65
|
+
### Create a sandbox or snapshot in a specific region
|
|
66
|
+
|
|
67
|
+
Pass `target:` in the sandbox create params, or `region_id:` in the snapshot create params, to choose the [region](https://www.daytona.io/docs/en/regions/) for that call. The region is resolved per call: the per-call value, then the client-level `target` (or `DAYTONA_TARGET`), then the organization's default region.
|
|
68
|
+
|
|
69
|
+
```ruby
|
|
70
|
+
require 'daytona'
|
|
71
|
+
|
|
72
|
+
daytona = Daytona::Daytona.new
|
|
73
|
+
sandbox = daytona.create(Daytona::CreateSandboxFromSnapshotParams.new(target: 'eu'))
|
|
74
|
+
snapshot = daytona.snapshot.create(
|
|
75
|
+
Daytona::CreateSnapshotParams.new(name: 'my-snapshot', image: 'python:3.12', region_id: 'eu')
|
|
76
|
+
)
|
|
77
|
+
```
|
|
78
|
+
|
|
65
79
|
### Create a sandbox with custom resources
|
|
66
80
|
|
|
67
81
|
Create a sandbox with [custom resources](https://www.daytona.io/docs/en/sandboxes/#resources) (CPU, memory, disk).
|
|
@@ -86,6 +86,11 @@ module Daytona
|
|
|
86
86
|
# ephemeral (auto_delete_interval=0) and cannot themselves be linked to another Sandbox.
|
|
87
87
|
attr_accessor :linked_sandbox
|
|
88
88
|
|
|
89
|
+
# @return [String, nil] Target (region) where the Sandbox is created. Overrides the client-level
|
|
90
|
+
# target for this call. If omitted, uses the client-level target when set; otherwise the
|
|
91
|
+
# organization's default region.
|
|
92
|
+
attr_accessor :target
|
|
93
|
+
|
|
89
94
|
# Initialize CreateSandboxBaseParams
|
|
90
95
|
#
|
|
91
96
|
# @param language [Symbol, nil] Programming language for the Sandbox
|
|
@@ -118,6 +123,8 @@ module Daytona
|
|
|
118
123
|
# @param spot [Boolean, nil] GPU-only. Whether the Sandbox may be instantly terminated to free GPU
|
|
119
124
|
# capacity for an on-demand GPU Sandbox
|
|
120
125
|
# @param linked_sandbox [String, nil] ID or name of an existing Sandbox to link the new Sandbox to
|
|
126
|
+
# @param target [String, nil] Target (region) where the Sandbox is created. Overrides the client-level
|
|
127
|
+
# target for this call.
|
|
121
128
|
def initialize( # rubocop:disable Metrics/MethodLength, Metrics/ParameterLists
|
|
122
129
|
language: nil,
|
|
123
130
|
os_user: nil,
|
|
@@ -141,7 +148,8 @@ module Daytona
|
|
|
141
148
|
otel_endpoint_override: nil,
|
|
142
149
|
ephemeral: nil,
|
|
143
150
|
spot: nil,
|
|
144
|
-
linked_sandbox: nil
|
|
151
|
+
linked_sandbox: nil,
|
|
152
|
+
target: nil
|
|
145
153
|
)
|
|
146
154
|
@language = language
|
|
147
155
|
@os_user = os_user
|
|
@@ -166,6 +174,7 @@ module Daytona
|
|
|
166
174
|
@ephemeral = ephemeral
|
|
167
175
|
@spot = spot
|
|
168
176
|
@linked_sandbox = linked_sandbox
|
|
177
|
+
@target = target
|
|
169
178
|
|
|
170
179
|
# Handle ephemeral and auto_delete_interval conflict
|
|
171
180
|
handle_ephemeral_auto_delete_conflict
|
|
@@ -198,7 +207,8 @@ module Daytona
|
|
|
198
207
|
otel_endpoint_override:,
|
|
199
208
|
ephemeral:,
|
|
200
209
|
spot:,
|
|
201
|
-
linked_sandbox
|
|
210
|
+
linked_sandbox:,
|
|
211
|
+
target:
|
|
202
212
|
}.compact
|
|
203
213
|
end
|
|
204
214
|
|
|
@@ -30,7 +30,8 @@ module Daytona
|
|
|
30
30
|
# @param image [String, Daytona::Image] Image of the snapshot
|
|
31
31
|
# @param resources [Daytona::Resources, nil] Resources of the snapshot
|
|
32
32
|
# @param entrypoint [Array<String>, nil] Entrypoint of the snapshot
|
|
33
|
-
# @param region_id [String, nil] ID of the region where the snapshot will be available
|
|
33
|
+
# @param region_id [String, nil] ID of the region where the snapshot will be available. If omitted, uses
|
|
34
|
+
# the client-level target when set; otherwise the organization's default region.
|
|
34
35
|
# @param sandbox_class [DaytonaApiClient::SandboxClass, nil] Target sandbox class
|
|
35
36
|
def initialize(name:, image:, resources: nil, entrypoint: nil, region_id: nil, sandbox_class: nil)
|
|
36
37
|
@name = name
|
data/lib/daytona/config.rb
CHANGED
|
@@ -77,7 +77,8 @@ module Daytona
|
|
|
77
77
|
# @return [String, nil] Daytona API URL
|
|
78
78
|
attr_accessor :organization_id
|
|
79
79
|
|
|
80
|
-
#
|
|
80
|
+
# Default region for Sandboxes and Snapshots. A per-call `target:` (Sandbox create params) or
|
|
81
|
+
# `region_id:` (Snapshot create params) overrides it.
|
|
81
82
|
#
|
|
82
83
|
# @return [String, nil] Daytona target
|
|
83
84
|
attr_accessor :target
|
|
@@ -108,7 +109,8 @@ module Daytona
|
|
|
108
109
|
# @param jwt_token [String, nil] Daytona JWT token. Defaults to ENV['DAYTONA_JWT_TOKEN'].
|
|
109
110
|
# @param api_url [String, nil] Daytona API URL. Defaults to ENV['DAYTONA_API_URL'] or Daytona::Config::API_URL.
|
|
110
111
|
# @param organization_id [String, nil] Daytona organization ID. Defaults to ENV['DAYTONA_ORGANIZATION_ID'].
|
|
111
|
-
# @param target [String, nil]
|
|
112
|
+
# @param target [String, nil] Default region for Sandboxes and Snapshots; a per-call `target:` / `region_id:`
|
|
113
|
+
# overrides it. Defaults to ENV['DAYTONA_TARGET'].
|
|
112
114
|
# @param otel_enabled [Boolean, nil] Enable OpenTelemetry tracing for SDK operations.
|
|
113
115
|
# @param use_deprecated_polling [Boolean, nil] Observe sandbox state by legacy polling instead of
|
|
114
116
|
# WebSocket event streaming. Defaults to false (event streaming). Can also be enabled via the
|
data/lib/daytona/daytona.rb
CHANGED
|
@@ -286,7 +286,7 @@ module Daytona
|
|
|
286
286
|
env: params.env_vars || {},
|
|
287
287
|
labels: labels,
|
|
288
288
|
public: params.public,
|
|
289
|
-
target: config.target,
|
|
289
|
+
target: params.target.to_s.empty? ? config.target : params.target,
|
|
290
290
|
auto_stop_interval: params.auto_stop_interval,
|
|
291
291
|
auto_pause_interval: params.auto_pause_interval,
|
|
292
292
|
auto_archive_interval: params.auto_archive_interval,
|
data/lib/daytona/process.rb
CHANGED
|
@@ -40,6 +40,20 @@ module Daytona
|
|
|
40
40
|
|
|
41
41
|
# Execute a shell command in the Sandbox
|
|
42
42
|
#
|
|
43
|
+
# The command is run by the first available of zsh, bash or sh in the sandbox, which is zsh
|
|
44
|
+
# in the default snapshots. Quote arguments that contain glob characters, for example
|
|
45
|
+
# `pip install -e '.[test]'`, or wrap bash-specific scripts in `bash -c '...'`.
|
|
46
|
+
#
|
|
47
|
+
# The call returns when the command finishes. To start a long-running process such as a
|
|
48
|
+
# server, run it in the background with its output redirected, e.g.
|
|
49
|
+
# `python3 -m http.server 8000 > server.log 2>&1 &`, or use a session with `run_async: true`
|
|
50
|
+
# (see {#execute_session_command}). A background process that keeps the command's output open
|
|
51
|
+
# (`cmd &` without a redirect) can block the call until that process exits.
|
|
52
|
+
#
|
|
53
|
+
# Tools in the sandbox may report the host's CPU count and memory (for example `nproc` or
|
|
54
|
+
# `Etc.nprocessors`) rather than the sandbox's own limits. Size worker pools from the
|
|
55
|
+
# sandbox's cpu and memory instead, e.g. `pytest -n 2` rather than `pytest -n auto`.
|
|
56
|
+
#
|
|
43
57
|
# @param command [String] Shell command to execute
|
|
44
58
|
# @param cwd [String, nil] Working directory for command execution. If not specified, uses the sandbox working directory
|
|
45
59
|
# @param env [Hash<String, String>, nil] Environment variables to set for the command
|
|
@@ -48,15 +62,18 @@ module Daytona
|
|
|
48
62
|
#
|
|
49
63
|
# @example
|
|
50
64
|
# # Simple command
|
|
51
|
-
# response = sandbox.process.exec("echo 'Hello'")
|
|
65
|
+
# response = sandbox.process.exec(command: "echo 'Hello'")
|
|
52
66
|
# puts response.artifacts.stdout
|
|
53
67
|
# => "Hello\n"
|
|
54
68
|
#
|
|
55
69
|
# # Command with working directory
|
|
56
|
-
# result = sandbox.process.exec("ls", cwd: "workspace/src")
|
|
70
|
+
# result = sandbox.process.exec(command: "ls", cwd: "workspace/src")
|
|
57
71
|
#
|
|
58
72
|
# # Command with timeout
|
|
59
|
-
# result = sandbox.process.exec("sleep 10", timeout: 5)
|
|
73
|
+
# result = sandbox.process.exec(command: "sleep 10", timeout: 5)
|
|
74
|
+
#
|
|
75
|
+
# # Start a server in the background
|
|
76
|
+
# sandbox.process.exec(command: "python3 -m http.server 8000 > server.log 2>&1 &")
|
|
60
77
|
def exec(command:, cwd: nil, env: nil, timeout: nil)
|
|
61
78
|
envs = env&.empty? ? nil : env
|
|
62
79
|
|
data/lib/daytona/sandbox.rb
CHANGED
|
@@ -364,6 +364,21 @@ module Daytona
|
|
|
364
364
|
process_response(data)
|
|
365
365
|
end
|
|
366
366
|
|
|
367
|
+
# Sets whether the Sandbox's preview URLs are publicly accessible.
|
|
368
|
+
# When public, preview URLs (see #preview_url) can be opened without a preview token or API key.
|
|
369
|
+
# When private, every preview request must authenticate.
|
|
370
|
+
#
|
|
371
|
+
# @param is_public [Boolean]
|
|
372
|
+
# @return [Boolean]
|
|
373
|
+
# @raise [Daytona::Sdk::Error]
|
|
374
|
+
#
|
|
375
|
+
# @example
|
|
376
|
+
# sandbox.public = true
|
|
377
|
+
def public=(is_public)
|
|
378
|
+
sandbox_api.update_public_status(id, is_public)
|
|
379
|
+
@public = is_public
|
|
380
|
+
end
|
|
381
|
+
|
|
367
382
|
# Sets the auto-stop interval for the Sandbox.
|
|
368
383
|
# The Sandbox will automatically stop after being idle (no new events) for the specified interval.
|
|
369
384
|
# Events include any state changes or interactions with the Sandbox through the SDK.
|
|
@@ -555,8 +570,21 @@ module Daytona
|
|
|
555
570
|
# it will be opened automatically. For private sandboxes, a token is included to grant access
|
|
556
571
|
# to the URL.
|
|
557
572
|
#
|
|
573
|
+
# For a private sandbox, requests to the URL must authenticate, otherwise they are answered
|
|
574
|
+
# with 401 Unauthorized. Send the returned token in the X-Daytona-Preview-Token header, or
|
|
575
|
+
# send your Daytona API key as "Authorization: Bearer <api key>". To get a URL that works
|
|
576
|
+
# without extra headers (for example to open it in a browser or share it), use
|
|
577
|
+
# {#create_signed_preview_url} instead. Public sandboxes need no credentials.
|
|
578
|
+
#
|
|
558
579
|
# @param port [Integer]
|
|
559
580
|
# @return [DaytonaApiClient::PortPreviewUrl]
|
|
581
|
+
#
|
|
582
|
+
# @example
|
|
583
|
+
# preview = sandbox.preview_url(3000)
|
|
584
|
+
# uri = URI(preview.url)
|
|
585
|
+
# request = Net::HTTP::Get.new(uri)
|
|
586
|
+
# request['X-Daytona-Preview-Token'] = preview.token
|
|
587
|
+
# response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) { |http| http.request(request) }
|
|
560
588
|
def preview_url(port)
|
|
561
589
|
sandbox_api.get_port_preview_url(id, port)
|
|
562
590
|
end
|
|
@@ -633,9 +661,14 @@ module Daytona
|
|
|
633
661
|
|
|
634
662
|
# Creates a signed preview URL for the sandbox at the specified port.
|
|
635
663
|
#
|
|
664
|
+
# The access token is embedded in the returned URL, so it can be used without any headers,
|
|
665
|
+
# for example in a browser or by another service. The URL stops working when it expires or
|
|
666
|
+
# when it is expired with {#expire_signed_preview_url}.
|
|
667
|
+
#
|
|
636
668
|
# @param port [Integer] The port to open the preview link on
|
|
637
669
|
# @param expires_in_seconds [Integer, nil] The number of seconds the signed preview URL
|
|
638
|
-
# will be valid for. Defaults to 60 seconds
|
|
670
|
+
# will be valid for. Defaults to 60 seconds; set a longer value for links that need to
|
|
671
|
+
# stay usable, e.g. 3600 for one hour.
|
|
639
672
|
# @return [DaytonaApiClient::SignedPortPreviewUrl] The signed preview URL response object
|
|
640
673
|
#
|
|
641
674
|
# @example
|
|
@@ -951,7 +984,7 @@ module Daytona
|
|
|
951
984
|
end
|
|
952
985
|
end
|
|
953
986
|
|
|
954
|
-
with_events :archive, :auto_archive_interval=, :auto_delete_interval=, :auto_stop_interval=,
|
|
987
|
+
with_events :archive, :auto_archive_interval=, :auto_delete_interval=, :auto_stop_interval=, :public=,
|
|
955
988
|
:create_ssh_access, :delete, :get_user_home_dir, :get_work_dir, :labels=,
|
|
956
989
|
:preview_url, :create_signed_preview_url, :expire_signed_preview_url,
|
|
957
990
|
:refresh, :refresh_activity, :revoke_ssh_access, :start, :recover, :stop,
|
|
@@ -960,7 +993,7 @@ module Daytona
|
|
|
960
993
|
:fork, :create_snapshot, :pause
|
|
961
994
|
|
|
962
995
|
instrument :archive, :auto_archive_interval=, :auto_delete_interval=, :auto_pause_interval=, :auto_stop_interval=,
|
|
963
|
-
:ttl_minutes=,
|
|
996
|
+
:ttl_minutes=, :public=,
|
|
964
997
|
:update_network_settings, :update_secrets, :update_env,
|
|
965
998
|
:create_ssh_access, :delete, :get_user_home_dir, :get_work_dir, :get_metrics, :get_metrics_latest,
|
|
966
999
|
:labels=,
|
data/lib/daytona/sdk/version.rb
CHANGED
|
@@ -117,7 +117,7 @@ module Daytona
|
|
|
117
117
|
create_snapshot_req.disk = params.resources.disk
|
|
118
118
|
end
|
|
119
119
|
|
|
120
|
-
create_snapshot_req.region_id = params.region_id
|
|
120
|
+
create_snapshot_req.region_id = params.region_id.to_s.empty? ? @default_region_id : params.region_id
|
|
121
121
|
create_snapshot_req.sandbox_class = params.sandbox_class
|
|
122
122
|
|
|
123
123
|
snapshot = snapshots_api.create_snapshot(create_snapshot_req)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: daytona
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.224.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daytona Platforms Inc.
|
|
@@ -91,42 +91,42 @@ dependencies:
|
|
|
91
91
|
requirements:
|
|
92
92
|
- - '='
|
|
93
93
|
- !ruby/object:Gem::Version
|
|
94
|
-
version: 0.
|
|
94
|
+
version: 0.224.0
|
|
95
95
|
type: :runtime
|
|
96
96
|
prerelease: false
|
|
97
97
|
version_requirements: !ruby/object:Gem::Requirement
|
|
98
98
|
requirements:
|
|
99
99
|
- - '='
|
|
100
100
|
- !ruby/object:Gem::Version
|
|
101
|
-
version: 0.
|
|
101
|
+
version: 0.224.0
|
|
102
102
|
- !ruby/object:Gem::Dependency
|
|
103
103
|
name: daytona_api_client
|
|
104
104
|
requirement: !ruby/object:Gem::Requirement
|
|
105
105
|
requirements:
|
|
106
106
|
- - '='
|
|
107
107
|
- !ruby/object:Gem::Version
|
|
108
|
-
version: 0.
|
|
108
|
+
version: 0.224.0
|
|
109
109
|
type: :runtime
|
|
110
110
|
prerelease: false
|
|
111
111
|
version_requirements: !ruby/object:Gem::Requirement
|
|
112
112
|
requirements:
|
|
113
113
|
- - '='
|
|
114
114
|
- !ruby/object:Gem::Version
|
|
115
|
-
version: 0.
|
|
115
|
+
version: 0.224.0
|
|
116
116
|
- !ruby/object:Gem::Dependency
|
|
117
117
|
name: daytona_toolbox_api_client
|
|
118
118
|
requirement: !ruby/object:Gem::Requirement
|
|
119
119
|
requirements:
|
|
120
120
|
- - '='
|
|
121
121
|
- !ruby/object:Gem::Version
|
|
122
|
-
version: 0.
|
|
122
|
+
version: 0.224.0
|
|
123
123
|
type: :runtime
|
|
124
124
|
prerelease: false
|
|
125
125
|
version_requirements: !ruby/object:Gem::Requirement
|
|
126
126
|
requirements:
|
|
127
127
|
- - '='
|
|
128
128
|
- !ruby/object:Gem::Version
|
|
129
|
-
version: 0.
|
|
129
|
+
version: 0.224.0
|
|
130
130
|
- !ruby/object:Gem::Dependency
|
|
131
131
|
name: dotenv
|
|
132
132
|
requirement: !ruby/object:Gem::Requirement
|