w.repos
: Repos¶
- class databricks.sdk.service.workspace.ReposAPI¶
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.
- create(url: str, provider: str [, path: Optional[str], sparse_checkout: Optional[SparseCheckout]]) CreateRepoResponse ¶
Usage:
import time from databricks.sdk import WorkspaceClient w = WorkspaceClient() root = f'sdk-{time.time_ns()}' ri = w.repos.create(path=root, url="https://github.com/shreyas-goenka/empty-repo.git", provider="github") # cleanup w.repos.delete(repo_id=ri.id)
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.
- Parameters:
url – str URL of the Git repository to be linked.
provider – str Git provider. This field is case-insensitive. The available Git providers are gitHub, bitbucketCloud, gitLab, azureDevOpsServices, gitHubEnterprise, bitbucketServer, gitLabEnterpriseEdition and awsCodeCommit.
path – str (optional) 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}.
sparse_checkout –
SparseCheckout
(optional) If specified, the repo will be created with sparse checkout enabled. You cannot enable/disable sparse checkout after the repo is created.
- Returns:
- delete(repo_id: int)¶
Delete a repo.
Deletes the specified repo.
- Parameters:
repo_id – int The ID for the corresponding repo to delete.
- get(repo_id: int) GetRepoResponse ¶
Usage:
import time from databricks.sdk import WorkspaceClient w = WorkspaceClient() root = f'sdk-{time.time_ns()}' ri = w.repos.create(path=root, url="https://github.com/shreyas-goenka/empty-repo.git", provider="github") by_id = w.repos.get(repo_id=ri.id) # cleanup w.repos.delete(repo_id=ri.id)
Get a repo.
Returns the repo with the given repo ID.
- Parameters:
repo_id – int ID of the Git folder (repo) object in the workspace.
- Returns:
- get_permission_levels(repo_id: str) GetRepoPermissionLevelsResponse ¶
Get repo permission levels.
Gets the permission levels that a user can have on an object.
- Parameters:
repo_id – str The repo for which to get or manage permissions.
- Returns:
- get_permissions(repo_id: str) RepoPermissions ¶
Get repo permissions.
Gets the permissions of a repo. Repos can inherit permissions from their root object.
- Parameters:
repo_id – str The repo for which to get or manage permissions.
- Returns:
- list([, next_page_token: Optional[str], path_prefix: Optional[str]]) Iterator[RepoInfo] ¶
Usage:
from databricks.sdk import WorkspaceClient from databricks.sdk.service import workspace w = WorkspaceClient() all = w.repos.list(workspace.ListReposRequest())
Get repos.
Returns repos that the calling user has Manage permissions on. Use next_page_token to iterate through additional pages.
- Parameters:
next_page_token – str (optional) 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.
path_prefix – str (optional) Filters repos that have paths starting with the given path prefix. If not provided or when provided an effectively empty prefix (/ or /Workspace) Git folders (repos) from /Workspace/Repos will be served.
- Returns:
Iterator over
RepoInfo
- set_permissions(repo_id: str [, access_control_list: Optional[List[RepoAccessControlRequest]]]) RepoPermissions ¶
Set repo permissions.
Sets permissions on an object, replacing existing permissions if they exist. Deletes all direct permissions if none are specified. Objects can inherit permissions from their root object.
- Parameters:
repo_id – str The repo for which to get or manage permissions.
access_control_list – List[
RepoAccessControlRequest
] (optional)
- Returns:
- update(repo_id: int [, branch: Optional[str], sparse_checkout: Optional[SparseCheckoutUpdate], tag: Optional[str]])¶
Usage:
import time from databricks.sdk import WorkspaceClient w = WorkspaceClient() root = f'sdk-{time.time_ns()}' ri = w.repos.create(path=root, url="https://github.com/shreyas-goenka/empty-repo.git", provider="github") w.repos.update(repo_id=ri.id, branch="foo") # cleanup w.repos.delete(repo_id=ri.id)
Update a repo.
Updates the repo to a different branch or tag, or updates the repo to the latest commit on the same branch.
- Parameters:
repo_id – int ID of the Git folder (repo) object in the workspace.
branch – str (optional) Branch that the local version of the repo is checked out to.
sparse_checkout –
SparseCheckoutUpdate
(optional) If specified, update the sparse checkout settings. The update will fail if sparse checkout is not enabled for the repo.tag – str (optional) 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.
- update_permissions(repo_id: str [, access_control_list: Optional[List[RepoAccessControlRequest]]]) RepoPermissions ¶
Update repo permissions.
Updates the permissions on a repo. Repos can inherit permissions from their root object.
- Parameters:
repo_id – str The repo for which to get or manage permissions.
access_control_list – List[
RepoAccessControlRequest
] (optional)
- Returns: