Just a quick note. I write our own integration code for Google Apps in part because of our scale, and in part because I started integrating our systems before GADS (Google Apps Directory Sync) existed. The code mostly just works, so I don’t look at it very often, and I’m not a strong python coder.
Recently I need to move a fairly large number of users into an organization, but there’s no way to do this in the GUI as a batch job, so I needed to code it. I found the docs, but mostly I have to go through a lot of trial and error. Here’s the ultimate shape of the code I came up with, and an explanation. I’m just writing a quick utility script here so it’s nothing fancy:
# get a client and log in as an integration user
ouclient = gdata.apps.organization.client.OrganizationUnitProvisioningClient(domain='yourdomain.com')
ouclient.ClientLogin(email@example.com', password='adminuserpassword', source ='apps')
# grab the customerId of the integration account - this is new
clientid = ouclient.RetrieveCustomerId()
customer_id = clientid.customer_id
# you need the customer id to do anything, I think. Read the provisioning docs.
# Objects that are camelCase in the XML, change to underscore in python
# I have never found that documented anywhere so I figure it is something you just know!
ouclient.move_users_to_org_unit(customer_id=customer_id, org_unit_path='nameorpathofOU', users_to_move=['firstname.lastname@example.org'])
#users_to_move is a list, up to 25 email addresses. See the docs on move_users_to_org_unit.