From d7aa8468317d39746882d6402affbf800de5cf51 Mon Sep 17 00:00:00 2001 From: Loic Baron Date: Fri, 23 Jan 2015 17:14:03 +0100 Subject: [PATCH] REST clear cache: simple update to clear Manifold cache --- myslice/urls.py | 1 + rest/cache.py | 22 ++++++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 rest/cache.py diff --git a/myslice/urls.py b/myslice/urls.py index c815148e..da697cf7 100644 --- a/myslice/urls.py +++ b/myslice/urls.py @@ -92,6 +92,7 @@ urls = [ (r'^create/(?P[^/]+)/(?P[^/]+)?/?$', 'rest.create.dispatch'), (r'^delete/(?P[^/]+)/(?P[^/]+)?/?$', 'rest.delete.dispatch'), (r'^credentials/(?P[^/]+)/?$', 'rest.credentials.dispatch'), + (r'^cache/(?P[^/]+)/?$', 'rest.cache.dispatch'), (r'^initscript/(?P[^/]+)/?$', 'rest.initscript.dispatch'), # # REST monitoring diff --git a/rest/cache.py b/rest/cache.py new file mode 100644 index 00000000..39439469 --- /dev/null +++ b/rest/cache.py @@ -0,0 +1,22 @@ +from django.http import HttpResponse +from portal.actions import clear_user_creds + +from manifoldapi.manifoldapi import execute_query +from manifold.core.query import Query + +import json + +def dispatch(request, action): + + if (action == 'clear') : + query = Query.update('myslice:user').filter_by('user_hrn', '==', '$user_hrn').set({'user_email':str(request.user)}) + try: + res = execute_query(request, query) + except Exception, e: + ret = { "ret" : -1, "error" : "error clearing cache: %s" % e } + return HttpResponse(json.dumps(ret), content_type="application/json") + + ret = { "ret" : 1 } + else: + ret = { "ret" : 0, "error" : "action not supported" } + return HttpResponse(json.dumps(ret), content_type="application/json") -- 2.43.0