You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/06/14 21:32:26 UTC

[GitHub] [airflow] mik-laj commented on a change in pull request #9266: add crud endpoint for connections

mik-laj commented on a change in pull request #9266:
URL: https://github.com/apache/airflow/pull/9266#discussion_r439869565



##########
File path: airflow/api_connexion/endpoints/connection_endpoint.py
##########
@@ -47,31 +55,53 @@ def get_connection(connection_id, session):
 
 
 @provide_session
-def get_connections(session):
+def get_connections(session, limit, offset=0):
     """
     Get all connection entries
     """
-    offset = request.args.get(parameters.page_offset, 0)
-    limit = min(int(request.args.get(parameters.page_limit, 100)), 100)
-
+    total_entries = session.query(func.count(Connection.id)).scalar()
     query = session.query(Connection)
-    total_entries = query.count()
-    query = query.offset(offset).limit(limit)
-
-    connections = query.all()
+    connections = query.offset(offset).limit(limit).all()
     return connection_collection_schema.dump(ConnectionCollection(connections=connections,
                                                                   total_entries=total_entries))
 
 
-def patch_connection():
+@provide_session
+def patch_connection(connection_id, session, update_mask=None):
     """
     Update a connection entry
     """
-    raise NotImplementedError("Not implemented yet.")
+    body = request.json
+    connection = session.query(Connection).filter_by(conn_id=connection_id).first()
+    if connection is None:
+        raise NotFound("Connection not found")
+    if update_mask:

Review comment:
       Can you also add validation for the mask? The mask should not contain fields that are on the allowed list. In particular, you should not be able to save any data to the _password field. This is a very common mistake, which leads to CATastrophe.




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

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