Documentation
¶
Overview ¶
These APIs allow you to manage Git Credentials, Repos, Secrets, Workspace, etc.
Index ¶
- type AclItem
- type AclPermission
- type AzureKeyVaultSecretScopeMetadata
- type CreateCredentials
- type CreateCredentialsResponse
- type CreateRepo
- type CreateScope
- type CredentialInfo
- type Delete
- type DeleteAcl
- type DeleteGitCredentialRequest
- type DeleteRepoRequest
- type DeleteScope
- type DeleteSecret
- type ExportFormat
- type ExportRequest
- type ExportResponse
- type GetAclRequest
- type GetCredentialsResponse
- type GetGitCredentialRequest
- type GetRepoRequest
- type GetStatusRequest
- type GitCredentialsAPI
- func (a *GitCredentialsAPI) Create(ctx context.Context, request CreateCredentials) (*CreateCredentialsResponse, error)
- func (a *GitCredentialsAPI) CredentialInfoGitProviderToCredentialIdMap(ctx context.Context) (map[string]int64, error)
- func (a *GitCredentialsAPI) Delete(ctx context.Context, request DeleteGitCredentialRequest) error
- func (a *GitCredentialsAPI) DeleteByCredentialId(ctx context.Context, credentialId int64) error
- func (a *GitCredentialsAPI) Get(ctx context.Context, request GetGitCredentialRequest) (*CredentialInfo, error)
- func (a *GitCredentialsAPI) GetByCredentialId(ctx context.Context, credentialId int64) (*CredentialInfo, error)
- func (a *GitCredentialsAPI) GetByGitProvider(ctx context.Context, name string) (*CredentialInfo, error)
- func (a *GitCredentialsAPI) Impl() GitCredentialsService
- func (a *GitCredentialsAPI) ListAll(ctx context.Context) ([]CredentialInfo, error)
- func (a *GitCredentialsAPI) Update(ctx context.Context, request UpdateCredentials) error
- func (a *GitCredentialsAPI) WithImpl(impl GitCredentialsService) *GitCredentialsAPI
- type GitCredentialsService
- type Import
- type Language
- type ListAclsRequest
- type ListAclsResponse
- type ListReposRequest
- type ListReposResponse
- type ListResponse
- type ListScopesResponse
- type ListSecretsRequest
- type ListSecretsResponse
- type ListWorkspaceRequest
- type Mkdirs
- type ObjectInfo
- type ObjectType
- type PutAcl
- type PutSecret
- type RepoInfo
- type ReposAPI
- func (a *ReposAPI) Create(ctx context.Context, request CreateRepo) (*RepoInfo, error)
- func (a *ReposAPI) Delete(ctx context.Context, request DeleteRepoRequest) error
- func (a *ReposAPI) DeleteByRepoId(ctx context.Context, repoId int64) error
- func (a *ReposAPI) Get(ctx context.Context, request GetRepoRequest) (*RepoInfo, error)
- func (a *ReposAPI) GetByPath(ctx context.Context, name string) (*RepoInfo, error)
- func (a *ReposAPI) GetByRepoId(ctx context.Context, repoId int64) (*RepoInfo, error)
- func (a *ReposAPI) Impl() ReposService
- func (a *ReposAPI) ListAll(ctx context.Context, request ListReposRequest) ([]RepoInfo, error)
- func (a *ReposAPI) RepoInfoPathToIdMap(ctx context.Context, request ListReposRequest) (map[string]int64, error)
- func (a *ReposAPI) Update(ctx context.Context, request UpdateRepo) error
- func (a *ReposAPI) WithImpl(impl ReposService) *ReposAPI
- type ReposService
- type ScopeBackendType
- type SecretMetadata
- type SecretScope
- type SecretsAPI
- func (a *SecretsAPI) CreateScope(ctx context.Context, request CreateScope) error
- func (a *SecretsAPI) DeleteAcl(ctx context.Context, request DeleteAcl) error
- func (a *SecretsAPI) DeleteScope(ctx context.Context, request DeleteScope) error
- func (a *SecretsAPI) DeleteScopeByScope(ctx context.Context, scope string) error
- func (a *SecretsAPI) DeleteSecret(ctx context.Context, request DeleteSecret) error
- func (a *SecretsAPI) GetAcl(ctx context.Context, request GetAclRequest) (*AclItem, error)
- func (a *SecretsAPI) Impl() SecretsService
- func (a *SecretsAPI) ListAclsAll(ctx context.Context, request ListAclsRequest) ([]AclItem, error)
- func (a *SecretsAPI) ListAclsByScope(ctx context.Context, scope string) (*ListAclsResponse, error)
- func (a *SecretsAPI) ListScopesAll(ctx context.Context) ([]SecretScope, error)
- func (a *SecretsAPI) ListSecretsAll(ctx context.Context, request ListSecretsRequest) ([]SecretMetadata, error)
- func (a *SecretsAPI) ListSecretsByScope(ctx context.Context, scope string) (*ListSecretsResponse, error)
- func (a *SecretsAPI) PutAcl(ctx context.Context, request PutAcl) error
- func (a *SecretsAPI) PutSecret(ctx context.Context, request PutSecret) error
- func (a *SecretsAPI) WithImpl(impl SecretsService) *SecretsAPI
- type SecretsService
- type SparseCheckout
- type SparseCheckoutUpdate
- type UpdateCredentials
- type UpdateRepo
- type WorkspaceAPI
- func (a *WorkspaceAPI) Delete(ctx context.Context, request Delete) error
- func (a *WorkspaceAPI) Export(ctx context.Context, request ExportRequest) (*ExportResponse, error)
- func (a *WorkspaceAPI) GetByPath(ctx context.Context, name string) (*ObjectInfo, error)
- func (a *WorkspaceAPI) GetStatus(ctx context.Context, request GetStatusRequest) (*ObjectInfo, error)
- func (a *WorkspaceAPI) GetStatusByPath(ctx context.Context, path string) (*ObjectInfo, error)
- func (a *WorkspaceAPI) Impl() WorkspaceService
- func (a *WorkspaceAPI) Import(ctx context.Context, request Import) error
- func (a *WorkspaceAPI) ListAll(ctx context.Context, request ListWorkspaceRequest) ([]ObjectInfo, error)
- func (a *WorkspaceAPI) Mkdirs(ctx context.Context, request Mkdirs) error
- func (a *WorkspaceAPI) MkdirsByPath(ctx context.Context, path string) error
- func (a *WorkspaceAPI) ObjectInfoPathToObjectIdMap(ctx context.Context, request ListWorkspaceRequest) (map[string]int64, error)
- func (a *WorkspaceAPI) RecursiveList(ctx context.Context, path string) ([]ObjectInfo, error)
- func (a *WorkspaceAPI) WithImpl(impl WorkspaceService) *WorkspaceAPI
- type WorkspaceService
Examples ¶
- GitCredentialsAPI.Create (GitCredentials)
- GitCredentialsAPI.Get (GitCredentials)
- GitCredentialsAPI.ListAll (GitCredentials)
- GitCredentialsAPI.Update (GitCredentials)
- ReposAPI.Create (Repos)
- ReposAPI.Get (Repos)
- ReposAPI.GetByPath (CheckoutBranchByPath)
- ReposAPI.ListAll (Repos)
- ReposAPI.Update (Repos)
- SecretsAPI.CreateScope (Secrets)
- SecretsAPI.PutAcl (Secrets)
- SecretsAPI.PutSecret (Secrets)
- WorkspaceAPI.Export (WorkspaceIntegration)
- WorkspaceAPI.GetStatus (GenericPermissions)
- WorkspaceAPI.GetStatus (WorkspaceIntegration)
- WorkspaceAPI.Import (GenericPermissions)
- WorkspaceAPI.Import (JobsApiFullIntegration)
- WorkspaceAPI.Import (Pipelines)
- WorkspaceAPI.Import (WorkspaceIntegration)
- WorkspaceAPI.ListAll (WorkspaceIntegration)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
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 (ap *AclPermission) Set(v string) error
Set raw string value and validate it against allowed values
func (*AclPermission) String ¶ added in v0.8.0
func (ap *AclPermission) String() string
String representation for fmt.Print
func (*AclPermission) Type ¶ added in v0.8.0
func (ap *AclPermission) Type() string
Type always returns AclPermission to satisfy [pflag.Value] interface
type AzureKeyVaultSecretScopeMetadata ¶ added in v0.8.0
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"` // Git username. GitUsername string `json:"git_username,omitempty"` // The personal access token used to authenticate to the corresponding Git // provider. PersonalAccessToken string `json:"personal_access_token,omitempty"` }
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"` // Git username. GitUsername string `json:"git_username,omitempty"` }
type CreateRepo ¶ added in v0.8.0
type CreateRepo struct { // Desired path for the repo in the workspace. 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"` }
type CreateScope ¶ added in v0.8.0
type CreateScope struct { // The principal that is initially granted `MANAGE` permission to the // created scope. InitialManagePrincipal string `json:"initial_manage_principal,omitempty"` // The metadata for the secret scope if the type is `AZURE_KEYVAULT` KeyvaultMetadata *AzureKeyVaultSecretScopeMetadata `json:"keyvault_metadata,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"` }
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, bitbucketCloud, gitLab, azureDevOpsServices, // gitHubEnterprise, bitbucketServer, gitLabEnterpriseEdition and // awsCodeCommit. GitProvider string `json:"git_provider,omitempty"` // Git username. GitUsername string `json:"git_username,omitempty"` }
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"` }
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 DeleteScope ¶ added in v0.8.0
type DeleteScope struct { // Name of the scope to delete. Scope string `json:"scope"` }
type DeleteSecret ¶ added in v0.8.0
type ExportFormat ¶
type ExportFormat string
This specifies the format of the file to be imported. By default, this is `SOURCE`.
If using `AUTO` the item is imported or exported as either a workspace file or a notebook,depending on an analysis of the item’s extension and the header content provided in the request. The value is case sensitive. In addition, if the item is imported as a notebook, then the item’s extension is automatically removed.
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 (ef *ExportFormat) Set(v string) error
Set raw string value and validate it against allowed values
func (*ExportFormat) String ¶ added in v0.2.0
func (ef *ExportFormat) String() string
String representation for fmt.Print
func (*ExportFormat) Type ¶ added in v0.2.0
func (ef *ExportFormat) Type() string
Type always returns ExportFormat to satisfy [pflag.Value] interface
type ExportRequest ¶ added in v0.8.0
type ExportRequest struct { // Flag to enable direct download. If it is `true`, the response will be the // exported file itself. Otherwise, the response contains content as base64 // encoded string. DirectDownload bool `json:"-" url:"direct_download,omitempty"` // This specifies the format of the exported file. By default, this is // `SOURCE`. However it may be one of: `SOURCE`, `HTML`, `JUPYTER`, `DBC`. // // The value is case sensitive. Format ExportFormat `json:"-" url:"format,omitempty"` // The absolute path of the object or directory. Exporting a directory is // only supported for the `DBC` 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** will be thrown. Content string `json:"content,omitempty"` }
func (*ExportResponse) Bytes ¶
func (r *ExportResponse) Bytes() ([]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 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 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 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
func (a *GitCredentialsAPI) Create(ctx context.Context, request CreateCredentials) (*CreateCredentialsResponse, error)
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
func (a *GitCredentialsAPI) Delete(ctx context.Context, request DeleteGitCredentialRequest) error
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
func (a *GitCredentialsAPI) Get(ctx context.Context, request GetGitCredentialRequest) (*CredentialInfo, error)
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
func (a *GitCredentialsAPI) Impl() GitCredentialsService
Impl returns low-level GitCredentials API implementation
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
func (a *GitCredentialsAPI) WithImpl(impl GitCredentialsService) *GitCredentialsAPI
WithImpl could be used to override low-level API implementations for unit testing purposes with github.com/golang/mock or other mocking frameworks.
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** will be thrown. This parameter might be // absent, and instead a posted file will be used. Content string `json:"content,omitempty"` // This specifies the format of the file to be imported. By default, this is // `SOURCE`. // // If using `AUTO` the item is imported or exported as either a workspace // file or a notebook,depending on an analysis of the item’s extension and // the header content provided in the request. The value is case sensitive. // In addition, if the item is imported as a notebook, then the item’s // extension is automatically removed. Format ExportFormat `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` format. Path string `json:"path"` }
func PythonNotebookOverwrite ¶
PythonNotebookOverwrite crafts Python import notebook request also by trimming the code specified in the second argument
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`
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. PathPrefix string `json:"-" url:"path_prefix,omitempty"` }
Get repos
type ListReposResponse ¶ added in v0.8.0
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 { // <content needed> NotebooksModifiedAfter int `json:"-" url:"notebooks_modified_after,omitempty"` // The absolute path of the notebook or directory. Path string `json:"-" url:"path"` }
List contents
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 ObjectInfo ¶
type ObjectInfo struct { // <content needed> 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"` // <content needed> ModifiedAt int64 `json:"modified_at,omitempty"` // <content needed> ObjectId int64 `json:"object_id,omitempty"` // The type of the object in workspace. ObjectType ObjectType `json:"object_type,omitempty"` // The absolute path of the object. Path string `json:"path,omitempty"` // <content needed> Size int64 `json:"size,omitempty"` }
type ObjectType ¶
type ObjectType string
The type of the object in workspace.
const ObjectTypeDirectory ObjectType = `DIRECTORY`
const ObjectTypeFile ObjectType = `FILE`
const ObjectTypeLibrary ObjectType = `LIBRARY`
const ObjectTypeNotebook ObjectType = `NOTEBOOK`
const ObjectTypeRepo ObjectType = `REPO`
func (*ObjectType) Set ¶ added in v0.2.0
func (ot *ObjectType) Set(v string) error
Set raw string value and validate it against allowed values
func (*ObjectType) String ¶ added in v0.2.0
func (ot *ObjectType) String() string
String representation for fmt.Print
func (*ObjectType) Type ¶ added in v0.2.0
func (ot *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 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"` }
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. 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"` }
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
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) Get ¶ added in v0.8.0
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
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) Impl ¶ added in v0.8.0
func (a *ReposAPI) Impl() ReposService
Impl returns low-level Repos API implementation
func (*ReposAPI) ListAll ¶ added in v0.8.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.
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) 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) WithImpl ¶ added in v0.8.0
func (a *ReposAPI) WithImpl(impl ReposService) *ReposAPI
WithImpl could be used to override low-level API implementations for unit testing purposes with github.com/golang/mock or other mocking frameworks.
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 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) // 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 }
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 (sbt *ScopeBackendType) Set(v string) error
Set raw string value and validate it against allowed values
func (*ScopeBackendType) String ¶ added in v0.8.0
func (sbt *ScopeBackendType) String() string
String representation for fmt.Print
func (*ScopeBackendType) Type ¶ added in v0.8.0
func (sbt *ScopeBackendType) Type() string
Type always returns ScopeBackendType to satisfy [pflag.Value] interface
type SecretMetadata ¶ added in v0.8.0
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"` }
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. The maximum number of scopes in a workspace is 100.
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) Impl ¶ added in v0.8.0
func (a *SecretsAPI) Impl() SecretsService
Impl returns low-level Secrets API implementation
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) 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) 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 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) *SecretsAPI
WithImpl could be used to override low-level API implementations for unit testing purposes with github.com/golang/mock or other mocking frameworks.
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. The maximum // number of scopes in a workspace is 100. 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) // 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 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"` // Git username. GitUsername string `json:"git_username,omitempty"` // The personal access token used to authenticate to the corresponding Git // provider. PersonalAccessToken string `json:"personal_access_token,omitempty"` }
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"` }
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) 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`.
One can only export a directory in `DBC` format. 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{ DirectDownload: false, Format: "SOURCE", 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) 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
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`. One can only use `DBC` format to import a directory.
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.ExportFormatSource, 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.ExportFormatSource, 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.ExportFormatSource, 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: "SOURCE", Language: "PYTHON", Content: base64.StdEncoding.EncodeToString([]byte(("# Databricks notebook source\nprint('hello from job')"))), Overwrite: true, }) if err != nil { panic(err) }
Output:
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 parrent 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 parrent 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) 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) WithImpl ¶
func (a *WorkspaceAPI) WithImpl(impl WorkspaceService) *WorkspaceAPI
WithImpl could be used to override low-level API implementations for unit testing purposes with github.com/golang/mock or other mocking frameworks.
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`. // // One can only export a directory in `DBC` format. 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 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`. // One can only use `DBC` format to import a directory. 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 parrent directories. Mkdirs(ctx context.Context, request Mkdirs) 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.