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


##########
airflow/api_fastapi/core_api/routes/public/variables.py:
##########
@@ -58,6 +63,42 @@ async def get_variable(
     return VariableResponse.model_validate(variable, from_attributes=True)
 
 
+@variables_router.get(
+    "/",
+    responses=create_openapi_http_exception_doc([401, 403]),
+)
+async def get_variables(
+    limit: QueryLimit,
+    offset: QueryOffset,
+    order_by: Annotated[
+        SortParam,
+        Depends(
+            SortParam(
+                ["key", "id"],
+                Variable,
+            ).dynamic_depends()
+        ),
+    ],
+    session: Annotated[Session, Depends(get_session)],
+) -> VariableCollectionResponse:
+    """Get all Variables entries."""
+    variable_select, total_entries = paginated_select(
+        select(Variable),
+        [],
+        order_by=order_by,
+        offset=offset,
+        limit=limit,
+        session=session,
+    )
+
+    variables = session.scalars(variable_select).all()
+
+    return VariableCollectionResponse(
+        variables=[VariableResponse.model_validate(variable, 
from_attributes=True) for variable in variables],

Review Comment:
   Test would be really verbose if asserting the entire payload. But all of 
this (get_variable, get_variables, etc...) is using the same model which holds 
that logic and implements it through descriptor. (each get/set to val attribute 
does it's magic)



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