REST api for clearing user credentials
authorCiro Scognamiglio <ciro.scognamiglio@cslash.net>
Fri, 25 Jul 2014 14:29:46 +0000 (16:29 +0200)
committerCiro Scognamiglio <ciro.scognamiglio@cslash.net>
Fri, 25 Jul 2014 14:29:46 +0000 (16:29 +0200)
myslice/urls.py
rest/credentials.py [new file with mode: 0644]

index dacebde..a4dcf96 100644 (file)
@@ -80,7 +80,10 @@ urls = [
     (r'^update/(?P<object_type>[^/]+)/(?P<object_name>[^/]+)?/?$', 'rest.update.dispatch'),
     (r'^create/(?P<object_type>[^/]+)/(?P<object_name>[^/]+)?/?$', 'rest.create.dispatch'),
     (r'^delete/(?P<object_type>[^/]+)/(?P<object_name>[^/]+)?/?$', 'rest.delete.dispatch'),
+    (r'^credentials/(?P<action>[^/]+)/(?P<object>[^/]+)?/?$', 'rest.credentials.dispatch'),
     #
+    # REST monitoring
+    (r'^monitor/sfa/getversion/?$', 'rest.monitor.sfaGetVersion'),
     #
     #(r'^view/?', include('view.urls')),
     #(r'^list/slices', 'view.list.slices')
diff --git a/rest/credentials.py b/rest/credentials.py
new file mode 100644 (file)
index 0000000..fa1f9b8
--- /dev/null
@@ -0,0 +1,18 @@
+from django.http                    import HttpResponse
+from portal.actions import clear_user_creds
+import json
+
+def dispatch(request, action, object):
+    
+    if (action == 'clear') :
+        try :
+            res = clear_user_creds(request, object)
+        except :
+            pass
+        
+        if res is not None :
+            ret = { "ret" : 1, "email" : res }
+        else :
+            ret = { "ret" : 0 }
+    
+    return HttpResponse(json.dumps(ret), content_type="application/json")