SDKs
Lists the methods of the Python, TypeScript, Go, Ruby and Java clients.
Last updated
On this page
Install and import
| Language | Source | Import | Construct |
|---|---|---|---|
| Python | Copy python/kloudlite.py into your project; it is one file | from kloudlite import Kloudlite, ApiError | Kloudlite() |
| TypeScript | Copy typescript/index.ts into your project; there is no build step | import { Kloudlite } from "./index.ts" | new Kloudlite() |
| Go | Run go get github.com/kloudlite/sdk/go (source); Go 1.24 | import kloudlite "github.com/kloudlite/sdk/go" | kloudlite.New(kloudlite.Options{}) |
| Ruby | Copy ruby/kloudlite.rb into your project; it is one file | require_relative "kloudlite" | Kloudlite::Client.new |
| Java | Copy java/Kloudlite.java into your project; it is one file; Java 11 or later | compile it with your code | new Kloudlite() |
The command pip install kloudlite installs a different package, the client of the model and dataset hub. It is not this SDK, so copy kloudlite.py into your project instead.
Secret references
An environment value refers to a secret of the owner as ${{ secrets.NAME }}. With a team owner, the secrets calls work on your own secrets in that team; give the scope team for the secrets of the team. The secrets API lists the routes that take a reference.
Pipeline definitions
The definition of pipelines.create and pipelines.update is plain data in the shape of Pipeline definition. Python takes a dict, Ruby a hash and TypeScript an object. Go takes the struct PipelineDefinition, and Java the builder class PipelineDefinition.
The order of jobs, inputs and each matrix is part of the definition. Python, Ruby and TypeScript keep the order that you write. Go keeps the order of its Jobs and Inputs slices, and Java the order of its job and input calls.
A save returns the pipeline with its version. rotate_webhook returns the new URL, which no later call shows.
Authentication and base URL
The SDK uses the login of kloudlite, so a client needs no arguments. It takes the API origin and the CLI token from the first source that has each, adds /v1 to the origin, and sends the token as Authorization: Bearer.
| Order | Source | Origin | Token |
|---|---|---|---|
| 1 | The argument in code | base_url (baseUrl, BaseURL) | token (Token) |
| 2 | The environment | KLOUDLITE_URL | KLOUDLITE_TOKEN |
| 3 | The kloudlite login | api in config.json | token in config.json |
config.json is in KLOUDLITE_CONFIG_DIR, or in ~/.config/kloudlite. With no token, the SDK stops with no Kloudlite login: pass token=, set KLOUDLITE_TOKEN, or run kloudlite login (Go returns it from the first call). For a CI job or a server with no kloudlite, set KLOUDLITE_URL and KLOUDLITE_TOKEN. The token must be a CLI token: an API token does not open /v1. Every request times out after 30 seconds, set with timeout (Python, Ruby), timeoutMs (TypeScript) or Options.Timeout (Go).
Inputs, results and errors
Every input is named. Python takes keyword-only arguments, Ruby keywords, TypeScript one options object, Go one request struct (kloudlite.CreateWorkspace{Workspace: …}) and Java a nested params class (new Kloudlite.CreateWorkspace().workspace(…)).
A workspace, environment or session is "name" for your own or "team/name" for a team's, or its id. Something new made from an existing one is to.
Every method returns the decoded JSON of the route, except the sandbox and pipeline handles below. Java returns the raw JSON string from every method, except those two.
Errors, one per SDK:
- Python:
ApiErrorwithstatusandmessage;SandboxTerminated, a subclass, when a sandbox that you wait for has ended. - TypeScript:
ApiErrorwithstatusandmessage;TimeoutErrorwhen a client-side wait runs out. A terminated sandbox is anApiErrorwith status 409. - Go:
*ApiErrorwithStatusandMessage;ErrTimeout, tested witherrors.Is, when a wait runs out. A terminated sandbox is an*ApiErrorwith status 409. - Ruby:
Kloudlite::ApiErrorwithstatusandmessage;SandboxTerminated < ApiError;TimeoutErrorwhen a wait runs out. - Java:
Kloudlite.ApiException, anIOException, with publicstatusandmessage.
A missing required field is refused before anything is sent: ValueError in Python, an IllegalArgumentException in Java.
Methods
Resources hang off the client under these names: workspaces, environments, sessions, volumes, secrets, connectors, sandboxes and pipelines. Java reaches them as a call, kl.workspaces(), and Go as the field kl.Workspaces. The ide, sandbox, process and run rows are on objects that those methods return. workspaces.ide returns the tool-server client. sandboxes.create and get return a sandbox handle, and the exec method of a sandbox returns a process handle. pipelines.run and get_run return a run handle.
Python also has an .aio form of its calls for asyncio. Every cell is the method name in that language.
The tool-server rows call the tool server directly with the workspace's token, so they take the tool's own arguments. The SDKs have no method for these resources: teams, invites, keys, tokens, container images, requests, regions and builders.
| Resource.method | python | typescript | go | ruby | java | Route |
|---|---|---|---|---|---|---|
| client.quota | quota | quota | Quota | quota | quota | GET /v1/quota |
| client.request | request | request | Request | request | request | any route, your method and path |
| workspaces.create | create | create | Create | create | create | POST /v1/workspaces |
| workspaces.list | list | list | List | list | list | GET /v1/workspaces |
| workspaces.get | get | get | Get | get | get | GET /v1/workspaces/{id} |
| workspaces.delete | delete | delete | Delete | delete | delete | DELETE /v1/workspaces/{id} |
| workspaces.start | start | start | Start | start | start | POST /v1/workspaces/{id}/start |
| workspaces.stop | stop | stop | Stop | stop | stop | POST /v1/workspaces/{id}/stop |
| workspaces.restart | restart | restart | Restart | restart | restart | POST /v1/workspaces/{id}/restart |
| workspaces.take_snapshot | take_snapshot | takeSnapshot | TakeSnapshot | take_snapshot | takeSnapshot | POST /v1/workspaces/{id}/snapshots |
| workspaces.clone | clone | clone | Clone | clone | clone | POST /v1/workspaces/{id}/clone |
| workspaces.restore | restore | restore | Restore | restore | restore | POST /v1/workspaces/restore |
| workspaces.set_packages | set_packages | setPackages | SetPackages | set_packages | setPackages | PATCH /v1/workspaces/{id} |
| workspaces.set_ttl | set_ttl | setTtl | SetTTL | set_ttl | setTtl | PUT /v1/workspaces/{id}/ttl |
| workspaces.set_env | set_env | setEnv | SetEnv | set_env | setEnv | PUT /v1/workspaces/{id}/env |
| workspaces.update_packages | update_packages | updatePackages | UpdatePackages | update_packages | updatePackages | POST /v1/workspaces/{id}/packages/update |
| workspaces.tools | tools | tools | Tools | tools | tools | GET /v1/workspaces/{id}/tools |
| workspaces.ide | ide | ide | Ide | ide | ide | GET /v1/workspaces/{id}/tools, then a client for the tool server |
| ide.list | list | list | List | list | list | GET /tools |
| ide.call | call | call | Call | call | call | POST /tools/{tool} |
| ide.read | read | read | Read | read | read | POST /tools/read |
| ide.write | write | write | Write | write | write | POST /tools/write |
| ide.edit | edit | edit | Edit | edit | edit | POST /tools/edit |
| ide.patch | patch | patch | Patch | patch | patch | POST /tools/patch |
| ide.glob | glob | glob | Glob | glob | glob | POST /tools/glob |
| ide.grep | grep | grep | Grep | grep | grep | POST /tools/grep |
| ide.exec | exec | exec | Exec | exec | exec | POST /tools/exec |
| ide.process_list | process_list | processList | ProcessList | process_list | processList | POST /tools/process_list |
| ide.process_output | process_output | processOutput | ProcessOutput | process_output | processOutput | POST /tools/process_output |
| ide.process_write | process_write | processWrite | ProcessWrite | process_write | processWrite | POST /tools/process_write |
| ide.process_kill | process_kill | processKill | ProcessKill | process_kill | processKill | POST /tools/process_kill |
| ide.watch | watch | watch | Watch | watch | watch | POST /tools/watch |
| ide.watch_poll | watch_poll | watchPoll | WatchPoll | watch_poll | watchPoll | POST /tools/watch_poll |
| ide.watch_stop | watch_stop | watchStop | WatchStop | watch_stop | watchStop | POST /tools/watch_stop |
| ide.container_build | container_build | containerBuild | ContainerBuild | container_build | containerBuild | POST /tools/container_build |
| ide.container_push | container_push | containerPush | ContainerPush | container_push | containerPush | POST /tools/container_push |
| environments.create | create | create | Create | create | create | POST /v1/environments |
| environments.list | list | list | List | list | list | GET /v1/environments |
| environments.get | get | get | Get | get | get | GET /v1/environments/{id} |
| environments.set_services | set_services | setServices | SetServices | set_services | setServices | PATCH /v1/environments/{id} |
| environments.start | start | start | Start | start | start | POST /v1/environments/{id}/start |
| environments.stop | stop | stop | Stop | stop | stop | POST /v1/environments/{id}/stop |
| environments.restart | restart | restart | Restart | restart | restart | POST /v1/environments/{id}/services/{service}/restart |
| environments.set_ttl | set_ttl | setTtl | SetTTL | set_ttl | setTtl | PUT /v1/environments/{id}/ttl |
| environments.delete | delete | delete | Delete | delete | delete | DELETE /v1/environments/{id} |
| environments.take_snapshot | take_snapshot | takeSnapshot | TakeSnapshot | take_snapshot | takeSnapshot | POST /v1/environments/{id}/snapshots |
| environments.clone | clone | clone | Clone | clone | clone | POST /v1/environments/{id}/clone |
| environments.restore | restore | restore | Restore | restore | restore | POST /v1/environments/{id}/restore |
| sessions.create | create | create | Create | create | create | POST /v1/sessions |
| sessions.set_ttl | set_ttl | setTtl | SetTTL | set_ttl | setTtl | PUT /v1/sessions/{id}/ttl |
| sessions.list | list | list | List | list | list | GET /v1/sessions |
| sessions.get | get | get | Get | get | get | GET /v1/sessions/{id} |
| sessions.delete | delete | delete | Delete | delete | delete | DELETE /v1/sessions/{id} |
| sessions.stop | stop | stop | Stop | stop | stop | POST /v1/sessions/{id}/stop |
| sessions.connect | connect | connect | Connect | connect | connect | PUT /v1/sessions/{id}/environment |
| sessions.create_workspace | create_workspace | createWorkspace | CreateWorkspace | create_workspace | createWorkspace | POST /v1/sessions/{id}/workspaces |
| sessions.create_sandbox | create_sandbox | createSandbox | CreateSandbox | create_sandbox | createSandbox | POST /v1/sessions/{id}/sandboxes |
| sessions.delete_workspace | delete_workspace | deleteWorkspace | DeleteWorkspace | delete_workspace | deleteWorkspace | DELETE /v1/sessions/{id}/workspaces/{workspace} |
| sessions.intercept | intercept | intercept | Intercept | intercept | intercept | POST /v1/sessions/{id}/intercepts |
| sessions.release | release | release | Release | release | release | DELETE /v1/sessions/{id}/intercepts/{service} |
| volumes.list | list | list | List | list | list | GET /v1/volumes |
| volumes.history | history | history | History | history | history | GET /v1/volumes/{key}/history |
| volumes.refs | refs | refs | Refs | refs | refs | GET /v1/volumes/{key}/refs |
| volumes.delete_snapshot | delete_snapshot | deleteSnapshot | DeleteSnapshot | delete_snapshot | deleteSnapshot | DELETE /v1/volumes/{key}/snapshots/{snapshot} |
| volumes.delete_by_id | delete_by_id | deleteById | DeleteByID | delete_by_id | deleteById | DELETE /v1/volumes/{key} |
| volumes.get | get | get | Get | get | get | GET /v1/volumes/{key}/{name} |
| volumes.versions | versions | versions | Versions | versions | versions | GET /v1/volumes/{key}/{name}/versions |
| volumes.delete | delete | delete | Delete | delete | delete | DELETE /v1/volumes/{key}/{name} |
| volumes.delete_version | delete_version | deleteVersion | DeleteVersion | delete_version | deleteVersion | DELETE /v1/volumes/{key}/{name}/versions/{n} |
| secrets.set | set | set | Set | set | set | PUT /v1/secrets/{owner}/mine/{name} |
| secrets.list | list | list | List | list | list | GET /v1/secrets/{owner}/mine |
| secrets.delete | delete | delete | Delete | delete | delete | DELETE /v1/secrets/{owner}/mine/{name} |
| connectors.list | list | list | List | list | list | GET /v1/connectors |
| connectors.delete | delete | delete | Delete | delete | delete | DELETE /v1/connectors/{name} |
| sandboxes.create | create | create | Create | create | create | POST /v1/sandboxes |
| sandboxes.get | get | get | Get | get | get | GET /v1/sandboxes/{id} |
| sandboxes.list | list | list | List | list | list | GET /v1/sandboxes; one page, limit and cursor pick it |
| sandboxes.list_page | list_page | listPage | ListPage | list_page | listPage | the page and the cursor of the next one |
| sandboxes.run | run | run | Run | run | run | create, wait, logs and terminate in one call |
| sandbox handle.refresh | refresh | refresh | Refresh | refresh | refresh | GET /v1/sandboxes/{id} |
| sandbox handle.wait_running | wait_running | waitRunning | WaitRunning | wait_running | waitRunning | polls GET /v1/sandboxes/{id} |
| sandbox handle.logs | logs | logs | Logs | logs | logs | GET /v1/sandboxes/{id}/logs; follow holds until the process ends |
| sandbox handle.attach | attach | attach | Attach | attach | attach | GET /v1/sandboxes/{id}/attach (WebSocket); waits for running first |
| sandbox handle.terminate | terminate | terminate | Terminate | terminate | terminate | POST /v1/sandboxes/{id}/terminate |
| sandbox handle.wait | wait | wait | Wait | wait | waitFor | POST /v1/sandboxes/{id}/wait; answers the exit code |
| sandbox handle.delete | delete | delete | Delete | delete | delete | DELETE /v1/sandboxes/{id} |
| attach handle.write | write | write | Write | write | write | channel 0 (stdin) |
| attach handle.read | read | read | Read | read | read | channels 1 and 2 (output); the end is None, null, io.EOF, nil |
| attach handle.resize | resize | resize | Resize | resize | resize | channel 4 |
| attach handle.wait | wait | wait | Wait | wait | waitFor | channel 3 (exit code) |
| attach handle.close | close | close | Close | close | close | closes the WebSocket |
| pipelines.create | create | create | Create | create | create | POST /v1/pipelines/{owner} |
| pipelines.update | update | update | Update | update | update | PUT /v1/pipelines/{owner}/{name} |
| pipelines.list | list | list | List | list | list | GET /v1/pipelines/{owner} |
| pipelines.get | get | get | Get | get | get | GET /v1/pipelines/{owner}/{name} |
| pipelines.versions | versions | versions | Versions | versions | versions | GET /v1/pipelines/{owner}/{name}/versions |
| pipelines.delete | delete | delete | Delete | delete | delete | DELETE /v1/pipelines/{owner}/{name} |
| pipelines.run | run | run | Run | run | run | POST /v1/pipelines/{owner}/{name}/runs |
| pipelines.rotate_webhook | rotate_webhook | rotateWebhook | RotateWebhook | rotate_webhook | rotateWebhook | POST /v1/pipelines/{owner}/{name}/webhook/rotate |
| pipelines.runs | runs | runs | Runs | runs | runs | GET /v1/pipelines/{owner}/{pipeline}/runs |
| pipelines.get_run | get_run | getRun | GetRun | get_run | getRun | GET /v1/pipelines/{owner}/{pipeline}/runs/{run} |
| run handle.refresh | refresh | refresh | Refresh | refresh | refresh | GET /v1/pipelines/{owner}/{pipeline}/runs/{run} |
| run handle.cancel | cancel | cancel | Cancel | cancel | cancel | POST /v1/pipelines/{owner}/{pipeline}/runs/{run}/cancel |
| run handle.wait | wait | wait | Wait | wait | waitFor | polls GET /v1/pipelines/{owner}/{pipeline}/runs/{run} |
| run handle.logs | logs | logs | Logs | logs | logs | GET /v1/pipelines/{owner}/{pipeline}/runs/{run}/jobs/{index}/logs |
| run handle.follow | follow | follow | Follow | follow | follow | GET /v1/pipelines/{owner}/{pipeline}/runs/{run}/jobs/{index}/logs, paged |
| ide.process_close_stdin | — | — | — | — | — | POST /tools/process_close_stdin; reach it with call |
| ide.process_wait | — | — | — | — | — | POST /tools/process_wait; reach it with call |
Two tool-server tools have no typed method, process_close_stdin and process_wait; call reaches them in every language.