google_apps 0.4.8.1 → 0.4.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/google_apps/atom/atom.rb +2 -2
- data/lib/google_apps/atom/document.rb +78 -0
- data/lib/google_apps/atom/export.rb +4 -1
- data/lib/google_apps/atom/group.rb +1 -24
- data/lib/google_apps/atom/group_member.rb +1 -11
- data/lib/google_apps/atom/nickname.rb +18 -88
- data/lib/google_apps/atom/public_key.rb +6 -10
- data/lib/google_apps/atom/user.rb +1 -31
- data/lib/google_apps/transport.rb +93 -46
- metadata +24 -33
@@ -38,8 +38,8 @@ module GoogleApps
|
|
38
38
|
|
39
39
|
CATEGORY = {
|
40
40
|
user: [['scheme', 'http://schemas.google.com/g/2005#kind'], ['term', 'http://schemas.google.com/apps/2006#user']],
|
41
|
-
nickname: [['scheme', 'http://schemas.google.com/g/2005#kind'], ['term', 'http://schemas.google.com/apps/2006#nickname']]
|
42
|
-
group: [['scheme', 'http://schemas.google.com/g/2005#kind'], ['term', 'http://schemas.google.com/apps/2006#group']]
|
41
|
+
nickname: [['scheme', 'http://schemas.google.com/g/2005#kind'], ['term', 'http://schemas.google.com/apps/2006#nickname']]
|
42
|
+
#group: [['scheme', 'http://schemas.google.com/g/2005#kind'], ['term', 'http://schemas.google.com/apps/2006#group']]
|
43
43
|
}
|
44
44
|
|
45
45
|
ENTRY_TAG = ["<atom:entry xmlns:atom=\"#{NAMESPACES[:atom]}\" xmlns:apps=\"#{NAMESPACES[:apps]}\" xmlns:gd=\"#{NAMESPACES[:gd]}\">", '</atom:entry>']
|
@@ -36,6 +36,84 @@ module GoogleApps
|
|
36
36
|
def new_empty_doc
|
37
37
|
Atom::XML::Document.new
|
38
38
|
end
|
39
|
+
|
40
|
+
|
41
|
+
# find_values searches @document and assigns any values
|
42
|
+
# to their corresponding instance variables. This is
|
43
|
+
# useful when we've been given a string of XML and need
|
44
|
+
# internal consistency in the object.
|
45
|
+
#
|
46
|
+
# find_values
|
47
|
+
def find_values # Moved from User and Group, causing segfault but only at odd times
|
48
|
+
map_key = self.class.to_s.split(':').last.downcase.to_sym
|
49
|
+
map = Atom::MAPS[map_key]
|
50
|
+
|
51
|
+
@document.root.each do |entry|
|
52
|
+
unless entry.name.match 'gd' or entry.name.match 'atom' or entry.name.match 'openSearch'
|
53
|
+
entry.attributes.each do |attribute|
|
54
|
+
instance_variable_set "@#{map[attribute.name.to_sym]}", check_value(attribute.value)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
# build_root creates the shared root structure for the
|
62
|
+
# document.
|
63
|
+
#
|
64
|
+
# build_root
|
65
|
+
#
|
66
|
+
# build_root returns an atom:entry node with an
|
67
|
+
# apps:category element appropriate for the document
|
68
|
+
# type.
|
69
|
+
def build_root
|
70
|
+
root = create_node(type: 'atom:entry')
|
71
|
+
|
72
|
+
add_namespaces root, determine_namespaces
|
73
|
+
root << create_node(type: 'apps:category', attrs: Atom::CATEGORY[type_to_sym]) if Atom::CATEGORY[type_to_sym]
|
74
|
+
|
75
|
+
root
|
76
|
+
end
|
77
|
+
|
78
|
+
|
79
|
+
# type_to_s returns the current document's type as a
|
80
|
+
# string.
|
81
|
+
#
|
82
|
+
# type_to_s
|
83
|
+
#
|
84
|
+
# type_to_s returns a string
|
85
|
+
def type_to_s
|
86
|
+
self.class.to_s.split(':').last.downcase
|
87
|
+
end
|
88
|
+
|
89
|
+
|
90
|
+
# type_to_sym returns the current document's type as a
|
91
|
+
# symbol.
|
92
|
+
#
|
93
|
+
# type_to_sym
|
94
|
+
#
|
95
|
+
# type_to_sym returns a symbol
|
96
|
+
def type_to_sym
|
97
|
+
type_to_s.to_sym
|
98
|
+
end
|
99
|
+
|
100
|
+
|
101
|
+
# determine_namespaces builds a hash of namespace key/value
|
102
|
+
# pairs.
|
103
|
+
#
|
104
|
+
# determine_namespaces
|
105
|
+
#
|
106
|
+
# determine_namespaces returns a hash
|
107
|
+
def determine_namespaces
|
108
|
+
ns = { atom: Atom::NAMESPACES[:atom], apps: Atom::NAMESPACES[:apps] }
|
109
|
+
|
110
|
+
case type_to_s
|
111
|
+
when 'group', 'groupmember'
|
112
|
+
ns[:gd] = Atom::NAMESPACES[:gd]
|
113
|
+
end
|
114
|
+
|
115
|
+
ns
|
116
|
+
end
|
39
117
|
end
|
40
118
|
end
|
41
119
|
end
|
@@ -1,12 +1,15 @@
|
|
1
1
|
module GoogleApps
|
2
2
|
module Atom
|
3
3
|
class Export
|
4
|
+
include Atom::Node
|
5
|
+
include Atom::Document
|
6
|
+
|
4
7
|
HEADER = 'HEADER_ONLY'
|
5
8
|
FULL = 'FULL_MESSAGE'
|
6
9
|
|
7
10
|
def initialize
|
8
11
|
@document = Atom::XML::Document.new
|
9
|
-
|
12
|
+
@document.root = build_root
|
10
13
|
end
|
11
14
|
|
12
15
|
# to_s returns @document as a string.
|
@@ -11,7 +11,7 @@ module GoogleApps
|
|
11
11
|
@document = parse(xml)
|
12
12
|
else
|
13
13
|
@document = Atom::XML::Document.new
|
14
|
-
|
14
|
+
@document.root = build_root
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -56,29 +56,6 @@ module GoogleApps
|
|
56
56
|
|
57
57
|
private
|
58
58
|
|
59
|
-
# add_header sets the required boilerplate for a
|
60
|
-
# Google Apps group.
|
61
|
-
def add_header
|
62
|
-
@document.root = Atom::XML::Node.new('atom:entry')
|
63
|
-
|
64
|
-
Atom::XML::Namespace.new(@document.root, 'atom', 'http://www.w3.org/2005/Atom')
|
65
|
-
Atom::XML::Namespace.new(@document.root, 'apps', 'http://schemas.google.com/apps/2006')
|
66
|
-
Atom::XML::Namespace.new(@document.root, 'gd', 'http://schemas.google.com/g/2005')
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
|
-
def find_values
|
71
|
-
map = Atom::MAPS[:user]
|
72
|
-
|
73
|
-
@document.root.each do |entry|
|
74
|
-
unless entry.name.match 'gd' or entry.name.match 'atom'
|
75
|
-
entry.attributes.each do |attribute|
|
76
|
-
instance_variable_set "@#{map[attribute.name.to_sym]}", check_value(attribute.value)
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
59
|
|
83
60
|
def check_value(value)
|
84
61
|
case value
|
@@ -8,7 +8,7 @@ module GoogleApps
|
|
8
8
|
|
9
9
|
def initialize
|
10
10
|
@document = Atom::XML::Document.new
|
11
|
-
|
11
|
+
@document.root = build_root
|
12
12
|
end
|
13
13
|
|
14
14
|
|
@@ -69,16 +69,6 @@ module GoogleApps
|
|
69
69
|
def parse_doc(document = @document)
|
70
70
|
Atom::XML::Parser.document(document).parse
|
71
71
|
end
|
72
|
-
|
73
|
-
|
74
|
-
# add_header sets the root element of @document
|
75
|
-
def add_header
|
76
|
-
@document.root = Atom::XML::Node.new('atom:entry')
|
77
|
-
|
78
|
-
Atom::XML::Namespace.new(@document.root, 'atom', 'http://www.w3.org/2005/Atom')
|
79
|
-
Atom::XML::Namespace.new(@document.root, 'apps', 'http://schemas.google.com/apps/2006')
|
80
|
-
Atom::XML::Namespace.new(@document.root, 'gd', 'http://schemas.google.com/g/2005')
|
81
|
-
end
|
82
72
|
end
|
83
73
|
end
|
84
74
|
end
|
@@ -10,8 +10,7 @@ module GoogleApps
|
|
10
10
|
|
11
11
|
def initialize
|
12
12
|
@document = Atom::XML::Document.new
|
13
|
-
@document.root =
|
14
|
-
@document.root << category
|
13
|
+
@document.root = build_root
|
15
14
|
end
|
16
15
|
|
17
16
|
# nickname= sets the nickname value on the object and in the
|
@@ -21,7 +20,9 @@ module GoogleApps
|
|
21
20
|
#
|
22
21
|
# nickname= returns the new nickname value
|
23
22
|
def nickname=(nick)
|
24
|
-
@nickname
|
23
|
+
@nickname ? find_and_update(@document, '//apps:nickname', name: [@nickname, nick]) : create('nickname', nick)
|
24
|
+
|
25
|
+
@nickname = nick
|
25
26
|
end
|
26
27
|
|
27
28
|
|
@@ -33,7 +34,9 @@ module GoogleApps
|
|
33
34
|
#
|
34
35
|
# user= returns the new username value
|
35
36
|
def user=(username)
|
36
|
-
@user
|
37
|
+
@user ? find_and_update(@document, '//apps:login', userName: [@user, username]) : create('login', username)
|
38
|
+
|
39
|
+
@user = username
|
37
40
|
end
|
38
41
|
|
39
42
|
|
@@ -47,94 +50,21 @@ module GoogleApps
|
|
47
50
|
private
|
48
51
|
|
49
52
|
|
50
|
-
#
|
51
|
-
#
|
52
|
-
def header
|
53
|
-
add_namespaces create_node(type: 'atom:entry'), atom: 'http://www.w3.org/2005/Atom', apps: 'http://schemas.google.com/apps/2006'
|
54
|
-
end
|
55
|
-
|
56
|
-
|
57
|
-
# category constructs an atom:category node with the
|
58
|
-
# appropriate attributes for a GoogleApps nickname
|
59
|
-
# document.
|
60
|
-
def category
|
61
|
-
create_node type: 'atom:category', attrs: Atom::CATEGORY[:nickname]
|
62
|
-
end
|
63
|
-
|
64
|
-
|
65
|
-
# set_nickname adds an apps:nickname node to the
|
66
|
-
# underlying XML document and sets @nickname.
|
67
|
-
# It takes a nickname in string form for its
|
68
|
-
# argument.
|
53
|
+
# create adds the specified node to @document. It takes
|
54
|
+
# a type and a value as arguments.
|
69
55
|
#
|
70
|
-
#
|
56
|
+
# create 'nickname', 'Bob'
|
71
57
|
#
|
72
|
-
#
|
73
|
-
def
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
# set_user adds an apps:login node to the underlying
|
81
|
-
# XML document and sets @user. It takes a username
|
82
|
-
# (current/default username) in string form for its
|
83
|
-
# argument.
|
84
|
-
#
|
85
|
-
# set_user 'bob'
|
86
|
-
#
|
87
|
-
# set_user returns the new user value.
|
88
|
-
def set_user(username)
|
89
|
-
@document.root << create_node(type: 'apps:login', attrs: [['userName', username]])
|
90
|
-
|
91
|
-
@user = username
|
92
|
-
end
|
93
|
-
|
94
|
-
|
95
|
-
# change_nickname changes the name attribute for the
|
96
|
-
# apps:nickname node in the underlying XML document.
|
97
|
-
# It takes a nickname in string form.
|
98
|
-
#
|
99
|
-
# change_nickname 'Timmy'
|
100
|
-
#
|
101
|
-
# change_nickname returns the new nickname.
|
102
|
-
def change_nickname(nick)
|
103
|
-
@document.root.each do |node|
|
104
|
-
node.attributes['name'] = nick if node.attributes['name'] == @nickname
|
58
|
+
# create returns a parsed copy of the document.
|
59
|
+
def create(type, value)
|
60
|
+
case type
|
61
|
+
when 'nickname'
|
62
|
+
@document.root << create_node(type: 'apps:nickname', attrs: [['name', value]])
|
63
|
+
when 'login'
|
64
|
+
@document.root << create_node(type: 'apps:login', attrs: [['userName', value]])
|
105
65
|
end
|
106
66
|
|
107
|
-
@
|
108
|
-
end
|
109
|
-
|
110
|
-
|
111
|
-
# change_user changes the userName attribute for the
|
112
|
-
# apps:login node in the underlying XML document. It
|
113
|
-
# takes a username (Email format) in string form.
|
114
|
-
#
|
115
|
-
# change_user 'bob@work.com'
|
116
|
-
#
|
117
|
-
# change_user returns the new user value.
|
118
|
-
def change_user(username)
|
119
|
-
@document.root.each do |node|
|
120
|
-
node.attributes['userName'] = username if node.attributes['userName'] == @user
|
121
|
-
end
|
122
|
-
|
123
|
-
@user = username
|
124
|
-
end
|
125
|
-
|
126
|
-
# :nodoc:
|
127
|
-
def change_element(type, value)
|
128
|
-
@document.root.each do |node|
|
129
|
-
node.attributes[ELEMENTS[type][1]] = value
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
|
134
|
-
# parse_document takes an XML document and returns
|
135
|
-
# a parsed copy of that document.
|
136
|
-
def parse_document(document = @document)
|
137
|
-
Atom::XML::Parser.document(document).parse
|
67
|
+
@document = parse @document
|
138
68
|
end
|
139
69
|
end
|
140
70
|
end
|
@@ -1,9 +1,14 @@
|
|
1
1
|
module GoogleApps
|
2
2
|
module Atom
|
3
3
|
class PublicKey
|
4
|
+
include Atom::Node
|
5
|
+
include Atom::Document
|
6
|
+
|
7
|
+
attr_reader :document
|
8
|
+
|
4
9
|
def initialize
|
5
10
|
@document = Atom::XML::Document.new
|
6
|
-
|
11
|
+
@document.root = build_root
|
7
12
|
end
|
8
13
|
|
9
14
|
# new_key adds the actual key to the PublicKey
|
@@ -24,15 +29,6 @@ module GoogleApps
|
|
24
29
|
def to_s
|
25
30
|
@document.to_s
|
26
31
|
end
|
27
|
-
|
28
|
-
private
|
29
|
-
|
30
|
-
def add_header
|
31
|
-
@document.root = Atom::XML::Node.new('atom:entry')
|
32
|
-
|
33
|
-
Atom::XML::Namespace.new(@document.root, 'atom', 'http://www.w3.org/2005/Atom')
|
34
|
-
Atom::XML::Namespace.new(@document.root, 'apps', 'http://schemas.google.com/apps/2006')
|
35
|
-
end
|
36
32
|
end
|
37
33
|
end
|
38
34
|
end
|
@@ -14,7 +14,7 @@ module GoogleApps
|
|
14
14
|
find_values
|
15
15
|
else
|
16
16
|
@document = new_empty_doc
|
17
|
-
|
17
|
+
@document.root = build_root
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
@@ -166,22 +166,6 @@ module GoogleApps
|
|
166
166
|
end
|
167
167
|
|
168
168
|
|
169
|
-
# TODO: This needs to target the proper nodes.
|
170
|
-
# TODO: This needs to treat 'true' and 'false' properly
|
171
|
-
def find_values
|
172
|
-
map = Atom::MAPS[:user]
|
173
|
-
|
174
|
-
@document.root.each do |entry|
|
175
|
-
# Something in the feedLink entries causes a segfault.
|
176
|
-
unless entry.name.match 'gd' or entry.name.match 'atom'
|
177
|
-
entry.attributes.each do |attribute|
|
178
|
-
instance_variable_set "@#{map[attribute.name.to_sym]}", check_value(attribute.value)
|
179
|
-
end
|
180
|
-
end
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
|
185
169
|
def check_value(value)
|
186
170
|
case value
|
187
171
|
when 'true'
|
@@ -192,20 +176,6 @@ module GoogleApps
|
|
192
176
|
value
|
193
177
|
end
|
194
178
|
end
|
195
|
-
|
196
|
-
|
197
|
-
def add_header
|
198
|
-
@document.root = Atom::XML::Node.new('atom:entry')
|
199
|
-
|
200
|
-
Atom::XML::Namespace.new(@document.root, 'atom', 'http://www.w3.org/2005/Atom')
|
201
|
-
Atom::XML::Namespace.new(@document.root, 'apps', 'http://schemas.google.com/apps/2006')
|
202
|
-
|
203
|
-
category = Atom::XML::Node.new('atom:category')
|
204
|
-
category.attributes['scheme'] = 'http://schemas.google.com/g/2005#kind'
|
205
|
-
category.attributes['term'] = 'http://schemas.google.com/apps/2006#user'
|
206
|
-
|
207
|
-
@document.root << category
|
208
|
-
end
|
209
179
|
end
|
210
180
|
end
|
211
181
|
end
|
@@ -4,9 +4,9 @@ require 'openssl'
|
|
4
4
|
require 'rexml/document'
|
5
5
|
|
6
6
|
module GoogleApps
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
class Transport
|
8
|
+
attr_reader :request, :response, :domain, :feeds
|
9
|
+
attr_accessor :auth, :user, :group, :nickname, :export
|
10
10
|
|
11
11
|
BOUNDARY = "=AaB03xDFHT8xgg"
|
12
12
|
PAGE_SIZE = {
|
@@ -14,20 +14,20 @@ module GoogleApps
|
|
14
14
|
group: 200
|
15
15
|
}
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
17
|
+
def initialize(domain, targets = {})
|
18
|
+
@auth = targets[:auth] || "https://www.google.com/accounts/ClientLogin"
|
19
|
+
@user = targets[:user] || "https://apps-apis.google.com/a/feeds/#{domain}/user/2.0"
|
20
20
|
@pubkey = targets[:pubkey] || "https://apps-apis.google.com/a/feeds/compliance/audit/publickey/#{domain}"
|
21
21
|
@migration = targets[:migration] || "https://apps-apis.google.com/a/feeds/migration/2.0/#{domain}"
|
22
|
-
|
23
|
-
|
22
|
+
@group = targets[:group] || "https://apps-apis.google.com/a/feeds/group/2.0/#{domain}"
|
23
|
+
@nickname = targets[:nickname] || "https://apps-apis.google.com/a/feeds/#{domain}/nickname/2.0"
|
24
24
|
@export = targets[:export] || "https://apps-apis.google.com/a/feeds/compliance/audit/mail/export/#{domain}"
|
25
25
|
@domain = domain
|
26
|
-
|
27
|
-
|
28
|
-
|
26
|
+
@token = nil
|
27
|
+
@response = nil
|
28
|
+
@request = nil
|
29
29
|
@feeds = []
|
30
|
-
|
30
|
+
end
|
31
31
|
|
32
32
|
|
33
33
|
# authenticate will take the provided account and
|
@@ -38,18 +38,18 @@ module GoogleApps
|
|
38
38
|
#
|
39
39
|
# authenticate returns the HTTP response received
|
40
40
|
# from Google
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
41
|
+
def authenticate(account, pass)
|
42
|
+
uri = URI(@auth)
|
43
|
+
@request = Net::HTTP::Post.new(uri.path)
|
44
|
+
@request.body = auth_body(account, pass)
|
45
|
+
set_headers :auth
|
46
46
|
|
47
|
-
|
47
|
+
@response = request uri
|
48
48
|
|
49
|
-
|
49
|
+
set_auth_token
|
50
50
|
|
51
51
|
@response
|
52
|
-
|
52
|
+
end
|
53
53
|
|
54
54
|
# request_export performs the GoogleApps API call to
|
55
55
|
# generate a mailbox export. It takes the username
|
@@ -131,17 +131,41 @@ module GoogleApps
|
|
131
131
|
#
|
132
132
|
# get_users returns the final response from google.
|
133
133
|
def get_users(options = {})
|
134
|
-
|
134
|
+
get_all :users, options
|
135
|
+
end
|
136
|
+
|
137
|
+
|
138
|
+
# get_groups retrieves all the groups from the domain
|
139
|
+
#
|
140
|
+
# get_groups
|
141
|
+
#
|
142
|
+
# get_groups returns the final response from Google.
|
143
|
+
def get_groups(options = {})
|
144
|
+
get_all :groups, options
|
145
|
+
end
|
146
|
+
|
147
|
+
|
148
|
+
# get_all retrieves a batch of records of the specified type
|
149
|
+
# from google. You must specify the type of object you want
|
150
|
+
# to retreive. You can also specify a start point and a limit.
|
151
|
+
#
|
152
|
+
# get_all 'users', start: 'lholcomb2', limit: 300
|
153
|
+
#
|
154
|
+
# get_all returns the HTTP response received from Google.
|
155
|
+
def get_all(type, options = {})
|
156
|
+
@feeds, current_page = [], 0
|
157
|
+
type = type.to_s
|
158
|
+
type.gsub!(/\w*s$/) { |match| match[0..-2] }
|
135
159
|
|
136
160
|
options[:limit] ? limit = options[:limit] : limit = 1000000
|
137
|
-
options[:start] ? get(
|
161
|
+
options[:start] ? get(instance_variable_get("@#{type}") + "?#{start_query(type)}=#{options[:start]}") : get(instance_variable_get("@#{type}"))
|
138
162
|
|
139
163
|
add_feed
|
140
|
-
|
164
|
+
current_page += 1
|
141
165
|
|
142
|
-
while (@feeds.last.next_page) and (
|
166
|
+
while (@feeds.last.next_page) and (current_page * PAGE_SIZE[:user] < limit)
|
143
167
|
get_next_page
|
144
|
-
|
168
|
+
current_page += 1
|
145
169
|
end
|
146
170
|
|
147
171
|
@response
|
@@ -171,6 +195,17 @@ module GoogleApps
|
|
171
195
|
end
|
172
196
|
|
173
197
|
|
198
|
+
# get_nicknames_for retrieves all the nicknames associated
|
199
|
+
# with the requested user. It takes the username as a string.
|
200
|
+
#
|
201
|
+
# get_nickname_for 'lholcomb2'
|
202
|
+
#
|
203
|
+
# get_nickname_for returns the HTTP response from Google
|
204
|
+
def get_nicknames_for(login)
|
205
|
+
get_nickname "?username=#{login}"
|
206
|
+
end
|
207
|
+
|
208
|
+
|
174
209
|
# add is a generic target for method_missing. It is
|
175
210
|
# intended to handle the general case of adding
|
176
211
|
# to the GoogleApps Domain. It takes an API endpoint
|
@@ -179,14 +214,14 @@ module GoogleApps
|
|
179
214
|
# add 'endpoint', document
|
180
215
|
#
|
181
216
|
# add returns the HTTP response received from Google.
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
217
|
+
def add(endpoint, document)
|
218
|
+
uri = URI(endpoint)
|
219
|
+
@request = Net::HTTP::Post.new(uri.path)
|
220
|
+
@request.body = document.to_s
|
221
|
+
set_headers :user
|
187
222
|
|
188
|
-
|
189
|
-
|
223
|
+
@response = request uri
|
224
|
+
end
|
190
225
|
|
191
226
|
# update is a generic target for method_missing. It is
|
192
227
|
# intended to handle the general case of updating an
|
@@ -243,27 +278,26 @@ module GoogleApps
|
|
243
278
|
|
244
279
|
# TODO: This should perform the instance_variable_get and pass the value to the appropriate method.
|
245
280
|
def method_missing(name, *args)
|
246
|
-
|
281
|
+
super unless name.match /([a-z]*)_([a-z]*)/
|
247
282
|
|
248
283
|
case $1
|
249
|
-
when "new"
|
250
|
-
|
284
|
+
when "new", "add"
|
285
|
+
self.send(:add, instance_variable_get("@#{$2}"), *args)
|
251
286
|
when "delete"
|
252
287
|
self.send(:delete, instance_variable_get("@#{$2}"), *args)
|
253
288
|
when "update"
|
254
289
|
self.send(:update, instance_variable_get("@#{$2}"), *args)
|
255
290
|
when "get"
|
256
291
|
self.send(:get, instance_variable_get("@#{$2}"), *args)
|
257
|
-
when "add"
|
258
|
-
self.send(:add, instance_variable_get("@#{$2}"), *args)
|
259
292
|
else
|
260
|
-
|
293
|
+
super
|
261
294
|
end
|
262
295
|
end
|
263
296
|
|
264
297
|
|
265
298
|
private
|
266
299
|
|
300
|
+
|
267
301
|
# auth_body generates the body for the authentication
|
268
302
|
# request made by authenticate.
|
269
303
|
#
|
@@ -298,20 +332,33 @@ module GoogleApps
|
|
298
332
|
end
|
299
333
|
|
300
334
|
|
335
|
+
# start_query builds the value for the starting point
|
336
|
+
# query string used for retrieving batches of objects
|
337
|
+
# from Google.
|
338
|
+
def start_query(type)
|
339
|
+
case type
|
340
|
+
when 'user'
|
341
|
+
"startUsername"
|
342
|
+
when 'group'
|
343
|
+
"startGroup"
|
344
|
+
end
|
345
|
+
end
|
346
|
+
|
347
|
+
|
301
348
|
# add_feed adds a feed to the @feeds array.
|
302
349
|
def add_feed
|
303
350
|
@feeds << GoogleApps::Atom.feed(@response.body)
|
304
351
|
end
|
305
352
|
|
306
353
|
|
307
|
-
|
354
|
+
def request(uri)
|
308
355
|
# TODO: Clashes with @request reader
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
356
|
+
Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
|
357
|
+
http.request(@request)
|
358
|
+
end
|
359
|
+
end
|
313
360
|
|
314
|
-
|
361
|
+
def set_headers(request_type)
|
315
362
|
case request_type
|
316
363
|
when :auth
|
317
364
|
@request['content-type'] = "application/x-www-form-urlencoded"
|
@@ -322,7 +369,7 @@ module GoogleApps
|
|
322
369
|
@request['content-type'] = "application/atom+xml"
|
323
370
|
@request['authorization'] = "GoogleLogin auth=#{@token}"
|
324
371
|
end
|
325
|
-
|
372
|
+
end
|
326
373
|
|
327
374
|
def multi_part(properties, message)
|
328
375
|
post_body = []
|
@@ -336,5 +383,5 @@ module GoogleApps
|
|
336
383
|
|
337
384
|
post_body.join
|
338
385
|
end
|
339
|
-
|
386
|
+
end
|
340
387
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: google_apps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-07-
|
12
|
+
date: 2012-07-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: libxml-ruby
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,41 +21,32 @@ dependencies:
|
|
21
21
|
version: 2.2.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 2.2.2
|
25
30
|
description: Library for interfacing with Google Apps' Domain and Application APIs
|
26
31
|
email:
|
27
32
|
executables: []
|
28
33
|
extensions: []
|
29
34
|
extra_rdoc_files: []
|
30
35
|
files:
|
31
|
-
-
|
32
|
-
|
33
|
-
-
|
34
|
-
|
35
|
-
-
|
36
|
-
|
37
|
-
-
|
38
|
-
|
39
|
-
-
|
40
|
-
|
41
|
-
-
|
42
|
-
|
43
|
-
-
|
44
|
-
|
45
|
-
- !binary |-
|
46
|
-
bGliL2dvb2dsZV9hcHBzL2F0b20vbWVzc2FnZV9hdHRyaWJ1dGVzLnJi
|
47
|
-
- !binary |-
|
48
|
-
bGliL2dvb2dsZV9hcHBzL2F0b20vbmlja25hbWUucmI=
|
49
|
-
- !binary |-
|
50
|
-
bGliL2dvb2dsZV9hcHBzL2F0b20vbm9kZS5yYg==
|
51
|
-
- !binary |-
|
52
|
-
bGliL2dvb2dsZV9hcHBzL2F0b20vcHVibGljX2tleS5yYg==
|
53
|
-
- !binary |-
|
54
|
-
bGliL2dvb2dsZV9hcHBzL2F0b20vdXNlci5yYg==
|
55
|
-
- !binary |-
|
56
|
-
bGliL2dvb2dsZV9hcHBzL3RyYW5zcG9ydC5yYg==
|
57
|
-
- !binary |-
|
58
|
-
bGliL2dvb2dsZV9hcHBzLnJi
|
36
|
+
- lib/google_apps/atom/atom.rb
|
37
|
+
- lib/google_apps/atom/document.rb
|
38
|
+
- lib/google_apps/atom/export.rb
|
39
|
+
- lib/google_apps/atom/feed.rb
|
40
|
+
- lib/google_apps/atom/group.rb
|
41
|
+
- lib/google_apps/atom/group_member.rb
|
42
|
+
- lib/google_apps/atom/message.rb
|
43
|
+
- lib/google_apps/atom/message_attributes.rb
|
44
|
+
- lib/google_apps/atom/nickname.rb
|
45
|
+
- lib/google_apps/atom/node.rb
|
46
|
+
- lib/google_apps/atom/public_key.rb
|
47
|
+
- lib/google_apps/atom/user.rb
|
48
|
+
- lib/google_apps/transport.rb
|
49
|
+
- lib/google_apps.rb
|
59
50
|
homepage: https://github.com/LeakyBucket/google_apps
|
60
51
|
licenses: []
|
61
52
|
post_install_message:
|
@@ -76,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
67
|
version: '0'
|
77
68
|
requirements: []
|
78
69
|
rubyforge_project:
|
79
|
-
rubygems_version: 1.8.
|
70
|
+
rubygems_version: 1.8.23
|
80
71
|
signing_key:
|
81
72
|
specification_version: 3
|
82
73
|
summary: Google Apps APIs
|