|
21 | 21 | // |
22 | 22 | // # Sandbox Lifecycle |
23 | 23 | // |
24 | | -// sandbox, err := client.Sandboxes().Create(ctx, "my-sandbox", &v1.SandboxSpec{ |
| 24 | +// sandbox, err := client.Sandboxes().Create(ctx, "default", "my-sandbox", &v1.SandboxSpec{ |
25 | 25 | // Template: &v1.SandboxTemplate{Image: "python:3.12"}, |
26 | 26 | // Environment: map[string]string{"LANG": "en_US.UTF-8"}, |
27 | 27 | // }, nil) |
28 | 28 | // if err != nil { |
29 | 29 | // log.Fatal(err) |
30 | 30 | // } |
31 | 31 | // |
32 | | -// sandbox, err = client.Sandboxes().WaitReady(ctx, sandbox.Name) |
| 32 | +// sandbox, err = client.Sandboxes().WaitReady(ctx, "default", sandbox.Name) |
33 | 33 | // if err != nil { |
34 | 34 | // log.Fatal(err) |
35 | 35 | // } |
36 | 36 | // |
37 | 37 | // # Command Execution (available in a future release) |
38 | 38 | // |
39 | | -// result, err := client.Exec().Run(ctx, sandbox.Name, []string{"echo", "hello"}, v1.ExecOptions{}) |
| 39 | +// result, err := client.Exec().Run(ctx, "default", sandbox.Name, []string{"echo", "hello"}, v1.ExecOptions{}) |
40 | 40 | // if err != nil { |
41 | 41 | // log.Fatal(err) |
42 | 42 | // } |
43 | 43 | // fmt.Println(string(result.Stdout)) // "hello\n" |
44 | 44 | // |
45 | 45 | // # Error Handling |
46 | 46 | // |
47 | | -// _, err = client.Sandboxes().Get(ctx, "missing") |
| 47 | +// _, err = client.Sandboxes().Get(ctx, "default", "missing") |
48 | 48 | // if v1.IsNotFound(err) { |
49 | 49 | // // handle not found |
50 | 50 | // } |
51 | 51 | // |
52 | 52 | // # Watching |
53 | 53 | // |
54 | | -// watcher, err := client.Sandboxes().Watch(ctx, sandbox.Name) |
| 54 | +// watcher, err := client.Sandboxes().Watch(ctx, "default", sandbox.Name) |
55 | 55 | // if err != nil { |
56 | 56 | // log.Fatal(err) |
57 | 57 | // } |
|
65 | 65 | // Use StopOnTerminal to auto-close the watcher when the sandbox reaches a |
66 | 66 | // terminal phase (Ready or Error): |
67 | 67 | // |
68 | | -// watcher, err := client.Sandboxes().Watch(ctx, sandbox.Name, |
| 68 | +// watcher, err := client.Sandboxes().Watch(ctx, "default", sandbox.Name, |
69 | 69 | // v1.WatchOptions{StopOnTerminal: true}, |
70 | 70 | // ) |
71 | 71 | // if err != nil { |
|
80 | 80 | // |
81 | 81 | // Expose an HTTP service running inside a sandbox and retrieve its public URL: |
82 | 82 | // |
83 | | -// endpoint, err := client.Services().Expose(ctx, "my-sandbox", "api", 8080, true) |
| 83 | +// endpoint, err := client.Services().Expose(ctx, "default", "my-sandbox", "api", 8080, true) |
84 | 84 | // if err != nil { |
85 | 85 | // log.Fatal(err) |
86 | 86 | // } |
87 | 87 | // fmt.Printf("Service URL: %s\n", endpoint.URL) |
88 | 88 | // |
89 | | -// endpoints, err := client.Services().List(ctx, "my-sandbox") |
| 89 | +// endpoints, err := client.Services().List(ctx, "default", "my-sandbox") |
90 | 90 | // if err != nil { |
91 | 91 | // log.Fatal(err) |
92 | 92 | // } |
|
98 | 98 | // |
99 | 99 | // List available provider profiles and import new ones: |
100 | 100 | // |
101 | | -// profiles, err := client.Providers().Profiles().List(ctx) |
| 101 | +// profiles, err := client.Providers().Profiles().List(ctx, "default") |
102 | 102 | // if err != nil { |
103 | 103 | // log.Fatal(err) |
104 | 104 | // } |
105 | 105 | // for _, p := range profiles { |
106 | 106 | // fmt.Printf("%s (%s): %s\n", p.DisplayName, p.Category, p.Description) |
107 | 107 | // } |
108 | 108 | // |
109 | | -// result, err := client.Providers().Profiles().Import(ctx, []v1.ProfileImportItem{ |
| 109 | +// result, err := client.Providers().Profiles().Import(ctx, "default", []v1.ProfileImportItem{ |
110 | 110 | // {Source: "openai-profile.yaml", Profile: v1.ProviderProfile{ |
111 | 111 | // DisplayName: "OpenAI", |
112 | 112 | // Category: v1.ProfileCategoryInference, |
|
123 | 123 | // |
124 | 124 | // Configure gateway-owned credential refresh for a provider: |
125 | 125 | // |
126 | | -// status, err := client.Providers().Refresh().Configure(ctx, &v1.RefreshConfig{ |
| 126 | +// status, err := client.Providers().Refresh().Configure(ctx, "default", &v1.RefreshConfig{ |
127 | 127 | // Provider: "openai", |
128 | 128 | // CredentialKey: "api-key", |
129 | 129 | // Strategy: v1.RefreshStrategyOAuth2ClientCredentials, |
|
198 | 198 | // Note: CreateSession accepts a sandbox ID, not a name. For name-based access |
199 | 199 | // with automatic session cleanup, prefer SSH().Tunnel() instead. |
200 | 200 | // |
201 | | -// session, err := client.SSH().CreateSession(ctx, sandbox.ID) |
| 201 | +// session, err := client.SSH().CreateSession(ctx, "default", sandbox.ID) |
202 | 202 | // if err != nil { |
203 | 203 | // log.Fatal(err) |
204 | 204 | // } |
|
207 | 207 | // fmt.Printf("Host key: %s\n", session.HostKeyFingerprint) |
208 | 208 | // // Use session.Token to authenticate the SSH connection. |
209 | 209 | // |
210 | | -// revoked, err := client.SSH().RevokeSession(ctx, session.Token) |
| 210 | +// revoked, err := client.SSH().RevokeSession(ctx, "default", session.Token) |
211 | 211 | // if err != nil { |
212 | 212 | // log.Fatal(err) |
213 | 213 | // } |
|
217 | 217 | // |
218 | 218 | // Forward a local connection to a port inside a sandbox: |
219 | 219 | // |
220 | | -// conn, err := client.TCP().Forward(ctx, "my-sandbox", 5432) |
| 220 | +// conn, err := client.TCP().Forward(ctx, "default", "my-sandbox", 5432) |
221 | 221 | // if err != nil { |
222 | 222 | // log.Fatal(err) |
223 | 223 | // } |
|
238 | 238 | // Use WithForwardServiceID to tag the forwarding session with a service |
239 | 239 | // identifier for audit logging: |
240 | 240 | // |
241 | | -// conn, err := client.TCP().Forward(ctx, "my-sandbox", 5432, |
| 241 | +// conn, err := client.TCP().Forward(ctx, "default", "my-sandbox", 5432, |
242 | 242 | // v1.WithForwardServiceID("billing-db"), |
243 | 243 | // ) |
244 | 244 | // |
|
248 | 248 | // session creation, TCP forwarding with an SSH relay target, and automatic |
249 | 249 | // session cleanup into one operation: |
250 | 250 | // |
251 | | -// tunnel, err := client.SSH().Tunnel(ctx, "my-sandbox", 22) |
| 251 | +// tunnel, err := client.SSH().Tunnel(ctx, "default", "my-sandbox", 22) |
252 | 252 | // if err != nil { |
253 | 253 | // log.Fatal(err) |
254 | 254 | // } |
|
269 | 269 | // |
270 | 270 | // Use WithTunnelServiceID to associate a service identifier with the tunnel: |
271 | 271 | // |
272 | | -// tunnel, err := client.SSH().Tunnel(ctx, "my-sandbox", 22, |
| 272 | +// tunnel, err := client.SSH().Tunnel(ctx, "default", "my-sandbox", 22, |
273 | 273 | // v1.WithTunnelServiceID("dev-ssh"), |
274 | 274 | // ) |
275 | 275 | // |
276 | 276 | // # Sandbox Policy |
277 | 277 | // |
278 | 278 | // Set an initial security policy when creating a sandbox: |
279 | 279 | // |
280 | | -// sandbox, err := client.Sandboxes().Create(ctx, "secure-sandbox", &v1.SandboxSpec{ |
| 280 | +// sandbox, err := client.Sandboxes().Create(ctx, "default", "secure-sandbox", &v1.SandboxSpec{ |
281 | 281 | // Template: &v1.SandboxTemplate{Image: "python:3.12"}, |
282 | 282 | // Policy: &v1.SandboxPolicy{ |
283 | 283 | // Version: 1, |
|
302 | 302 | // |
303 | 303 | // Replace the full policy at runtime via configuration update (available in a future release): |
304 | 304 | // |
305 | | -// result, err := client.Config().Update(ctx, &v1.ConfigUpdate{ |
| 305 | +// result, err := client.Config().Update(ctx, "default", &v1.ConfigUpdate{ |
306 | 306 | // Name: "secure-sandbox", |
307 | 307 | // Policy: &v1.SandboxPolicy{ |
308 | 308 | // Version: 2, |
|
314 | 314 | // |
315 | 315 | // Read a policy back from revision history (available in a future release): |
316 | 316 | // |
317 | | -// revisions, err := client.Policy().List(ctx, "secure-sandbox") |
| 317 | +// revisions, err := client.Policy().List(ctx, "default") |
318 | 318 | // if err != nil { |
319 | 319 | // log.Fatal(err) |
320 | 320 | // } |
|
328 | 328 | // |
329 | 329 | // Read sandbox and gateway configuration, and update settings: |
330 | 330 | // |
331 | | -// sbCfg, err := client.Config().GetSandbox(ctx, "my-sandbox") |
| 331 | +// sbCfg, err := client.Config().GetSandbox(ctx, "default", "my-sandbox") |
332 | 332 | // if err != nil { |
333 | 333 | // log.Fatal(err) |
334 | 334 | // } |
|
343 | 343 | // } |
344 | 344 | // fmt.Printf("Gateway settings revision: %d\n", gwCfg.SettingsRevision) |
345 | 345 | // |
346 | | -// result, err := client.Config().Update(ctx, &v1.ConfigUpdate{ |
| 346 | +// result, err := client.Config().Update(ctx, "default", &v1.ConfigUpdate{ |
347 | 347 | // Name: "my-sandbox", |
348 | 348 | // SettingKey: "max_tokens", |
349 | 349 | // SettingValue: &v1.SettingValue{ |
|
0 commit comments