VUser::Google::ProvisioningAPI::V2_0(3pm) | User Contributed Perl Documentation | VUser::Google::ProvisioningAPI::V2_0(3pm) |
VUser::Google::ProvisioningAPI::V2_0 - Perl module that implements version 2.0 of the Google Apps for Your Domain Provisioning API
use VUser::Google::ProvisioningAPI; my $google = new VUser::Google::ProvisioningAPI($domain, $admin, $passwd, '2.0'); $google->CreateUser($userName, $givenName, $familyName, $password, $quotaMB); my $user = $google->RetrieveUser($userName);
VUser::Google::ProvisioningAPI requires the following modules to be installed:
VUser::Google::ProvisioningAPI provides a simple interface to the Google Apps for Your Domain Provisioning API. It uses the "LWP::UserAgent" module for the HTTP transport, and the "HTTP::Request" module for the HTTP request and response.
Adding a user:
use VUser::Google::ProvisioningAPI; my $google = VUser::Google::ProvisioningAPI->new('yourdomain.com', 'admin', 'your password', '2.0'); my $entry = $google->CreateUser('joeb', 'Joe', 'Blow', 'joespassword'); if (defined $entry) { print $entry->User, " created\n"; } else { die "Add failed: ".$google->{result}{reason}; }
Updating a user:
my $new_entry = VUser::Google::ProvisioningAPI::V2_0::UserEntry->new(); $new_entry->Password('heresmynewpassword'); $new_entry->GivenName('Joseph'); my $entry = $google->UpdateUser('joeb', $new_entry);
Delete a user:
my $rc = $google->DeleteUser('joeb'); if (not $rc) { die "Can't delete user: ".$google->{result}{reason}; }
new ($domain, $admin, $adminpasswd)
This is the constructor for a new VUser::Google::ProvisioningAPI object. $domain is the domain name registered with Google Apps For Your Domain, $admin is an account in the above domain that has the right to manage that domain, and $adminpassword is the password for that account.
Note that the constructor will NOT attempt to perform the 'ClientLogin' call to the Google Provisioning API (see below). Authentication happens automatically when the first API call is performed. The token will be remembered for the duration of the object, and will be automatically refreshed as needed. If you want to verify that you can get a valid token before performing any operations, follow the constructor with a call to IsAuthenticated() as such:
print "Authentication OK\n" unless not $google->IsAuthenticated();
Below are all the methods available on the object. For the Google API specific methods, see the Google API documentation for more details.
When a request is properly handed by Google's API engine, the results of the action are returned as the content of the request.
If the request fails (as determined by the "HTTP::Request" method is_success()), it could mean a couple of things. If it's a failure within the Google API, the content will contain an XML encoded error message. All other HTTP errors are still possible.
IsAuthenticated()
Relogin()
These are the acutual API calls. These calls match up with the client library methods described for the .Net and Java libraries.
CreateUser($userName, $givenName, $familyName, $password, $quota, $forceChange, $hashName)
If $forceChange is true, the user will be required to change their password after log in.
$hashName, if set, must be sha-1 or md5.
CreateUser() returns a "VUser::Google::ProvisioningAPI::V2_0::UserEntry" object if the request was successful and "undef" otherwise.
RetrieveUser($userName)
RetrieveAllUsers()
RetrievePageOfUsers($startUser)
RetrievePageOfUsers() returns a list of "VUser::Google::ProvisioningAPI::V2_0::UserEntry" objects.
UpdateUser($userName, $newUserEntry)
SuspendUser($userName)
Returns a "VUser::Google::ProvisioningAPI::V2_0::UserEntry" object if successful.
RestoreUser($userName)
Returns a "VUser::Google::ProvisioningAPI::V2_0::UserEntry" object if successful.
DeleteUser($userName)
Returns '1' on success.
Nickname methods
CreateNickname($userName, $nickName)
Returns a "VUser::Google::ProvisioningAPI::V2_0::NicknameEntry" object on success.
RetrieveNickname($nickName)
RetrieveNicknames($userName)
Returns a list of "VUser::Google::ProvisioningAPI::V2_0::NicknameEntry" objects.
RetrieveAllNicknames()
Returns a list of "VUser::Google::ProvisioningAPI::V2_0::NicknameEntry" objects.
RetrievePageOfNicknames($startNick)
Returns a list of "VUser::Google::ProvisioningAPI::V2_0::NicknameEntry" objects.
DeleteNickname($nickName)
Email list methods
CreateEmailList($listName)
Returns a "VUser::Google::ProvisioningAPI::V2_0::EmailListEntry" on success.
RetrieveEmailLists($recipient)
Returns a list of "VUser::Google::ProvisioningAPI::V2_0::EmailListEntry" objects.
RetrieveAllEmailLists()
Returns a list of "VUser::Google::ProvisioningAPI::V2_0::EmailListEntry" objects.
RetrievePageOfEmailLists($startList)
DeleteEmailList($emailList)
Returns 1 on success.
AddRecipientToEmailList($recipient, $emailList)
Returns a "VUser::Google::ProvisioningAPI::V2_0::EmailListRecipientEntry" object on success.
RetrieveAllRecipients($emailList)
Returns a list of "VUser::Google::ProvisioningAPI::V2_0::EmailListRecipientEntry" objects.
RetrievePageOfRecipients($emailList, $startRecpt)
Returns a list of "VUser::Google::ProvisioningAPI::V2_0::EmailListRecipientEntry" objects.
RemoveRecipientFromEmailList($recipient, $emailList)
Returns 1 in success.
Most API calls return an object so that you don't have to screw around with the XML data. The parsed XML (by XML::Simple) is available in "$google-"{result}>.
None by default.
The perldocs for VUser::Google::ProvisioningAPI::V2_0::UserEntry; VUser::Google::ProvisioningAPI::V2_0::NicknameEntry; VUser::Google::ProvisioningAPI::V2_0::EmailListEntry; and VUser::Google::ProvisioningAPI::V2_0::EmailListRecipientEntry.
The official Google documentation can be found at http://code.google.com/apis/apps-for-your-domain/google_apps_provisioning_api_v2.0_reference.html
http://code.google.com/apis/apps/gdata_provisioning_api_v2.0_reference.html
For support, see the Google Group at http://groups.google.com/group/apps-for-your-domain-apis
For additional support specific to this modules, email me at johan at reinalda dot net.
Johan Reinalda, johan at reinalda dot net Randy Smith, perlstalker at vuser dot org
Copyright (C) 2006 by Johan Reinalda, johan at reinalda dot net Copyright (C) 2007 by Randy Smith, perlstalker at vuser dot org
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.
If you make useful modification, kindly consider emailing then to me for inclusion in a future version of this module.
2021-01-09 | perl v5.32.0 |