Sep 23, 2009 13:26
class GoogleUsers(object):
""" Pythonic interface to Google Provisioning API. """
...
def __delitem__(self, key):
delete_key = 'delete%d%d' % (time.time(), os.getpid())
self.gdata_api.RenameUser(key, delete_key)
self.gdata_api.DeleteUser(delete_key)
...
Leave a comment
Comments 2
Reply
Oh right, yeah, they haven't put that into the Python API yet...
Yes! You can rename Google accounts but not with the current Python API implementation. I hacked in a new method in gdata/apps/service.py:
...
class AppsService(gdata.service.GDataService):
"""Client for the Google Apps Provisioning service."""
...
def RenameUser(self, user_name, new_user_name):
"""Update a user account."""
uri = "%s/user/%s/%s" % (self._baseURL(), API_VER, user_name)
try:
return gdata.apps.UserEntryFromString(str(self.Put(gdata.apps.UserEntry(login=gdata.apps.Login(user_name=new_user_name)), uri)))
except gdata.service.RequestError, e:
raise AppsForYourDomainException(e.args[0])
...
Alternately you could use gdata.apps.service.AppsService(...).UpdateUser(old_user_name, gdata.apps.UserEntry(login=gdata.apps.Login(user_name=new_user_name)))
Reply
Leave a comment