Skip to content

GitProvider API#

You can obtain a GetApi handle via Project.get_git_api. Once you have an API handle, you can use it to obtain GitProvider objects using the following methods:

set_provider #

set_provider(
    provider: Literal["GitHub", "GitLab", "BitBucket"],
    username: str,
    token: str,
    host: str = None,
)

Configure a Git provider.

import hopsworks

project = hopsworks.login()

git_api = project.get_git_api()

git_api.set_provider("GitHub", "my_user", "my_token", host="github.com")
PARAMETER DESCRIPTION
provider

Name of the git provider.

TYPE: Literal['GitHub', 'GitLab', 'BitBucket']

username

Username for the git provider service.

TYPE: str

token

Token to set for the git provider service.

TYPE: str

host

Host for the git provider, e.g., "github.com" for GitHub, "gitlab.com" for GitLab, "bitbucket.org" for BitBucket.

TYPE: str DEFAULT: None

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request.

get_provider #

get_provider(
    provider: Literal["GitHub", "GitLab", "BitBucket"],
    host: str = None,
) -> git_provider.GitProvider | None

Get the configured Git provider.

PARAMETER DESCRIPTION
provider

Name of the git provider.

TYPE: Literal['GitHub', 'GitLab', 'BitBucket']

host

Optional host for the git provider, e.g., "github.com" for GitHub, "gitlab.com" for GitLab, "bitbucket.org" for BitBucket.

TYPE: str DEFAULT: None

RETURNS DESCRIPTION
git_provider.GitProvider | None

The git provider or None if it does not exist.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request.

get_providers #

get_providers() -> list[git_provider.GitProvider]

Get the configured Git providers.

RETURNS DESCRIPTION
list[git_provider.GitProvider]

List of git provider objects.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request.

GitProvider #

git_provider property #

git_provider

Name of the provider, can be GitHub, GitLab or BitBucket.

host property #

host

Host of the provider, can be for example github.com for GitHub, gitlab.com for GitLab or bitbucket.org for BitBucket.

username property #

username

Username set for the provider.

delete #

delete()

Remove the git provider configuration.

RAISES DESCRIPTION
hopsworks.client.exceptions.RestAPIError

If the backend encounters an error when handling the request