summaryrefslogtreecommitdiffstats
path: root/api/resources/v2
diff options
context:
space:
mode:
Diffstat (limited to 'api/resources/v2')
-rw-r--r--api/resources/v2/pods.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/api/resources/v2/pods.py b/api/resources/v2/pods.py
index ffb8a6046..ebc1312da 100644
--- a/api/resources/v2/pods.py
+++ b/api/resources/v2/pods.py
@@ -77,3 +77,24 @@ class V2Pod(ApiResource):
content = jsonutils.loads(pod.content)
return result_handler(consts.API_SUCCESS, {'pod': content})
+
+ def delete(self, pod_id):
+ try:
+ uuid.UUID(pod_id)
+ except ValueError:
+ return result_handler(consts.API_ERROR, 'invalid pod id')
+
+ pod_handler = V2PodHandler()
+ try:
+ pod = pod_handler.get_by_uuid(pod_id)
+ except ValueError:
+ return result_handler(consts.API_ERROR, 'no such pod')
+
+ LOG.info('update pod in environment')
+ environment_handler = V2EnvironmentHandler()
+ environment_handler.update_attr(pod.environment_id, {'pod_id': None})
+
+ LOG.info('delete pod in database')
+ pod_handler.delete_by_uuid(pod_id)
+
+ return result_handler(consts.API_SUCCESS, {'pod': pod_id})