PNL0 commented on code in PR #51264:
URL: https://github.com/apache/airflow/pull/51264#discussion_r2155455005


##########
airflow-core/src/airflow/api_fastapi/core_api/routes/public/dags.py:
##########
@@ -346,6 +358,55 @@ def patch_dags(
     )
 
 
+@dags_router.post(
+    "/{dag_id}/favorite",
+    responses=create_openapi_http_exception_doc([status.HTTP_404_NOT_FOUND]),
+    dependencies=[Depends(requires_access_dag(method="POST")), 
Depends(action_logging())],
+)
+def favorite_dag(
+    dag_id: str,
+    session: SessionDep,
+    user: GetUserDep,
+) -> DAGResponse:
+    """Mark the DAG as favorite."""
+    dag = session.get(DagModel, dag_id)
+    if not dag:
+        raise HTTPException(status.HTTP_404_NOT_FOUND, detail=f"DAG with id 
'{dag_id}' not found")
+
+    user_id = user.get_id()
+    session.execute(insert(DagFavorite).values(dag_id=dag_id, user_id=user_id))
+    session.commit()

Review Comment:
   Done.



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