SameerMesiah97 commented on code in PR #72036:
URL: https://github.com/apache/airflow/pull/72036#discussion_r3908136888


##########
airflow-core/newsfragments/72036.feature.rst:
##########
@@ -0,0 +1 @@
+Add an ``airflow teams inspect`` CLI command for displaying resources 
associated with a team, including DAG bundles, pools, connections, and 
variables.

Review Comment:
   Fixed.



##########
airflow-core/src/airflow/cli/commands/team_command.py:
##########
@@ -308,3 +308,51 @@ def team_verify(args, *, session=NEW_SESSION):
         raise SystemExit(1)
 
     print("Verification succeeded.")
+
+
+@cli_utils.action_cli
+@providers_configuration_loaded
+@provide_session
+def team_inspect(args, *, session=NEW_SESSION):
+    """Inspect resources belonging to a team."""
+    team_name = _extract_team_name(args)
+
+    team = session.scalar(select(Team).where(Team.name == team_name))
+    if team is None:
+        raise SystemExit(f"Team '{team_name}' does not exist")
+
+    bundle_names = session.scalars(
+        select(dag_bundle_team_association_table.c.dag_bundle_name)
+        .where(dag_bundle_team_association_table.c.team_name == team_name)
+        .order_by(dag_bundle_team_association_table.c.dag_bundle_name)
+    ).all()
+
+    pool_names = session.scalars(
+        select(Pool.pool).where(Pool.team_name == 
team_name).order_by(Pool.pool)
+    ).all()
+
+    connection_ids = session.scalars(
+        select(Connection.conn_id).where(Connection.team_name == 
team_name).order_by(Connection.conn_id)
+    ).all()
+
+    variable_keys = session.scalars(
+        select(Variable.key).where(Variable.team_name == 
team_name).order_by(Variable.key)
+    ).all()
+
+    print(f"Team: {team_name}")
+    print()
+
+    def print_section(title: str, values: list[str]) -> None:

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