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


##########
airflow/api_fastapi/core_api/routes/public/dags.py:
##########
@@ -199,6 +202,49 @@ def get_dag_details(dag_id: str, session: SessionDep, 
request: Request) -> DAGDe
     return dag_model
 
 
+@dags_router.get(
+    "/{dag_id}/versions",
+    responses=create_openapi_http_exception_doc(
+        [
+            status.HTTP_400_BAD_REQUEST,

Review Comment:
   400 can't be returned.



##########
airflow/api_fastapi/core_api/routes/public/dags.py:
##########
@@ -199,6 +202,49 @@ def get_dag_details(dag_id: str, session: SessionDep, 
request: Request) -> DAGDe
     return dag_model
 
 
+@dags_router.get(
+    "/{dag_id}/versions",
+    responses=create_openapi_http_exception_doc(
+        [
+            status.HTTP_400_BAD_REQUEST,
+            status.HTTP_404_NOT_FOUND,
+        ]
+    ),
+)
+def get_dag_versions(dag_id: str, session: SessionDep, request: Request) -> 
DagVersionResponse:

Review Comment:
   We are missing filters, search and sort parameters.



##########
airflow/api_fastapi/core_api/routes/public/dags.py:
##########
@@ -199,6 +202,49 @@ def get_dag_details(dag_id: str, session: SessionDep, 
request: Request) -> DAGDe
     return dag_model
 
 
+@dags_router.get(
+    "/{dag_id}/versions",
+    responses=create_openapi_http_exception_doc(
+        [
+            status.HTTP_400_BAD_REQUEST,
+            status.HTTP_404_NOT_FOUND,
+        ]
+    ),
+)
+def get_dag_versions(dag_id: str, session: SessionDep, request: Request) -> 
DagVersionResponse:
+    dag_version = request.app.state.DagVersion()
+    if dag_version is None:
+        raise HTTPException(
+            status.HTTP_404_NOT_FOUND, detail=f"DagVersion with dag_id 
{dag_id} was not found"
+        )
+    version_name = dag_version.version

Review Comment:
   We are not handling the `~` wildcard dag_id parameters to retrieve for 'all' 
dags.



##########
airflow/api_fastapi/core_api/routes/public/dags.py:
##########
@@ -199,6 +202,49 @@ def get_dag_details(dag_id: str, session: SessionDep, 
request: Request) -> DAGDe
     return dag_model
 
 
+@dags_router.get(
+    "/{dag_id}/versions",
+    responses=create_openapi_http_exception_doc(
+        [
+            status.HTTP_400_BAD_REQUEST,
+            status.HTTP_404_NOT_FOUND,
+        ]
+    ),
+)
+def get_dag_versions(dag_id: str, session: SessionDep, request: Request) -> 
DagVersionResponse:
+    dag_version = request.app.state.DagVersion()
+    if dag_version is None:
+        raise HTTPException(
+            status.HTTP_404_NOT_FOUND, detail=f"DagVersion with dag_id 
{dag_id} was not found"
+        )
+    version_name = dag_version.version
+
+    dag_run = session.scalar(
+        select(DagRun).where(DagRun.dag_id == 
dag_id).order_by(DagRun.created_at.desc()).limit(1)
+    )
+    if dag_run is None:
+        raise HTTPException(status.HTTP_404_NOT_FOUND, detail=f"DagRun with 
id: {dag_id} was not found")
+    bundle_version = dag_run.bundle_version
+
+    dag_version = session.scalar(
+        select(DagVersion).where(DagVersion.dag_id == 
dag_id).order_by(DagVersion.created_at.desc()).limit(1)
+    )
+    if dag_version is None:
+        raise HTTPException(status.HTTP_404_NOT_FOUND, detail=f"DagVesrion 
with id: {dag_id} was not found")
+    created_at = dag_version.created_at
+
+    bundle_name = dag_version.bundle_name
+    bundle_version = dag_version.bundle_version
+    bundle_link = DagBundlesManager.view_url(bundle_name, bundle_version)

Review Comment:
   We have function helper to not do that by hand.



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