gam7 7.3.4__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of gam7 might be problematic. Click here for more details.

Files changed (72) hide show
  1. gam/__init__.py +77555 -0
  2. gam/__main__.py +40 -0
  3. gam/atom/__init__.py +1460 -0
  4. gam/atom/auth.py +41 -0
  5. gam/atom/client.py +214 -0
  6. gam/atom/core.py +535 -0
  7. gam/atom/data.py +327 -0
  8. gam/atom/http.py +354 -0
  9. gam/atom/http_core.py +599 -0
  10. gam/atom/http_interface.py +144 -0
  11. gam/atom/mock_http.py +123 -0
  12. gam/atom/mock_http_core.py +313 -0
  13. gam/atom/mock_service.py +235 -0
  14. gam/atom/service.py +723 -0
  15. gam/atom/token_store.py +105 -0
  16. gam/atom/url.py +130 -0
  17. gam/cacerts.pem +1130 -0
  18. gam/cbcm-v1.1beta1.json +593 -0
  19. gam/contactdelegation-v1.json +249 -0
  20. gam/datastudio-v1.json +486 -0
  21. gam/gamlib/__init__.py +17 -0
  22. gam/gamlib/glaction.py +308 -0
  23. gam/gamlib/glapi.py +837 -0
  24. gam/gamlib/glcfg.py +616 -0
  25. gam/gamlib/glclargs.py +1184 -0
  26. gam/gamlib/glentity.py +831 -0
  27. gam/gamlib/glgapi.py +817 -0
  28. gam/gamlib/glgdata.py +98 -0
  29. gam/gamlib/glglobals.py +307 -0
  30. gam/gamlib/glindent.py +46 -0
  31. gam/gamlib/glmsgs.py +547 -0
  32. gam/gamlib/glskus.py +246 -0
  33. gam/gamlib/gluprop.py +279 -0
  34. gam/gamlib/glverlibs.py +33 -0
  35. gam/gamlib/yubikey.py +202 -0
  36. gam/gdata/__init__.py +825 -0
  37. gam/gdata/alt/__init__.py +20 -0
  38. gam/gdata/alt/app_engine.py +101 -0
  39. gam/gdata/alt/appengine.py +321 -0
  40. gam/gdata/apps/__init__.py +526 -0
  41. gam/gdata/apps/audit/__init__.py +1 -0
  42. gam/gdata/apps/audit/service.py +278 -0
  43. gam/gdata/apps/contacts/__init__.py +874 -0
  44. gam/gdata/apps/contacts/service.py +355 -0
  45. gam/gdata/apps/service.py +544 -0
  46. gam/gdata/apps/sites/__init__.py +283 -0
  47. gam/gdata/apps/sites/service.py +246 -0
  48. gam/gdata/service.py +1714 -0
  49. gam/gdata/urlfetch.py +247 -0
  50. gam/googleapiclient/__init__.py +27 -0
  51. gam/googleapiclient/_auth.py +167 -0
  52. gam/googleapiclient/_helpers.py +207 -0
  53. gam/googleapiclient/channel.py +315 -0
  54. gam/googleapiclient/discovery.py +1662 -0
  55. gam/googleapiclient/discovery_cache/__init__.py +78 -0
  56. gam/googleapiclient/discovery_cache/appengine_memcache.py +55 -0
  57. gam/googleapiclient/discovery_cache/base.py +46 -0
  58. gam/googleapiclient/discovery_cache/file_cache.py +145 -0
  59. gam/googleapiclient/errors.py +197 -0
  60. gam/googleapiclient/http.py +1962 -0
  61. gam/googleapiclient/mimeparse.py +183 -0
  62. gam/googleapiclient/model.py +429 -0
  63. gam/googleapiclient/schema.py +317 -0
  64. gam/googleapiclient/version.py +15 -0
  65. gam/iso8601/__init__.py +28 -0
  66. gam/iso8601/iso8601.py +160 -0
  67. gam/serviceaccountlookup-v1.json +141 -0
  68. gam/six.py +982 -0
  69. gam7-7.3.4.dist-info/METADATA +69 -0
  70. gam7-7.3.4.dist-info/RECORD +72 -0
  71. gam7-7.3.4.dist-info/WHEEL +4 -0
  72. gam7-7.3.4.dist-info/licenses/LICENSE +201 -0
@@ -0,0 +1,355 @@
1
+ #!/usr/bin/env python
2
+ #
3
+ # Copyright 2009 Google Inc. All Rights Reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ """ContactsService extends the GDataService for Google Contacts operations.
18
+
19
+ ContactsService: Provides methods to query feeds and manipulate items.
20
+ Extends GDataService.
21
+ """
22
+
23
+
24
+ import gdata.apps
25
+ import gdata.apps.service
26
+ import gdata.service
27
+
28
+
29
+ class ContactsService(gdata.service.GDataService):
30
+ """Client for the Google Contacts service."""
31
+
32
+ def __init__(self, email=None, password=None, source=None,
33
+ server='www.google.com', additional_headers=None,
34
+ contact_list='default', contactFeed=True, **kwargs):
35
+ """Creates a client for the Contacts service.
36
+
37
+ Args:
38
+ email: string (optional) The user's email address, used for
39
+ authentication.
40
+ password: string (optional) The user's password.
41
+ source: string (optional) The name of the user's application.
42
+ server: string (optional) The name of the server to which a connection
43
+ will be opened. Default value: 'www.google.com'.
44
+ contact_list: string (optional) The name of the default contact list to
45
+ use when no URI is specified to the methods of the service.
46
+ Default value: 'default' (the logged in user's contact list).
47
+ contactFeed: Boolean (optional) Is this contacts feed or a gal feed
48
+ Default value: True (the logged in user's contact list).
49
+ **kwargs: The other parameters to pass to gdata.service.GDataService
50
+ constructor.
51
+ """
52
+
53
+ self.contact_list = contact_list
54
+ self.feed_type = ['gal', 'contacts'][contactFeed]
55
+ if additional_headers == None:
56
+ additional_headers = {}
57
+ additional_headers['GData-Version'] = ['1.1', '3.1'][contactFeed]
58
+ gdata.service.GDataService.__init__(self,
59
+ email=email, password=password, service='cp', source=source,
60
+ server=server, additional_headers=additional_headers, **kwargs)
61
+ self.ssl = True
62
+ self.port = 443
63
+
64
+ def _CleanUri(self, uri):
65
+ """Sanitizes a feed URI.
66
+
67
+ Args:
68
+ uri: The URI to sanitize, can be relative or absolute.
69
+
70
+ Returns:
71
+ The given URI without its https://server prefix, if any.
72
+ Keeps the leading slash of the URI.
73
+ """
74
+ url_prefix = 'https://%s' % self.server
75
+ if uri.startswith(url_prefix):
76
+ uri = uri[len(url_prefix):]
77
+ return uri
78
+
79
+ def GetContactFeedUri(self, contact_list=None, projection='full', contactId=None):
80
+ """Builds a contact feed URI. """
81
+ contact_list = contact_list or self.contact_list
82
+ uri = 'https://{0}/m8/feeds/{1}/{2}/{3}'.format(self.server, self.feed_type, contact_list, projection)
83
+ if contactId:
84
+ uri += '/{0}'.format(contactId)
85
+ return uri
86
+
87
+ def GetContactsFeed(self, uri=None,
88
+ extra_headers=None, url_params=None, escape_params=True):
89
+ uri = uri or self.GetContactFeedUri()
90
+ try:
91
+ return self.Get(uri,
92
+ url_params=url_params, extra_headers=extra_headers, escape_params=escape_params,
93
+ converter=gdata.apps.contacts.ContactsFeedFromString)
94
+ except gdata.service.RequestError as e:
95
+ raise gdata.apps.service.AppsForYourDomainException(e.args[0])
96
+
97
+ def GetContact(self, uri):
98
+ try:
99
+ return self.Get(uri, converter=gdata.apps.contacts.ContactEntryFromString)
100
+ except gdata.service.RequestError as e:
101
+ raise gdata.apps.service.AppsForYourDomainException(e.args[0])
102
+
103
+ def CreateContact(self, new_contact, insert_uri=None, url_params=None,
104
+ escape_params=True):
105
+ """Adds an new contact to Google Contacts.
106
+
107
+ Args:
108
+ new_contact: atom.Entry or subclass A new contact which is to be added to
109
+ Google Contacts.
110
+ insert_uri: the URL to post new contacts to the feed
111
+ url_params: dict (optional) Additional URL parameters to be included
112
+ in the insertion request.
113
+ escape_params: boolean (optional) If true, the url_parameters will be
114
+ escaped before they are included in the request.
115
+
116
+ Returns:
117
+ On successful insert, an entry containing the contact created
118
+ On failure, a RequestError is raised of the form:
119
+ {'status': HTTP status code from server,
120
+ 'reason': HTTP reason from the server,
121
+ 'body': HTTP body of the server's response}
122
+ """
123
+ insert_uri = insert_uri or self.GetContactFeedUri()
124
+ try:
125
+ return self.Post(new_contact, insert_uri, url_params=url_params,
126
+ escape_params=escape_params,
127
+ converter=gdata.apps.contacts.ContactEntryFromString)
128
+ except gdata.service.RequestError as e:
129
+ raise gdata.apps.service.AppsForYourDomainException(e.args[0])
130
+
131
+ def UpdateContact(self, edit_uri, updated_contact, extra_headers=None, url_params=None,
132
+ escape_params=True):
133
+ """Updates an existing contact.
134
+
135
+ Args:
136
+ edit_uri: string The edit link URI for the element being updated
137
+ updated_contact: string, atom.Entry or subclass containing
138
+ the Atom Entry which will replace the contact which is
139
+ stored at the edit_url
140
+ url_params: dict (optional) Additional URL parameters to be included
141
+ in the update request.
142
+ escape_params: boolean (optional) If true, the url_parameters will be
143
+ escaped before they are included in the request.
144
+
145
+ Returns:
146
+ On successful update, a httplib.HTTPResponse containing the server's
147
+ response to the PUT request.
148
+ On failure, a RequestError is raised of the form:
149
+ {'status': HTTP status code from server,
150
+ 'reason': HTTP reason from the server,
151
+ 'body': HTTP body of the server's response}
152
+ """
153
+ try:
154
+ return self.Put(updated_contact, self._CleanUri(edit_uri),
155
+ url_params=url_params, extra_headers=extra_headers,
156
+ escape_params=escape_params,
157
+ converter=gdata.apps.contacts.ContactEntryFromString)
158
+ except gdata.service.RequestError as e:
159
+ raise gdata.apps.service.AppsForYourDomainException(e.args[0])
160
+
161
+ def DeleteContact(self, edit_uri, extra_headers=None,
162
+ url_params=None, escape_params=True):
163
+ """Removes an contact with the specified ID from Google Contacts.
164
+
165
+ Args:
166
+ edit_uri: string The edit URL of the entry to be deleted. Example:
167
+ '/m8/feeds/contacts/default/full/xxx/yyy'
168
+ extra_headers: dict (optional)
169
+ url_params: dict (optional) Additional URL parameters to be included
170
+ in the deletion request.
171
+ escape_params: boolean (optional) If true, the url_parameters will be
172
+ escaped before they are included in the request.
173
+
174
+ Returns:
175
+ On successful delete, a httplib.HTTPResponse containing the server's
176
+ response to the DELETE request.
177
+ On failure, a RequestError is raised of the form:
178
+ {'status': HTTP status code from server,
179
+ 'reason': HTTP reason from the server,
180
+ 'body': HTTP body of the server's response}
181
+ """
182
+ try:
183
+ return self.Delete(self._CleanUri(edit_uri),
184
+ url_params=url_params, escape_params=escape_params, extra_headers=extra_headers)
185
+ except gdata.service.RequestError as e:
186
+ raise gdata.apps.service.AppsForYourDomainException(e.args[0])
187
+
188
+ def ChangePhoto(self, media, contact_entry_or_url, content_type=None,
189
+ content_length=None, extra_headers=None):
190
+ """Change the photo for the contact by uploading a new photo.
191
+
192
+ Performs a PUT against the photo edit URL to send the binary data for the
193
+ photo.
194
+
195
+ Args:
196
+ media: filename, file-like-object, or a gdata.MediaSource object to send.
197
+ contact_entry_or_url: ContactEntry or str If it is a ContactEntry, this
198
+ method will search for an edit photo link URL and
199
+ perform a PUT to the URL.
200
+ content_type: str (optional) the mime type for the photo data. This is
201
+ necessary if media is a file or file name, but if media
202
+ is a MediaSource object then the media object can contain
203
+ the mime type. If media_type is set, it will override the
204
+ mime type in the media object.
205
+ content_length: int or str (optional) Specifying the content length is
206
+ only required if media is a file-like object. If media
207
+ is a filename, the length is determined using
208
+ os.path.getsize. If media is a MediaSource object, it is
209
+ assumed that it already contains the content length.
210
+ extra_headers: dict (optional)
211
+ """
212
+ if isinstance(contact_entry_or_url, gdata.apps.contacts.ContactEntry):
213
+ # url = contact_entry_or_url.GetPhotoEditLink().href
214
+ url = contact_entry_or_url.GetPhotoLink().href
215
+ else:
216
+ url = contact_entry_or_url
217
+ if isinstance(media, gdata.MediaSource):
218
+ payload = media
219
+ # If the media object is a file-like object, then use it as the file
220
+ # handle in the in the MediaSource.
221
+ elif hasattr(media, 'read'):
222
+ payload = gdata.MediaSource(file_handle=media,
223
+ content_type=content_type, content_length=content_length)
224
+ # Assume that the media object is a file name.
225
+ else:
226
+ payload = gdata.MediaSource(content_type=content_type,
227
+ content_length=content_length, file_path=media)
228
+ return self.Put(payload, url, extra_headers=extra_headers)
229
+
230
+ def GetPhoto(self, contact_entry_or_url):
231
+ """Retrives the binary data for the contact's profile photo as a string.
232
+
233
+ Args:
234
+ contact_entry_or_url: a gdata.apps.contacts.ContactEntry object or a string
235
+ containing the photo link's URL. If the contact entry does not
236
+ contain a photo link, the image will not be fetched and this method
237
+ will return None.
238
+ """
239
+ # TODO: add the ability to write out the binary image data to a file,
240
+ # reading and writing a chunk at a time to avoid potentially using up
241
+ # large amounts of memory.
242
+ url = None
243
+ if isinstance(contact_entry_or_url, gdata.apps.contacts.ContactEntry):
244
+ photo_link = contact_entry_or_url.GetPhotoLink()
245
+ if photo_link:
246
+ url = photo_link.href
247
+ else:
248
+ url = contact_entry_or_url
249
+ if url:
250
+ try:
251
+ return self.Get(url, converter=str)
252
+ except gdata.service.RequestError as e:
253
+ raise gdata.apps.service.AppsForYourDomainException(e.args[0])
254
+ else:
255
+ return None
256
+
257
+ def DeletePhoto(self, contact_entry_or_url, extra_headers=None):
258
+ """Deletes the contact's profile photo.
259
+
260
+ Args:
261
+ contact_entry_or_url: a gdata.apps.contacts.ContactEntry object or a string
262
+ containing the photo link's URL.
263
+ will return None.
264
+ extra_headers: dict (optional)
265
+ """
266
+ url = None
267
+ if isinstance(contact_entry_or_url, gdata.apps.contacts.ContactEntry):
268
+ # url = contact_entry_or_url.GetPhotoEditLink().href
269
+ url = contact_entry_or_url.GetPhotoLink().href
270
+ else:
271
+ url = contact_entry_or_url
272
+ if url:
273
+ self.Delete(url, extra_headers=extra_headers)
274
+
275
+ def ExecuteBatch(self, batch_feed, url,
276
+ converter=gdata.apps.contacts.ContactsFeedFromString):
277
+ """Sends a batch request feed to the server.
278
+
279
+ Args:
280
+ batch_feed: gdata.apps.contacts.ContactFeed A feed containing batch
281
+ request entries. Each entry contains the operation to be performed
282
+ on the data contained in the entry. For example an entry with an
283
+ operation type of insert will be used as if the individual entry
284
+ had been inserted.
285
+ url: str The batch URL to which these operations should be applied.
286
+ converter: Function (optional) The function used to convert the server's
287
+ response to an object. The default value is ContactsFeedFromString.
288
+
289
+ Returns:
290
+ The results of the batch request's execution on the server. If the
291
+ default converter is used, this is stored in a ContactsFeed.
292
+ """
293
+ return self.Post(batch_feed, url, converter=converter)
294
+
295
+ def GetContactGroupFeedUri(self, contact_list=None, projection='full', groupId=None):
296
+ """Builds a contact feed URI. """
297
+ contact_list = contact_list or self.contact_list
298
+ uri = 'https://{0}/m8/feeds/groups/{1}/{2}'.format(self.server, contact_list, projection)
299
+ if groupId:
300
+ uri += '/{0}'.format(groupId)
301
+ return uri
302
+
303
+ def GetGroupsFeed(self, uri=None,
304
+ extra_headers=None, url_params=None, escape_params=True):
305
+ uri = uri or self.GetContactGroupFeedUri()
306
+ try:
307
+ return self.Get(uri,
308
+ url_params=url_params, extra_headers=extra_headers, escape_params=escape_params,
309
+ converter=gdata.apps.contacts.GroupsFeedFromString)
310
+ except gdata.service.RequestError as e:
311
+ raise gdata.apps.service.AppsForYourDomainException(e.args[0])
312
+
313
+ def GetGroup(self, uri):
314
+ try:
315
+ return self.Get(uri, converter=gdata.apps.contacts.GroupEntryFromString)
316
+ except gdata.service.RequestError as e:
317
+ raise gdata.apps.service.AppsForYourDomainException(e.args[0])
318
+
319
+ def CreateGroup(self, new_group, insert_uri=None, url_params=None,
320
+ escape_params=True):
321
+ insert_uri = insert_uri or self.GetContactGroupFeedUri()
322
+ try:
323
+ return self.Post(new_group, insert_uri, url_params=url_params,
324
+ escape_params=escape_params,
325
+ converter=gdata.apps.contacts.GroupEntryFromString)
326
+ except gdata.service.RequestError as e:
327
+ raise gdata.apps.service.AppsForYourDomainException(e.args[0])
328
+
329
+ def UpdateGroup(self, edit_uri, updated_group, extra_headers=None, url_params=None,
330
+ escape_params=True):
331
+ try:
332
+ return self.Put(updated_group, self._CleanUri(edit_uri),
333
+ url_params=url_params, extra_headers=extra_headers,
334
+ escape_params=escape_params,
335
+ converter=gdata.apps.contacts.GroupEntryFromString)
336
+ except gdata.service.RequestError as e:
337
+ raise gdata.apps.service.AppsForYourDomainException(e.args[0])
338
+
339
+ def DeleteGroup(self, edit_uri, extra_headers=None,
340
+ url_params=None, escape_params=True):
341
+ try:
342
+ return self.Delete(self._CleanUri(edit_uri),
343
+ url_params=url_params, escape_params=escape_params, extra_headers=extra_headers)
344
+ except gdata.service.RequestError as e:
345
+ raise gdata.apps.service.AppsForYourDomainException(e.args[0])
346
+
347
+ class ContactsQuery(gdata.service.Query):
348
+
349
+ def __init__(self, feed=None, text_query=None, params=None,
350
+ categories=None, group=None):
351
+ self.feed = feed or '/m8/feeds/contacts/default/full'
352
+ if group:
353
+ self['group'] = group
354
+ gdata.service.Query.__init__(self, feed=self.feed, text_query=text_query,
355
+ params=params, categories=categories)