jason810496 commented on code in PR #55278:
URL: https://github.com/apache/airflow/pull/55278#discussion_r2324043882


##########
airflow-core/src/airflow/api_fastapi/core_api/security.py:
##########
@@ -289,6 +378,43 @@ def inner(
     return inner
 
 
+def requires_access_variable_bulk() -> Callable[[BulkBody[VariableBody], 
BaseUser], None]:
+    def inner(
+        request: BulkBody[VariableBody],
+        user: GetUserDep,
+    ) -> None:
+        requests: list[IsAuthorizedVariableRequest] = []
+        for action in request.actions:
+            if action.action == BulkAction.DELETE:
+                requests.extend(
+                    [
+                        {
+                            "method": 
MAP_BULK_ACTION_TO_AUTH_METHOD[action.action],
+                            "details": VariableDetails(key=cast("str", 
variable_key)),
+                        }
+                        for variable_key in action.entities
+                    ]
+                )
+            else:
+                requests.extend(
+                    [
+                        {
+                            "method": 
MAP_BULK_ACTION_TO_AUTH_METHOD[action.action],
+                            "details": VariableDetails(key=variable.key),
+                        }
+                        for variable in action.entities
+                    ]
+                )

Review Comment:
   Would it be better to simplify as the following? 
   
   ```suggestion
           requests: list[IsAuthorizedVariableRequest] = [
               {
                   "method": MAP_BULK_ACTION_TO_AUTH_METHOD[action.action],
                   "details": VariableDetails(
                       key=cast(
                           "str",
                           entity if action.action == BulkAction.DELETE else 
entity.key
                       )
                   ),
               }
               for entity in action.entities
           ]
       )
   ```



##########
airflow-core/src/airflow/api_fastapi/core_api/security.py:
##########
@@ -254,6 +306,43 @@ def inner(
     return inner
 
 
+def requires_access_connection_bulk() -> Callable[[BulkBody[ConnectionBody], 
BaseUser], None]:
+    def inner(
+        request: BulkBody[ConnectionBody],
+        user: GetUserDep,
+    ) -> None:
+        requests: list[IsAuthorizedConnectionRequest] = []
+        for action in request.actions:
+            if action.action == BulkAction.DELETE:

Review Comment:
   If yes, then we can remove the `BulkAction.DELETE` special case with inline 
distinguish.



-- 
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: commits-unsubscr...@airflow.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to