rawwar commented on code in PR #44366:
URL: https://github.com/apache/airflow/pull/44366#discussion_r1857341067
##########
airflow/api_fastapi/core_api/routes/public/xcom.py:
##########
@@ -90,5 +93,56 @@ def get_xcom_entry(
if stringify:
return XComResponseString.model_validate(item)
-
return XComResponseNative.model_validate(item)
+
+
+@xcom_router.get(
+ "",
+ responses=create_openapi_http_exception_doc(
+ [
+ status.HTTP_400_BAD_REQUEST,
+ status.HTTP_404_NOT_FOUND,
+ ]
+ ),
+)
+def get_xcom_entries(
+ dag_id: str,
+ dag_run_id: str,
+ task_id: str,
+ limit: QueryLimit,
+ offset: QueryOffset,
+ session: Annotated[Session, Depends(get_session)],
+ xcom_key: Annotated[str | None, Query()] = None,
+ map_index: Annotated[int | None, Query(ge=-1)] = None,
+) -> XComCollection:
+ """
+ Get all XCom entries.
+
+ This endpoint allows specifying `~` as the dag_id, dag_run_id, task_id to
retrieve XCom entries for all DAGs.
+ """
+ query = select(XCom)
+ if dag_id != "~":
+ query = query.where(XCom.dag_id == dag_id)
+ query = query.join(DR, and_(XCom.dag_id == DR.dag_id, XCom.run_id ==
DR.run_id))
+
+ if task_id != "~":
+ query = query.where(XCom.task_id == task_id)
+ if dag_run_id != "~":
+ query = query.where(DR.run_id == dag_run_id)
+ if map_index is not None:
+ query = query.where(XCom.map_index == map_index)
+ if xcom_key is not None:
+ query = query.where(XCom.key == xcom_key)
+
+ query, total_entries = paginated_select(
+ select=query,
+ filters=[],
+ order_by=SortParam(["dag_id", "task_id", "run_id", "map_index",
"key"], XCom),
+ offset=offset,
+ limit=limit,
+ session=session,
+ )
+ xcoms = session.scalars(query)
+ return XComCollection(
+ xcom_entries=[XComResponse.model_validate(xcom) for xcom in xcoms],
total_entries=total_entries
+ )
Review Comment:
```suggestion
return XComCollection(
xcom_entries=xcoms, total_entries=total_entries
)
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]