Class: GoogleAppsApi::Provisioning::Api

Inherits:
BaseApi
  • Object
show all
Defined in:
lib/google_apps_api/provisioning.rb

Instance Attribute Summary collapse

Attributes inherited from BaseApi

#domain

Instance Method Summary collapse

Methods inherited from BaseApi

#entity

Constructor Details

#initialize(*args) ⇒ Api

Returns a new instance of Api.



9
10
11
# File 'lib/google_apps_api/provisioning.rb', line 9

def initialize(*args)
  super(:provisioning, *args)
end

Instance Attribute Details

#tokenObject (readonly)

Returns the value of attribute token.



6
7
8
# File 'lib/google_apps_api/provisioning.rb', line 6

def token
  @token
end

Instance Method Details

#create_user(username, *args) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/google_apps_api/provisioning.rb', line 27

def create_user(username, *args)
  options = args.extract_options!      
  options.each { |k,v| options[k] = escapeXML(v)}

  res = <<-DESCXML
  <?xml version="1.0" encoding="UTF-8"?>
  <atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:apps="http://schemas.google.com/apps/2006">
  <atom:category scheme="http://schemas.google.com/g/2005#kind" 
  term="http://schemas.google.com/apps/2006#user"/>
  <apps:login userName="#{escapeXML(username)}" 
  password="#{options[:password]}" suspended="false"/>
  <apps:name familyName="#{options[:family_name]}" givenName="#{options[:given_name]}"/>
  </atom:entry>

  DESCXML


  request(:create_user, options.merge(:body => res.strip))
end

#delete_user(username, *args) ⇒ Object



67
68
69
70
# File 'lib/google_apps_api/provisioning.rb', line 67

def delete_user(username, *args)
  options = args.extract_options!.merge(:username => username)
  request(:delete_user, options)
end

#retrieve_all_users(*args) ⇒ Object



21
22
23
24
# File 'lib/google_apps_api/provisioning.rb', line 21

def retrieve_all_users(*args)
  options = args.extract_options!
  request(:retrieve_all_users, options)
end

#retrieve_user(user, *args) ⇒ Object



13
14
15
16
17
18
# File 'lib/google_apps_api/provisioning.rb', line 13

def retrieve_user(user, *args)
  username = user.kind_of?(UserEntity) ? user.id : user
  
  options = args.extract_options!.merge(:username => username)
  request(:retrieve_user, options) 
end

#update_user(username, *args) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/google_apps_api/provisioning.rb', line 49

def update_user(username, *args)
  options = args.extract_options!      
  options.each { |k,v| options[k] = escapeXML(v)}

  res = <<-DESCXML
  <?xml version="1.0" encoding="UTF-8"?>
  <atom:entry xmlns:atom="http://www.w3.org/2005/Atom"
  xmlns:apps="http://schemas.google.com/apps/2006">
  <atom:category scheme="http://schemas.google.com/g/2005#kind" 
  term="http://schemas.google.com/apps/2006#user"/>
  <apps:name familyName="#{options[:family_name]}" givenName="#{options[:given_name]}"/>
  </atom:entry>

  DESCXML
  request(:update_user, options.merge(:username => username, :body => res.strip))
end