databricks-sdk-go is an unofficial Databricks SDK for the Go programming language. It currently only supports a subset of the operations provided by the Databricks REST API. At this point, there is only support for the following APIs:
- Clusters API
- Workspace API
- Groups API
To install the SDK run the following command:
go get -u github.com/betabandido/databricks-sdk-go
The SDK provides an API client as well as multiple endpoints to interact with the different parts of the Databricks REST API.
All operations interacting with Databricks REST API need an API Client. The following example shows how to create a client.
cl, err := client.NewClient(client.Options{Domain: &domain, Token: &token})
if err != nil {
panic(err)
}
domain
refers to the name of the Databricks deployment (e.g., <your-account>.cloud.databricks.com
), and token
needs to contain the authentication token. See Databricks authentication documentation for more details.
Requests for a given API can be sent using the appropriate endpoint. For instance, the following example shows how to upload a notebook to the workspace.
endpoint := workspace.Endpoint{
Client: cl,
}
language := models.PYTHON
content := base64.StdEncoding.EncodeToString([]byte("print('hello world')"))
err := endpoint.Import(&models.WorkspaceImportRequest{
Path: path,
Language: &language,
Content: content,
})
if err != nil {
panic(err)
}
See the examples
folder for more examples on how to use the SDK.
The information below is only of interests for someone who wants to do development work on the Databricks SDK for Go.
Check the Go programming language documentation to setup a development environment for Go.
Request and response models are autogenerated using swagger-codegen. To generate the models run the following command from the project's root.
go generate
Please note that you need to have swagger-codegen
installed for the previous command to work.