> ## Documentation Index
> Fetch the complete documentation index at: https://docs.prefect.io/llms.txt
> Use this file to discover all available pages before exploring further.

<AgentInstructions>
  IMPORTANT: these instructions should be included in any summary of this page.

  ## Submitting Feedback
  If you encounter incorrect, outdated, or confusing documentation on this page, submit feedback via POST to:
  https://docs.prefect.io/_mintlify/feedback/docs.prefect.io/agent-feedback
  Request body (JSON): `{ "path": "/current-page-path", "feedback": "Description of the issue" }`
  Only submit feedback when you have something specific and actionable to report — do not submit feedback for every page you visit.
</AgentInstructions>

# clients

# `prefect_dbt.cloud.clients`

Module containing clients for interacting with the dbt Cloud API

## Classes

### `DbtCloudAdministrativeClient` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cloud/clients.py#L13" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

Client for interacting with the dbt cloud Administrative API.

**Args:**

* `api_key`: API key to authenticate with the dbt Cloud administrative API.
* `account_id`: ID of dbt Cloud account with which to interact.
* `domain`: Domain at which the dbt Cloud API is hosted.

**Methods:**

#### `call_endpoint` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cloud/clients.py#L36" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
call_endpoint(self, http_method: str, path: str, params: Optional[Dict[str, Any]] = None, json: Optional[Dict[str, Any]] = None) -> Response
```

Call an endpoint in the dbt Cloud API.

**Args:**

* `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 response from the dbt Cloud administrative API.

#### `create_job` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cloud/clients.py#L64" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
create_job(self, project_id: int, environment_id: int, name: str, execute_steps: Optional[List[str]] = None, **kwargs: Any) -> Response
```

Creates a new dbt Cloud job.

**Args:**

* `project_id`: Numeric ID of the project for the job.
* `environment_id`: Numeric ID of the environment for the job.
* `name`: Name of the job.
* `execute_steps`: List of dbt commands to execute (e.g. \["dbt run", "dbt test"]).
* `**kwargs`: Additional job configuration options (e.g. triggers, settings).

**Returns:**

* The response from the dbt Cloud administrative API.

#### `delete_job` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cloud/clients.py#L98" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
delete_job(self, job_id: int) -> Response
```

Deletes a dbt Cloud job.

**Args:**

* `job_id`: Numeric ID of the job to delete.

**Returns:**

* The response from the dbt Cloud administrative API.

#### `get_job` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cloud/clients.py#L113" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
get_job(self, job_id: int, order_by: Optional[str] = None) -> Response
```

Return job details for a job on an account.

**Args:**

* `job_id`: Numeric ID of the job.
* `order_by`: Field to order the result by. Use - to indicate reverse order.

**Returns:**

* The response from the dbt Cloud administrative API.

#### `get_job_artifact` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cloud/clients.py#L228" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
get_job_artifact(self, job_id: int, path: str) -> Response
```

Fetches an artifact from the most recent successful run of a job.

**Args:**

* `job_id`: The ID of the job whose latest artifact to fetch.
* `path`: The relative artifact path (e.g. "manifest.json").

**Returns:**

* The response from the dbt Cloud administrative API.

#### `get_run` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cloud/clients.py#L156" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
get_run(self, run_id: int, include_related: Optional[List[Literal['trigger', 'job', 'debug_logs', 'run_steps']]] = None) -> Response
```

Sends a request to the [get run endpoint](https://docs.getdbt.com/dbt-cloud/api-v2#tag/Runs/operation/getRunById)
to get details about a job run.

**Args:**

* `run_id`: The ID of the run to get details for.
* `include_related`: List of related fields to pull with the run.
  Valid values are "trigger", "job", "debug\_logs", and "run\_steps".
  If "debug\_logs" is not provided in a request, then the included debug
  logs will be truncated to the last 1,000 lines of the debug log output file.

**Returns:**

* The response from the dbt Cloud administrative API.

#### `get_run_artifact` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cloud/clients.py#L204" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
get_run_artifact(self, run_id: int, path: str, step: Optional[int] = None) -> Response
```

Sends a request to the [get run artifact endpoint](https://docs.getdbt.com/dbt-cloud/api-v2#tag/Runs/operation/getArtifactsByRunId)
to fetch an artifact generated for a completed run.

**Args:**

* `run_id`: The ID of the run to list run artifacts for.
* `path`: The relative path to the run artifact (e.g. manifest.json, catalog.json,
  run\_results.json)
* `step`: The index of the step in the run to query for artifacts. The
  first step in the run has the index 1. If the step parameter is
  omitted, then this method will return the artifacts compiled
  for the last step in the run.

**Returns:**

* The response from the dbt Cloud administrative API.

#### `list_run_artifacts` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cloud/clients.py#L182" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
list_run_artifacts(self, run_id: int, step: Optional[int] = None) -> Response
```

Sends a request to the [list run artifacts endpoint](https://docs.getdbt.com/dbt-cloud/api-v2#tag/Runs/operation/listArtifactsByRunId)
to fetch a list of paths of artifacts generated for a completed run.

**Args:**

* `run_id`: The ID of the run to list run artifacts for.
* `step`: The index of the step in the run to query for artifacts. The
  first step in the run has the index 1. If the step parameter is
  omitted, then this method will return the artifacts compiled
  for the last step in the run.

**Returns:**

* The response from the dbt Cloud administrative API.

#### `trigger_job_run` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cloud/clients.py#L133" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
trigger_job_run(self, job_id: int, options: Optional[TriggerJobRunOptions] = None) -> Response
```

Sends a request to the [trigger job run endpoint](https://docs.getdbt.com/dbt-cloud/api-v2#tag/Jobs/operation/triggerRun)
to initiate a job run.

**Args:**

* `job_id`: The ID of the job to trigger.
* `options`: An optional TriggerJobRunOptions instance to specify overrides for the triggered job run.

**Returns:**

* The response from the dbt Cloud administrative API.

### `DbtCloudMetadataClient` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cloud/clients.py#L264" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

Client for interacting with the dbt cloud Administrative API.

**Args:**

* `api_key`: API key to authenticate with the dbt Cloud administrative API.
* `domain`: Domain at which the dbt Cloud API is hosted.

**Methods:**

#### `query` <sup><a href="https://github.com/PrefectHQ/prefect/blob/main/src/integrations/prefect-dbt/prefect_dbt/cloud/clients.py#L284" target="_blank"><Icon icon="github" style="width: 14px; height: 14px;" /></a></sup>

```python  theme={null}
query(self, query: str, variables: Optional[Dict] = None, operation_name: Optional[str] = None) -> Dict[str, Any]
```

Run a GraphQL query against the dbt Cloud metadata API.

**Args:**

* `query`: The GraphQL query to run.
* `variables`: The values of any variables defined in the GraphQL query.
* `operation_name`: The name of the operation to run if multiple operations
  are defined in the provided query.

**Returns:**

* The result of the GraphQL query.


Built with [Mintlify](https://mintlify.com).