OmairK commented on a change in pull request #9329:
URL: https://github.com/apache/airflow/pull/9329#discussion_r443254354
##########
File path: airflow/api_connexion/endpoints/pool_endpoint.py
##########
@@ -53,18 +55,52 @@ def get_pools(session):
total_entries = session.query(func.count(Pool.id)).scalar()
pools =
session.query(Pool).order_by(Pool.id).offset(offset).limit(limit).all()
- return pool_collection_schema.dump(PoolCollection(pools=pools,
total_entries=total_entries)).data
+ return pool_collection_schema.dump(
+ PoolCollection(pools=pools, total_entries=total_entries)
+ ).data
-def patch_pool():
+@provide_session
+def patch_pool(pool_name, session, update_mask=None):
"""
Update a pool
"""
- raise NotImplementedError("Not implemented yet.")
+ pool = session.query(Pool).filter(Pool.pool == pool_name).first()
+ if not pool:
+ raise NotFound(f"Pool with name:'{pool_name}' not found")
+ patch_body = pool_schema.load(request.json).data
+ if update_mask:
+ update_mask = [i.strip() for i in update_mask]
+ _patch_body = {}
+ try:
+ update_mask = [
+ pool_schema.declared_fields[field].attribute
+ if pool_schema.declared_fields[field].attribute
+ else field
+ for field in update_mask
+ ]
+ except KeyError as err:
+ raise BadRequest(f"Invalid field: {err.args[0]} in update mask")
+ _patch_body = {field: patch_body[field] for field in update_mask}
+ patch_body = _patch_body
-def post_pool():
+ for key, value in patch_body.items():
+ setattr(pool, key, value)
+ session.commit()
+ return pool_schema.dump(pool)
+
+
+@provide_session
+def post_pool(session):
"""
- Create aa pool
+ Create a pool
"""
- raise NotImplementedError("Not implemented yet.")
+ post_body = pool_schema.load(request.json, session=session).data
+ pool_instance = session.query(Pool).filter(Pool.pool ==
post_body["pool"]).first()
Review comment:
Thanks,
[fixed](https://github.com/apache/airflow/pull/9329/files#diff-89eaafe05e80053aa3cbf1e0610ca09dR102-R106).
----------------------------------------------------------------
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:
[email protected]