Skip to content
DocsAll docs
Console

SDKs

Lists the methods of the Python, TypeScript, Go, Ruby and Java clients.

Last updated

On this page

Install and import

LanguageSourceImportConstruct
PythonCopy python/kloudlite.py into your project; it is one filefrom kloudlite import Kloudlite, ApiErrorKloudlite()
TypeScriptCopy typescript/index.ts into your project; there is no build stepimport { Kloudlite } from "./index.ts"new Kloudlite()
GoRun go get github.com/kloudlite/sdk/go (source); Go 1.24import kloudlite "github.com/kloudlite/sdk/go"kloudlite.New(kloudlite.Options{})
RubyCopy ruby/kloudlite.rb into your project; it is one filerequire_relative "kloudlite"Kloudlite::Client.new
JavaCopy java/Kloudlite.java into your project; it is one file; Java 11 or latercompile it with your codenew 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.

OrderSourceOriginToken
1The argument in codebase_url (baseUrl, BaseURL)token (Token)
2The environmentKLOUDLITE_URLKLOUDLITE_TOKEN
3The kloudlite loginapi in config.jsontoken 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: ApiError with status and message; SandboxTerminated, a subclass, when a sandbox that you wait for has ended.
  • TypeScript: ApiError with status and message; TimeoutError when a client-side wait runs out. A terminated sandbox is an ApiError with status 409.
  • Go: *ApiError with Status and Message; ErrTimeout, tested with errors.Is, when a wait runs out. A terminated sandbox is an *ApiError with status 409.
  • Ruby: Kloudlite::ApiError with status and message; SandboxTerminated < ApiError; TimeoutError when a wait runs out.
  • Java: Kloudlite.ApiException, an IOException, with public status and message.

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.methodpythontypescriptgorubyjavaRoute
client.quotaquotaquotaQuotaquotaquotaGET /v1/quota
client.requestrequestrequestRequestrequestrequestany route, your method and path
workspaces.createcreatecreateCreatecreatecreatePOST /v1/workspaces
workspaces.listlistlistListlistlistGET /v1/workspaces
workspaces.getgetgetGetgetgetGET /v1/workspaces/{id}
workspaces.deletedeletedeleteDeletedeletedeleteDELETE /v1/workspaces/{id}
workspaces.startstartstartStartstartstartPOST /v1/workspaces/{id}/start
workspaces.stopstopstopStopstopstopPOST /v1/workspaces/{id}/stop
workspaces.restartrestartrestartRestartrestartrestartPOST /v1/workspaces/{id}/restart
workspaces.take_snapshottake_snapshottakeSnapshotTakeSnapshottake_snapshottakeSnapshotPOST /v1/workspaces/{id}/snapshots
workspaces.cloneclonecloneClonecloneclonePOST /v1/workspaces/{id}/clone
workspaces.restorerestorerestoreRestorerestorerestorePOST /v1/workspaces/restore
workspaces.set_packagesset_packagessetPackagesSetPackagesset_packagessetPackagesPATCH /v1/workspaces/{id}
workspaces.set_ttlset_ttlsetTtlSetTTLset_ttlsetTtlPUT /v1/workspaces/{id}/ttl
workspaces.set_envset_envsetEnvSetEnvset_envsetEnvPUT /v1/workspaces/{id}/env
workspaces.update_packagesupdate_packagesupdatePackagesUpdatePackagesupdate_packagesupdatePackagesPOST /v1/workspaces/{id}/packages/update
workspaces.toolstoolstoolsToolstoolstoolsGET /v1/workspaces/{id}/tools
workspaces.ideideideIdeideideGET /v1/workspaces/{id}/tools, then a client for the tool server
ide.listlistlistListlistlistGET /tools
ide.callcallcallCallcallcallPOST /tools/{tool}
ide.readreadreadReadreadreadPOST /tools/read
ide.writewritewriteWritewritewritePOST /tools/write
ide.editediteditEditediteditPOST /tools/edit
ide.patchpatchpatchPatchpatchpatchPOST /tools/patch
ide.globglobglobGlobglobglobPOST /tools/glob
ide.grepgrepgrepGrepgrepgrepPOST /tools/grep
ide.execexecexecExecexecexecPOST /tools/exec
ide.process_listprocess_listprocessListProcessListprocess_listprocessListPOST /tools/process_list
ide.process_outputprocess_outputprocessOutputProcessOutputprocess_outputprocessOutputPOST /tools/process_output
ide.process_writeprocess_writeprocessWriteProcessWriteprocess_writeprocessWritePOST /tools/process_write
ide.process_killprocess_killprocessKillProcessKillprocess_killprocessKillPOST /tools/process_kill
ide.watchwatchwatchWatchwatchwatchPOST /tools/watch
ide.watch_pollwatch_pollwatchPollWatchPollwatch_pollwatchPollPOST /tools/watch_poll
ide.watch_stopwatch_stopwatchStopWatchStopwatch_stopwatchStopPOST /tools/watch_stop
ide.container_buildcontainer_buildcontainerBuildContainerBuildcontainer_buildcontainerBuildPOST /tools/container_build
ide.container_pushcontainer_pushcontainerPushContainerPushcontainer_pushcontainerPushPOST /tools/container_push
environments.createcreatecreateCreatecreatecreatePOST /v1/environments
environments.listlistlistListlistlistGET /v1/environments
environments.getgetgetGetgetgetGET /v1/environments/{id}
environments.set_servicesset_servicessetServicesSetServicesset_servicessetServicesPATCH /v1/environments/{id}
environments.startstartstartStartstartstartPOST /v1/environments/{id}/start
environments.stopstopstopStopstopstopPOST /v1/environments/{id}/stop
environments.restartrestartrestartRestartrestartrestartPOST /v1/environments/{id}/services/{service}/restart
environments.set_ttlset_ttlsetTtlSetTTLset_ttlsetTtlPUT /v1/environments/{id}/ttl
environments.deletedeletedeleteDeletedeletedeleteDELETE /v1/environments/{id}
environments.take_snapshottake_snapshottakeSnapshotTakeSnapshottake_snapshottakeSnapshotPOST /v1/environments/{id}/snapshots
environments.cloneclonecloneClonecloneclonePOST /v1/environments/{id}/clone
environments.restorerestorerestoreRestorerestorerestorePOST /v1/environments/{id}/restore
sessions.createcreatecreateCreatecreatecreatePOST /v1/sessions
sessions.set_ttlset_ttlsetTtlSetTTLset_ttlsetTtlPUT /v1/sessions/{id}/ttl
sessions.listlistlistListlistlistGET /v1/sessions
sessions.getgetgetGetgetgetGET /v1/sessions/{id}
sessions.deletedeletedeleteDeletedeletedeleteDELETE /v1/sessions/{id}
sessions.stopstopstopStopstopstopPOST /v1/sessions/{id}/stop
sessions.connectconnectconnectConnectconnectconnectPUT /v1/sessions/{id}/environment
sessions.create_workspacecreate_workspacecreateWorkspaceCreateWorkspacecreate_workspacecreateWorkspacePOST /v1/sessions/{id}/workspaces
sessions.create_sandboxcreate_sandboxcreateSandboxCreateSandboxcreate_sandboxcreateSandboxPOST /v1/sessions/{id}/sandboxes
sessions.delete_workspacedelete_workspacedeleteWorkspaceDeleteWorkspacedelete_workspacedeleteWorkspaceDELETE /v1/sessions/{id}/workspaces/{workspace}
sessions.interceptinterceptinterceptInterceptinterceptinterceptPOST /v1/sessions/{id}/intercepts
sessions.releasereleasereleaseReleasereleasereleaseDELETE /v1/sessions/{id}/intercepts/{service}
volumes.listlistlistListlistlistGET /v1/volumes
volumes.historyhistoryhistoryHistoryhistoryhistoryGET /v1/volumes/{key}/history
volumes.refsrefsrefsRefsrefsrefsGET /v1/volumes/{key}/refs
volumes.delete_snapshotdelete_snapshotdeleteSnapshotDeleteSnapshotdelete_snapshotdeleteSnapshotDELETE /v1/volumes/{key}/snapshots/{snapshot}
volumes.delete_by_iddelete_by_iddeleteByIdDeleteByIDdelete_by_iddeleteByIdDELETE /v1/volumes/{key}
volumes.getgetgetGetgetgetGET /v1/volumes/{key}/{name}
volumes.versionsversionsversionsVersionsversionsversionsGET /v1/volumes/{key}/{name}/versions
volumes.deletedeletedeleteDeletedeletedeleteDELETE /v1/volumes/{key}/{name}
volumes.delete_versiondelete_versiondeleteVersionDeleteVersiondelete_versiondeleteVersionDELETE /v1/volumes/{key}/{name}/versions/{n}
secrets.setsetsetSetsetsetPUT /v1/secrets/{owner}/mine/{name}
secrets.listlistlistListlistlistGET /v1/secrets/{owner}/mine
secrets.deletedeletedeleteDeletedeletedeleteDELETE /v1/secrets/{owner}/mine/{name}
connectors.listlistlistListlistlistGET /v1/connectors
connectors.deletedeletedeleteDeletedeletedeleteDELETE /v1/connectors/{name}
sandboxes.createcreatecreateCreatecreatecreatePOST /v1/sandboxes
sandboxes.getgetgetGetgetgetGET /v1/sandboxes/{id}
sandboxes.listlistlistListlistlistGET /v1/sandboxes; one page, limit and cursor pick it
sandboxes.list_pagelist_pagelistPageListPagelist_pagelistPagethe page and the cursor of the next one
sandboxes.runrunrunRunrunruncreate, wait, logs and terminate in one call
sandbox handle.refreshrefreshrefreshRefreshrefreshrefreshGET /v1/sandboxes/{id}
sandbox handle.wait_runningwait_runningwaitRunningWaitRunningwait_runningwaitRunningpolls GET /v1/sandboxes/{id}
sandbox handle.logslogslogsLogslogslogsGET /v1/sandboxes/{id}/logs; follow holds until the process ends
sandbox handle.attachattachattachAttachattachattachGET /v1/sandboxes/{id}/attach (WebSocket); waits for running first
sandbox handle.terminateterminateterminateTerminateterminateterminatePOST /v1/sandboxes/{id}/terminate
sandbox handle.waitwaitwaitWaitwaitwaitForPOST /v1/sandboxes/{id}/wait; answers the exit code
sandbox handle.deletedeletedeleteDeletedeletedeleteDELETE /v1/sandboxes/{id}
attach handle.writewritewriteWritewritewritechannel 0 (stdin)
attach handle.readreadreadReadreadreadchannels 1 and 2 (output); the end is None, null, io.EOF, nil
attach handle.resizeresizeresizeResizeresizeresizechannel 4
attach handle.waitwaitwaitWaitwaitwaitForchannel 3 (exit code)
attach handle.closeclosecloseClosecloseclosecloses the WebSocket
pipelines.createcreatecreateCreatecreatecreatePOST /v1/pipelines/{owner}
pipelines.updateupdateupdateUpdateupdateupdatePUT /v1/pipelines/{owner}/{name}
pipelines.listlistlistListlistlistGET /v1/pipelines/{owner}
pipelines.getgetgetGetgetgetGET /v1/pipelines/{owner}/{name}
pipelines.versionsversionsversionsVersionsversionsversionsGET /v1/pipelines/{owner}/{name}/versions
pipelines.deletedeletedeleteDeletedeletedeleteDELETE /v1/pipelines/{owner}/{name}
pipelines.runrunrunRunrunrunPOST /v1/pipelines/{owner}/{name}/runs
pipelines.rotate_webhookrotate_webhookrotateWebhookRotateWebhookrotate_webhookrotateWebhookPOST /v1/pipelines/{owner}/{name}/webhook/rotate
pipelines.runsrunsrunsRunsrunsrunsGET /v1/pipelines/{owner}/{pipeline}/runs
pipelines.get_runget_rungetRunGetRunget_rungetRunGET /v1/pipelines/{owner}/{pipeline}/runs/{run}
run handle.refreshrefreshrefreshRefreshrefreshrefreshGET /v1/pipelines/{owner}/{pipeline}/runs/{run}
run handle.cancelcancelcancelCancelcancelcancelPOST /v1/pipelines/{owner}/{pipeline}/runs/{run}/cancel
run handle.waitwaitwaitWaitwaitwaitForpolls GET /v1/pipelines/{owner}/{pipeline}/runs/{run}
run handle.logslogslogsLogslogslogsGET /v1/pipelines/{owner}/{pipeline}/runs/{run}/jobs/{index}/logs
run handle.followfollowfollowFollowfollowfollowGET /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.