API Documentation

exception uwgroups.api.APIError[source]
exception uwgroups.api.AuthorizationError[source]
exception uwgroups.api.MissingResourceError[source]
class uwgroups.api.UWGroups(certfile, keyfile=None, environment='PROD', timeout=30)[source]

Class providing a connection to the UW groups REST API. certfile and keyfile are paths to files containing the certificate and private keys, respectively. timeout is passed to httplib.HTTPSConnection()

Example:

with UWGroups(certfile='/path/to/cert.pem') as conn:
    conn.get_group('some_group')
add_members(group_name, members, batchsize=50)[source]

Add uwnetids in list members to the specified group in batches of size batchsize.

close()[source]

Close the connection

connect(timeout=None)[source]

Establish a connection. If the UWGroups object is instantiated without a with block, must be called explicitly. timeout overrides the value for timeout in the class constructor.

create_group(group_name, admin_users=None)[source]

Create a group with name group_name. The dns user associated with the certificate, as well as the user identified as the email contact for the cert in field emailAddress are always added as admins. A list of additional admin users identified by uwnetid can be provided in admin_users.

Note that the API requires that a parent group (‘root_parent’) must be created before any of its children (‘root_parent_child’). This method will recursively create parent groups if necessary.

delete_group(group_name)[source]
delete_members(group_name, members, batchsize=50)[source]

Remove uwnetids in list members from the specified group in batches of size batchsize.

get_group(group_name)[source]

Return deserialized json representation of a group

get_members(group_name)[source]

Return a list of uwnetids

group_exists(group_name)[source]

Return True if the group exists

reset()[source]

Close and reopen the connection; may be necessary after an exception

search_user(netid)[source]

Return groups in which netid is a member

set_affiliate(group_name, service, active=True)[source]

Activate (active=True) or inactivate (active=False) Exchange (service=exchange) or Google Apps (service=google) for the specified group.

sync_members(group_name, members, batchsize=50, dry_run=False)[source]

Add or remove users from the specified group as necessary so that the group contains members (a list or uwnetids). When dry_run is True, log the necessary actions but don’t modify the group. The group is created if it does not already exist.

class uwgroups.api.User(uwnetid, type)[source]
user_types = {'dns', 'eppn', 'group', 'uwnetid'}
uwgroups.api.get_admins(certfile)[source]

Returns [dns_user, uwnetid_user] given data in cert