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/18 06:15:13 UTC

[GitHub] [airflow] houqp commented on a change in pull request #9329: [WIP] Pool CRUD Endpoints

houqp commented on a change in pull request #9329:
URL: https://github.com/apache/airflow/pull/9329#discussion_r441990554



##########
File path: airflow/api_connexion/endpoints/pool_endpoint.py
##########
@@ -14,20 +14,28 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
+from connexion import NoContent
 from flask import request
 
 from airflow.api_connexion import parameters
-from airflow.api_connexion.exceptions import NotFound
+from airflow.api_connexion.exceptions import AlreadyExists, NotFound
 from airflow.api_connexion.schemas.pool_schema import PoolCollection, pool_collection_schema, pool_schema
 from airflow.models.pool import Pool
 from airflow.utils.session import provide_session
 
 
-def delete_pool():
+@provide_session
+def delete_pool(pool_name, session):
     """
     Delete a pool
     """
-    raise NotImplementedError("Not implemented yet.")
+    pool_id = pool_name
+    query = session.query(Pool)
+    obj = query.filter(Pool.pool == pool_id).one_or_none()
+    if obj is None:
+        raise NotFound("Pool not found")
+    session.delete(obj)

Review comment:
       you can optimize this by running delete query with provided pool_id, then check for deleted row count to decide whether NotFound exception should be raised or not. This way, you can combine two queries into one.




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