workspace

package
v0.43.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 9, 2024 License: Apache-2.0 Imports: 14 Imported by: 18

Documentation

Overview

These APIs allow you to manage Git Credentials, Repos, Secrets, Workspace, etc.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func DownloadFormat added in v0.10.0

func DownloadFormat(f ExportFormat) func(q map[string]any)

Types

type AclItem added in v0.8.0

type AclItem struct {
	// The permission level applied to the principal.
	Permission AclPermission `json:"permission"`
	// The principal in which the permission is applied.
	Principal string `json:"principal"`
}

type AclPermission added in v0.8.0

type AclPermission string
const AclPermissionManage AclPermission = `MANAGE`
const AclPermissionRead AclPermission = `READ`
const AclPermissionWrite AclPermission = `WRITE`

func (*AclPermission) Set added in v0.8.0

func (f *AclPermission) Set(v string) error

Set raw string value and validate it against allowed values

func (*AclPermission) String added in v0.8.0

func (f *AclPermission) String() string

String representation for fmt.Print

func (*AclPermission) Type added in v0.8.0

func (f *AclPermission) Type() string

Type always returns AclPermission to satisfy [pflag.Value] interface

type AzureKeyVaultSecretScopeMetadata added in v0.8.0

type AzureKeyVaultSecretScopeMetadata struct {
	// The DNS of the KeyVault
	DnsName string `json:"dns_name"`
	// The resource id of the azure KeyVault that user wants to associate the
	// scope with.
	ResourceId string `json:"resource_id"`
}

type CreateCredentials added in v0.8.0

type CreateCredentials struct {
	// Git provider. This field is case-insensitive. The available Git providers
	// are gitHub, bitbucketCloud, gitLab, azureDevOpsServices,
	// gitHubEnterprise, bitbucketServer, gitLabEnterpriseEdition and
	// awsCodeCommit.
	GitProvider string `json:"git_provider"`
	// The username or email provided with your Git provider account, depending
	// on which provider you are using. For GitHub, GitHub Enterprise Server, or
	// Azure DevOps Services, either email or username may be used. For GitLab,
	// GitLab Enterprise Edition, email must be used. For AWS CodeCommit,
	// BitBucket or BitBucket Server, username must be used. For all other
	// providers please see your provider's Personal Access Token authentication
	// documentation to see what is supported.
	GitUsername string `json:"git_username,omitempty"`
	// The personal access token used to authenticate to the corresponding Git
	// provider. For certain providers, support may exist for other types of
	// scoped access tokens. [Learn more]. The personal access token used to
	// authenticate to the corresponding Git
	//
	// [Learn more]: https://docs.databricks.com/repos/get-access-tokens-from-git-provider.html
	PersonalAccessToken string `json:"personal_access_token,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (CreateCredentials) MarshalJSON added in v0.23.0

func (s CreateCredentials) MarshalJSON() ([]byte, error)

func (*CreateCredentials) UnmarshalJSON added in v0.23.0

func (s *CreateCredentials) UnmarshalJSON(b []byte) error

type CreateCredentialsResponse added in v0.8.0

type CreateCredentialsResponse struct {
	// ID of the credential object in the workspace.
	CredentialId int64 `json:"credential_id,omitempty"`
	// Git provider. This field is case-insensitive. The available Git providers
	// are gitHub, bitbucketCloud, gitLab, azureDevOpsServices,
	// gitHubEnterprise, bitbucketServer, gitLabEnterpriseEdition and
	// awsCodeCommit.
	GitProvider string `json:"git_provider,omitempty"`
	// The username or email provided with your Git provider account, depending
	// on which provider you are using. For GitHub, GitHub Enterprise Server, or
	// Azure DevOps Services, either email or username may be used. For GitLab,
	// GitLab Enterprise Edition, email must be used. For AWS CodeCommit,
	// BitBucket or BitBucket Server, username must be used. For all other
	// providers please see your provider's Personal Access Token authentication
	// documentation to see what is supported.
	GitUsername string `json:"git_username,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (CreateCredentialsResponse) MarshalJSON added in v0.23.0

func (s CreateCredentialsResponse) MarshalJSON() ([]byte, error)

func (*CreateCredentialsResponse) UnmarshalJSON added in v0.23.0

func (s *CreateCredentialsResponse) UnmarshalJSON(b []byte) error

type CreateRepo added in v0.8.0

type CreateRepo struct {
	// Desired path for the repo in the workspace. Almost any path in the
	// workspace can be chosen. If repo is created in /Repos, path must be in
	// the format /Repos/{folder}/{repo-name}.
	Path string `json:"path,omitempty"`
	// Git provider. This field is case-insensitive. The available Git providers
	// are gitHub, bitbucketCloud, gitLab, azureDevOpsServices,
	// gitHubEnterprise, bitbucketServer, gitLabEnterpriseEdition and
	// awsCodeCommit.
	Provider string `json:"provider"`
	// If specified, the repo will be created with sparse checkout enabled. You
	// cannot enable/disable sparse checkout after the repo is created.
	SparseCheckout *SparseCheckout `json:"sparse_checkout,omitempty"`
	// URL of the Git repository to be linked.
	Url string `json:"url"`

	ForceSendFields []string `json:"-"`
}

func (CreateRepo) MarshalJSON added in v0.23.0

func (s CreateRepo) MarshalJSON() ([]byte, error)

func (*CreateRepo) UnmarshalJSON added in v0.23.0

func (s *CreateRepo) UnmarshalJSON(b []byte) error

type CreateScope added in v0.8.0

type CreateScope struct {
	// The metadata for the secret scope if the type is `AZURE_KEYVAULT`
	BackendAzureKeyvault *AzureKeyVaultSecretScopeMetadata `json:"backend_azure_keyvault,omitempty"`
	// The principal that is initially granted `MANAGE` permission to the
	// created scope.
	InitialManagePrincipal string `json:"initial_manage_principal,omitempty"`
	// Scope name requested by the user. Scope names are unique.
	Scope string `json:"scope"`
	// The backend type the scope will be created with. If not specified, will
	// default to `DATABRICKS`
	ScopeBackendType ScopeBackendType `json:"scope_backend_type,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (CreateScope) MarshalJSON added in v0.23.0

func (s CreateScope) MarshalJSON() ([]byte, error)

func (*CreateScope) UnmarshalJSON added in v0.23.0

func (s *CreateScope) UnmarshalJSON(b []byte) error

type CreateScopeResponse added in v0.34.0

type CreateScopeResponse struct {
}

type CredentialInfo added in v0.8.0

type CredentialInfo struct {
	// ID of the credential object in the workspace.
	CredentialId int64 `json:"credential_id,omitempty"`
	// Git provider. This field is case-insensitive. The available Git providers
	// are gitHub, gitHubOAuth, bitbucketCloud, gitLab, azureDevOpsServices,
	// gitHubEnterprise, bitbucketServer, gitLabEnterpriseEdition and
	// awsCodeCommit.
	GitProvider string `json:"git_provider,omitempty"`
	// The username or email provided with your Git provider account, depending
	// on which provider you are using. For GitHub, GitHub Enterprise Server, or
	// Azure DevOps Services, either email or username may be used. For GitLab,
	// GitLab Enterprise Edition, email must be used. For AWS CodeCommit,
	// BitBucket or BitBucket Server, username must be used. For all other
	// providers please see your provider's Personal Access Token authentication
	// documentation to see what is supported.
	GitUsername string `json:"git_username,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (CredentialInfo) MarshalJSON added in v0.23.0

func (s CredentialInfo) MarshalJSON() ([]byte, error)

func (*CredentialInfo) UnmarshalJSON added in v0.23.0

func (s *CredentialInfo) UnmarshalJSON(b []byte) error

type Delete

type Delete struct {
	// The absolute path of the notebook or directory.
	Path string `json:"path"`
	// The flag that specifies whether to delete the object recursively. It is
	// `false` by default. Please note this deleting directory is not atomic. If
	// it fails in the middle, some of objects under this directory may be
	// deleted and cannot be undone.
	Recursive bool `json:"recursive,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (Delete) MarshalJSON added in v0.23.0

func (s Delete) MarshalJSON() ([]byte, error)

func (*Delete) UnmarshalJSON added in v0.23.0

func (s *Delete) UnmarshalJSON(b []byte) error

type DeleteAcl added in v0.8.0

type DeleteAcl struct {
	// The principal to remove an existing ACL from.
	Principal string `json:"principal"`
	// The name of the scope to remove permissions from.
	Scope string `json:"scope"`
}

type DeleteAclResponse added in v0.34.0

type DeleteAclResponse struct {
}

type DeleteGitCredentialRequest added in v0.8.0

type DeleteGitCredentialRequest struct {
	// The ID for the corresponding credential to access.
	CredentialId int64 `json:"-" url:"-"`
}

Delete a credential

type DeleteRepoRequest added in v0.8.0

type DeleteRepoRequest struct {
	// The ID for the corresponding repo to access.
	RepoId int64 `json:"-" url:"-"`
}

Delete a repo

type DeleteResponse added in v0.34.0

type DeleteResponse struct {
}

type DeleteScope added in v0.8.0

type DeleteScope struct {
	// Name of the scope to delete.
	Scope string `json:"scope"`
}

type DeleteScopeResponse added in v0.34.0

type DeleteScopeResponse struct {
}

type DeleteSecret added in v0.8.0

type DeleteSecret struct {
	// Name of the secret to delete.
	Key string `json:"key"`
	// The name of the scope that contains the secret to delete.
	Scope string `json:"scope"`
}

type DeleteSecretResponse added in v0.34.0

type DeleteSecretResponse struct {
}

type DownloadOption added in v0.10.0

type DownloadOption = func(q map[string]any)

type ExportFormat

type ExportFormat string
const ExportFormatAuto ExportFormat = `AUTO`
const ExportFormatDbc ExportFormat = `DBC`
const ExportFormatHtml ExportFormat = `HTML`
const ExportFormatJupyter ExportFormat = `JUPYTER`
const ExportFormatRMarkdown ExportFormat = `R_MARKDOWN`
const ExportFormatSource ExportFormat = `SOURCE`

func (*ExportFormat) Set added in v0.2.0

func (f *ExportFormat) Set(v string) error

Set raw string value and validate it against allowed values

func (*ExportFormat) String added in v0.2.0

func (f *ExportFormat) String() string

String representation for fmt.Print

func (*ExportFormat) Type added in v0.2.0

func (f *ExportFormat) Type() string

Type always returns ExportFormat to satisfy [pflag.Value] interface

type ExportRequest added in v0.8.0

type ExportRequest struct {
	// This specifies the format of the exported file. By default, this is
	// `SOURCE`.
	//
	// The value is case sensitive.
	//
	// - `SOURCE`: The notebook is exported as source code. Directory exports
	// will not include non-notebook entries. - `HTML`: The notebook is exported
	// as an HTML file. - `JUPYTER`: The notebook is exported as a
	// Jupyter/IPython Notebook file. - `DBC`: The notebook is exported in
	// Databricks archive format. Directory exports will not include
	// non-notebook entries. - `R_MARKDOWN`: The notebook is exported to R
	// Markdown format. - `AUTO`: The object or directory is exported depending
	// on the objects type. Directory exports will include notebooks and
	// workspace files.
	Format ExportFormat `json:"-" url:"format,omitempty"`
	// The absolute path of the object or directory. Exporting a directory is
	// only supported for the `DBC`, `SOURCE`, and `AUTO` format.
	Path string `json:"-" url:"path"`
}

Export a workspace object

type ExportResponse

type ExportResponse struct {
	// The base64-encoded content. If the limit (10MB) is exceeded, exception
	// with error code **MAX_NOTEBOOK_SIZE_EXCEEDED** is thrown.
	Content string `json:"content,omitempty"`
	// The file type of the exported file.
	FileType string `json:"file_type,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (*ExportResponse) Bytes

func (r *ExportResponse) Bytes() ([]byte, error)

func (ExportResponse) MarshalJSON added in v0.23.0

func (s ExportResponse) MarshalJSON() ([]byte, error)

func (*ExportResponse) UnmarshalJSON added in v0.23.0

func (s *ExportResponse) UnmarshalJSON(b []byte) error

type GetAclRequest added in v0.8.0

type GetAclRequest struct {
	// The principal to fetch ACL information for.
	Principal string `json:"-" url:"principal"`
	// The name of the scope to fetch ACL information from.
	Scope string `json:"-" url:"scope"`
}

Get secret ACL details

type GetCredentialsResponse added in v0.8.0

type GetCredentialsResponse struct {
	Credentials []CredentialInfo `json:"credentials,omitempty"`
}

type GetGitCredentialRequest added in v0.8.0

type GetGitCredentialRequest struct {
	// The ID for the corresponding credential to access.
	CredentialId int64 `json:"-" url:"-"`
}

Get a credential entry

type GetRepoPermissionLevelsRequest added in v0.15.0

type GetRepoPermissionLevelsRequest struct {
	// The repo for which to get or manage permissions.
	RepoId string `json:"-" url:"-"`
}

Get repo permission levels

type GetRepoPermissionLevelsResponse added in v0.15.0

type GetRepoPermissionLevelsResponse struct {
	// Specific permission levels
	PermissionLevels []RepoPermissionsDescription `json:"permission_levels,omitempty"`
}

type GetRepoPermissionsRequest added in v0.15.0

type GetRepoPermissionsRequest struct {
	// The repo for which to get or manage permissions.
	RepoId string `json:"-" url:"-"`
}

Get repo permissions

type GetRepoRequest added in v0.8.0

type GetRepoRequest struct {
	// The ID for the corresponding repo to access.
	RepoId int64 `json:"-" url:"-"`
}

Get a repo

type GetSecretRequest added in v0.17.0

type GetSecretRequest struct {
	// The key to fetch secret for.
	Key string `json:"-" url:"key"`
	// The name of the scope to fetch secret information from.
	Scope string `json:"-" url:"scope"`
}

Get a secret

type GetSecretResponse added in v0.17.0

type GetSecretResponse struct {
	// A unique name to identify the secret.
	Key string `json:"key,omitempty"`
	// The value of the secret in its byte representation.
	Value string `json:"value,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (GetSecretResponse) MarshalJSON added in v0.23.0

func (s GetSecretResponse) MarshalJSON() ([]byte, error)

func (*GetSecretResponse) UnmarshalJSON added in v0.23.0

func (s *GetSecretResponse) UnmarshalJSON(b []byte) error

type GetStatusRequest added in v0.8.0

type GetStatusRequest struct {
	// The absolute path of the notebook or directory.
	Path string `json:"-" url:"path"`
}

Get status

type GetWorkspaceObjectPermissionLevelsRequest added in v0.15.0

type GetWorkspaceObjectPermissionLevelsRequest struct {
	// The workspace object for which to get or manage permissions.
	WorkspaceObjectId string `json:"-" url:"-"`
	// The workspace object type for which to get or manage permissions.
	WorkspaceObjectType string `json:"-" url:"-"`
}

Get workspace object permission levels

type GetWorkspaceObjectPermissionLevelsResponse added in v0.15.0

type GetWorkspaceObjectPermissionLevelsResponse struct {
	// Specific permission levels
	PermissionLevels []WorkspaceObjectPermissionsDescription `json:"permission_levels,omitempty"`
}

type GetWorkspaceObjectPermissionsRequest added in v0.15.0

type GetWorkspaceObjectPermissionsRequest struct {
	// The workspace object for which to get or manage permissions.
	WorkspaceObjectId string `json:"-" url:"-"`
	// The workspace object type for which to get or manage permissions.
	WorkspaceObjectType string `json:"-" url:"-"`
}

Get workspace object permissions

type GitCredentialsAPI added in v0.8.0

type GitCredentialsAPI struct {
	// contains filtered or unexported fields
}

Registers personal access token for Databricks to do operations on behalf of the user.

See more info.

func NewGitCredentials added in v0.8.0

func NewGitCredentials(client *client.DatabricksClient) *GitCredentialsAPI

func (*GitCredentialsAPI) Create added in v0.8.0

Create a credential entry.

Creates a Git credential entry for the user. Only one Git credential per user is supported, so any attempts to create credentials if an entry already exists will fail. Use the PATCH endpoint to update existing credentials, or the DELETE endpoint to delete existing credentials.

Example (GitCredentials)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

cr, err := w.GitCredentials.Create(ctx, workspace.CreateCredentials{
	GitProvider:         "gitHub",
	GitUsername:         "test",
	PersonalAccessToken: "test",
})
if err != nil {
	panic(err)
}
logger.Infof(ctx, "found %v", cr)

// cleanup

err = w.GitCredentials.DeleteByCredentialId(ctx, cr.CredentialId)
if err != nil {
	panic(err)
}
Output:

func (*GitCredentialsAPI) CredentialInfoGitProviderToCredentialIdMap added in v0.8.0

func (a *GitCredentialsAPI) CredentialInfoGitProviderToCredentialIdMap(ctx context.Context) (map[string]int64, error)

CredentialInfoGitProviderToCredentialIdMap calls GitCredentialsAPI.ListAll and creates a map of results with CredentialInfo.GitProvider as key and CredentialInfo.CredentialId as value.

Returns an error if there's more than one CredentialInfo with the same .GitProvider.

Note: All CredentialInfo instances are loaded into memory before creating a map.

This method is generated by Databricks SDK Code Generator.

func (*GitCredentialsAPI) Delete added in v0.8.0

Delete a credential.

Deletes the specified Git credential.

func (*GitCredentialsAPI) DeleteByCredentialId added in v0.8.0

func (a *GitCredentialsAPI) DeleteByCredentialId(ctx context.Context, credentialId int64) error

Delete a credential.

Deletes the specified Git credential.

func (*GitCredentialsAPI) Get added in v0.8.0

Get a credential entry.

Gets the Git credential with the specified credential ID.

Example (GitCredentials)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

cr, err := w.GitCredentials.Create(ctx, workspace.CreateCredentials{
	GitProvider:         "gitHub",
	GitUsername:         "test",
	PersonalAccessToken: "test",
})
if err != nil {
	panic(err)
}
logger.Infof(ctx, "found %v", cr)

byId, err := w.GitCredentials.GetByCredentialId(ctx, cr.CredentialId)
if err != nil {
	panic(err)
}
logger.Infof(ctx, "found %v", byId)

// cleanup

err = w.GitCredentials.DeleteByCredentialId(ctx, cr.CredentialId)
if err != nil {
	panic(err)
}
Output:

func (*GitCredentialsAPI) GetByCredentialId added in v0.8.0

func (a *GitCredentialsAPI) GetByCredentialId(ctx context.Context, credentialId int64) (*CredentialInfo, error)

Get a credential entry.

Gets the Git credential with the specified credential ID.

func (*GitCredentialsAPI) GetByGitProvider added in v0.8.0

func (a *GitCredentialsAPI) GetByGitProvider(ctx context.Context, name string) (*CredentialInfo, error)

GetByGitProvider calls GitCredentialsAPI.CredentialInfoGitProviderToCredentialIdMap and returns a single CredentialInfo.

Returns an error if there's more than one CredentialInfo with the same .GitProvider.

Note: All CredentialInfo instances are loaded into memory before returning matching by name.

This method is generated by Databricks SDK Code Generator.

func (*GitCredentialsAPI) Impl added in v0.8.0

Impl returns low-level GitCredentials API implementation Deprecated: use MockGitCredentialsInterface instead.

func (*GitCredentialsAPI) List added in v0.24.0

Get Git credentials.

Lists the calling user's Git credentials. One credential per user is supported.

This method is generated by Databricks SDK Code Generator.

func (*GitCredentialsAPI) ListAll added in v0.8.0

func (a *GitCredentialsAPI) ListAll(ctx context.Context) ([]CredentialInfo, error)

Get Git credentials.

Lists the calling user's Git credentials. One credential per user is supported.

This method is generated by Databricks SDK Code Generator.

Example (GitCredentials)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

list, err := w.GitCredentials.ListAll(ctx)
if err != nil {
	panic(err)
}
logger.Infof(ctx, "found %v", list)
Output:

func (*GitCredentialsAPI) Update added in v0.8.0

func (a *GitCredentialsAPI) Update(ctx context.Context, request UpdateCredentials) error

Update a credential.

Updates the specified Git credential.

Example (GitCredentials)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

cr, err := w.GitCredentials.Create(ctx, workspace.CreateCredentials{
	GitProvider:         "gitHub",
	GitUsername:         "test",
	PersonalAccessToken: "test",
})
if err != nil {
	panic(err)
}
logger.Infof(ctx, "found %v", cr)

err = w.GitCredentials.Update(ctx, workspace.UpdateCredentials{
	CredentialId:        cr.CredentialId,
	GitProvider:         "gitHub",
	GitUsername:         fmt.Sprintf("sdk-%x@example.com", time.Now().UnixNano()),
	PersonalAccessToken: fmt.Sprintf("sdk-%x", time.Now().UnixNano()),
})
if err != nil {
	panic(err)
}

// cleanup

err = w.GitCredentials.DeleteByCredentialId(ctx, cr.CredentialId)
if err != nil {
	panic(err)
}
Output:

func (*GitCredentialsAPI) WithImpl added in v0.8.0

WithImpl could be used to override low-level API implementations for unit testing purposes with github.com/golang/mock or other mocking frameworks. Deprecated: use MockGitCredentialsInterface instead.

type GitCredentialsInterface added in v0.29.0

type GitCredentialsInterface interface {
	// WithImpl could be used to override low-level API implementations for unit
	// testing purposes with [github.com/golang/mock] or other mocking frameworks.
	// Deprecated: use MockGitCredentialsInterface instead.
	WithImpl(impl GitCredentialsService) GitCredentialsInterface

	// Impl returns low-level GitCredentials API implementation
	// Deprecated: use MockGitCredentialsInterface instead.
	Impl() GitCredentialsService

	// Create a credential entry.
	//
	// Creates a Git credential entry for the user. Only one Git credential per user
	// is supported, so any attempts to create credentials if an entry already
	// exists will fail. Use the PATCH endpoint to update existing credentials, or
	// the DELETE endpoint to delete existing credentials.
	Create(ctx context.Context, request CreateCredentials) (*CreateCredentialsResponse, error)

	// Delete a credential.
	//
	// Deletes the specified Git credential.
	Delete(ctx context.Context, request DeleteGitCredentialRequest) error

	// Delete a credential.
	//
	// Deletes the specified Git credential.
	DeleteByCredentialId(ctx context.Context, credentialId int64) error

	// Get a credential entry.
	//
	// Gets the Git credential with the specified credential ID.
	Get(ctx context.Context, request GetGitCredentialRequest) (*CredentialInfo, error)

	// Get a credential entry.
	//
	// Gets the Git credential with the specified credential ID.
	GetByCredentialId(ctx context.Context, credentialId int64) (*CredentialInfo, error)

	// Get Git credentials.
	//
	// Lists the calling user's Git credentials. One credential per user is
	// supported.
	//
	// This method is generated by Databricks SDK Code Generator.
	List(ctx context.Context) listing.Iterator[CredentialInfo]

	// Get Git credentials.
	//
	// Lists the calling user's Git credentials. One credential per user is
	// supported.
	//
	// This method is generated by Databricks SDK Code Generator.
	ListAll(ctx context.Context) ([]CredentialInfo, error)

	// CredentialInfoGitProviderToCredentialIdMap calls [GitCredentialsAPI.ListAll] and creates a map of results with [CredentialInfo].GitProvider as key and [CredentialInfo].CredentialId as value.
	//
	// Returns an error if there's more than one [CredentialInfo] with the same .GitProvider.
	//
	// Note: All [CredentialInfo] instances are loaded into memory before creating a map.
	//
	// This method is generated by Databricks SDK Code Generator.
	CredentialInfoGitProviderToCredentialIdMap(ctx context.Context) (map[string]int64, error)

	// GetByGitProvider calls [GitCredentialsAPI.CredentialInfoGitProviderToCredentialIdMap] and returns a single [CredentialInfo].
	//
	// Returns an error if there's more than one [CredentialInfo] with the same .GitProvider.
	//
	// Note: All [CredentialInfo] instances are loaded into memory before returning matching by name.
	//
	// This method is generated by Databricks SDK Code Generator.
	GetByGitProvider(ctx context.Context, name string) (*CredentialInfo, error)

	// Update a credential.
	//
	// Updates the specified Git credential.
	Update(ctx context.Context, request UpdateCredentials) error
}

type GitCredentialsService added in v0.8.0

type GitCredentialsService interface {

	// Create a credential entry.
	//
	// Creates a Git credential entry for the user. Only one Git credential per
	// user is supported, so any attempts to create credentials if an entry
	// already exists will fail. Use the PATCH endpoint to update existing
	// credentials, or the DELETE endpoint to delete existing credentials.
	Create(ctx context.Context, request CreateCredentials) (*CreateCredentialsResponse, error)

	// Delete a credential.
	//
	// Deletes the specified Git credential.
	Delete(ctx context.Context, request DeleteGitCredentialRequest) error

	// Get a credential entry.
	//
	// Gets the Git credential with the specified credential ID.
	Get(ctx context.Context, request GetGitCredentialRequest) (*CredentialInfo, error)

	// Get Git credentials.
	//
	// Lists the calling user's Git credentials. One credential per user is
	// supported.
	//
	// Use ListAll() to get all CredentialInfo instances
	List(ctx context.Context) (*GetCredentialsResponse, error)

	// Update a credential.
	//
	// Updates the specified Git credential.
	Update(ctx context.Context, request UpdateCredentials) error
}

Registers personal access token for Databricks to do operations on behalf of the user.

See more info.

type Import

type Import struct {
	// The base64-encoded content. This has a limit of 10 MB.
	//
	// If the limit (10MB) is exceeded, exception with error code
	// **MAX_NOTEBOOK_SIZE_EXCEEDED** is thrown. This parameter might be absent,
	// and instead a posted file is used.
	Content string `json:"content,omitempty"`
	// This specifies the format of the file to be imported.
	//
	// The value is case sensitive.
	//
	// - `AUTO`: The item is imported depending on an analysis of the item's
	// extension and the header content provided in the request. If the item is
	// imported as a notebook, then the item's extension is automatically
	// removed. - `SOURCE`: The notebook or directory is imported as source
	// code. - `HTML`: The notebook is imported as an HTML file. - `JUPYTER`:
	// The notebook is imported as a Jupyter/IPython Notebook file. - `DBC`: The
	// notebook is imported in Databricks archive format. Required for
	// directories. - `R_MARKDOWN`: The notebook is imported from R Markdown
	// format.
	Format ImportFormat `json:"format,omitempty"`
	// The language of the object. This value is set only if the object type is
	// `NOTEBOOK`.
	Language Language `json:"language,omitempty"`
	// The flag that specifies whether to overwrite existing object. It is
	// `false` by default. For `DBC` format, `overwrite` is not supported since
	// it may contain a directory.
	Overwrite bool `json:"overwrite,omitempty"`
	// The absolute path of the object or directory. Importing a directory is
	// only supported for the `DBC` and `SOURCE` formats.
	Path string `json:"path"`

	ForceSendFields []string `json:"-"`
}

func PythonNotebookOverwrite

func PythonNotebookOverwrite(path, content string) Import

PythonNotebookOverwrite crafts Python import notebook request also by trimming the code specified in the second argument

func PythonNotebookOverwriteReader

func PythonNotebookOverwriteReader(path string, r io.Reader) (Import, error)

func (Import) MarshalJSON added in v0.23.0

func (s Import) MarshalJSON() ([]byte, error)

func (*Import) UnmarshalJSON added in v0.23.0

func (s *Import) UnmarshalJSON(b []byte) error

type ImportFormat added in v0.10.0

type ImportFormat string

This specifies the format of the file to be imported.

The value is case sensitive.

- `AUTO`: The item is imported depending on an analysis of the item's extension and the header content provided in the request. If the item is imported as a notebook, then the item's extension is automatically removed. - `SOURCE`: The notebook or directory is imported as source code. - `HTML`: The notebook is imported as an HTML file. - `JUPYTER`: The notebook is imported as a Jupyter/IPython Notebook file. - `DBC`: The notebook is imported in Databricks archive format. Required for directories. - `R_MARKDOWN`: The notebook is imported from R Markdown format.

const ImportFormatAuto ImportFormat = `AUTO`

The item is imported depending on an analysis of the item's extension and

const ImportFormatDbc ImportFormat = `DBC`

The notebook is imported in <Databricks> archive format. Required for directories.

const ImportFormatHtml ImportFormat = `HTML`

The notebook is imported as an HTML file.

const ImportFormatJupyter ImportFormat = `JUPYTER`

The notebook is imported as a Jupyter/IPython Notebook file.

const ImportFormatRMarkdown ImportFormat = `R_MARKDOWN`

The notebook is imported from R Markdown format.

const ImportFormatSource ImportFormat = `SOURCE`

The notebook or directory is imported as source code.

func (*ImportFormat) Set added in v0.10.0

func (f *ImportFormat) Set(v string) error

Set raw string value and validate it against allowed values

func (*ImportFormat) String added in v0.10.0

func (f *ImportFormat) String() string

String representation for fmt.Print

func (*ImportFormat) Type added in v0.10.0

func (f *ImportFormat) Type() string

Type always returns ImportFormat to satisfy [pflag.Value] interface

type ImportResponse added in v0.34.0

type ImportResponse struct {
}

type Language

type Language string

The language of the object. This value is set only if the object type is `NOTEBOOK`.

const LanguagePython Language = `PYTHON`
const LanguageR Language = `R`
const LanguageScala Language = `SCALA`
const LanguageSql Language = `SQL`

func (*Language) Set added in v0.2.0

func (f *Language) Set(v string) error

Set raw string value and validate it against allowed values

func (*Language) String added in v0.2.0

func (f *Language) String() string

String representation for fmt.Print

func (*Language) Type added in v0.2.0

func (f *Language) Type() string

Type always returns Language to satisfy [pflag.Value] interface

type ListAclsRequest added in v0.8.0

type ListAclsRequest struct {
	// The name of the scope to fetch ACL information from.
	Scope string `json:"-" url:"scope"`
}

Lists ACLs

type ListAclsResponse added in v0.8.0

type ListAclsResponse struct {
	// The associated ACLs rule applied to principals in the given scope.
	Items []AclItem `json:"items,omitempty"`
}

type ListReposRequest added in v0.8.0

type ListReposRequest struct {
	// Token used to get the next page of results. If not specified, returns the
	// first page of results as well as a next page token if there are more
	// results.
	NextPageToken string `json:"-" url:"next_page_token,omitempty"`
	// Filters repos that have paths starting with the given path prefix. If not
	// provided repos from /Repos will be served.
	PathPrefix string `json:"-" url:"path_prefix,omitempty"`

	ForceSendFields []string `json:"-"`
}

Get repos

func (ListReposRequest) MarshalJSON added in v0.23.0

func (s ListReposRequest) MarshalJSON() ([]byte, error)

func (*ListReposRequest) UnmarshalJSON added in v0.23.0

func (s *ListReposRequest) UnmarshalJSON(b []byte) error

type ListReposResponse added in v0.8.0

type ListReposResponse struct {
	// Token that can be specified as a query parameter to the GET /repos
	// endpoint to retrieve the next page of results.
	NextPageToken string `json:"next_page_token,omitempty"`

	Repos []RepoInfo `json:"repos,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (ListReposResponse) MarshalJSON added in v0.23.0

func (s ListReposResponse) MarshalJSON() ([]byte, error)

func (*ListReposResponse) UnmarshalJSON added in v0.23.0

func (s *ListReposResponse) UnmarshalJSON(b []byte) error

type ListResponse

type ListResponse struct {
	// List of objects.
	Objects []ObjectInfo `json:"objects,omitempty"`
}

type ListScopesResponse added in v0.8.0

type ListScopesResponse struct {
	// The available secret scopes.
	Scopes []SecretScope `json:"scopes,omitempty"`
}

type ListSecretsRequest added in v0.8.0

type ListSecretsRequest struct {
	// The name of the scope to list secrets within.
	Scope string `json:"-" url:"scope"`
}

List secret keys

type ListSecretsResponse added in v0.8.0

type ListSecretsResponse struct {
	// Metadata information of all secrets contained within the given scope.
	Secrets []SecretMetadata `json:"secrets,omitempty"`
}

type ListWorkspaceRequest added in v0.8.0

type ListWorkspaceRequest struct {
	// UTC timestamp in milliseconds
	NotebooksModifiedAfter int `json:"-" url:"notebooks_modified_after,omitempty"`
	// The absolute path of the notebook or directory.
	Path string `json:"-" url:"path"`

	ForceSendFields []string `json:"-"`
}

List contents

func (ListWorkspaceRequest) MarshalJSON added in v0.23.0

func (s ListWorkspaceRequest) MarshalJSON() ([]byte, error)

func (*ListWorkspaceRequest) UnmarshalJSON added in v0.23.0

func (s *ListWorkspaceRequest) UnmarshalJSON(b []byte) error

type Mkdirs

type Mkdirs struct {
	// The absolute path of the directory. If the parent directories do not
	// exist, it will also create them. If the directory already exists, this
	// command will do nothing and succeed.
	Path string `json:"path"`
}

type MkdirsResponse added in v0.34.0

type MkdirsResponse struct {
}

type ObjectInfo

type ObjectInfo struct {
	// Only applicable to files. The creation UTC timestamp.
	CreatedAt int64 `json:"created_at,omitempty"`
	// The language of the object. This value is set only if the object type is
	// `NOTEBOOK`.
	Language Language `json:"language,omitempty"`
	// Only applicable to files, the last modified UTC timestamp.
	ModifiedAt int64 `json:"modified_at,omitempty"`
	// Unique identifier for the object.
	ObjectId int64 `json:"object_id,omitempty"`
	// The type of the object in workspace.
	//
	// - `NOTEBOOK`: document that contains runnable code, visualizations, and
	// explanatory text. - `DIRECTORY`: directory - `LIBRARY`: library - `FILE`:
	// file - `REPO`: repository - `DASHBOARD`: Lakeview dashboard
	ObjectType ObjectType `json:"object_type,omitempty"`
	// The absolute path of the object.
	Path string `json:"path,omitempty"`
	// A unique identifier for the object that is consistent across all
	// Databricks APIs.
	ResourceId string `json:"resource_id,omitempty"`
	// Only applicable to files. The file size in bytes can be returned.
	Size int64 `json:"size,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (ObjectInfo) MarshalJSON added in v0.23.0

func (s ObjectInfo) MarshalJSON() ([]byte, error)

func (*ObjectInfo) UnmarshalJSON added in v0.23.0

func (s *ObjectInfo) UnmarshalJSON(b []byte) error

type ObjectType

type ObjectType string

The type of the object in workspace.

- `NOTEBOOK`: document that contains runnable code, visualizations, and explanatory text. - `DIRECTORY`: directory - `LIBRARY`: library - `FILE`: file - `REPO`: repository - `DASHBOARD`: Lakeview dashboard

const ObjectTypeDashboard ObjectType = `DASHBOARD`

Lakeview dashboard

const ObjectTypeDirectory ObjectType = `DIRECTORY`

directory

const ObjectTypeFile ObjectType = `FILE`

file

const ObjectTypeLibrary ObjectType = `LIBRARY`

library

const ObjectTypeNotebook ObjectType = `NOTEBOOK`

document that contains runnable code, visualizations, and explanatory text.

const ObjectTypeRepo ObjectType = `REPO`

repository

func (*ObjectType) Set added in v0.2.0

func (f *ObjectType) Set(v string) error

Set raw string value and validate it against allowed values

func (*ObjectType) String added in v0.2.0

func (f *ObjectType) String() string

String representation for fmt.Print

func (*ObjectType) Type added in v0.2.0

func (f *ObjectType) Type() string

Type always returns ObjectType to satisfy [pflag.Value] interface

type PutAcl added in v0.8.0

type PutAcl struct {
	// The permission level applied to the principal.
	Permission AclPermission `json:"permission"`
	// The principal in which the permission is applied.
	Principal string `json:"principal"`
	// The name of the scope to apply permissions to.
	Scope string `json:"scope"`
}

type PutAclResponse added in v0.34.0

type PutAclResponse struct {
}

type PutSecret added in v0.8.0

type PutSecret struct {
	// If specified, value will be stored as bytes.
	BytesValue string `json:"bytes_value,omitempty"`
	// A unique name to identify the secret.
	Key string `json:"key"`
	// The name of the scope to which the secret will be associated with.
	Scope string `json:"scope"`
	// If specified, note that the value will be stored in UTF-8 (MB4) form.
	StringValue string `json:"string_value,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (PutSecret) MarshalJSON added in v0.23.0

func (s PutSecret) MarshalJSON() ([]byte, error)

func (*PutSecret) UnmarshalJSON added in v0.23.0

func (s *PutSecret) UnmarshalJSON(b []byte) error

type PutSecretResponse added in v0.34.0

type PutSecretResponse struct {
}

type RepoAccessControlRequest added in v0.15.0

type RepoAccessControlRequest struct {
	// name of the group
	GroupName string `json:"group_name,omitempty"`
	// Permission level
	PermissionLevel RepoPermissionLevel `json:"permission_level,omitempty"`
	// application ID of a service principal
	ServicePrincipalName string `json:"service_principal_name,omitempty"`
	// name of the user
	UserName string `json:"user_name,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (RepoAccessControlRequest) MarshalJSON added in v0.23.0

func (s RepoAccessControlRequest) MarshalJSON() ([]byte, error)

func (*RepoAccessControlRequest) UnmarshalJSON added in v0.23.0

func (s *RepoAccessControlRequest) UnmarshalJSON(b []byte) error

type RepoAccessControlResponse added in v0.15.0

type RepoAccessControlResponse struct {
	// All permissions.
	AllPermissions []RepoPermission `json:"all_permissions,omitempty"`
	// Display name of the user or service principal.
	DisplayName string `json:"display_name,omitempty"`
	// name of the group
	GroupName string `json:"group_name,omitempty"`
	// Name of the service principal.
	ServicePrincipalName string `json:"service_principal_name,omitempty"`
	// name of the user
	UserName string `json:"user_name,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (RepoAccessControlResponse) MarshalJSON added in v0.23.0

func (s RepoAccessControlResponse) MarshalJSON() ([]byte, error)

func (*RepoAccessControlResponse) UnmarshalJSON added in v0.23.0

func (s *RepoAccessControlResponse) UnmarshalJSON(b []byte) error

type RepoInfo added in v0.8.0

type RepoInfo struct {
	// Branch that the local version of the repo is checked out to.
	Branch string `json:"branch,omitempty"`
	// SHA-1 hash representing the commit ID of the current HEAD of the repo.
	HeadCommitId string `json:"head_commit_id,omitempty"`
	// ID of the repo object in the workspace.
	Id int64 `json:"id,omitempty"`
	// Desired path for the repo in the workspace. Almost any path in the
	// workspace can be chosen. If repo is created in /Repos, path must be in
	// the format /Repos/{folder}/{repo-name}.
	Path string `json:"path,omitempty"`
	// Git provider. This field is case-insensitive. The available Git providers
	// are gitHub, bitbucketCloud, gitLab, azureDevOpsServices,
	// gitHubEnterprise, bitbucketServer, gitLabEnterpriseEdition and
	// awsCodeCommit.
	Provider string `json:"provider,omitempty"`

	SparseCheckout *SparseCheckout `json:"sparse_checkout,omitempty"`
	// URL of the Git repository to be linked.
	Url string `json:"url,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (RepoInfo) MarshalJSON added in v0.23.0

func (s RepoInfo) MarshalJSON() ([]byte, error)

func (*RepoInfo) UnmarshalJSON added in v0.23.0

func (s *RepoInfo) UnmarshalJSON(b []byte) error

type RepoPermission added in v0.15.0

type RepoPermission struct {
	Inherited bool `json:"inherited,omitempty"`

	InheritedFromObject []string `json:"inherited_from_object,omitempty"`
	// Permission level
	PermissionLevel RepoPermissionLevel `json:"permission_level,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (RepoPermission) MarshalJSON added in v0.23.0

func (s RepoPermission) MarshalJSON() ([]byte, error)

func (*RepoPermission) UnmarshalJSON added in v0.23.0

func (s *RepoPermission) UnmarshalJSON(b []byte) error

type RepoPermissionLevel added in v0.15.0

type RepoPermissionLevel string

Permission level

const RepoPermissionLevelCanEdit RepoPermissionLevel = `CAN_EDIT`
const RepoPermissionLevelCanManage RepoPermissionLevel = `CAN_MANAGE`
const RepoPermissionLevelCanRead RepoPermissionLevel = `CAN_READ`
const RepoPermissionLevelCanRun RepoPermissionLevel = `CAN_RUN`

func (*RepoPermissionLevel) Set added in v0.15.0

func (f *RepoPermissionLevel) Set(v string) error

Set raw string value and validate it against allowed values

func (*RepoPermissionLevel) String added in v0.15.0

func (f *RepoPermissionLevel) String() string

String representation for fmt.Print

func (*RepoPermissionLevel) Type added in v0.15.0

func (f *RepoPermissionLevel) Type() string

Type always returns RepoPermissionLevel to satisfy [pflag.Value] interface

type RepoPermissions added in v0.15.0

type RepoPermissions struct {
	AccessControlList []RepoAccessControlResponse `json:"access_control_list,omitempty"`

	ObjectId string `json:"object_id,omitempty"`

	ObjectType string `json:"object_type,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (RepoPermissions) MarshalJSON added in v0.23.0

func (s RepoPermissions) MarshalJSON() ([]byte, error)

func (*RepoPermissions) UnmarshalJSON added in v0.23.0

func (s *RepoPermissions) UnmarshalJSON(b []byte) error

type RepoPermissionsDescription added in v0.15.0

type RepoPermissionsDescription struct {
	Description string `json:"description,omitempty"`
	// Permission level
	PermissionLevel RepoPermissionLevel `json:"permission_level,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (RepoPermissionsDescription) MarshalJSON added in v0.23.0

func (s RepoPermissionsDescription) MarshalJSON() ([]byte, error)

func (*RepoPermissionsDescription) UnmarshalJSON added in v0.23.0

func (s *RepoPermissionsDescription) UnmarshalJSON(b []byte) error

type RepoPermissionsRequest added in v0.15.0

type RepoPermissionsRequest struct {
	AccessControlList []RepoAccessControlRequest `json:"access_control_list,omitempty"`
	// The repo for which to get or manage permissions.
	RepoId string `json:"-" url:"-"`
}

type ReposAPI added in v0.8.0

type ReposAPI struct {
	// contains filtered or unexported fields
}

The Repos API allows users to manage their git repos. Users can use the API to access all repos that they have manage permissions on.

Databricks Repos is a visual Git client in Databricks. It supports common Git operations such a cloning a repository, committing and pushing, pulling, branch management, and visual comparison of diffs when committing.

Within Repos you can develop code in notebooks or other files and follow data science and engineering code development best practices using Git for version control, collaboration, and CI/CD.

func NewRepos added in v0.8.0

func NewRepos(client *client.DatabricksClient) *ReposAPI

func (*ReposAPI) Create added in v0.8.0

func (a *ReposAPI) Create(ctx context.Context, request CreateRepo) (*RepoInfo, error)

Create a repo.

Creates a repo in the workspace and links it to the remote Git repo specified. Note that repos created programmatically must be linked to a remote Git repo, unlike repos created in the browser.

Example (Repos)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

root := fmt.Sprintf("sdk-%x", time.Now().UnixNano())

ri, err := w.Repos.Create(ctx, workspace.CreateRepo{
	Path:     root,
	Url:      "https://github.com/shreyas-goenka/empty-repo.git",
	Provider: "github",
})
if err != nil {
	panic(err)
}
logger.Infof(ctx, "found %v", ri)

// cleanup

err = w.Repos.DeleteByRepoId(ctx, ri.Id)
if err != nil {
	panic(err)
}
Output:

func (*ReposAPI) Delete added in v0.8.0

func (a *ReposAPI) Delete(ctx context.Context, request DeleteRepoRequest) error

Delete a repo.

Deletes the specified repo.

func (*ReposAPI) DeleteByRepoId added in v0.8.0

func (a *ReposAPI) DeleteByRepoId(ctx context.Context, repoId int64) error

Delete a repo.

Deletes the specified repo.

func (*ReposAPI) Get added in v0.8.0

func (a *ReposAPI) Get(ctx context.Context, request GetRepoRequest) (*RepoInfo, error)

Get a repo.

Returns the repo with the given repo ID.

Example (Repos)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

root := fmt.Sprintf("sdk-%x", time.Now().UnixNano())

ri, err := w.Repos.Create(ctx, workspace.CreateRepo{
	Path:     root,
	Url:      "https://github.com/shreyas-goenka/empty-repo.git",
	Provider: "github",
})
if err != nil {
	panic(err)
}
logger.Infof(ctx, "found %v", ri)

byId, err := w.Repos.GetByRepoId(ctx, ri.Id)
if err != nil {
	panic(err)
}
logger.Infof(ctx, "found %v", byId)

// cleanup

err = w.Repos.DeleteByRepoId(ctx, ri.Id)
if err != nil {
	panic(err)
}
Output:

func (*ReposAPI) GetByPath added in v0.8.0

func (a *ReposAPI) GetByPath(ctx context.Context, name string) (*RepoInfo, error)

GetByPath calls ReposAPI.RepoInfoPathToIdMap and returns a single RepoInfo.

Returns an error if there's more than one RepoInfo with the same .Path.

Note: All RepoInfo instances are loaded into memory before returning matching by name.

This method is generated by Databricks SDK Code Generator.

Example (CheckoutBranchByPath)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}
// shortcut for getting RepoInfo by path
repo, err := w.Repos.GetByPath(ctx, "/Repos/path/to/prod")
if err != nil {
	panic(err)
}
// because you can update repo only by ID, not by path
err = w.Repos.Update(ctx, workspace.UpdateRepo{
	RepoId: repo.Id,
	Branch: "v1.4.18",
})
if err != nil {
	panic(err)
}
Output:

func (*ReposAPI) GetByRepoId added in v0.8.0

func (a *ReposAPI) GetByRepoId(ctx context.Context, repoId int64) (*RepoInfo, error)

Get a repo.

Returns the repo with the given repo ID.

func (*ReposAPI) GetPermissionLevels added in v0.19.0

Get repo permission levels.

Gets the permission levels that a user can have on an object.

func (*ReposAPI) GetPermissionLevelsByRepoId added in v0.19.0

func (a *ReposAPI) GetPermissionLevelsByRepoId(ctx context.Context, repoId string) (*GetRepoPermissionLevelsResponse, error)

Get repo permission levels.

Gets the permission levels that a user can have on an object.

func (*ReposAPI) GetPermissions added in v0.19.0

func (a *ReposAPI) GetPermissions(ctx context.Context, request GetRepoPermissionsRequest) (*RepoPermissions, error)

Get repo permissions.

Gets the permissions of a repo. Repos can inherit permissions from their root object.

func (*ReposAPI) GetPermissionsByRepoId added in v0.19.0

func (a *ReposAPI) GetPermissionsByRepoId(ctx context.Context, repoId string) (*RepoPermissions, error)

Get repo permissions.

Gets the permissions of a repo. Repos can inherit permissions from their root object.

func (*ReposAPI) Impl added in v0.8.0

func (a *ReposAPI) Impl() ReposService

Impl returns low-level Repos API implementation Deprecated: use MockReposInterface instead.

func (*ReposAPI) List added in v0.24.0

Get repos.

Returns repos that the calling user has Manage permissions on. Results are paginated with each page containing twenty repos.

This method is generated by Databricks SDK Code Generator.

func (*ReposAPI) ListAll added in v0.8.0

func (a *ReposAPI) ListAll(ctx context.Context, request ListReposRequest) ([]RepoInfo, error)

Get repos.

Returns repos that the calling user has Manage permissions on. Results are paginated with each page containing twenty repos.

This method is generated by Databricks SDK Code Generator.

Example (Repos)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

all, err := w.Repos.ListAll(ctx, workspace.ListReposRequest{})
if err != nil {
	panic(err)
}
logger.Infof(ctx, "found %v", all)
Output:

func (*ReposAPI) RepoInfoPathToIdMap added in v0.8.0

func (a *ReposAPI) RepoInfoPathToIdMap(ctx context.Context, request ListReposRequest) (map[string]int64, error)

RepoInfoPathToIdMap calls ReposAPI.ListAll and creates a map of results with RepoInfo.Path as key and RepoInfo.Id as value.

Returns an error if there's more than one RepoInfo with the same .Path.

Note: All RepoInfo instances are loaded into memory before creating a map.

This method is generated by Databricks SDK Code Generator.

func (*ReposAPI) SetPermissions added in v0.19.0

func (a *ReposAPI) SetPermissions(ctx context.Context, request RepoPermissionsRequest) (*RepoPermissions, error)

Set repo permissions.

Sets permissions on a repo. Repos can inherit permissions from their root object.

func (*ReposAPI) Update added in v0.8.0

func (a *ReposAPI) Update(ctx context.Context, request UpdateRepo) error

Update a repo.

Updates the repo to a different branch or tag, or updates the repo to the latest commit on the same branch.

Example (Repos)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

root := fmt.Sprintf("sdk-%x", time.Now().UnixNano())

ri, err := w.Repos.Create(ctx, workspace.CreateRepo{
	Path:     root,
	Url:      "https://github.com/shreyas-goenka/empty-repo.git",
	Provider: "github",
})
if err != nil {
	panic(err)
}
logger.Infof(ctx, "found %v", ri)

err = w.Repos.Update(ctx, workspace.UpdateRepo{
	RepoId: ri.Id,
	Branch: "foo",
})
if err != nil {
	panic(err)
}

// cleanup

err = w.Repos.DeleteByRepoId(ctx, ri.Id)
if err != nil {
	panic(err)
}
Output:

func (*ReposAPI) UpdatePermissions added in v0.19.0

func (a *ReposAPI) UpdatePermissions(ctx context.Context, request RepoPermissionsRequest) (*RepoPermissions, error)

Update repo permissions.

Updates the permissions on a repo. Repos can inherit permissions from their root object.

func (*ReposAPI) WithImpl added in v0.8.0

func (a *ReposAPI) WithImpl(impl ReposService) ReposInterface

WithImpl could be used to override low-level API implementations for unit testing purposes with github.com/golang/mock or other mocking frameworks. Deprecated: use MockReposInterface instead.

type ReposInterface added in v0.29.0

type ReposInterface interface {
	// WithImpl could be used to override low-level API implementations for unit
	// testing purposes with [github.com/golang/mock] or other mocking frameworks.
	// Deprecated: use MockReposInterface instead.
	WithImpl(impl ReposService) ReposInterface

	// Impl returns low-level Repos API implementation
	// Deprecated: use MockReposInterface instead.
	Impl() ReposService

	// Create a repo.
	//
	// Creates a repo in the workspace and links it to the remote Git repo
	// specified. Note that repos created programmatically must be linked to a
	// remote Git repo, unlike repos created in the browser.
	Create(ctx context.Context, request CreateRepo) (*RepoInfo, error)

	// Delete a repo.
	//
	// Deletes the specified repo.
	Delete(ctx context.Context, request DeleteRepoRequest) error

	// Delete a repo.
	//
	// Deletes the specified repo.
	DeleteByRepoId(ctx context.Context, repoId int64) error

	// Get a repo.
	//
	// Returns the repo with the given repo ID.
	Get(ctx context.Context, request GetRepoRequest) (*RepoInfo, error)

	// Get a repo.
	//
	// Returns the repo with the given repo ID.
	GetByRepoId(ctx context.Context, repoId int64) (*RepoInfo, error)

	// Get repo permission levels.
	//
	// Gets the permission levels that a user can have on an object.
	GetPermissionLevels(ctx context.Context, request GetRepoPermissionLevelsRequest) (*GetRepoPermissionLevelsResponse, error)

	// Get repo permission levels.
	//
	// Gets the permission levels that a user can have on an object.
	GetPermissionLevelsByRepoId(ctx context.Context, repoId string) (*GetRepoPermissionLevelsResponse, error)

	// Get repo permissions.
	//
	// Gets the permissions of a repo. Repos can inherit permissions from their root
	// object.
	GetPermissions(ctx context.Context, request GetRepoPermissionsRequest) (*RepoPermissions, error)

	// Get repo permissions.
	//
	// Gets the permissions of a repo. Repos can inherit permissions from their root
	// object.
	GetPermissionsByRepoId(ctx context.Context, repoId string) (*RepoPermissions, error)

	// Get repos.
	//
	// Returns repos that the calling user has Manage permissions on. Results are
	// paginated with each page containing twenty repos.
	//
	// This method is generated by Databricks SDK Code Generator.
	List(ctx context.Context, request ListReposRequest) listing.Iterator[RepoInfo]

	// Get repos.
	//
	// Returns repos that the calling user has Manage permissions on. Results are
	// paginated with each page containing twenty repos.
	//
	// This method is generated by Databricks SDK Code Generator.
	ListAll(ctx context.Context, request ListReposRequest) ([]RepoInfo, error)

	// RepoInfoPathToIdMap calls [ReposAPI.ListAll] and creates a map of results with [RepoInfo].Path as key and [RepoInfo].Id as value.
	//
	// Returns an error if there's more than one [RepoInfo] with the same .Path.
	//
	// Note: All [RepoInfo] instances are loaded into memory before creating a map.
	//
	// This method is generated by Databricks SDK Code Generator.
	RepoInfoPathToIdMap(ctx context.Context, request ListReposRequest) (map[string]int64, error)

	// GetByPath calls [ReposAPI.RepoInfoPathToIdMap] and returns a single [RepoInfo].
	//
	// Returns an error if there's more than one [RepoInfo] with the same .Path.
	//
	// Note: All [RepoInfo] instances are loaded into memory before returning matching by name.
	//
	// This method is generated by Databricks SDK Code Generator.
	GetByPath(ctx context.Context, name string) (*RepoInfo, error)

	// Set repo permissions.
	//
	// Sets permissions on a repo. Repos can inherit permissions from their root
	// object.
	SetPermissions(ctx context.Context, request RepoPermissionsRequest) (*RepoPermissions, error)

	// Update a repo.
	//
	// Updates the repo to a different branch or tag, or updates the repo to the
	// latest commit on the same branch.
	Update(ctx context.Context, request UpdateRepo) error

	// Update repo permissions.
	//
	// Updates the permissions on a repo. Repos can inherit permissions from their
	// root object.
	UpdatePermissions(ctx context.Context, request RepoPermissionsRequest) (*RepoPermissions, error)
}

type ReposService added in v0.8.0

type ReposService interface {

	// Create a repo.
	//
	// Creates a repo in the workspace and links it to the remote Git repo
	// specified. Note that repos created programmatically must be linked to a
	// remote Git repo, unlike repos created in the browser.
	Create(ctx context.Context, request CreateRepo) (*RepoInfo, error)

	// Delete a repo.
	//
	// Deletes the specified repo.
	Delete(ctx context.Context, request DeleteRepoRequest) error

	// Get a repo.
	//
	// Returns the repo with the given repo ID.
	Get(ctx context.Context, request GetRepoRequest) (*RepoInfo, error)

	// Get repo permission levels.
	//
	// Gets the permission levels that a user can have on an object.
	GetPermissionLevels(ctx context.Context, request GetRepoPermissionLevelsRequest) (*GetRepoPermissionLevelsResponse, error)

	// Get repo permissions.
	//
	// Gets the permissions of a repo. Repos can inherit permissions from their
	// root object.
	GetPermissions(ctx context.Context, request GetRepoPermissionsRequest) (*RepoPermissions, error)

	// Get repos.
	//
	// Returns repos that the calling user has Manage permissions on. Results
	// are paginated with each page containing twenty repos.
	//
	// Use ListAll() to get all RepoInfo instances, which will iterate over every result page.
	List(ctx context.Context, request ListReposRequest) (*ListReposResponse, error)

	// Set repo permissions.
	//
	// Sets permissions on a repo. Repos can inherit permissions from their root
	// object.
	SetPermissions(ctx context.Context, request RepoPermissionsRequest) (*RepoPermissions, error)

	// Update a repo.
	//
	// Updates the repo to a different branch or tag, or updates the repo to the
	// latest commit on the same branch.
	Update(ctx context.Context, request UpdateRepo) error

	// Update repo permissions.
	//
	// Updates the permissions on a repo. Repos can inherit permissions from
	// their root object.
	UpdatePermissions(ctx context.Context, request RepoPermissionsRequest) (*RepoPermissions, error)
}

The Repos API allows users to manage their git repos. Users can use the API to access all repos that they have manage permissions on.

Databricks Repos is a visual Git client in Databricks. It supports common Git operations such a cloning a repository, committing and pushing, pulling, branch management, and visual comparison of diffs when committing.

Within Repos you can develop code in notebooks or other files and follow data science and engineering code development best practices using Git for version control, collaboration, and CI/CD.

type ScopeBackendType added in v0.8.0

type ScopeBackendType string
const ScopeBackendTypeAzureKeyvault ScopeBackendType = `AZURE_KEYVAULT`
const ScopeBackendTypeDatabricks ScopeBackendType = `DATABRICKS`

func (*ScopeBackendType) Set added in v0.8.0

func (f *ScopeBackendType) Set(v string) error

Set raw string value and validate it against allowed values

func (*ScopeBackendType) String added in v0.8.0

func (f *ScopeBackendType) String() string

String representation for fmt.Print

func (*ScopeBackendType) Type added in v0.8.0

func (f *ScopeBackendType) Type() string

Type always returns ScopeBackendType to satisfy [pflag.Value] interface

type SecretMetadata added in v0.8.0

type SecretMetadata struct {
	// A unique name to identify the secret.
	Key string `json:"key,omitempty"`
	// The last updated timestamp (in milliseconds) for the secret.
	LastUpdatedTimestamp int64 `json:"last_updated_timestamp,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (SecretMetadata) MarshalJSON added in v0.23.0

func (s SecretMetadata) MarshalJSON() ([]byte, error)

func (*SecretMetadata) UnmarshalJSON added in v0.23.0

func (s *SecretMetadata) UnmarshalJSON(b []byte) error

type SecretScope added in v0.8.0

type SecretScope struct {
	// The type of secret scope backend.
	BackendType ScopeBackendType `json:"backend_type,omitempty"`
	// The metadata for the secret scope if the type is `AZURE_KEYVAULT`
	KeyvaultMetadata *AzureKeyVaultSecretScopeMetadata `json:"keyvault_metadata,omitempty"`
	// A unique name to identify the secret scope.
	Name string `json:"name,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (SecretScope) MarshalJSON added in v0.23.0

func (s SecretScope) MarshalJSON() ([]byte, error)

func (*SecretScope) UnmarshalJSON added in v0.23.0

func (s *SecretScope) UnmarshalJSON(b []byte) error

type SecretsAPI added in v0.8.0

type SecretsAPI struct {
	// contains filtered or unexported fields
}

The Secrets API allows you to manage secrets, secret scopes, and access permissions.

Sometimes accessing data requires that you authenticate to external data sources through JDBC. Instead of directly entering your credentials into a notebook, use Databricks secrets to store your credentials and reference them in notebooks and jobs.

Administrators, secret creators, and users granted permission can read Databricks secrets. While Databricks makes an effort to redact secret values that might be displayed in notebooks, it is not possible to prevent such users from reading secrets.

func NewSecrets added in v0.8.0

func NewSecrets(client *client.DatabricksClient) *SecretsAPI

func (*SecretsAPI) CreateScope added in v0.8.0

func (a *SecretsAPI) CreateScope(ctx context.Context, request CreateScope) error

Create a new secret scope.

The scope name must consist of alphanumeric characters, dashes, underscores, and periods, and may not exceed 128 characters.

Example (Secrets)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

keyName := fmt.Sprintf("sdk-%x", time.Now().UnixNano())

scopeName := fmt.Sprintf("sdk-%x", time.Now().UnixNano())

err = w.Secrets.CreateScope(ctx, workspace.CreateScope{
	Scope: scopeName,
})
if err != nil {
	panic(err)
}

// cleanup

err = w.Secrets.DeleteSecret(ctx, workspace.DeleteSecret{
	Scope: scopeName,
	Key:   keyName,
})
if err != nil {
	panic(err)
}
err = w.Secrets.DeleteScopeByScope(ctx, scopeName)
if err != nil {
	panic(err)
}
Output:

func (*SecretsAPI) DeleteAcl added in v0.8.0

func (a *SecretsAPI) DeleteAcl(ctx context.Context, request DeleteAcl) error

Delete an ACL.

Deletes the given ACL on the given scope.

Users must have the `MANAGE` permission to invoke this API. Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope, principal, or ACL exists. Throws `PERMISSION_DENIED` if the user does not have permission to make this API call.

func (*SecretsAPI) DeleteScope added in v0.8.0

func (a *SecretsAPI) DeleteScope(ctx context.Context, request DeleteScope) error

Delete a secret scope.

Deletes a secret scope.

Throws `RESOURCE_DOES_NOT_EXIST` if the scope does not exist. Throws `PERMISSION_DENIED` if the user does not have permission to make this API call.

func (*SecretsAPI) DeleteScopeByScope added in v0.8.0

func (a *SecretsAPI) DeleteScopeByScope(ctx context.Context, scope string) error

Delete a secret scope.

Deletes a secret scope.

Throws `RESOURCE_DOES_NOT_EXIST` if the scope does not exist. Throws `PERMISSION_DENIED` if the user does not have permission to make this API call.

func (*SecretsAPI) DeleteSecret added in v0.8.0

func (a *SecretsAPI) DeleteSecret(ctx context.Context, request DeleteSecret) error

Delete a secret.

Deletes the secret stored in this secret scope. You must have `WRITE` or `MANAGE` permission on the secret scope.

Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope or secret exists. Throws `PERMISSION_DENIED` if the user does not have permission to make this API call.

func (*SecretsAPI) GetAcl added in v0.8.0

func (a *SecretsAPI) GetAcl(ctx context.Context, request GetAclRequest) (*AclItem, error)

Get secret ACL details.

Gets the details about the given ACL, such as the group and permission. Users must have the `MANAGE` permission to invoke this API.

Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws `PERMISSION_DENIED` if the user does not have permission to make this API call.

func (*SecretsAPI) GetSecret added in v0.17.0

func (a *SecretsAPI) GetSecret(ctx context.Context, request GetSecretRequest) (*GetSecretResponse, error)

Get a secret.

Gets the bytes representation of a secret value for the specified scope and key.

Users need the READ permission to make this call.

Note that the secret value returned is in bytes. The interpretation of the bytes is determined by the caller in DBUtils and the type the data is decoded into.

Throws “PERMISSION_DENIED“ if the user does not have permission to make this API call. Throws “RESOURCE_DOES_NOT_EXIST“ if no such secret or secret scope exists.

func (*SecretsAPI) Impl added in v0.8.0

func (a *SecretsAPI) Impl() SecretsService

Impl returns low-level Secrets API implementation Deprecated: use MockSecretsInterface instead.

func (*SecretsAPI) ListAcls added in v0.24.0

func (a *SecretsAPI) ListAcls(ctx context.Context, request ListAclsRequest) listing.Iterator[AclItem]

Lists ACLs.

List the ACLs for a given secret scope. Users must have the `MANAGE` permission to invoke this API.

Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws `PERMISSION_DENIED` if the user does not have permission to make this API call.

This method is generated by Databricks SDK Code Generator.

Example (Secrets)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

keyName := fmt.Sprintf("sdk-%x", time.Now().UnixNano())

scopeName := fmt.Sprintf("sdk-%x", time.Now().UnixNano())

err = w.Secrets.CreateScope(ctx, workspace.CreateScope{
	Scope: scopeName,
})
if err != nil {
	panic(err)
}

acls, err := w.Secrets.ListAclsByScope(ctx, scopeName)
if err != nil {
	panic(err)
}
logger.Infof(ctx, "found %v", acls)

// cleanup

err = w.Secrets.DeleteSecret(ctx, workspace.DeleteSecret{
	Scope: scopeName,
	Key:   keyName,
})
if err != nil {
	panic(err)
}
err = w.Secrets.DeleteScopeByScope(ctx, scopeName)
if err != nil {
	panic(err)
}
Output:

func (*SecretsAPI) ListAclsAll added in v0.8.0

func (a *SecretsAPI) ListAclsAll(ctx context.Context, request ListAclsRequest) ([]AclItem, error)

Lists ACLs.

List the ACLs for a given secret scope. Users must have the `MANAGE` permission to invoke this API.

Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws `PERMISSION_DENIED` if the user does not have permission to make this API call.

This method is generated by Databricks SDK Code Generator.

func (*SecretsAPI) ListAclsByScope added in v0.8.0

func (a *SecretsAPI) ListAclsByScope(ctx context.Context, scope string) (*ListAclsResponse, error)

Lists ACLs.

List the ACLs for a given secret scope. Users must have the `MANAGE` permission to invoke this API.

Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws `PERMISSION_DENIED` if the user does not have permission to make this API call.

func (*SecretsAPI) ListScopes added in v0.24.0

func (a *SecretsAPI) ListScopes(ctx context.Context) listing.Iterator[SecretScope]

List all scopes.

Lists all secret scopes available in the workspace.

Throws `PERMISSION_DENIED` if the user does not have permission to make this API call.

This method is generated by Databricks SDK Code Generator.

Example (Secrets)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

scopes, err := w.Secrets.ListScopesAll(ctx)
if err != nil {
	panic(err)
}
logger.Infof(ctx, "found %v", scopes)
Output:

func (*SecretsAPI) ListScopesAll added in v0.8.0

func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error)

List all scopes.

Lists all secret scopes available in the workspace.

Throws `PERMISSION_DENIED` if the user does not have permission to make this API call.

This method is generated by Databricks SDK Code Generator.

func (*SecretsAPI) ListSecrets added in v0.24.0

List secret keys.

Lists the secret keys that are stored at this scope. This is a metadata-only operation; secret data cannot be retrieved using this API. Users need the READ permission to make this call.

The lastUpdatedTimestamp returned is in milliseconds since epoch. Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws `PERMISSION_DENIED` if the user does not have permission to make this API call.

This method is generated by Databricks SDK Code Generator.

Example (Secrets)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

keyName := fmt.Sprintf("sdk-%x", time.Now().UnixNano())

scopeName := fmt.Sprintf("sdk-%x", time.Now().UnixNano())

err = w.Secrets.CreateScope(ctx, workspace.CreateScope{
	Scope: scopeName,
})
if err != nil {
	panic(err)
}

scrts, err := w.Secrets.ListSecretsByScope(ctx, scopeName)
if err != nil {
	panic(err)
}
logger.Infof(ctx, "found %v", scrts)

// cleanup

err = w.Secrets.DeleteSecret(ctx, workspace.DeleteSecret{
	Scope: scopeName,
	Key:   keyName,
})
if err != nil {
	panic(err)
}
err = w.Secrets.DeleteScopeByScope(ctx, scopeName)
if err != nil {
	panic(err)
}
Output:

func (*SecretsAPI) ListSecretsAll added in v0.8.0

func (a *SecretsAPI) ListSecretsAll(ctx context.Context, request ListSecretsRequest) ([]SecretMetadata, error)

List secret keys.

Lists the secret keys that are stored at this scope. This is a metadata-only operation; secret data cannot be retrieved using this API. Users need the READ permission to make this call.

The lastUpdatedTimestamp returned is in milliseconds since epoch. Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws `PERMISSION_DENIED` if the user does not have permission to make this API call.

This method is generated by Databricks SDK Code Generator.

func (*SecretsAPI) ListSecretsByScope added in v0.8.0

func (a *SecretsAPI) ListSecretsByScope(ctx context.Context, scope string) (*ListSecretsResponse, error)

List secret keys.

Lists the secret keys that are stored at this scope. This is a metadata-only operation; secret data cannot be retrieved using this API. Users need the READ permission to make this call.

The lastUpdatedTimestamp returned is in milliseconds since epoch. Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws `PERMISSION_DENIED` if the user does not have permission to make this API call.

func (*SecretsAPI) PutAcl added in v0.8.0

func (a *SecretsAPI) PutAcl(ctx context.Context, request PutAcl) error

Create/update an ACL.

Creates or overwrites the Access Control List (ACL) associated with the given principal (user or group) on the specified scope point.

In general, a user or group will use the most powerful permission available to them, and permissions are ordered as follows:

* `MANAGE` - Allowed to change ACLs, and read and write to this secret scope. * `WRITE` - Allowed to read and write to this secret scope. * `READ` - Allowed to read this secret scope and list what secrets are available.

Note that in general, secret values can only be read from within a command on a cluster (for example, through a notebook). There is no API to read the actual secret value material outside of a cluster. However, the user's permission will be applied based on who is executing the command, and they must have at least READ permission.

Users must have the `MANAGE` permission to invoke this API.

The principal is a user or group name corresponding to an existing Databricks principal to be granted or revoked access.

Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws `RESOURCE_ALREADY_EXISTS` if a permission for the principal already exists. Throws `INVALID_PARAMETER_VALUE` if the permission or principal is invalid. Throws `PERMISSION_DENIED` if the user does not have permission to make this API call.

Example (Secrets)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

keyName := fmt.Sprintf("sdk-%x", time.Now().UnixNano())

group, err := w.Groups.Create(ctx, iam.Group{
	DisplayName: fmt.Sprintf("sdk-%x", time.Now().UnixNano()),
})
if err != nil {
	panic(err)
}
logger.Infof(ctx, "found %v", group)

scopeName := fmt.Sprintf("sdk-%x", time.Now().UnixNano())

err = w.Secrets.CreateScope(ctx, workspace.CreateScope{
	Scope: scopeName,
})
if err != nil {
	panic(err)
}

err = w.Secrets.PutAcl(ctx, workspace.PutAcl{
	Scope:      scopeName,
	Permission: workspace.AclPermissionManage,
	Principal:  group.DisplayName,
})
if err != nil {
	panic(err)
}

// cleanup

err = w.Groups.DeleteById(ctx, group.Id)
if err != nil {
	panic(err)
}
err = w.Secrets.DeleteSecret(ctx, workspace.DeleteSecret{
	Scope: scopeName,
	Key:   keyName,
})
if err != nil {
	panic(err)
}
err = w.Secrets.DeleteScopeByScope(ctx, scopeName)
if err != nil {
	panic(err)
}
Output:

func (*SecretsAPI) PutSecret added in v0.8.0

func (a *SecretsAPI) PutSecret(ctx context.Context, request PutSecret) error

Add a secret.

Inserts a secret under the provided scope with the given name. If a secret already exists with the same name, this command overwrites the existing secret's value. The server encrypts the secret using the secret scope's encryption settings before storing it.

You must have `WRITE` or `MANAGE` permission on the secret scope. The secret key must consist of alphanumeric characters, dashes, underscores, and periods, and cannot exceed 128 characters. The maximum allowed secret value size is 128 KB. The maximum number of secrets in a given scope is 1000.

The input fields "string_value" or "bytes_value" specify the type of the secret, which will determine the value returned when the secret value is requested. Exactly one must be specified.

Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws `RESOURCE_LIMIT_EXCEEDED` if maximum number of secrets in scope is exceeded. Throws `INVALID_PARAMETER_VALUE` if the key name or value length is invalid. Throws `PERMISSION_DENIED` if the user does not have permission to make this API call.

Example (Secrets)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

keyName := fmt.Sprintf("sdk-%x", time.Now().UnixNano())

scopeName := fmt.Sprintf("sdk-%x", time.Now().UnixNano())

err = w.Secrets.CreateScope(ctx, workspace.CreateScope{
	Scope: scopeName,
})
if err != nil {
	panic(err)
}

err = w.Secrets.PutSecret(ctx, workspace.PutSecret{
	Scope:       scopeName,
	Key:         keyName,
	StringValue: fmt.Sprintf("sdk-%x", time.Now().UnixNano()),
})
if err != nil {
	panic(err)
}

// cleanup

err = w.Secrets.DeleteSecret(ctx, workspace.DeleteSecret{
	Scope: scopeName,
	Key:   keyName,
})
if err != nil {
	panic(err)
}
err = w.Secrets.DeleteScopeByScope(ctx, scopeName)
if err != nil {
	panic(err)
}
Output:

func (*SecretsAPI) WithImpl added in v0.8.0

func (a *SecretsAPI) WithImpl(impl SecretsService) SecretsInterface

WithImpl could be used to override low-level API implementations for unit testing purposes with github.com/golang/mock or other mocking frameworks. Deprecated: use MockSecretsInterface instead.

type SecretsInterface added in v0.29.0

type SecretsInterface interface {
	// WithImpl could be used to override low-level API implementations for unit
	// testing purposes with [github.com/golang/mock] or other mocking frameworks.
	// Deprecated: use MockSecretsInterface instead.
	WithImpl(impl SecretsService) SecretsInterface

	// Impl returns low-level Secrets API implementation
	// Deprecated: use MockSecretsInterface instead.
	Impl() SecretsService

	// Create a new secret scope.
	//
	// The scope name must consist of alphanumeric characters, dashes, underscores,
	// and periods, and may not exceed 128 characters.
	CreateScope(ctx context.Context, request CreateScope) error

	// Delete an ACL.
	//
	// Deletes the given ACL on the given scope.
	//
	// Users must have the `MANAGE` permission to invoke this API. Throws
	// `RESOURCE_DOES_NOT_EXIST` if no such secret scope, principal, or ACL exists.
	// Throws `PERMISSION_DENIED` if the user does not have permission to make this
	// API call.
	DeleteAcl(ctx context.Context, request DeleteAcl) error

	// Delete a secret scope.
	//
	// Deletes a secret scope.
	//
	// Throws `RESOURCE_DOES_NOT_EXIST` if the scope does not exist. Throws
	// `PERMISSION_DENIED` if the user does not have permission to make this API
	// call.
	DeleteScope(ctx context.Context, request DeleteScope) error

	// Delete a secret scope.
	//
	// Deletes a secret scope.
	//
	// Throws `RESOURCE_DOES_NOT_EXIST` if the scope does not exist. Throws
	// `PERMISSION_DENIED` if the user does not have permission to make this API
	// call.
	DeleteScopeByScope(ctx context.Context, scope string) error

	// Delete a secret.
	//
	// Deletes the secret stored in this secret scope. You must have `WRITE` or
	// `MANAGE` permission on the secret scope.
	//
	// Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope or secret exists.
	// Throws `PERMISSION_DENIED` if the user does not have permission to make this
	// API call.
	DeleteSecret(ctx context.Context, request DeleteSecret) error

	// Get secret ACL details.
	//
	// Gets the details about the given ACL, such as the group and permission. Users
	// must have the `MANAGE` permission to invoke this API.
	//
	// Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws
	// `PERMISSION_DENIED` if the user does not have permission to make this API
	// call.
	GetAcl(ctx context.Context, request GetAclRequest) (*AclItem, error)

	// Get a secret.
	//
	// Gets the bytes representation of a secret value for the specified scope and
	// key.
	//
	// Users need the READ permission to make this call.
	//
	// Note that the secret value returned is in bytes. The interpretation of the
	// bytes is determined by the caller in DBUtils and the type the data is decoded
	// into.
	//
	// Throws “PERMISSION_DENIED“ if the user does not have permission to make
	// this API call. Throws “RESOURCE_DOES_NOT_EXIST“ if no such secret or secret
	// scope exists.
	GetSecret(ctx context.Context, request GetSecretRequest) (*GetSecretResponse, error)

	// Lists ACLs.
	//
	// List the ACLs for a given secret scope. Users must have the `MANAGE`
	// permission to invoke this API.
	//
	// Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws
	// `PERMISSION_DENIED` if the user does not have permission to make this API
	// call.
	//
	// This method is generated by Databricks SDK Code Generator.
	ListAcls(ctx context.Context, request ListAclsRequest) listing.Iterator[AclItem]

	// Lists ACLs.
	//
	// List the ACLs for a given secret scope. Users must have the `MANAGE`
	// permission to invoke this API.
	//
	// Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws
	// `PERMISSION_DENIED` if the user does not have permission to make this API
	// call.
	//
	// This method is generated by Databricks SDK Code Generator.
	ListAclsAll(ctx context.Context, request ListAclsRequest) ([]AclItem, error)

	// Lists ACLs.
	//
	// List the ACLs for a given secret scope. Users must have the `MANAGE`
	// permission to invoke this API.
	//
	// Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws
	// `PERMISSION_DENIED` if the user does not have permission to make this API
	// call.
	ListAclsByScope(ctx context.Context, scope string) (*ListAclsResponse, error)

	// List all scopes.
	//
	// Lists all secret scopes available in the workspace.
	//
	// Throws `PERMISSION_DENIED` if the user does not have permission to make this
	// API call.
	//
	// This method is generated by Databricks SDK Code Generator.
	ListScopes(ctx context.Context) listing.Iterator[SecretScope]

	// List all scopes.
	//
	// Lists all secret scopes available in the workspace.
	//
	// Throws `PERMISSION_DENIED` if the user does not have permission to make this
	// API call.
	//
	// This method is generated by Databricks SDK Code Generator.
	ListScopesAll(ctx context.Context) ([]SecretScope, error)

	// List secret keys.
	//
	// Lists the secret keys that are stored at this scope. This is a metadata-only
	// operation; secret data cannot be retrieved using this API. Users need the
	// READ permission to make this call.
	//
	// The lastUpdatedTimestamp returned is in milliseconds since epoch. Throws
	// `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws
	// `PERMISSION_DENIED` if the user does not have permission to make this API
	// call.
	//
	// This method is generated by Databricks SDK Code Generator.
	ListSecrets(ctx context.Context, request ListSecretsRequest) listing.Iterator[SecretMetadata]

	// List secret keys.
	//
	// Lists the secret keys that are stored at this scope. This is a metadata-only
	// operation; secret data cannot be retrieved using this API. Users need the
	// READ permission to make this call.
	//
	// The lastUpdatedTimestamp returned is in milliseconds since epoch. Throws
	// `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws
	// `PERMISSION_DENIED` if the user does not have permission to make this API
	// call.
	//
	// This method is generated by Databricks SDK Code Generator.
	ListSecretsAll(ctx context.Context, request ListSecretsRequest) ([]SecretMetadata, error)

	// List secret keys.
	//
	// Lists the secret keys that are stored at this scope. This is a metadata-only
	// operation; secret data cannot be retrieved using this API. Users need the
	// READ permission to make this call.
	//
	// The lastUpdatedTimestamp returned is in milliseconds since epoch. Throws
	// `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws
	// `PERMISSION_DENIED` if the user does not have permission to make this API
	// call.
	ListSecretsByScope(ctx context.Context, scope string) (*ListSecretsResponse, error)

	// Create/update an ACL.
	//
	// Creates or overwrites the Access Control List (ACL) associated with the given
	// principal (user or group) on the specified scope point.
	//
	// In general, a user or group will use the most powerful permission available
	// to them, and permissions are ordered as follows:
	//
	// * `MANAGE` - Allowed to change ACLs, and read and write to this secret scope.
	// * `WRITE` - Allowed to read and write to this secret scope. * `READ` -
	// Allowed to read this secret scope and list what secrets are available.
	//
	// Note that in general, secret values can only be read from within a command on
	// a cluster (for example, through a notebook). There is no API to read the
	// actual secret value material outside of a cluster. However, the user's
	// permission will be applied based on who is executing the command, and they
	// must have at least READ permission.
	//
	// Users must have the `MANAGE` permission to invoke this API.
	//
	// The principal is a user or group name corresponding to an existing Databricks
	// principal to be granted or revoked access.
	//
	// Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws
	// `RESOURCE_ALREADY_EXISTS` if a permission for the principal already exists.
	// Throws `INVALID_PARAMETER_VALUE` if the permission or principal is invalid.
	// Throws `PERMISSION_DENIED` if the user does not have permission to make this
	// API call.
	PutAcl(ctx context.Context, request PutAcl) error

	// Add a secret.
	//
	// Inserts a secret under the provided scope with the given name. If a secret
	// already exists with the same name, this command overwrites the existing
	// secret's value. The server encrypts the secret using the secret scope's
	// encryption settings before storing it.
	//
	// You must have `WRITE` or `MANAGE` permission on the secret scope. The secret
	// key must consist of alphanumeric characters, dashes, underscores, and
	// periods, and cannot exceed 128 characters. The maximum allowed secret value
	// size is 128 KB. The maximum number of secrets in a given scope is 1000.
	//
	// The input fields "string_value" or "bytes_value" specify the type of the
	// secret, which will determine the value returned when the secret value is
	// requested. Exactly one must be specified.
	//
	// Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws
	// `RESOURCE_LIMIT_EXCEEDED` if maximum number of secrets in scope is exceeded.
	// Throws `INVALID_PARAMETER_VALUE` if the key name or value length is invalid.
	// Throws `PERMISSION_DENIED` if the user does not have permission to make this
	// API call.
	PutSecret(ctx context.Context, request PutSecret) error
}

type SecretsService added in v0.8.0

type SecretsService interface {

	// Create a new secret scope.
	//
	// The scope name must consist of alphanumeric characters, dashes,
	// underscores, and periods, and may not exceed 128 characters.
	CreateScope(ctx context.Context, request CreateScope) error

	// Delete an ACL.
	//
	// Deletes the given ACL on the given scope.
	//
	// Users must have the `MANAGE` permission to invoke this API. Throws
	// `RESOURCE_DOES_NOT_EXIST` if no such secret scope, principal, or ACL
	// exists. Throws `PERMISSION_DENIED` if the user does not have permission
	// to make this API call.
	DeleteAcl(ctx context.Context, request DeleteAcl) error

	// Delete a secret scope.
	//
	// Deletes a secret scope.
	//
	// Throws `RESOURCE_DOES_NOT_EXIST` if the scope does not exist. Throws
	// `PERMISSION_DENIED` if the user does not have permission to make this API
	// call.
	DeleteScope(ctx context.Context, request DeleteScope) error

	// Delete a secret.
	//
	// Deletes the secret stored in this secret scope. You must have `WRITE` or
	// `MANAGE` permission on the secret scope.
	//
	// Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope or secret
	// exists. Throws `PERMISSION_DENIED` if the user does not have permission
	// to make this API call.
	DeleteSecret(ctx context.Context, request DeleteSecret) error

	// Get secret ACL details.
	//
	// Gets the details about the given ACL, such as the group and permission.
	// Users must have the `MANAGE` permission to invoke this API.
	//
	// Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws
	// `PERMISSION_DENIED` if the user does not have permission to make this API
	// call.
	GetAcl(ctx context.Context, request GetAclRequest) (*AclItem, error)

	// Get a secret.
	//
	// Gets the bytes representation of a secret value for the specified scope
	// and key.
	//
	// Users need the READ permission to make this call.
	//
	// Note that the secret value returned is in bytes. The interpretation of
	// the bytes is determined by the caller in DBUtils and the type the data is
	// decoded into.
	//
	// Throws “PERMISSION_DENIED“ if the user does not have permission to make
	// this API call. Throws “RESOURCE_DOES_NOT_EXIST“ if no such secret or
	// secret scope exists.
	GetSecret(ctx context.Context, request GetSecretRequest) (*GetSecretResponse, error)

	// Lists ACLs.
	//
	// List the ACLs for a given secret scope. Users must have the `MANAGE`
	// permission to invoke this API.
	//
	// Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws
	// `PERMISSION_DENIED` if the user does not have permission to make this API
	// call.
	//
	// Use ListAclsAll() to get all AclItem instances
	ListAcls(ctx context.Context, request ListAclsRequest) (*ListAclsResponse, error)

	// List all scopes.
	//
	// Lists all secret scopes available in the workspace.
	//
	// Throws `PERMISSION_DENIED` if the user does not have permission to make
	// this API call.
	//
	// Use ListScopesAll() to get all SecretScope instances
	ListScopes(ctx context.Context) (*ListScopesResponse, error)

	// List secret keys.
	//
	// Lists the secret keys that are stored at this scope. This is a
	// metadata-only operation; secret data cannot be retrieved using this API.
	// Users need the READ permission to make this call.
	//
	// The lastUpdatedTimestamp returned is in milliseconds since epoch. Throws
	// `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws
	// `PERMISSION_DENIED` if the user does not have permission to make this API
	// call.
	//
	// Use ListSecretsAll() to get all SecretMetadata instances
	ListSecrets(ctx context.Context, request ListSecretsRequest) (*ListSecretsResponse, error)

	// Create/update an ACL.
	//
	// Creates or overwrites the Access Control List (ACL) associated with the
	// given principal (user or group) on the specified scope point.
	//
	// In general, a user or group will use the most powerful permission
	// available to them, and permissions are ordered as follows:
	//
	// * `MANAGE` - Allowed to change ACLs, and read and write to this secret
	// scope. * `WRITE` - Allowed to read and write to this secret scope. *
	// `READ` - Allowed to read this secret scope and list what secrets are
	// available.
	//
	// Note that in general, secret values can only be read from within a
	// command on a cluster (for example, through a notebook). There is no API
	// to read the actual secret value material outside of a cluster. However,
	// the user's permission will be applied based on who is executing the
	// command, and they must have at least READ permission.
	//
	// Users must have the `MANAGE` permission to invoke this API.
	//
	// The principal is a user or group name corresponding to an existing
	// Databricks principal to be granted or revoked access.
	//
	// Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws
	// `RESOURCE_ALREADY_EXISTS` if a permission for the principal already
	// exists. Throws `INVALID_PARAMETER_VALUE` if the permission or principal
	// is invalid. Throws `PERMISSION_DENIED` if the user does not have
	// permission to make this API call.
	PutAcl(ctx context.Context, request PutAcl) error

	// Add a secret.
	//
	// Inserts a secret under the provided scope with the given name. If a
	// secret already exists with the same name, this command overwrites the
	// existing secret's value. The server encrypts the secret using the secret
	// scope's encryption settings before storing it.
	//
	// You must have `WRITE` or `MANAGE` permission on the secret scope. The
	// secret key must consist of alphanumeric characters, dashes, underscores,
	// and periods, and cannot exceed 128 characters. The maximum allowed secret
	// value size is 128 KB. The maximum number of secrets in a given scope is
	// 1000.
	//
	// The input fields "string_value" or "bytes_value" specify the type of the
	// secret, which will determine the value returned when the secret value is
	// requested. Exactly one must be specified.
	//
	// Throws `RESOURCE_DOES_NOT_EXIST` if no such secret scope exists. Throws
	// `RESOURCE_LIMIT_EXCEEDED` if maximum number of secrets in scope is
	// exceeded. Throws `INVALID_PARAMETER_VALUE` if the key name or value
	// length is invalid. Throws `PERMISSION_DENIED` if the user does not have
	// permission to make this API call.
	PutSecret(ctx context.Context, request PutSecret) error
}

The Secrets API allows you to manage secrets, secret scopes, and access permissions.

Sometimes accessing data requires that you authenticate to external data sources through JDBC. Instead of directly entering your credentials into a notebook, use Databricks secrets to store your credentials and reference them in notebooks and jobs.

Administrators, secret creators, and users granted permission can read Databricks secrets. While Databricks makes an effort to redact secret values that might be displayed in notebooks, it is not possible to prevent such users from reading secrets.

type SparseCheckout added in v0.8.0

type SparseCheckout struct {
	// List of patterns to include for sparse checkout.
	Patterns []string `json:"patterns,omitempty"`
}

type SparseCheckoutUpdate added in v0.8.0

type SparseCheckoutUpdate struct {
	// List of patterns to include for sparse checkout.
	Patterns []string `json:"patterns,omitempty"`
}

type UpdateCredentials added in v0.8.0

type UpdateCredentials struct {
	// The ID for the corresponding credential to access.
	CredentialId int64 `json:"-" url:"-"`
	// Git provider. This field is case-insensitive. The available Git providers
	// are gitHub, bitbucketCloud, gitLab, azureDevOpsServices,
	// gitHubEnterprise, bitbucketServer, gitLabEnterpriseEdition and
	// awsCodeCommit.
	GitProvider string `json:"git_provider,omitempty"`
	// The username or email provided with your Git provider account, depending
	// on which provider you are using. For GitHub, GitHub Enterprise Server, or
	// Azure DevOps Services, either email or username may be used. For GitLab,
	// GitLab Enterprise Edition, email must be used. For AWS CodeCommit,
	// BitBucket or BitBucket Server, username must be used. For all other
	// providers please see your provider's Personal Access Token authentication
	// documentation to see what is supported.
	GitUsername string `json:"git_username,omitempty"`
	// The personal access token used to authenticate to the corresponding Git
	// provider. For certain providers, support may exist for other types of
	// scoped access tokens. [Learn more]. The personal access token used to
	// authenticate to the corresponding Git
	//
	// [Learn more]: https://docs.databricks.com/repos/get-access-tokens-from-git-provider.html
	PersonalAccessToken string `json:"personal_access_token,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (UpdateCredentials) MarshalJSON added in v0.23.0

func (s UpdateCredentials) MarshalJSON() ([]byte, error)

func (*UpdateCredentials) UnmarshalJSON added in v0.23.0

func (s *UpdateCredentials) UnmarshalJSON(b []byte) error

type UpdateRepo added in v0.8.0

type UpdateRepo struct {
	// Branch that the local version of the repo is checked out to.
	Branch string `json:"branch,omitempty"`
	// The ID for the corresponding repo to access.
	RepoId int64 `json:"-" url:"-"`
	// If specified, update the sparse checkout settings. The update will fail
	// if sparse checkout is not enabled for the repo.
	SparseCheckout *SparseCheckoutUpdate `json:"sparse_checkout,omitempty"`
	// Tag that the local version of the repo is checked out to. Updating the
	// repo to a tag puts the repo in a detached HEAD state. Before committing
	// new changes, you must update the repo to a branch instead of the detached
	// HEAD.
	Tag string `json:"tag,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (UpdateRepo) MarshalJSON added in v0.23.0

func (s UpdateRepo) MarshalJSON() ([]byte, error)

func (*UpdateRepo) UnmarshalJSON added in v0.23.0

func (s *UpdateRepo) UnmarshalJSON(b []byte) error

type UpdateResponse added in v0.34.0

type UpdateResponse struct {
}

type UploadOption added in v0.10.0

type UploadOption = func(*Import)

func UploadFormat added in v0.10.0

func UploadFormat(f ImportFormat) UploadOption

func UploadLanguage added in v0.10.0

func UploadLanguage(l Language) UploadOption

func UploadOverwrite added in v0.10.0

func UploadOverwrite() UploadOption

type WorkspaceAPI

type WorkspaceAPI struct {
	// contains filtered or unexported fields
}

The Workspace API allows you to list, import, export, and delete notebooks and folders.

A notebook is a web-based interface to a document that contains runnable code, visualizations, and explanatory text.

func NewWorkspace

func NewWorkspace(client *client.DatabricksClient) *WorkspaceAPI

func (*WorkspaceAPI) Delete

func (a *WorkspaceAPI) Delete(ctx context.Context, request Delete) error

Delete a workspace object.

Deletes an object or a directory (and optionally recursively deletes all objects in the directory). * If `path` does not exist, this call returns an error `RESOURCE_DOES_NOT_EXIST`. * If `path` is a non-empty directory and `recursive` is set to `false`, this call returns an error `DIRECTORY_NOT_EMPTY`.

Object deletion cannot be undone and deleting a directory recursively is not atomic.

func (*WorkspaceAPI) Download added in v0.10.0

func (a *WorkspaceAPI) Download(ctx context.Context, path string, opts ...DownloadOption) (io.ReadCloser, error)

Download a notebook or file from the workspace by path.

By default, it acts as if workspace.DownloadFormat(workspace.ExportFormatSource) option is supplied. When using workspace.ExportFormatAuto, the `path` is imported or exported as either a workspace file or a notebook, depending on an analysis of the `item`’s extension and the file content header provided in the request.

Returns bytes.Buffer of the path contents.

func (*WorkspaceAPI) Export

func (a *WorkspaceAPI) Export(ctx context.Context, request ExportRequest) (*ExportResponse, error)

Export a workspace object.

Exports an object or the contents of an entire directory.

If `path` does not exist, this call returns an error `RESOURCE_DOES_NOT_EXIST`.

If the exported data would exceed size limit, this call returns `MAX_NOTEBOOK_SIZE_EXCEEDED`. Currently, this API does not support exporting a library.

Example (WorkspaceIntegration)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

notebook := func() string {
	me, err := w.CurrentUser.Me(ctx)
	if err != nil {
		panic(err)
	}
	return filepath.Join("/Users", me.UserName, fmt.Sprintf("sdk-%x", time.Now().UnixNano()))
}()

exportResponse, err := w.Workspace.Export(ctx, workspace.ExportRequest{
	Format: workspace.ExportFormatSource,
	Path:   notebook,
})
if err != nil {
	panic(err)
}
logger.Infof(ctx, "found %v", exportResponse)
Output:

func (*WorkspaceAPI) GetByPath

func (a *WorkspaceAPI) GetByPath(ctx context.Context, name string) (*ObjectInfo, error)

GetByPath calls WorkspaceAPI.ObjectInfoPathToObjectIdMap and returns a single ObjectInfo.

Returns an error if there's more than one ObjectInfo with the same .Path.

Note: All ObjectInfo instances are loaded into memory before returning matching by name.

This method is generated by Databricks SDK Code Generator.

func (*WorkspaceAPI) GetPermissionLevels added in v0.19.0

Get workspace object permission levels.

Gets the permission levels that a user can have on an object.

func (*WorkspaceAPI) GetPermissionLevelsByWorkspaceObjectTypeAndWorkspaceObjectId added in v0.19.0

func (a *WorkspaceAPI) GetPermissionLevelsByWorkspaceObjectTypeAndWorkspaceObjectId(ctx context.Context, workspaceObjectType string, workspaceObjectId string) (*GetWorkspaceObjectPermissionLevelsResponse, error)

Get workspace object permission levels.

Gets the permission levels that a user can have on an object.

func (*WorkspaceAPI) GetPermissions added in v0.19.0

Get workspace object permissions.

Gets the permissions of a workspace object. Workspace objects can inherit permissions from their parent objects or root object.

func (*WorkspaceAPI) GetPermissionsByWorkspaceObjectTypeAndWorkspaceObjectId added in v0.19.0

func (a *WorkspaceAPI) GetPermissionsByWorkspaceObjectTypeAndWorkspaceObjectId(ctx context.Context, workspaceObjectType string, workspaceObjectId string) (*WorkspaceObjectPermissions, error)

Get workspace object permissions.

Gets the permissions of a workspace object. Workspace objects can inherit permissions from their parent objects or root object.

func (*WorkspaceAPI) GetStatus

func (a *WorkspaceAPI) GetStatus(ctx context.Context, request GetStatusRequest) (*ObjectInfo, error)

Get status.

Gets the status of an object or a directory. If `path` does not exist, this call returns an error `RESOURCE_DOES_NOT_EXIST`.

Example (GenericPermissions)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

notebookPath := func() string {
	me, err := w.CurrentUser.Me(ctx)
	if err != nil {
		panic(err)
	}
	return filepath.Join("/Users", me.UserName, fmt.Sprintf("sdk-%x", time.Now().UnixNano()))
}()

obj, err := w.Workspace.GetStatusByPath(ctx, notebookPath)
if err != nil {
	panic(err)
}
logger.Infof(ctx, "found %v", obj)
Output:

Example (WorkspaceIntegration)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

notebook := func() string {
	me, err := w.CurrentUser.Me(ctx)
	if err != nil {
		panic(err)
	}
	return filepath.Join("/Users", me.UserName, fmt.Sprintf("sdk-%x", time.Now().UnixNano()))
}()

getStatusResponse, err := w.Workspace.GetStatusByPath(ctx, notebook)
if err != nil {
	panic(err)
}
logger.Infof(ctx, "found %v", getStatusResponse)
Output:

func (*WorkspaceAPI) GetStatusByPath

func (a *WorkspaceAPI) GetStatusByPath(ctx context.Context, path string) (*ObjectInfo, error)

Get status.

Gets the status of an object or a directory. If `path` does not exist, this call returns an error `RESOURCE_DOES_NOT_EXIST`.

func (*WorkspaceAPI) Impl

func (a *WorkspaceAPI) Impl() WorkspaceService

Impl returns low-level Workspace API implementation Deprecated: use MockWorkspaceInterface instead.

func (*WorkspaceAPI) Import

func (a *WorkspaceAPI) Import(ctx context.Context, request Import) error

Import a workspace object.

Imports a workspace object (for example, a notebook or file) or the contents of an entire directory. If `path` already exists and `overwrite` is set to `false`, this call returns an error `RESOURCE_ALREADY_EXISTS`. To import a directory, you can use either the `DBC` format or the `SOURCE` format with the `language` field unset. To import a single file as `SOURCE`, you must set the `language` field.

Example (GenericPermissions)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

notebookPath := func() string {
	me, err := w.CurrentUser.Me(ctx)
	if err != nil {
		panic(err)
	}
	return filepath.Join("/Users", me.UserName, fmt.Sprintf("sdk-%x", time.Now().UnixNano()))
}()

err = w.Workspace.Import(ctx, workspace.Import{
	Path:      notebookPath,
	Overwrite: true,
	Format:    workspace.ImportFormatSource,
	Language:  workspace.LanguagePython,
	Content: base64.StdEncoding.EncodeToString([]byte((`print(1)
`))),
})
if err != nil {
	panic(err)
}
Output:

Example (JobsApiFullIntegration)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

notebookPath := func() string {
	me, err := w.CurrentUser.Me(ctx)
	if err != nil {
		panic(err)
	}
	return filepath.Join("/Users", me.UserName, fmt.Sprintf("sdk-%x", time.Now().UnixNano()))
}()

err = w.Workspace.Import(ctx, workspace.Import{
	Path:      notebookPath,
	Overwrite: true,
	Format:    workspace.ImportFormatSource,
	Language:  workspace.LanguagePython,
	Content: base64.StdEncoding.EncodeToString([]byte((`import time
time.sleep(10)
dbutils.notebook.exit('hello')
`))),
})
if err != nil {
	panic(err)
}
Output:

Example (Pipelines)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

notebookPath := func() string {
	me, err := w.CurrentUser.Me(ctx)
	if err != nil {
		panic(err)
	}
	return filepath.Join("/Users", me.UserName, fmt.Sprintf("sdk-%x", time.Now().UnixNano()))
}()

err = w.Workspace.Import(ctx, workspace.Import{
	Content:   base64.StdEncoding.EncodeToString([]byte(("CREATE LIVE TABLE dlt_sample AS SELECT 1"))),
	Format:    workspace.ImportFormatSource,
	Language:  workspace.LanguageSql,
	Overwrite: true,
	Path:      notebookPath,
})
if err != nil {
	panic(err)
}
Output:

Example (WorkspaceIntegration)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

notebook := func() string {
	me, err := w.CurrentUser.Me(ctx)
	if err != nil {
		panic(err)
	}
	return filepath.Join("/Users", me.UserName, fmt.Sprintf("sdk-%x", time.Now().UnixNano()))
}()

err = w.Workspace.Import(ctx, workspace.Import{
	Path:      notebook,
	Format:    workspace.ImportFormatSource,
	Language:  workspace.LanguagePython,
	Content:   base64.StdEncoding.EncodeToString([]byte(("# Databricks notebook source\nprint('hello from job')"))),
	Overwrite: true,
})
if err != nil {
	panic(err)
}
Output:

func (*WorkspaceAPI) List added in v0.24.0

List contents.

Lists the contents of a directory, or the object if it is not a directory. If the input path does not exist, this call returns an error `RESOURCE_DOES_NOT_EXIST`.

This method is generated by Databricks SDK Code Generator.

func (*WorkspaceAPI) ListAll

func (a *WorkspaceAPI) ListAll(ctx context.Context, request ListWorkspaceRequest) ([]ObjectInfo, error)

List contents.

Lists the contents of a directory, or the object if it is not a directory. If the input path does not exist, this call returns an error `RESOURCE_DOES_NOT_EXIST`.

This method is generated by Databricks SDK Code Generator.

Example (WorkspaceIntegration)
ctx := context.Background()
w, err := databricks.NewWorkspaceClient()
if err != nil {
	panic(err)
}

notebook := func() string {
	me, err := w.CurrentUser.Me(ctx)
	if err != nil {
		panic(err)
	}
	return filepath.Join("/Users", me.UserName, fmt.Sprintf("sdk-%x", time.Now().UnixNano()))
}()

objects, err := w.Workspace.ListAll(ctx, workspace.ListWorkspaceRequest{
	Path: filepath.Dir(notebook),
})
if err != nil {
	panic(err)
}
logger.Infof(ctx, "found %v", objects)
Output:

func (*WorkspaceAPI) Mkdirs

func (a *WorkspaceAPI) Mkdirs(ctx context.Context, request Mkdirs) error

Create a directory.

Creates the specified directory (and necessary parent directories if they do not exist). If there is an object (not a directory) at any prefix of the input path, this call returns an error `RESOURCE_ALREADY_EXISTS`.

Note that if this operation fails it may have succeeded in creating some of the necessary parent directories.

func (*WorkspaceAPI) MkdirsByPath

func (a *WorkspaceAPI) MkdirsByPath(ctx context.Context, path string) error

Create a directory.

Creates the specified directory (and necessary parent directories if they do not exist). If there is an object (not a directory) at any prefix of the input path, this call returns an error `RESOURCE_ALREADY_EXISTS`.

Note that if this operation fails it may have succeeded in creating some of the necessary parent directories.

func (*WorkspaceAPI) ObjectInfoPathToObjectIdMap

func (a *WorkspaceAPI) ObjectInfoPathToObjectIdMap(ctx context.Context, request ListWorkspaceRequest) (map[string]int64, error)

ObjectInfoPathToObjectIdMap calls WorkspaceAPI.ListAll and creates a map of results with ObjectInfo.Path as key and ObjectInfo.ObjectId as value.

Returns an error if there's more than one ObjectInfo with the same .Path.

Note: All ObjectInfo instances are loaded into memory before creating a map.

This method is generated by Databricks SDK Code Generator.

func (*WorkspaceAPI) ReadFile added in v0.10.0

func (a *WorkspaceAPI) ReadFile(ctx context.Context, name string) ([]byte, error)

ReadFile is identical to os.ReadFile but for workspace files.

func (*WorkspaceAPI) RecursiveList

func (a *WorkspaceAPI) RecursiveList(ctx context.Context, path string) ([]ObjectInfo, error)

RecursiveList traverses the workspace tree and returns all non-directory objects under the path

func (*WorkspaceAPI) SetPermissions added in v0.19.0

Set workspace object permissions.

Sets permissions on a workspace object. Workspace objects can inherit permissions from their parent objects or root object.

func (*WorkspaceAPI) UpdatePermissions added in v0.19.0

Update workspace object permissions.

Updates the permissions on a workspace object. Workspace objects can inherit permissions from their parent objects or root object.

func (*WorkspaceAPI) Upload added in v0.10.0

func (a *WorkspaceAPI) Upload(ctx context.Context, path string, r io.Reader, opts ...UploadOption) error

Upload a workspace object (for example, a notebook or file) or the contents of an entire directory (`DBC` format).

Errors:

  • RESOURCE_ALREADY_EXISTS: if `path` already exists no `overwrite=True`.
  • INVALID_PARAMETER_VALUE: if `format` and `content` values are not compatible.

By default, workspace.UploadFormat(workspace.ImportFormatSource). If using workspace.UploadFormat(workspace.ImportFormatAuto) the `path` is imported or exported as either a workspace file or a notebook, depending on an analysis of the `path`’s extension and the header content provided in the request. In addition, if the `path` is imported as a notebook, then the `item`’s extension is automatically removed.

workspace.UploadLanguage(...) is only required if source format.

func (*WorkspaceAPI) WithImpl

WithImpl could be used to override low-level API implementations for unit testing purposes with github.com/golang/mock or other mocking frameworks. Deprecated: use MockWorkspaceInterface instead.

func (*WorkspaceAPI) WriteFile added in v0.10.0

func (a *WorkspaceAPI) WriteFile(ctx context.Context, name string, data []byte) error

WriteFile is identical to os.WriteFile but for Workspace File. Keep in mind: It doesn't upload the notebook, but the file and does always overwrite it.

type WorkspaceInterface added in v0.29.0

type WorkspaceInterface interface {

	// WithImpl could be used to override low-level API implementations for unit
	// testing purposes with [github.com/golang/mock] or other mocking frameworks.
	// Deprecated: use MockWorkspaceInterface instead.
	WithImpl(impl WorkspaceService) WorkspaceInterface

	// Impl returns low-level Workspace API implementation
	// Deprecated: use MockWorkspaceInterface instead.
	Impl() WorkspaceService

	// Delete a workspace object.
	//
	// Deletes an object or a directory (and optionally recursively deletes all
	// objects in the directory). * If `path` does not exist, this call returns an
	// error `RESOURCE_DOES_NOT_EXIST`. * If `path` is a non-empty directory and
	// `recursive` is set to `false`, this call returns an error
	// `DIRECTORY_NOT_EMPTY`.
	//
	// Object deletion cannot be undone and deleting a directory recursively is not
	// atomic.
	Delete(ctx context.Context, request Delete) error

	// Export a workspace object.
	//
	// Exports an object or the contents of an entire directory.
	//
	// If `path` does not exist, this call returns an error
	// `RESOURCE_DOES_NOT_EXIST`.
	//
	// If the exported data would exceed size limit, this call returns
	// `MAX_NOTEBOOK_SIZE_EXCEEDED`. Currently, this API does not support exporting
	// a library.
	Export(ctx context.Context, request ExportRequest) (*ExportResponse, error)

	// Get workspace object permission levels.
	//
	// Gets the permission levels that a user can have on an object.
	GetPermissionLevels(ctx context.Context, request GetWorkspaceObjectPermissionLevelsRequest) (*GetWorkspaceObjectPermissionLevelsResponse, error)

	// Get workspace object permission levels.
	//
	// Gets the permission levels that a user can have on an object.
	GetPermissionLevelsByWorkspaceObjectTypeAndWorkspaceObjectId(ctx context.Context, workspaceObjectType string, workspaceObjectId string) (*GetWorkspaceObjectPermissionLevelsResponse, error)

	// Get workspace object permissions.
	//
	// Gets the permissions of a workspace object. Workspace objects can inherit
	// permissions from their parent objects or root object.
	GetPermissions(ctx context.Context, request GetWorkspaceObjectPermissionsRequest) (*WorkspaceObjectPermissions, error)

	// Get workspace object permissions.
	//
	// Gets the permissions of a workspace object. Workspace objects can inherit
	// permissions from their parent objects or root object.
	GetPermissionsByWorkspaceObjectTypeAndWorkspaceObjectId(ctx context.Context, workspaceObjectType string, workspaceObjectId string) (*WorkspaceObjectPermissions, error)

	// Get status.
	//
	// Gets the status of an object or a directory. If `path` does not exist, this
	// call returns an error `RESOURCE_DOES_NOT_EXIST`.
	GetStatus(ctx context.Context, request GetStatusRequest) (*ObjectInfo, error)

	// Get status.
	//
	// Gets the status of an object or a directory. If `path` does not exist, this
	// call returns an error `RESOURCE_DOES_NOT_EXIST`.
	GetStatusByPath(ctx context.Context, path string) (*ObjectInfo, error)

	// Import a workspace object.
	//
	// Imports a workspace object (for example, a notebook or file) or the contents
	// of an entire directory. If `path` already exists and `overwrite` is set to
	// `false`, this call returns an error `RESOURCE_ALREADY_EXISTS`. To import a
	// directory, you can use either the `DBC` format or the `SOURCE` format with
	// the `language` field unset. To import a single file as `SOURCE`, you must set
	// the `language` field.
	Import(ctx context.Context, request Import) error

	// List contents.
	//
	// Lists the contents of a directory, or the object if it is not a directory. If
	// the input path does not exist, this call returns an error
	// `RESOURCE_DOES_NOT_EXIST`.
	//
	// This method is generated by Databricks SDK Code Generator.
	List(ctx context.Context, request ListWorkspaceRequest) listing.Iterator[ObjectInfo]

	// List contents.
	//
	// Lists the contents of a directory, or the object if it is not a directory. If
	// the input path does not exist, this call returns an error
	// `RESOURCE_DOES_NOT_EXIST`.
	//
	// This method is generated by Databricks SDK Code Generator.
	ListAll(ctx context.Context, request ListWorkspaceRequest) ([]ObjectInfo, error)

	// ObjectInfoPathToObjectIdMap calls [WorkspaceAPI.ListAll] and creates a map of results with [ObjectInfo].Path as key and [ObjectInfo].ObjectId as value.
	//
	// Returns an error if there's more than one [ObjectInfo] with the same .Path.
	//
	// Note: All [ObjectInfo] instances are loaded into memory before creating a map.
	//
	// This method is generated by Databricks SDK Code Generator.
	ObjectInfoPathToObjectIdMap(ctx context.Context, request ListWorkspaceRequest) (map[string]int64, error)

	// GetByPath calls [WorkspaceAPI.ObjectInfoPathToObjectIdMap] and returns a single [ObjectInfo].
	//
	// Returns an error if there's more than one [ObjectInfo] with the same .Path.
	//
	// Note: All [ObjectInfo] instances are loaded into memory before returning matching by name.
	//
	// This method is generated by Databricks SDK Code Generator.
	GetByPath(ctx context.Context, name string) (*ObjectInfo, error)

	// Create a directory.
	//
	// Creates the specified directory (and necessary parent directories if they do
	// not exist). If there is an object (not a directory) at any prefix of the
	// input path, this call returns an error `RESOURCE_ALREADY_EXISTS`.
	//
	// Note that if this operation fails it may have succeeded in creating some of
	// the necessary parent directories.
	Mkdirs(ctx context.Context, request Mkdirs) error

	// Create a directory.
	//
	// Creates the specified directory (and necessary parent directories if they do
	// not exist). If there is an object (not a directory) at any prefix of the
	// input path, this call returns an error `RESOURCE_ALREADY_EXISTS`.
	//
	// Note that if this operation fails it may have succeeded in creating some of
	// the necessary parent directories.
	MkdirsByPath(ctx context.Context, path string) error

	// Set workspace object permissions.
	//
	// Sets permissions on a workspace object. Workspace objects can inherit
	// permissions from their parent objects or root object.
	SetPermissions(ctx context.Context, request WorkspaceObjectPermissionsRequest) (*WorkspaceObjectPermissions, error)

	// Update workspace object permissions.
	//
	// Updates the permissions on a workspace object. Workspace objects can inherit
	// permissions from their parent objects or root object.
	UpdatePermissions(ctx context.Context, request WorkspaceObjectPermissionsRequest) (*WorkspaceObjectPermissions, error)
	// contains filtered or unexported methods
}

type WorkspaceObjectAccessControlRequest added in v0.15.0

type WorkspaceObjectAccessControlRequest struct {
	// name of the group
	GroupName string `json:"group_name,omitempty"`
	// Permission level
	PermissionLevel WorkspaceObjectPermissionLevel `json:"permission_level,omitempty"`
	// application ID of a service principal
	ServicePrincipalName string `json:"service_principal_name,omitempty"`
	// name of the user
	UserName string `json:"user_name,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (WorkspaceObjectAccessControlRequest) MarshalJSON added in v0.23.0

func (s WorkspaceObjectAccessControlRequest) MarshalJSON() ([]byte, error)

func (*WorkspaceObjectAccessControlRequest) UnmarshalJSON added in v0.23.0

func (s *WorkspaceObjectAccessControlRequest) UnmarshalJSON(b []byte) error

type WorkspaceObjectAccessControlResponse added in v0.15.0

type WorkspaceObjectAccessControlResponse struct {
	// All permissions.
	AllPermissions []WorkspaceObjectPermission `json:"all_permissions,omitempty"`
	// Display name of the user or service principal.
	DisplayName string `json:"display_name,omitempty"`
	// name of the group
	GroupName string `json:"group_name,omitempty"`
	// Name of the service principal.
	ServicePrincipalName string `json:"service_principal_name,omitempty"`
	// name of the user
	UserName string `json:"user_name,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (WorkspaceObjectAccessControlResponse) MarshalJSON added in v0.23.0

func (s WorkspaceObjectAccessControlResponse) MarshalJSON() ([]byte, error)

func (*WorkspaceObjectAccessControlResponse) UnmarshalJSON added in v0.23.0

func (s *WorkspaceObjectAccessControlResponse) UnmarshalJSON(b []byte) error

type WorkspaceObjectPermission added in v0.15.0

type WorkspaceObjectPermission struct {
	Inherited bool `json:"inherited,omitempty"`

	InheritedFromObject []string `json:"inherited_from_object,omitempty"`
	// Permission level
	PermissionLevel WorkspaceObjectPermissionLevel `json:"permission_level,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (WorkspaceObjectPermission) MarshalJSON added in v0.23.0

func (s WorkspaceObjectPermission) MarshalJSON() ([]byte, error)

func (*WorkspaceObjectPermission) UnmarshalJSON added in v0.23.0

func (s *WorkspaceObjectPermission) UnmarshalJSON(b []byte) error

type WorkspaceObjectPermissionLevel added in v0.15.0

type WorkspaceObjectPermissionLevel string

Permission level

const WorkspaceObjectPermissionLevelCanEdit WorkspaceObjectPermissionLevel = `CAN_EDIT`
const WorkspaceObjectPermissionLevelCanManage WorkspaceObjectPermissionLevel = `CAN_MANAGE`
const WorkspaceObjectPermissionLevelCanRead WorkspaceObjectPermissionLevel = `CAN_READ`
const WorkspaceObjectPermissionLevelCanRun WorkspaceObjectPermissionLevel = `CAN_RUN`

func (*WorkspaceObjectPermissionLevel) Set added in v0.15.0

Set raw string value and validate it against allowed values

func (*WorkspaceObjectPermissionLevel) String added in v0.15.0

String representation for fmt.Print

func (*WorkspaceObjectPermissionLevel) Type added in v0.15.0

Type always returns WorkspaceObjectPermissionLevel to satisfy [pflag.Value] interface

type WorkspaceObjectPermissions added in v0.15.0

type WorkspaceObjectPermissions struct {
	AccessControlList []WorkspaceObjectAccessControlResponse `json:"access_control_list,omitempty"`

	ObjectId string `json:"object_id,omitempty"`

	ObjectType string `json:"object_type,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (WorkspaceObjectPermissions) MarshalJSON added in v0.23.0

func (s WorkspaceObjectPermissions) MarshalJSON() ([]byte, error)

func (*WorkspaceObjectPermissions) UnmarshalJSON added in v0.23.0

func (s *WorkspaceObjectPermissions) UnmarshalJSON(b []byte) error

type WorkspaceObjectPermissionsDescription added in v0.15.0

type WorkspaceObjectPermissionsDescription struct {
	Description string `json:"description,omitempty"`
	// Permission level
	PermissionLevel WorkspaceObjectPermissionLevel `json:"permission_level,omitempty"`

	ForceSendFields []string `json:"-"`
}

func (WorkspaceObjectPermissionsDescription) MarshalJSON added in v0.23.0

func (s WorkspaceObjectPermissionsDescription) MarshalJSON() ([]byte, error)

func (*WorkspaceObjectPermissionsDescription) UnmarshalJSON added in v0.23.0

func (s *WorkspaceObjectPermissionsDescription) UnmarshalJSON(b []byte) error

type WorkspaceObjectPermissionsRequest added in v0.15.0

type WorkspaceObjectPermissionsRequest struct {
	AccessControlList []WorkspaceObjectAccessControlRequest `json:"access_control_list,omitempty"`
	// The workspace object for which to get or manage permissions.
	WorkspaceObjectId string `json:"-" url:"-"`
	// The workspace object type for which to get or manage permissions.
	WorkspaceObjectType string `json:"-" url:"-"`
}

type WorkspaceService

type WorkspaceService interface {

	// Delete a workspace object.
	//
	// Deletes an object or a directory (and optionally recursively deletes all
	// objects in the directory). * If `path` does not exist, this call returns
	// an error `RESOURCE_DOES_NOT_EXIST`. * If `path` is a non-empty directory
	// and `recursive` is set to `false`, this call returns an error
	// `DIRECTORY_NOT_EMPTY`.
	//
	// Object deletion cannot be undone and deleting a directory recursively is
	// not atomic.
	Delete(ctx context.Context, request Delete) error

	// Export a workspace object.
	//
	// Exports an object or the contents of an entire directory.
	//
	// If `path` does not exist, this call returns an error
	// `RESOURCE_DOES_NOT_EXIST`.
	//
	// If the exported data would exceed size limit, this call returns
	// `MAX_NOTEBOOK_SIZE_EXCEEDED`. Currently, this API does not support
	// exporting a library.
	Export(ctx context.Context, request ExportRequest) (*ExportResponse, error)

	// Get workspace object permission levels.
	//
	// Gets the permission levels that a user can have on an object.
	GetPermissionLevels(ctx context.Context, request GetWorkspaceObjectPermissionLevelsRequest) (*GetWorkspaceObjectPermissionLevelsResponse, error)

	// Get workspace object permissions.
	//
	// Gets the permissions of a workspace object. Workspace objects can inherit
	// permissions from their parent objects or root object.
	GetPermissions(ctx context.Context, request GetWorkspaceObjectPermissionsRequest) (*WorkspaceObjectPermissions, error)

	// Get status.
	//
	// Gets the status of an object or a directory. If `path` does not exist,
	// this call returns an error `RESOURCE_DOES_NOT_EXIST`.
	GetStatus(ctx context.Context, request GetStatusRequest) (*ObjectInfo, error)

	// Import a workspace object.
	//
	// Imports a workspace object (for example, a notebook or file) or the
	// contents of an entire directory. If `path` already exists and `overwrite`
	// is set to `false`, this call returns an error `RESOURCE_ALREADY_EXISTS`.
	// To import a directory, you can use either the `DBC` format or the
	// `SOURCE` format with the `language` field unset. To import a single file
	// as `SOURCE`, you must set the `language` field.
	Import(ctx context.Context, request Import) error

	// List contents.
	//
	// Lists the contents of a directory, or the object if it is not a
	// directory. If the input path does not exist, this call returns an error
	// `RESOURCE_DOES_NOT_EXIST`.
	//
	// Use ListAll() to get all ObjectInfo instances
	List(ctx context.Context, request ListWorkspaceRequest) (*ListResponse, error)

	// Create a directory.
	//
	// Creates the specified directory (and necessary parent directories if they
	// do not exist). If there is an object (not a directory) at any prefix of
	// the input path, this call returns an error `RESOURCE_ALREADY_EXISTS`.
	//
	// Note that if this operation fails it may have succeeded in creating some
	// of the necessary parent directories.
	Mkdirs(ctx context.Context, request Mkdirs) error

	// Set workspace object permissions.
	//
	// Sets permissions on a workspace object. Workspace objects can inherit
	// permissions from their parent objects or root object.
	SetPermissions(ctx context.Context, request WorkspaceObjectPermissionsRequest) (*WorkspaceObjectPermissions, error)

	// Update workspace object permissions.
	//
	// Updates the permissions on a workspace object. Workspace objects can
	// inherit permissions from their parent objects or root object.
	UpdatePermissions(ctx context.Context, request WorkspaceObjectPermissionsRequest) (*WorkspaceObjectPermissions, error)
}

The Workspace API allows you to list, import, export, and delete notebooks and folders.

A notebook is a web-based interface to a document that contains runnable code, visualizations, and explanatory text.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL