jason810496 commented on code in PR #42959:
URL: https://github.com/apache/airflow/pull/42959#discussion_r1799751670


##########
airflow/api_fastapi/views/public/dags.py:
##########
@@ -92,6 +93,28 @@ async def get_dags(
     )
 
 
+@dags_router.get(
+    "/tags",
+    response_model=list[DAGTagResponse],
+    responses=create_openapi_http_exception_doc([400, 401, 403]),
+)
+async def get_dag_tags(
+    tags: QueryTagsFilter,
+    session: Annotated[Session, Depends(get_session)],
+) -> list[DAGTagResponse]:
+    """Get all DAG tags."""
+    dag_tag_names = 
session.query(distinct(DagTag.name)).order_by(DagTag.name).all()
+    if not dag_tag_names:
+        return []
+    selected_dag_tags = {}
+    if tags.value:
+        selected_dag_tags = {tag: True for tag in tags.value}
+    return [
+        DAGTagResponse(name=tag_name_row[0], 
selected=selected_dag_tags.get(tag_name_row[0], False))
+        for tag_name_row in dag_tag_names

Review Comment:
   According to the issue https://github.com/apache/airflow/issues/42713, the 
response schema should match the format defined here: 
https://github.com/apache/airflow/blob/main/airflow/www/views.py#L1035. The 
`selected` field indicates whether the tag is selected based on the query 
parameters in all `dag_tags`.
   



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