fix(api): allow get by id for general snapshots (#4033) Signed-off-by: fabjanvucina fabjanvucina@gmail.com
fix(api): allow get by id for general snapshots (#4033)
Signed-off-by: fabjanvucina fabjanvucina@gmail.com
Documentation · Report Bug · Request Feature · Join our Slack · Connect on X
pip install daytona
npm install @daytonaio/sdk
from daytona import Daytona, DaytonaConfig, CreateSandboxBaseParams # Initialize the Daytona client daytona = Daytona(DaytonaConfig(api_key="YOUR_API_KEY")) # Create the Sandbox instance sandbox = daytona.create(CreateSandboxBaseParams(language="python")) # Run code securely inside the Sandbox response = sandbox.process.code_run('print("Sum of 3 and 4 is " + str(3 + 4))') if response.exit_code != 0: print(f"Error running code: {response.exit_code} {response.result}") else: print(response.result) # Clean up the Sandbox daytona.delete(sandbox)
import { Daytona } from '@daytonaio/sdk' async function main() { // Initialize the Daytona client const daytona = new Daytona({ apiKey: 'YOUR_API_KEY', }) let sandbox try { // Create the Sandbox instance sandbox = await daytona.create({ language: 'typescript', }) // Run code securely inside the Sandbox const response = await sandbox.process.codeRun('console.log("Sum of 3 and 4 is " + (3 + 4))') if (response.exitCode !== 0) { console.error('Error running code:', response.exitCode, response.result) } else { console.log(response.result) } } catch (error) { console.error('Sandbox flow error:', error) } finally { if (sandbox) await daytona.delete(sandbox) } } main().catch(console.error)
package main import ( "context" "fmt" "log" "time" "github.com/daytonaio/daytona/libs/sdk-go/pkg/daytona" "github.com/daytonaio/daytona/libs/sdk-go/pkg/types" ) func main() { // Initialize the Daytona client with DAYTONA_API_KEY in env // Alternative is to use daytona.NewClientWithConfig(...) for more specific config client, err := daytona.NewClient() if err != nil { log.Fatalf("Failed to create client: %v", err) } ctx := context.Background() // Create the Sandbox instance params := types.SnapshotParams{ SandboxBaseParams: types.SandboxBaseParams{ Language: types.CodeLanguagePython, }, } sandbox, err := client.Create(ctx, params, daytona.WithTimeout(90*time.Second)) if err != nil { log.Fatalf("Failed to create sandbox: %v", err) } // Run code securely inside the Sandbox response, err := sandbox.Process.ExecuteCommand(ctx, `python3 -c "print('Sum of 3 and 4 is', 3 + 4)"`) if err != nil { log.Fatalf("Failed to execute command: %v", err) } if response.ExitCode != 0 { fmt.Printf("Error running code: %d %s\n", response.ExitCode, response.Result) } else { fmt.Println(response.Result) } // Clean up the Sandbox if err := sandbox.Delete(ctx); err != nil { log.Fatalf("Failed to delete sandbox: %v", err) } }
Daytona is Open Source under the GNU AFFERO GENERAL PUBLIC LICENSE, and is the copyright of its contributors. If you would like to contribute to the software, read the Developer Certificate of Origin Version 1.1 (https://developercertificate.org/). Afterwards, navigate to the contributing guide to get started.
版权所有:中国计算机学会技术支持:开源发展技术委员会 京ICP备13000930号-9 京公网安备 11010802032778号
Run AI Code.
Secure and Elastic Infrastructure for Running Your AI-Generated Code.
Documentation · Report Bug · Request Feature · Join our Slack · Connect on X
Installation
Python SDK
TypeScript SDK
Features
Quick Start
Creating your first Sandbox
Python SDK
Typescript SDK
Go SDK
Contributing
Daytona is Open Source under the GNU AFFERO GENERAL PUBLIC LICENSE, and is the copyright of its contributors. If you would like to contribute to the software, read the Developer Certificate of Origin Version 1.1 (https://developercertificate.org/). Afterwards, navigate to the contributing guide to get started.