REST::Google::Apps::Provisioning - A Perl library to Google's RESTful Apps Provisioning API
use REST::Google::Apps::Provisioning $google = REST::Google::Apps::Provisioning->new( domain => 'company.com', username => 'admin', password => 'g00gl34pp5!' ); $user->{'jsmith'} = $google->getUser( username => 'jsmith' );
REST::Google::Apps::Provisioning provides a Perl interface to Google's RESTful Apps API.
Creates a new REST::Google::Apps::Provisioning object. A domain parameter is required.
Supplying authentication information to the constructor is optional, but needs to happen either here or with a call to the authenticate method.
Example
$google = REST::Google::Apps::Provisioning->new( domain => 'company.com', username => 'admin', password => 'g00gl34pp5!' );
Authenticate a session.
$google->authenticate( username => 'admin', password => 'g00gl34pp5!' ) || die "Could not authenticate";
Create a new user.
The following parameters are required:
The username associated with the account being created.
The user's given (first) name.
The user's family (last) name.
The user's password.
The following parameters are optional:
The format of the value in the password attribute. Currently, the only valid values for this parameter are "SHA-1" and "MD5".
Can be 'true' or 'false', representing whether or not the user should be granted administrator access.
$user->{'jsmith'} = $google->createUser( username => 'jsmith', givenName => 'Joseph', familyName => 'Smith', password => 'j5m1thp455w0rd!' ) || die "Could not create user";
Delete a user.
delete $user->{'jsmith'} if $google->deleteUser( username => 'jsmith' );
Rename a user.
$google->renameUser( username => 'jsmith', newname => 'josephsmith' ) || die "Could not rename user";
Update a user's attributes. See the createUser function for a list of valid attributes.
$google->updateUser( username => 'jsmith', givenName => 'Joey' ) || die "Could not update user";
Retrieve a hash containing a user's account information.
$user->{'jsmith'} = $google->getUser( username => 'jsmith' );
Hash
Using the above example, the returned hash is:
'jsmith' => { 'admin' => 'false', 'ipWhitelisted' => 'false', 'suspended' => 'false', 'limit' => '7168', 'username' => 'jsmith`', 'changePasswordAtNextLogin' => 'false', 'givenName' => 'Joseph', 'familyName' => 'Smith', 'agreedToTerms' => 'false' }
Retrieve a list of all users.
$users = $google->getAllUsers();
Create a new group.
The group name.
A longer description of the group.
The permission level of the group. Valid values are:
Owners of the group.
Members of the group.
Any user who belongs to the same domain as the group.
Any user.
$google->createGroup( group => 'finance', description => 'Finance Department' ) || die "Could not create group";
Delete a group.
delete $group->{'finance'} if $google->deleteGroup( group => 'finance' );
Not yet implemented.
Retrieve a hash containing group information.
$group->{'finance'} = $google->getGroup( group => 'finance' );
'finance' => { 'emailPermission' => 'Anyone', 'groupId' => 'finance@company.com', 'updated' => '2009-09-16T21:05:15.697Z', 'groupName' => 'finance', 'description' => 'Finance Department' }
Retrieve a list of all groups.
$groups = $google->getAllGroups();
Add a member to a group.
$google->addGroupMember( group => 'finance', member => 'jsmith' ) || die "Could not add group member";
Remove a member from a group.
$google->deleteGroupMember( group => 'finance', member => 'jsmith' ) || die "Could not delete group member";
Retrieve a list of group members.
$group->{'finance'}->{'members'} = $google->getGroupMembers( group => 'finance' );
'members' => { 'jsmith' => { 'memberType' => 'User', 'directMember' => 'true', 'memberId' => 'jsmith@company.com' }, 'sschneid' => { 'memberType' => 'User', 'directMember' => 'true', 'memberId' => 'sschneid@company.com' } }
Add an owner to a group.
$google->addGroupOwner( group => 'finance', owner => 'jsmith' ) || die "Could not add group owner";
Remove an owner from a group.
$google->deleteGroupOwner( group => 'finance', owner => 'jsmith' ) || die "Could not delete group owner";
Retrieve a list of group owners.
$group->{'finance'}->{'owners'} = $google->getGroupOwners( group => 'finance' );
'owners' => { 'jsmith' => { 'email' => 'jsmith@company.com', 'type' => 'User' }, 'sschneid' => { 'email' => 'sschneid@company.com', 'type' => 'User' } }
Create a nickname (e-mail alias).
$google->createNickname( username => 'jsmith', nickname => 'joe' ) || die "Could not create nickname";
Delete a nickname (e-mail alias).
$google->deleteNickname( nickname => 'joe' );
Retrieve a nickname.
$nickname->{'frank'} = $google->getNickname( nickname => 'frank' );
'frank' => { 'name' => 'frank', 'username' => 'jsmith' }
Retrieve a list of a user's nicknames.
$user->{'jsmith'}->{'nicknames'} = $google->getUserNicknames( username => 'jsmith' );
Retrieve a list of all nicknames.
Scott Schneider <sschneid@gmail.com>
To install REST::Google::Apps::Provisioning, copy and paste the appropriate command in to your terminal.
cpanm
cpanm REST::Google::Apps::Provisioning
CPAN shell
perl -MCPAN -e shell install REST::Google::Apps::Provisioning
For more information on module installation, please visit the detailed CPAN module installation guide.