prefect_dbt.cloud.clients
¶
Module containing clients for interacting with the dbt Cloud API
DbtCloudAdministrativeClient
¶
Client for interacting with the dbt cloud Administrative API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_key
|
str
|
API key to authenticate with the dbt Cloud administrative API. |
required |
account_id
|
int
|
ID of dbt Cloud account with which to interact. |
required |
domain
|
str
|
Domain at which the dbt Cloud API is hosted. |
'cloud.getdbt.com'
|
Source code in prefect_dbt/cloud/clients.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
|
call_endpoint
async
¶
Call an endpoint in the dbt Cloud API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
str
|
The partial path for the request (e.g. /projects/). Will be appended onto the base URL as determined by the client configuration. |
required |
http_method
|
str
|
HTTP method to call on the endpoint. |
required |
params
|
Optional[Dict[str, Any]]
|
Query parameters to include in the request. |
None
|
json
|
Optional[Dict[str, Any]]
|
JSON serializable body to send in the request. |
None
|
Returns:
Type | Description |
---|---|
Response
|
The response from the dbt Cloud administrative API. |
Source code in prefect_dbt/cloud/clients.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
|
get_job
async
¶
Return job details for a job on an account.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job_id
|
int
|
Numeric ID of the job. |
required |
order_by
|
Optional[str]
|
Field to order the result by. Use - to indicate reverse order. |
None
|
Returns:
Type | Description |
---|---|
Response
|
The response from the dbt Cloud administrative API. |
Source code in prefect_dbt/cloud/clients.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
|
get_run
async
¶
Sends a request to the get run endpoint to get details about a job run.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
run_id
|
int
|
The ID of the run to get details for. |
required |
include_related
|
Optional[List[Literal['trigger', 'job', 'debug_logs', 'run_steps']]]
|
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. |
None
|
Returns:
Type | Description |
---|---|
Response
|
The response from the dbt Cloud administrative API. |
Source code in prefect_dbt/cloud/clients.py
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
get_run_artifact
async
¶
Sends a request to the get run artifact endpoint to fetch an artifact generated for a completed run.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
run_id
|
int
|
The ID of the run to list run artifacts for. |
required |
path
|
str
|
The relative path to the run artifact (e.g. manifest.json, catalog.json, run_results.json) |
required |
step
|
Optional[int]
|
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. |
None
|
Returns:
Type | Description |
---|---|
Response
|
The response from the dbt Cloud administrative API. |
Source code in prefect_dbt/cloud/clients.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
|
list_run_artifacts
async
¶
Sends a request to the list run artifacts endpoint to fetch a list of paths of artifacts generated for a completed run.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
run_id
|
int
|
The ID of the run to list run artifacts for. |
required |
step
|
Optional[int]
|
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. |
None
|
Returns:
Type | Description |
---|---|
Response
|
The response from the dbt Cloud administrative API. |
Source code in prefect_dbt/cloud/clients.py
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
|
trigger_job_run
async
¶
Sends a request to the trigger job run endpoint to initiate a job run.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
job_id
|
int
|
The ID of the job to trigger. |
required |
options
|
Optional[TriggerJobRunOptions]
|
An optional TriggerJobRunOptions instance to specify overrides for the triggered job run. |
None
|
Returns:
Type | Description |
---|---|
Response
|
The response from the dbt Cloud administrative API. |
Source code in prefect_dbt/cloud/clients.py
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
|
DbtCloudMetadataClient
¶
Client for interacting with the dbt cloud Administrative API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
api_key
|
str
|
API key to authenticate with the dbt Cloud administrative API. |
required |
domain
|
str
|
Domain at which the dbt Cloud API is hosted. |
'metadata.cloud.getdbt.com'
|
Source code in prefect_dbt/cloud/clients.py
195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|
query
¶
Run a GraphQL query against the dbt Cloud metadata API.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query
|
str
|
The GraphQL query to run. |
required |
variables
|
Optional[Dict]
|
The values of any variables defined in the GraphQL query. |
None
|
operation_name
|
Optional[str]
|
The name of the operation to run if multiple operations are defined in the provided query. |
None
|
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
The result of the GraphQL query. |
Source code in prefect_dbt/cloud/clients.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 |
|