Daytona uses reverse proxies to provide a seamless collaboration and feedback loop. The integration makes use of a Go API client to interact with the Daytona Server API. The API client was generated using the OpenAPI Generator project, which uses the OpenAPI-spec from a remote server to easily generate a client.
Installation
Install the following dependencies:
go get github.com/stretchr/testify/assert
go get golang.org/x/net/context
Put the package under your project folder and add the following in import:
import apiclient "github.com/GIT_USER_ID/GIT_REPO_ID/apiclient"
To use a proxy, set the environment variable HTTP_PROXY
:
os.Setenv("HTTP_PROXY", "http://proxy_name:proxy_port")
Configuration of Server URL
Default configuration comes with Servers
field that contains server objects as defined in the OpenAPI specification.
Select Server Configuration
For using other server than the one defined on index 0 set context value apiclient.ContextServerIndex
of type int
.
ctx := context.WithValue(context.Background(), apiclient.ContextServerIndex, 1)
Templated Server URL
Templated server URL is formatted using default variables from configuration or from context value apiclient.ContextServerVariables
of type map[string]string
.
ctx := context.WithValue(context.Background(), apiclient.ContextServerVariables, map[string]string{
"basePath": "v2",
})
Note, enum values are always validated and all unused variables are silently ignored.
URLs Configuration per Operation
Each operation can use different server URL defined using OperationServers
map in the Configuration
. An operation is uniquely identified by "{classname}Service.{nickname}"
string. Similar rules for overriding default operation server index and variables applies by using apiclient.ContextOperationServerIndices
and apiclient.ContextOperationServerVariables
context maps.
ctx := context.WithValue(context.Background(), apiclient.ContextOperationServerIndices, map[string]int{
"{classname}Service.{nickname}": 2,
})
ctx = context.WithValue(context.Background(), apiclient.ContextOperationServerVariables, map[string]map[string]string{
"{classname}Service.{nickname}": {
"port": "8443",
},
})
Documentation for API Endpoints
All URIs are relative to http://localhost:3986
Class | Method | HTTP request | Description |
---|---|---|---|
ApiKeyAPI | GenerateApiKey | Post /apikey/{apiKeyName} | Generate an API key |
ApiKeyAPI | ListClientApiKeys | Get /apikey | List API keys |
ApiKeyAPI | RevokeApiKey | Delete /apikey/{apiKeyName} | Revoke API key |
ContainerRegistryAPI | GetContainerRegistry | Get /container-registry/{server} | Get container registry credentials |
ContainerRegistryAPI | ListContainerRegistries | Get /container-registry | List container registries |
ContainerRegistryAPI | RemoveContainerRegistry | Delete /container-registry/{server} | Remove a container registry credentials |
ContainerRegistryAPI | SetContainerRegistry | Put /container-registry/{server} | Set container registry credentials |
GitProviderAPI | GetGitContext | Get /gitprovider/context/{gitUrl} | Get Git context |
GitProviderAPI | GetGitProviderForUrl | Get /gitprovider/for-url/{url} | Get Git provider |
GitProviderAPI | GetGitProviderIdForUrl | Get /gitprovider/id-for-url/{url} | Get Git provider ID |
GitProviderAPI | GetGitUser | Get /gitprovider/{gitProviderId}/user | Get Git context |
GitProviderAPI | GetNamespaces | Get /gitprovider/{gitProviderId}/namespaces | Get Git namespaces |
GitProviderAPI | GetRepoBranches | Get /gitprovider/{gitProviderId}/{namespaceId}/{repositoryId}/branches | Get Git repository branches |
GitProviderAPI | GetRepoPRs | Get /gitprovider/{gitProviderId}/{namespaceId}/{repositoryId}/pull-requests | Get Git repository PRs |
GitProviderAPI | GetRepositories | Get /gitprovider/{gitProviderId}/{namespaceId}/repositories | Get Git repositories |
GitProviderAPI | GetUrlFromRepository | Post /gitprovider/context/url | Get URL from Git repository |
GitProviderAPI | ListGitProviders | Get /gitprovider | List Git providers |
GitProviderAPI | RemoveGitProvider | Delete /gitprovider/{gitProviderId} | Remove Git provider |
GitProviderAPI | SetGitProvider | Put /gitprovider | Set Git provider |
ProfileAPI | DeleteProfileData | Delete /profile | Delete profile data |
ProfileAPI | GetProfileData | Get /profile | Get profile data |
ProfileAPI | SetProfileData | Put /profile | Set profile data |
ProjectConfigAPI | DeleteProjectConfig | Delete /project-config/{configName} | Delete project config data |
ProjectConfigAPI | GetDefaultProjectConfig | Get /project-config/default/{gitUrl} | Get project configs by git url |
ProjectConfigAPI | GetProjectConfig | Get /project-config/{configName} | Get project config data |
ProjectConfigAPI | ListProjectConfigs | Get /project-config | List project configs |
ProjectConfigAPI | SetDefaultProjectConfig | Patch /project-config/{configName}/set-default | Set project config to default |
ProjectConfigAPI | SetProjectConfig | Put /project-config | Set project config data |
ProviderAPI | GetTargetManifest | Get /provider/{provider}/target-manifest | Get provider target manifest |
ProviderAPI | InstallProvider | Post /provider/install | Install a provider |
ProviderAPI | ListProviders | Get /provider | List providers |
ProviderAPI | UninstallProvider | Post /provider/{provider}/uninstall | Uninstall a provider |
ServerAPI | GenerateNetworkKey | Post /server/network-key | Generate a new authentication key |
ServerAPI | GetConfig | Get /server/config | Get the server configuration |
ServerAPI | SetConfig | Post /server/config | Set the server configuration |
TargetAPI | ListTargets | Get /target | List targets |
TargetAPI | RemoveTarget | Delete /target/{target} | Remove a target |
TargetAPI | SetTarget | Put /target | Set a target |
WorkspaceAPI | CreateWorkspace | Post /workspace | Create a workspace |
WorkspaceAPI | GetWorkspace | Get /workspace/{workspaceId} | Get workspace info |
WorkspaceAPI | ListWorkspaces | Get /workspace | List workspaces |
WorkspaceAPI | RemoveWorkspace | Delete /workspace/{workspaceId} | Remove workspace |
WorkspaceAPI | SetProjectState | Post /workspace/{workspaceId}/{projectId}/state | Set project state |
WorkspaceAPI | StartProject | Post /workspace/{workspaceId}/{projectId}/start | Start project |
WorkspaceAPI | StartWorkspace | Post /workspace/{workspaceId}/start | Start workspace |
WorkspaceAPI | StopProject | Post /workspace/{workspaceId}/{projectId}/stop | Stop project |
WorkspaceAPI | StopWorkspace | Post /workspace/{workspaceId}/stop | Stop workspace |
Documentation For Models
- ApiKey
- ApikeyApiKeyType
- ContainerRegistry
- CreateProjectConfigDTO
- CreateProjectConfigSourceDTO
- CreateWorkspaceDTO
- DevcontainerConfig
- FRPSConfig
- FileStatus
- GitBranch
- GitNamespace
- GitProvider
- GitPullRequest
- GitRepository
- GitStatus
- GitUser
- InstallProviderRequest
- NetworkKey
- ProfileData
- Project
- ProjectBuildConfig
- ProjectConfig
- ProjectInfo
- ProjectState
- Provider
- ProviderProviderInfo
- ProviderProviderTargetProperty
- ProviderProviderTargetPropertyType
- ProviderTarget
- ServerConfig
- SetProjectState
- Status
- Workspace
- WorkspaceDTO
- WorkspaceInfo
Documentation For Authorization
Authentication schemes defined for the API:
Bearer
- Type: API key
- API key parameter name: Authorization
- Location: HTTP header
Note, each API key must be added to a map of map[string]APIKey
where the key is: Authorization and passed in as the auth context for each request.
Example
auth := context.WithValue(
context.Background(),
apiclient.ContextAPIKeys,
map[string]apiclient.APIKey{
"Authorization": {Key: "API_KEY_STRING"},
},
)
r, err := client.Service.Operation(auth, args)
Documentation for Utility Methods
Due to the fact that model structure members are all pointers, this package contains a number of utility functions to easily obtain pointers to values of basic types. Each of these functions takes a value of the given basic type and returns a pointer to it:
PtrBool
PtrInt
PtrInt32
PtrInt64
PtrFloat
PtrFloat32
PtrFloat64
PtrString
PtrTime
Author
## Top-Level Directory Explanations
<a class='local-link directory-link' data-ref="cmd/" href="#cmd/">cmd/</a> - Contains command-line interface tools and scripts.
<a class='local-link directory-link' data-ref="cmd/daytona/" href="#cmd/daytona/">cmd/daytona/</a> - Subdirectory for Daytona-specific command-line tools.
<a class='local-link directory-link' data-ref="cmd/daytona/config/" href="#cmd/daytona/config/">cmd/daytona/config/</a> - Subdirectory for configuration files for Daytona command-line tools.
<a class='local-link directory-link' data-ref="hack/" href="#hack/">hack/</a> - Directory for Go development, including build scripts and dependencies.
<a class='local-link directory-link' data-ref="internal/" href="#internal/">internal/</a> - Private package directory for the project's internal modules.
<a class='local-link directory-link' data-ref="internal/cmd/" href="#internal/cmd/">internal/cmd/</a> - Subdirectory for command-line tools.
<a class='local-link directory-link' data-ref="internal/cmd/tailscale/" href="#internal/cmd/tailscale/">internal/cmd/tailscale/</a> - Subdirectory for Tailscale command-line tools.
<a class='local-link directory-link' data-ref="internal/testing/" href="#internal/testing/">internal/testing/</a> - Subdirectory for testing-related modules.
<a class='local-link directory-link' data-ref="internal/testing/agent/" href="#internal/testing/agent/">internal/testing/agent/</a> - Subdirectory for testing agents.
<a class='local-link directory-link' data-ref="internal/util/" href="#internal/util/">internal/util/</a> - Subdirectory for utility modules.
<a class='local-link directory-link' data-ref="internal/util/apiclient/" href="#internal/util/apiclient/">internal/util/apiclient/</a> - Subdirectory for API client utilities.
<a class='local-link directory-link' data-ref="pkg/" href="#pkg/">pkg/</a> - Go packages directory.
<a class='local-link directory-link' data-ref="pkg/agent/" href="#pkg/agent/">pkg/agent/</a> - Subdirectory for the project's agent package.
<a class='local-link directory-link' data-ref="pkg/agent/ssh/" href="#pkg/agent/ssh/">pkg/agent/ssh/</a> - Subdirectory for SSH-related configurations and utilities.
<a class='local-link directory-link' data-ref="pkg/agent/tailscale/" href="#pkg/agent/tailscale/">pkg/agent/tailscale/</a> - Subdirectory for Tailscale-related configurations and utilities.
<a class='local-link directory-link' data-ref="pkg/api/" href="#pkg/api/">pkg/api/</a> - Subdirectory for API-related packages.
<a class='local-link directory-link' data-ref="pkg/api/controllers/" href="#pkg/api/controllers/">pkg/api/controllers/</a> - Subdirectory for API controller handlers.
<a class='local-link directory-link' data-ref="pkg/api/middlewares/" href="#pkg/api/middlewares/">pkg/api/middlewares/</a> - Subdirectory for API middlewares.
<a class='local-link directory-link' data-ref="pkg/apiclient/" href="#pkg/apiclient/">pkg/apiclient/</a> - Subdirectory for API client package.
<a class='local-link directory-link' data-ref="pkg/cmd/" href="#pkg/cmd/">pkg/cmd/</a> - Subdirectory for command-line interface tools.
<a class='local-link directory-link' data-ref="pkg/cmd/ports/" href="#pkg/cmd/ports/">pkg/cmd/ports/</a> - Subdirectory for port command-line tools.
<a class='local-link directory-link' data-ref="pkg/cmd/workspace/" href="#pkg/cmd/workspace/">pkg/cmd/workspace/</a> - Subdirectory for workspace command-line tools.
<a class='local-link directory-link' data-ref="pkg/ports/" href="#pkg/ports/">pkg/ports/</a> - Subdirectory for port-related packages and scripts.
<a class='local-link directory-link' data-ref="pkg/tailscale/" href="#pkg/tailscale/">pkg/tailscale/</a> - Subdirectory for Tailscale package.
<a class='local-link directory-link' data-ref="pkg/tailscale/tunnel/" href="#pkg/tailscale/tunnel/">pkg/tailscale/tunnel/</a> - Subdirectory for Tailscale tunnel.
<a class='local-link directory-link' data-ref="pkg/views/" href="#pkg/views/">pkg/views/</a> - Subdirectory for view templates.