henry3260 commented on code in PR #66188:
URL: https://github.com/apache/airflow/pull/66188#discussion_r3176250005


##########
airflow-ctl/src/airflowctl/ctl/commands/dag_command.py:
##########
@@ -72,3 +72,34 @@ def unpause(args, api_client=NEW_API_CLIENT) -> None:
         api_client=api_client,
         output=args.output,
     )
+
+
+_NEXT_EXECUTION_FIELDS = (
+    "next_dagrun_logical_date",
+    "next_dagrun_data_interval_start",
+    "next_dagrun_data_interval_end",
+    "next_dagrun_run_after",
+)
+
+
+@provide_api_client(kind=ClientKind.CLI)
+def next_execution(args, api_client=NEW_API_CLIENT) -> dict | None:
+    """Show next scheduled execution time for a DAG."""
+    try:
+        response = api_client.dags.get(dag_id=args.dag_id)
+    except ServerResponseError as e:
+        rich.print(f"[red]Error retrieving DAG {args.dag_id}: {e}[/red]")
+        sys.exit(1)
+
+    next_exec_data = {field: getattr(response, field) for field in 
_NEXT_EXECUTION_FIELDS}
+
+    if all(value is None for value in next_exec_data.values()):
+        rich.print(f"[yellow]No upcoming run scheduled for DAG 
{args.dag_id}.[/yellow]")
+        return None
+
+    result = {"dag_id": response.dag_id, **next_exec_data}

Review Comment:
   Should we include `dag_id `in result because as issue description mentioned 
we only need `_NEXT_EXECUTION_FIELDS `?



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