From 370a8f3992e07f9226bcab5dc7813f1f55b59b11 Mon Sep 17 00:00:00 2001 From: Andrey Pavlov Date: Mon, 10 Aug 2015 11:04:20 +0300 Subject: [PATCH] Adding HTTP PATCH method to modify existing resources Added support of PATCH HTTP method that will be implemented the same way as current PUT method. Partially-Implements: blueprint api-for-objects-update Change-Id: I3cd7cd7e03fa424d5bd47244dc4d58462b8c859e --- sahara/utils/api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sahara/utils/api.py b/sahara/utils/api.py index 386b0110..f40dc188 100644 --- a/sahara/utils/api.py +++ b/sahara/utils/api.py @@ -49,6 +49,9 @@ class Rest(flask.Blueprint): def delete(self, rule, status_code=204): return self._mroute('DELETE', rule, status_code) + def patch(self, rule, status_code=202): + return self._mroute('PATCH', rule, status_code) + def _mroute(self, methods, rule, status_code=None, **kw): if type(methods) is str: methods = [methods] @@ -85,7 +88,7 @@ class Rest(flask.Blueprint): flask.request.headers['X-Roles'].split(','), request_id=req_id) context.set_ctx(ctx) - if flask.request.method in ['POST', 'PUT']: + if flask.request.method in ['POST', 'PUT', 'PATCH']: kwargs['data'] = request_data() try: