Skip to main content
Connect a workspace to the git repository of its dbtâ„¢ project from code: read the deploy key, connect the repository through the deploy key or an app, check that the key can push, and rotate the key.
Prerequisites:
  • These operations are part of the Enterprise plan. On other plans, they fail with PLAN_UPGRADE_REQUIRED.
  • An account API key with the X-Paradime-Workspace header, or a workspace API key.
  • The Git repository admin capability group.
Keys, errors, jobs, and steps that need a person work the same in every area. See Conventions.

Operations

For new code, use these operations rather than gitRepository and setGitRepository from the Workspace Management API. The new ones read the deploy key, clone a deploy-key repository, check access, and report errors with a code. The older operations keep working with the same Git repository admin group.

Read the repository and its deploy key

gitRepository shows how the workspace reaches its repository:
  • mode is SSH_DEPLOY_KEY, GITHUB_APP, or GITLAB_APP.
  • state says where the connection is:
githubAppInstallUrl is the page where a workspace member installs the Paradime GitHub App, in a browser. It is null when your account can’t connect through the GitHub App. See Pending user action.
When the workspace has no deploy key yet, reading deployKey makes the first one and adds an audit entry. Add the public key to the repository as a deploy key with write access, on your git provider, before you connect it.

Connect a repository with the deploy key

Set exactly one field of connection: deployKey, githubApp, or gitlabApp. With deployKey:
  • provider is GITHUB, GITLAB, BITBUCKET, or AZURE_DEVOPS.
  • uri must be an SSH git URL, user@host:path or ssh://user@host/path, for example git@github.com:acme/analytics.git.
  • dbtProjectDir is the folder inside the repository that holds dbt_project.yml. Leave it out when the file is at the repository’s root.
  • validate is true by default: Paradime clones the repository in a job, checks dbt_project.yml, syncs production, and restarts the workspace’s editors. With validate: false, Paradime only saves the repository as PENDING_VALIDATION, for example before someone adds the deploy key to it.
  • force replaces a cloned repository with another one. Without it, connecting a different repository to a workspace that has a clone is a CONFLICT.
The payload holds the repository as it is now, and the job that clones it. Poll the job with adminJob until its status is SUCCEEDED or FAILED. The job has a time limit of 5 minutes, and its result is a GitRepositoryConnectResult. If the job fails, failure.code tells you why: job is null when nothing needed a clone: with validate: false, or when you send the same input again for a repository that is already cloned. Sending the same input again changes nothing and starts no job.

Connect a repository through the GitHub App or GitLab

The app connections finish before the mutation returns, so they start no job.
  • githubApp connects through the Paradime GitHub App. Send the installationId of an installation your account holds and the numeric repositoryId of the repository. Send neither to move the workspace’s current repository to the app. Install the app first: see Connect with the GitHub App.
  • gitlabApp connects through your account’s GitLab connection. Send the connection’s baseUrl and the numeric projectId, or neither to move the workspace’s current repository to the connection.
To move a workspace from an app back to its deploy key, send deployKey with the same uri and dbtProjectDir that the workspace has now.

Check that the deploy key can push

checkGitRepository checks, in a job, that the workspace’s deploy key can push to a repository. It changes nothing, so you can run it before you connect. The job has a time limit of 2 minutes. It fails with CONNECTION_TEST_FAILED when the key can’t push, and its result is a GitRepositoryCheckResult.

Rotate the deploy key

rotateGitDeployKey replaces the workspace’s deploy key and returns the new public key. Every call makes a new key.
If the connected repository uses the deploy key, clone and push break until you add the new key to the repository. In that case the call needs force: true. Without it, the call fails with CONFLICT and changes nothing.

Errors

These are the cases specific to git repositories. For the error format and the codes every area shares, see Errors. The jobs report their own failures in failure.code, as described in Connect a repository with the deploy key.