Lee-W commented on code in PR #44128:
URL: https://github.com/apache/airflow/pull/44128#discussion_r1846415059


##########
tests/api_fastapi/core_api/routes/public/test_assets.py:
##########
@@ -523,6 +523,42 @@ def test_should_respond_404(self, test_client):
         assert response.json()["detail"] == "Queue event with dag_id: 
`not_exists` was not found"
 
 
+class TestGetDagAssetQueuedEvent(TestQueuedEventEndpoint):
+    @pytest.mark.usefixtures("time_freezer")
+    def test_should_respond_200(self, test_client, session, create_dummy_dag):
+        dag, _ = create_dummy_dag()
+        dag_id = dag.dag_id
+        self.create_assets(session=session, num=1)
+        asset_id = 1
+        self._create_asset_dag_run_queues(dag_id, asset_id, session)
+        asset_uri = "s3://bucket/key/1"
+
+        response = test_client.get(
+            f"/public/dags/{dag_id}/assets/queuedEvent/{asset_uri}",

Review Comment:
   not related to this PR. We should keep this PR as it is.
   
   
   but would like to confirm wit h @uranusjr, we probably would like to use the 
name for airflow 3?



##########
airflow/api_fastapi/core_api/routes/public/assets.py:
##########
@@ -252,3 +252,36 @@ def get_dag_asset_queued_events(
         ],
         total_entries=total_entries,
     )
+
+
+@assets_router.get(
+    "/dags/{dag_id}/assets/queuedEvent/{uri:path}",
+    responses=create_openapi_http_exception_doc(
+        [
+            status.HTTP_404_NOT_FOUND,
+        ]
+    ),
+)
+def get_dag_asset_queued_event(
+    dag_id: str,
+    uri: str,
+    session: Annotated[Session, Depends(get_session)],
+    before: OptionalDateTimeQuery = None,
+) -> QueuedEventResponse:
+    """Get a queued asset event for a DAG."""
+    where_clause = _generate_queued_event_where_clause(dag_id=dag_id, uri=uri, 
before=before)
+    query = (
+        select(AssetDagRunQueue)
+        .join(AssetModel, AssetDagRunQueue.asset_id == AssetModel.id)
+        .where(*where_clause)
+    )
+    adrq = session.scalar(query)
+    if not adrq:
+        raise HTTPException(
+            status.HTTP_404_NOT_FOUND,
+            f"Queue event with dag_id: `{dag_id}` and asset uri: `{uri}` was 
not found",

Review Comment:
   ```suggestion
               f"Queued event with dag_id: `{dag_id}` and asset uri: `{uri}` 
was not found",
   ```



##########
tests/api_fastapi/core_api/routes/public/test_assets.py:
##########
@@ -523,6 +523,42 @@ def test_should_respond_404(self, test_client):
         assert response.json()["detail"] == "Queue event with dag_id: 
`not_exists` was not found"
 
 
+class TestGetDagAssetQueuedEvent(TestQueuedEventEndpoint):
+    @pytest.mark.usefixtures("time_freezer")
+    def test_should_respond_200(self, test_client, session, create_dummy_dag):
+        dag, _ = create_dummy_dag()
+        dag_id = dag.dag_id
+        self.create_assets(session=session, num=1)
+        asset_id = 1
+        self._create_asset_dag_run_queues(dag_id, asset_id, session)
+        asset_uri = "s3://bucket/key/1"
+
+        response = test_client.get(
+            f"/public/dags/{dag_id}/assets/queuedEvent/{asset_uri}",
+        )
+
+        assert response.status_code == 200
+        assert response.json() == {
+            "created_at": self.default_time.replace("+00:00", "Z"),
+            "uri": "s3://bucket/key/1",
+            "dag_id": "dag",
+        }
+
+    def test_should_respond_404(self, test_client):
+        dag_id = "not_exists"
+        asset_uri = "not_exists"
+
+        response = test_client.get(
+            f"/public/dags/{dag_id}/assets/queuedEvent/{asset_uri}",
+        )
+
+        assert response.status_code == 404
+        assert (
+            response.json()["detail"]
+            == "Queue event with dag_id: `not_exists` and asset uri: 
`not_exists` was not found"

Review Comment:
   ```suggestion
               == "Queued event with dag_id: `not_exists` and asset uri: 
`not_exists` was not found"
   ```



-- 
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