From 7f055ed854bca5d058c0885a5ec2eaf9882c3a53 Mon Sep 17 00:00:00 2001
From: Ciro Scognamiglio <ciro.scognamiglio@cslash.net>
Date: Fri, 25 Jul 2014 16:29:46 +0200
Subject: [PATCH] REST api for clearing user credentials

---
 myslice/urls.py     |  3 +++
 rest/credentials.py | 18 ++++++++++++++++++
 2 files changed, 21 insertions(+)
 create mode 100644 rest/credentials.py

diff --git a/myslice/urls.py b/myslice/urls.py
index dacebded..a4dcf96a 100644
--- a/myslice/urls.py
+++ b/myslice/urls.py
@@ -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
index 00000000..fa1f9b83
--- /dev/null
+++ b/rest/credentials.py
@@ -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")
-- 
2.47.0