pierrejeambrun commented on code in PR #44139:
URL: https://github.com/apache/airflow/pull/44139#discussion_r1846630974


##########
airflow/api_fastapi/core_api/routes/public/assets.py:
##########
@@ -252,3 +252,47 @@ def get_dag_asset_queued_events(
         ],
         total_entries=total_entries,
     )
+
+
+@assets_router.get(
+    "/assets/queuedEvent/{uri:path}",

Review Comment:
   ```suggestion
       "/assets/queuedEvents/{uri:path}",
   ```



##########
airflow/api_fastapi/core_api/routes/public/assets.py:
##########
@@ -252,3 +252,47 @@ def get_dag_asset_queued_events(
         ],
         total_entries=total_entries,
     )
+
+
+@assets_router.get(
+    "/assets/queuedEvent/{uri:path}",
+    responses=create_openapi_http_exception_doc(
+        [
+            status.HTTP_404_NOT_FOUND,
+        ]
+    ),
+)
+def get_asset_queued_events(
+    uri: str,
+    session: Annotated[Session, Depends(get_session)],
+    before: OptionalDateTimeQuery = None,
+) -> QueuedEventCollectionResponse:
+    """Get queued asset events for an asset."""
+    where_clause = _generate_queued_event_where_clause(uri=uri, before=before)
+    query = (
+        select(AssetDagRunQueue, AssetModel.uri)
+        .join(AssetModel, AssetDagRunQueue.asset_id == AssetModel.id)
+        .where(*where_clause)
+    )
+
+    dag_asset_queued_events_select, total_entries = paginated_select(
+        query,
+        [],
+    )
+    adrqs = session.execute(dag_asset_queued_events_select).all()
+
+    if not adrqs:
+        raise HTTPException(status.HTTP_404_NOT_FOUND, f"Queue event with uri: 
`{uri}` was not found")
+
+    queued_events = [
+        QueuedEventResponse(created_at=adrq.created_at, 
dag_id=adrq.target_dag_id, uri=uri)
+        for adrq, uri in adrqs
+    ]
+
+    return QueuedEventCollectionResponse(
+        queued_events=[
+            QueuedEventResponse.model_validate(queued_event, 
from_attributes=True)
+            for queued_event in queued_events
+        ],
+        total_entries=total_entries,

Review Comment:
   ```suggestion
       queued_events = [
           QueuedEventResponse(created_at=adrq.created_at, 
dag_id=adrq.target_dag_id, uri=uri)
           for adrq, uri in adrqs
       ]
   
       return QueuedEventCollectionResponse(
           queued_events=queued_events,
           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]

Reply via email to