provisioningapi.rb

Path: provisioningapi.rb
Last Update: Thu Sep 24 16:39:19 +0200 2009

Google Apps Provisioning API client library

This library allows you to manage your domain (accounts, email lists, aliases) within your Ruby code. It‘s based on the GDATA provisioning API v2.0. Reference : code.google.com/apis/apps/gdata_provisioning_api_v2.0_reference.html.

All the public methods with ruby_style names are aliased with javaStyle names. Ex : create_user and createUser.

Notice : because it uses REXML, your script using this library MUST be encoded in unicode (UTF-8).

Examples

     #!/usr/bin/ruby
     require 'gappsprovisioning/provisioningapi'
     include GAppsProvisioning
     adminuser = "root@mydomain.com"
     password  = "PaSsWo4d!"
     myapps = ProvisioningApi.new(adminuser,password)
     (see examples in  ProvisioningApi.new documentation for handling proxies)

     new_user = myapps.create_user("jsmith", "john", "smith", "secret", nil, "2048")
     puts new_user.family_name
     puts new_user.given_name

Want to update a user ?

     user = myapps.retrieve_user('jsmith')
     user_updated = myapps.update_user(user.username, user.given_name, user.family_name, nil, nil, "true")

Want to add an alias or nickname ?

     new_nickname = myapps.create_nickname("jsmith", "john.smith")

Want to manage groups ? (i.e. mailing lists)

    new_group = myapps.create_group("sales-dep", ['Sales Departement'])
    new_member = myapps.add_member_to_group("jsmith", "sales-dep")
    new_owner = myapps.add_owner_to_group("jsmith", "sales-dep")
    (ATTENTION: an owner is added only if it's already member of the group!)

Want to handle errors ?

     begin
             user = myapps.retrieve_user('noone')
             puts "givenName : "+user.given_name, "familyName : "+user.family_name, "username : "+user.username"
             puts "admin ? : "+user.admin
     rescue GDataError => e
             puts "errorcode = " +e.code, "input : "+e.input, "reason : "+e.reason
     end

Email lists (deprecated) ?

     new_list = myapps.create_email_list("sales-dep")
     new_address = myapps.add_address_to_email_list("sales-dep", "bibi@ruby-forge.org")

All methods described in the GAppsProvisioning::ProvisioningApi class documentation.

Authors :Jérôme Bousquié, Roberto Cerigato
Ruby version :from 1.8.6
Licence :Apache Licence, version 2

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Required files

cgi   rexml/document   gappsprovisioning/connection   gappsprovisioning/exceptions  

Included Modules

REXML

[Validate]