changeset 2009:b63adad7c4af beta

API updates - update_user will do lookup by userid param that can be id or username - all params are required for update_user api call - get_user/s will return ldap_dn param which is more correct
author Marcin Kuzminski <marcin@python-works.com>
date Tue, 21 Feb 2012 02:35:43 +0200
parents 9ddbfaeefb73
children 14dffcfebb02
files docs/api/api.rst rhodecode/controllers/api/api.py rhodecode/model/user.py
diffstat 3 files changed, 16 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/docs/api/api.rst	Tue Feb 21 01:18:00 2012 +0200
+++ b/docs/api/api.rst	Tue Feb 21 02:35:43 2012 +0200
@@ -111,7 +111,7 @@
                 "email" :    "<email>",
                 "active" :   "<bool>",
                 "admin" :    "<bool>",
-                "ldap" :     "<ldap_dn>"
+                "ldap_dn" :  "<ldap_dn>"
             }
 
     error:  null
@@ -141,7 +141,7 @@
                 "email" :    "<email>",
                 "active" :   "<bool>",
                 "admin" :    "<bool>",
-                "ldap" :     "<ldap_dn>"
+                "ldap_dn" :  "<ldap_dn>"
               },

             ]
@@ -191,14 +191,15 @@
     api_key : "<api_key>"
     method :  "update_user"
     args :    {
+                "userid" : "<user_id or username>",
                 "username" :  "<username>",
                 "password" :  "<password>",
                 "email" :     "<useremail>",
-                "firstname" : "<firstname> = None",
-                "lastname" :  "<lastname> = None",
-                "active" :    "<bool> = True",
-                "admin" :     "<bool> = False",
-                "ldap_dn" :   "<ldap_dn> = None"
+                "firstname" : "<firstname>",
+                "lastname" :  "<lastname>",
+                "active" :    "<bool>",
+                "admin" :     "<bool>",
+                "ldap_dn" :   "<ldap_dn>"
               }
 
 OUTPUT::
--- a/rhodecode/controllers/api/api.py	Tue Feb 21 01:18:00 2012 +0200
+++ b/rhodecode/controllers/api/api.py	Tue Feb 21 02:35:43 2012 +0200
@@ -100,7 +100,7 @@
             email=user.email,
             active=user.active,
             admin=user.admin,
-            ldap=user.ldap_dn
+            ldap_dn=user.ldap_dn
         )
 
     @HasPermissionAllDecorator('hg.admin')
@@ -122,7 +122,7 @@
                     email=user.email,
                     active=user.active,
                     admin=user.admin,
-                    ldap=user.ldap_dn
+                    ldap_dn=user.ldap_dn
                 )
             )
         return result
@@ -168,8 +168,8 @@
             raise JSONRPCError('failed to create user %s' % username)
 
     @HasPermissionAllDecorator('hg.admin')
-    def update_user(self, apiuser, username, password, email, firstname=None,
-                    lastname=None, active=True, admin=False, ldap_dn=None):
+    def update_user(self, apiuser, userid, username, password, email,
+                    firstname, lastname, active, admin, ldap_dn):
         """
         Updates given user
 
@@ -183,7 +183,7 @@
         :param admin:
         :param ldap_dn:
         """
-        if not User.get_by_username(username):
+        if not UserModel().get_user(userid):
             raise JSONRPCError("user %s does not exist" % username)
 
         try:
--- a/rhodecode/model/user.py	Tue Feb 21 01:18:00 2012 +0200
+++ b/rhodecode/model/user.py	Tue Feb 21 02:35:43 2012 +0200
@@ -74,6 +74,9 @@
                                           "get_user_%s" % user_id))
         return user.get(user_id)
 
+    def get_user(self, user):
+        return self.__get_user(user)
+
     def get_by_username(self, username, cache=False, case_insensitive=False):
 
         if case_insensitive: