FAQ | This is a LIVE service | Changelog

User Sync Tool - Step 1 - read and write custom schema, and initiate scanning

Step 1

This is just adding this functionality to the existing sync tool:

  • read the custom attributes from Google when getting users
  • set an action to initiate a scan if appropriate [1]
  • clearing custom attributes when reactivating (unsuspending) users

[1] For each user suspended for more than 6 months (suspended in Google, cancelled in Lookup and Lookup cancelledDate is 6+ months ago) and both mydrive-shared-action and mydrive-shared-result are unset/empty (i.e. no current/pending action nor a result of previous action, already scanned), update mydrive-shared-action to “scan”. See !33 (closed) for example code on retrieving cancelledDates from Lookup.

Reading Schema

In order to retrieve the customSchema property of a user when using the directory_service.users().get() or .list() actions the call needs to be made with projection='custom' and `customFieldMask='UCam'.

The user object(s) will then contain a structure, like this yaml:

...
id: '111123444555666778888'
emails:
- address: abc123@cam.ac.uk
  primary: true
...
customSchemas:
  UCam:
    mydrive-shared-action: scan
...
suspended: true
...

Don't assume any of the customSchemas branch exists, e.g. use user.get('customSchemas', {}).get('UCam', {}).get('mydrive-shared-action')

Custom schema updating

Performing a ds.users().update() with a body like the following will update just that key/value pair.

Setting to None will remove the key.

'customSchemas': {
  'UCam': {
    'mydrive-shared-action': 'scan',
  }
}
Edited by Robin Goodall