junyeong0619 commented on code in PR #66022:
URL: https://github.com/apache/airflow/pull/66022#discussion_r3215497296
##########
airflow-core/src/airflow/api_fastapi/execution_api/routes/variables.py:
##########
@@ -120,3 +125,25 @@ def delete_variable(
):
"""Delete an Airflow Variable."""
Variable.delete(key=variable_key, team_name=team_name)
+
+
+@keys_router.get(
+ "/keys",
+ responses={
+ status.HTTP_401_UNAUTHORIZED: {"description": "Unauthorized"},
+ },
+)
+def get_variable_keys(
+ session: SessionDep,
+ team_name: Annotated[str | None, Depends(get_team_name_dep)] = None,
+ prefix: Annotated[str | None, Query()] = None,
+) -> VariableKeysResponse:
+ """Get Airflow Variable keys, optionally filtered by prefix."""
+ stmt = select(Variable.key)
+ if prefix is not None:
+ stmt = stmt.where(Variable.key.startswith(prefix))
+ if team_name is not None:
+ stmt = stmt.where(Variable.team_name == team_name)
+
+ keys = session.scalars(stmt).all()
Review Comment:
Implemented pagination with `limit` (default=1000, max=10000) and `offset`
query params, plus `total_entries` in the response for public-API consistency.
The Task SDK's `_get_variable_keys`
paginates internally with page size 1000, transparent to user code. Added
`ORDER BY key ASC` for stable pagination ordering.
--
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]