Skip to content

Commit 9e5f7da

Browse files
jorwoodsclaude
andcommitted
docs: add Flow Runs section to api-ref.md
Documents the complete flow_runs endpoint, which was entirely absent from the docs, including FlowRunItem class attributes and all methods: get, get_by_id, cancel, wait_for_job (all API 3.10). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9162447 commit 9e5f7da

File tree

1 file changed

+202
-0
lines changed

1 file changed

+202
-0
lines changed

docs/api-ref.md

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1210,6 +1210,208 @@ Name | Description
12101210

12111211

12121212

1213+
<br>
1214+
<br>
1215+
1216+
---
1217+
1218+
## Flow Runs
1219+
1220+
Using the TSC library, you can query flow runs on a site, get details about a specific flow run, cancel a running flow, or wait for a flow run to complete. Flow runs are created when a flow is triggered to run, either manually or on a schedule.
1221+
1222+
The flow run resources for Tableau Server are defined in the `FlowRunItem` class. The class corresponds to the flow run resources you can access using the Tableau Server REST API.
1223+
1224+
<br>
1225+
1226+
### FlowRunItem class
1227+
1228+
The `FlowRunItem` represents the result of a flow run on Tableau Server. Instances of this class are returned by the flow run methods; you do not create them directly.
1229+
1230+
**Attributes**
1231+
1232+
Name | Description
1233+
:--- | :---
1234+
`id` | The identifier for the flow run.
1235+
`flow_id` | The identifier of the flow that was run.
1236+
`status` | The current status of the flow run. Possible values include `Success`, `Failed`, and `Cancelled`.
1237+
`started_at` | The date and time when the flow run started.
1238+
`completed_at` | The date and time when the flow run completed. Is `None` if the run is still in progress.
1239+
`progress` | The progress percentage of the flow run.
1240+
`background_job_id` | The identifier of the background job associated with the flow run.
1241+
1242+
Source file: models/flow_run_item.py
1243+
1244+
<br>
1245+
<br>
1246+
1247+
### Flow Runs methods
1248+
1249+
The Tableau Server Client provides several methods for interacting with flow run resources. These methods correspond to endpoints in the Tableau Server REST API.
1250+
1251+
Source file: server/endpoint/flow_runs_endpoint.py
1252+
1253+
<br>
1254+
<br>
1255+
1256+
#### flow_runs.get
1257+
1258+
```py
1259+
flow_runs.get(req_options=None)
1260+
```
1261+
1262+
Returns all flow runs on the site.
1263+
1264+
REST API: [Get Flow Runs](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_flow.htm#get_flow_runs){:target="_blank"}
1265+
1266+
**Parameters**
1267+
1268+
Name | Description
1269+
:--- | :---
1270+
`req_options` | (Optional) You can pass the method a request object that contains additional parameters to filter the request.
1271+
1272+
**Returns**
1273+
1274+
Returns a list of `FlowRunItem` objects and a `PaginationItem` object. Use these values to iterate through the results.
1275+
1276+
**Version**
1277+
1278+
Version 3.10 and later. See [REST API versions](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_versions.htm).
1279+
1280+
**Example**
1281+
1282+
```py
1283+
import tableauserverclient as TSC
1284+
tableau_auth = TSC.TableauAuth('USERNAME', 'PASSWORD')
1285+
server = TSC.Server('https://SERVERURL')
1286+
1287+
with server.auth.sign_in(tableau_auth):
1288+
all_runs, pagination_item = server.flow_runs.get()
1289+
print("\nThere are {} flow runs on site.".format(pagination_item.total_available))
1290+
for run in all_runs:
1291+
print(run.id, run.status)
1292+
```
1293+
1294+
<br>
1295+
<br>
1296+
1297+
#### flow_runs.get_by_id
1298+
1299+
```py
1300+
flow_runs.get_by_id(flow_run_id)
1301+
```
1302+
1303+
Returns the specified flow run item.
1304+
1305+
REST API: [Get Flow Run](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_flow.htm#get_flow_run){:target="_blank"}
1306+
1307+
**Parameters**
1308+
1309+
Name | Description
1310+
:--- | :---
1311+
`flow_run_id` | The identifier (`id`) for the `FlowRunItem` to query.
1312+
1313+
**Exceptions**
1314+
1315+
Error | Description
1316+
:--- | :---
1317+
`Flow ID undefined` | Raises an exception if a valid `flow_run_id` is not provided.
1318+
1319+
**Returns**
1320+
1321+
Returns a `FlowRunItem`.
1322+
1323+
**Version**
1324+
1325+
Version 3.10 and later. See [REST API versions](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_versions.htm).
1326+
1327+
**Example**
1328+
1329+
```py
1330+
flow_run = server.flow_runs.get_by_id('1a2a3b4b-5c6c-7d8d-9e0e-1f2f3a4a5b6b')
1331+
print(flow_run.status, flow_run.progress)
1332+
```
1333+
1334+
<br>
1335+
<br>
1336+
1337+
#### flow_runs.cancel
1338+
1339+
```py
1340+
flow_runs.cancel(flow_run_id)
1341+
```
1342+
1343+
Cancels the specified flow run.
1344+
1345+
REST API: [Cancel Flow Run](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_flow.htm#cancel_flow_run){:target="_blank"}
1346+
1347+
**Parameters**
1348+
1349+
Name | Description
1350+
:--- | :---
1351+
`flow_run_id` | The identifier (`id`) for the `FlowRunItem` to cancel. Can be the id string or a `FlowRunItem` object.
1352+
1353+
**Exceptions**
1354+
1355+
Error | Description
1356+
:--- | :---
1357+
`Flow ID undefined` | Raises an exception if a valid `flow_run_id` is not provided.
1358+
1359+
**Version**
1360+
1361+
Version 3.10 and later. See [REST API versions](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_versions.htm).
1362+
1363+
**Example**
1364+
1365+
```py
1366+
flow_run = server.flow_runs.get_by_id('1a2a3b4b-5c6c-7d8d-9e0e-1f2f3a4a5b6b')
1367+
server.flow_runs.cancel(flow_run.id)
1368+
```
1369+
1370+
<br>
1371+
<br>
1372+
1373+
#### flow_runs.wait_for_job
1374+
1375+
```py
1376+
flow_runs.wait_for_job(flow_run_id, *, timeout=None)
1377+
```
1378+
1379+
Waits for the specified flow run to complete and returns the finished `FlowRunItem`. This method polls the server repeatedly using exponential backoff until the run completes, then raises an exception if it failed or was cancelled.
1380+
1381+
**Parameters**
1382+
1383+
Name | Description
1384+
:--- | :---
1385+
`flow_run_id` | The identifier (`id`) for the flow run to wait for. Can be the id string or a `FlowRunItem` object.
1386+
`timeout` | (Optional) The maximum number of seconds to wait before raising a timeout error. If not specified, waits indefinitely.
1387+
1388+
**Exceptions**
1389+
1390+
Error | Description
1391+
:--- | :---
1392+
`FlowRunFailedException` | Raised if the flow run completes with a `Failed` status.
1393+
`FlowRunCancelledException` | Raised if the flow run completes with a `Cancelled` status.
1394+
1395+
**Returns**
1396+
1397+
Returns the completed `FlowRunItem` if the run succeeded.
1398+
1399+
**Version**
1400+
1401+
Version 3.10 and later. See [REST API versions](https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_versions.htm).
1402+
1403+
**Example**
1404+
1405+
```py
1406+
# Trigger a flow run and wait for it to finish
1407+
flow = server.flows.get_by_id('1a2a3b4b-5c6c-7d8d-9e0e-1f2f3a4a5b6b')
1408+
job = server.flows.refresh(flow)
1409+
1410+
# Wait for the resulting flow run to complete
1411+
flow_run = server.flow_runs.wait_for_job(job.id, timeout=300)
1412+
print("Flow run completed with status: {}".format(flow_run.status))
1413+
```
1414+
12131415
<br>
12141416
<br>
12151417

0 commit comments

Comments
 (0)