On Thu, May 5, 2011 at 3:13 PM, Danilo Nogueira < [email protected]> wrote:
> Dear All, > > I need a API (in python) where I can remove all contacts from my > Google contacts directory (Gapps enterprise). > > Anyone have something to send me? > > Thank you very much!!! > > Best regards, > > Danilo Nogueira > ICS/IT Team > > -- > You received this message because you are subscribed to the Google > Groups "Google Contacts, Shared Contacts and User Profiles APIs" group. > To post to this group, send email to > [email protected] > To unsubscribe from this group, send email to > [email protected] > For more options, visit this group at > http://code.google.com/apis/contacts/community/forum.html This is rough script bit it does wipe all contacts and groups if passed in a gdata.contacts.client.ContactsClient def wipe_google_account(Contacts): print "Wiping ALL Contact data from %r account" % account # lets clear out the google accounts with some batch deletes # patch submitted to enable Contact groups querying # groups = Contacts.get_groups(query=gdata.contacts.client.ContactGroupsQuery(max_results=9999)) while True: groups = Contacts.get_groups() non_system = [x for x in groups.entry if not x.system_group] if not non_system: break batch = gdata.contacts.data.GroupsFeed() [batch.AddDelete(entry=x) for x in non_system] Contacts.execute_batch(batch, groups.find_batch_link()) print "removed %s groups " % len(non_system) while True: # batch requests are limited to 100 operations contacts = Contacts.get_contacts(query=gdata.contacts.client.ContactsQuery(max_results=100)) data = contacts.entry if not data: break batch = gdata.contacts.data.ContactsFeed() [batch.AddDelete(entry=x) for x in data] Contacts.execute_batch(batch, contacts.find_batch_link()) print "removed %s contacts" % len(data) Vince -- You received this message because you are subscribed to the Google Groups "Google Contacts, Shared Contacts and User Profiles APIs" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://code.google.com/apis/contacts/community/forum.html
