Skip to main content

git_credentials

Creates, updates, deletes, gets or lists a git_credentials resource.

Overview​

Namegit_credentials
TypeResource
Iddatabricks_workspace.workspace.git_credentials

Fields​

The following fields are returned by SELECT queries:

NameDatatypeDescription
namestringthe name of the git credential, used for identification and ease of lookup
credential_idinteger
git_emailstringThe authenticating email associated with your Git provider user account. Used for authentication with the remote repository and also sets the author & committer identity for commits. Required for most Git providers except AWS CodeCommit. Learn more at https://docs.databricks.com/aws/en/repos/get-access-tokens-from-git-provider
git_providerstringThe Git provider associated with the credential.
git_usernamestringThe username provided with your Git provider account and associated with the credential. For most Git providers it is only used to set the Git committer & author names for commits, however it may be required for authentication depending on your Git provider / token requirements. Required for AWS CodeCommit.
is_default_for_providerbooleanif the credential is the default for the given provider

Methods​

The following methods are available for this resource:

NameAccessible byRequired ParamsOptional ParamsDescription
getselectcredential_id, deployment_name, workspace_domainprincipal_idGets the Git credential with the specified credential ID.
listselectdeployment_name, workspace_domainprincipal_idLists the calling user's Git credentials.
createinsertdeployment_name, workspace_domain, git_providerCreates a Git credential entry for the user. Use the PATCH endpoint to update existing credentials, or
updateupdatecredential_id, deployment_name, workspace_domain, git_providerUpdates the specified Git credential.
deletedeletecredential_id, deployment_name, workspace_domainprincipal_idDeletes the specified Git credential.

Parameters​

Parameters can be passed in the WHERE clause of a query. Check the Methods section to see which parameters are required or optional for each operation.

NameDatatypeDescription
credential_idintegerThe ID for the corresponding credential to access.
deployment_namestringThe Databricks workspace deployment name: the host prefix of the workspace URL (dbc-abcd0123-a1bc on AWS, adb-1234567890123456.7 on Azure, 1234567890123456.7 on GCP). Set DATABRICKS_DEPLOYMENT_NAME to default it for the session. (default: dbc-abcd0123-a1bc, x-stackQL-envVar: DATABRICKS_DEPLOYMENT_NAME)
workspace_domainstringThe Databricks workspace domain suffix for the cloud. Selected by DATABRICKS_CLOUD (aws, azure or gcp; default aws). (default: cloud.databricks.com, x-stackQL-envVarSelector: {"envVar":"DATABRICKS_CLOUD","default":"aws","values":{"aws":"cloud.databricks.com","azure":"azuredatabricks.net","gcp":"gcp.databricks.com"}})
principal_idintegerThe ID of the service principal whose credentials will be modified. Only service principal managers can perform this action.

SELECT examples​

Gets the Git credential with the specified credential ID.

SELECT
name,
credential_id,
git_email,
git_provider,
git_username,
is_default_for_provider
FROM databricks_workspace.workspace.git_credentials
WHERE credential_id = '{{ credential_id }}' -- required
AND deployment_name = '{{ deployment_name }}' -- required
AND workspace_domain = '{{ workspace_domain }}' -- required
AND principal_id = '{{ principal_id }}'
;

INSERT examples​

Creates a Git credential entry for the user. Use the PATCH endpoint to update existing credentials, or

INSERT INTO databricks_workspace.workspace.git_credentials (
git_provider,
git_email,
git_username,
is_default_for_provider,
name,
personal_access_token,
principal_id,
deployment_name,
workspace_domain
)
SELECT
'{{ git_provider }}' /* required */,
'{{ git_email }}',
'{{ git_username }}',
{{ is_default_for_provider }},
'{{ name }}',
'{{ personal_access_token }}',
{{ principal_id }},
'{{ deployment_name }}',
'{{ workspace_domain }}'
RETURNING
name,
credential_id,
git_email,
git_provider,
git_username,
is_default_for_provider
;

UPDATE examples​

Updates the specified Git credential.

UPDATE databricks_workspace.workspace.git_credentials
SET
git_provider = '{{ git_provider }}',
git_email = '{{ git_email }}',
git_username = '{{ git_username }}',
is_default_for_provider = {{ is_default_for_provider }},
name = '{{ name }}',
personal_access_token = '{{ personal_access_token }}',
principal_id = {{ principal_id }}
WHERE
credential_id = '{{ credential_id }}' --required
AND deployment_name = '{{ deployment_name }}' --required
AND workspace_domain = '{{ workspace_domain }}' --required
AND git_provider = '{{ git_provider }}' --required;

DELETE examples​

Deletes the specified Git credential.

DELETE FROM databricks_workspace.workspace.git_credentials
WHERE credential_id = '{{ credential_id }}' --required
AND deployment_name = '{{ deployment_name }}' --required
AND workspace_domain = '{{ workspace_domain }}' --required
AND principal_id = '{{ principal_id }}'
;