Skip to main content
Version: 0.5.4

helpers.dbt_cloud.client

DBTCloudClientV2 Objects

class DBTCloudClientV2()

[view_source]

A client for interacting with the dbt Cloud API (version 2).

__init__

def __init__(api_token: str,
account_id: Optional[str] = None,
base_api_url: str = BASE_URL)

[view_source]

Arguments:

  • api_token str - The API token for authentication.
  • account_id str, optional - The ID of the dbt Cloud account. Defaults to None.
  • base_api_url str, optional - The base URL of the dbt Cloud API. Defaults to "https://cloud.getdbt.com/api".

trigger_job_run

def trigger_job_run(job_id: Union[int, str],
data: Optional[Dict[Any, Any]] = None) -> int

[view_source]

Trigger a job run in dbt Cloud.

Uses https://cloud.getdbt.com/api/v2/accounts/{account_id}/jobs/{job_id}/run/ endpoint to kick off a run for a job.

When this endpoint returns a successful response, a new run will be enqueued for the account. Users can poll the Get run endpoint to poll the run until it completes. After the run has completed, users can use the Get run artifact endpoint to download artifacts generated by the run.

More info: https://docs.getdbt.com/dbt-cloud/api-v2#/operations/Trigger%20Job%20Run.

Arguments:

  • job_id int | str - The ID of the job.
  • data dict, optional - The JSON data to post. Defaults to None. Fields of data: '{
  • "cause" - "string",
  • "git_sha" - "string",
  • "git_branch" - "string",
  • "azure_pull_request_id" - integer,
  • "github_pull_request_id" - integer,
  • "gitlab_merge_request_id" - integer,
  • "schema_override" - "string",
  • "dbt_version_override" - "string",
  • "threads_override" - integer,
  • "target_name_override" - "string",
  • "generate_docs_override" - boolean,
  • "timeout_seconds_override" - integer,
  • "steps_override" - [ "string" ] }'

Returns:

  • int - The ID of the triggered job run.

Raises:

  • InvalidCredentialsException - If account_id or job_id is missing.

get_run_status

def get_run_status(run_id: Union[int, str]) -> Dict[Any, Any]

[view_source]

Get the status of a dbt Cloud job run by run_id.

Uses https://cloud.getdbt.com/api/v2/accounts/{account_id}/runs/{id}/ to get job run information.

More info: https://docs.getdbt.com/dbt-cloud/api-v2#/operations/Retrieve%20Run.

Arguments:

  • run_id int | str - The ID of the job run.

Returns:

Dict[Any, Any]: The status information of the job run.

Raises:

  • InvalidCredentialsException - If account_id or run_id is missing.

This demo works on codespaces. Codespaces is a development environment available for free to anyone with a Github account. You'll be asked to fork the demo repository and from there the README guides you with further steps.
The demo uses the Continue VSCode extension.

Off to codespaces!

DHelp

Ask a question

Welcome to "Codex Central", your next-gen help center, driven by OpenAI's GPT-4 model. It's more than just a forum or a FAQ hub – it's a dynamic knowledge base where coders can find AI-assisted solutions to their pressing problems. With GPT-4's powerful comprehension and predictive abilities, Codex Central provides instantaneous issue resolution, insightful debugging, and personalized guidance. Get your code running smoothly with the unparalleled support at Codex Central - coding help reimagined with AI prowess.