PNL0 commented on code in PR #51264: URL: https://github.com/apache/airflow/pull/51264#discussion_r2167379214
########## airflow-core/src/airflow/api_fastapi/core_api/routes/public/dags.py: ########## @@ -317,6 +322,64 @@ 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="GET")), Depends(action_logging())], +) +def favorite_dag( + dag_id: str, + session: SessionDep, + user: GetUserDep, +) -> Response: + """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)) + + return Response(status_code=status.HTTP_204_NO_CONTENT) + Review Comment: Done. ########## airflow-core/src/airflow/api_fastapi/core_api/openapi/v2-rest-api-generated.yaml: ########## @@ -3140,6 +3148,104 @@ paths: application/json: schema: $ref: '#/components/schemas/HTTPValidationError' + /api/v2/dags/{dag_id}/favorite: + post: + tags: + - DAG + summary: Favorite Dag + description: Mark the DAG as favorite. + operationId: favorite_dag + security: + - OAuth2PasswordBearer: [] + parameters: + - name: dag_id + in: path + required: true + schema: + type: string + title: Dag Id + responses: + '200': + description: Successful Response + content: + application/json: + schema: {} 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: commits-unsubscr...@airflow.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org