Skip to main content

prefect_dbt.cloud.utils

Utilities for common interactions with the dbt Cloud API

Functions

extract_user_message

Extracts user message from a error response from the dbt Cloud administrative API. Args:
  • ex: An HTTPStatusError raised by httpx
Returns:
  • user_message from dbt Cloud administrative API response or None if a
  • user_message cannot be extracted

extract_developer_message

Extracts developer message from a error response from the dbt Cloud administrative API. Args:
  • ex: An HTTPStatusError raised by httpx
Returns:
  • developer_message from dbt Cloud administrative API response or None if a
  • developer_message cannot be extracted

call_dbt_cloud_administrative_api_endpoint

Task that calls a specified endpoint in the dbt Cloud administrative API. Use this task if a prebuilt one is not yet available. Args:
  • dbt_cloud_credentials: Credentials for authenticating with dbt Cloud.
  • path: The partial path for the request (e.g. /projects/). Will be appended onto the base URL as determined by the client configuration.
  • http_method: HTTP method to call on the endpoint.
  • params: Query parameters to include in the request.
  • json: JSON serializable body to send in the request.
Returns:
  • The body of the response. If the body is JSON serializable, then the result of json.loads with the body as the input will be returned. Otherwise, the body will be returned directly.
Examples: List projects for an account:
Create a new job:

Classes

DbtCloudAdministrativeApiCallFailed

Raised when a call to dbt Cloud administrative API fails.