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,105 @@
1
+ #
2
+ # Copyright (C) 2008 Google Inc.
3
+ #
4
+ # Licensed under the Apache License 2.0;
5
+
6
+
7
+ """This module provides a TokenStore class which is designed to manage
8
+ auth tokens required for different services.
9
+
10
+ Each token is valid for a set of scopes which is the start of a URL. An HTTP
11
+ client will use a token store to find a valid Authorization header to send
12
+ in requests to the specified URL. If the HTTP client determines that a token
13
+ has expired or been revoked, it can remove the token from the store so that
14
+ it will not be used in future requests.
15
+ """
16
+
17
+ # __author__ = 'api.jscudder (Jeff Scudder)'
18
+
19
+ import atom.http_interface
20
+ import atom.url
21
+
22
+ SCOPE_ALL = 'http'
23
+
24
+
25
+ class TokenStore(object):
26
+ """Manages Authorization tokens which will be sent in HTTP headers."""
27
+
28
+ def __init__(self, scoped_tokens=None):
29
+ self._tokens = scoped_tokens or {}
30
+
31
+ def add_token(self, token):
32
+ """Adds a new token to the store (replaces tokens with the same scope).
33
+
34
+ Args:
35
+ token: A subclass of http_interface.GenericToken. The token object is
36
+ responsible for adding the Authorization header to the HTTP request.
37
+ The scopes defined in the token are used to determine if the token
38
+ is valid for a requested scope when find_token is called.
39
+
40
+ Returns:
41
+ True if the token was added, False if the token was not added becase
42
+ no scopes were provided.
43
+ """
44
+ if not hasattr(token, 'scopes') or not token.scopes:
45
+ return False
46
+
47
+ for scope in token.scopes:
48
+ self._tokens[str(scope)] = token
49
+ return True
50
+
51
+ def find_token(self, url):
52
+ """Selects an Authorization header token which can be used for the URL.
53
+
54
+ Args:
55
+ url: str or atom.url.Url or a list containing the same.
56
+ The URL which is going to be requested. All
57
+ tokens are examined to see if any scopes begin match the beginning
58
+ of the URL. The first match found is returned.
59
+
60
+ Returns:
61
+ The token object which should execute the HTTP request. If there was
62
+ no token for the url (the url did not begin with any of the token
63
+ scopes available), then the atom.http_interface.GenericToken will be
64
+ returned because the GenericToken calls through to the http client
65
+ without adding an Authorization header.
66
+ """
67
+ if url is None:
68
+ return None
69
+ if isinstance(url, str):
70
+ url = atom.url.parse_url(url)
71
+ if url in self._tokens:
72
+ token = self._tokens[url]
73
+ if token.valid_for_scope(url):
74
+ return token
75
+ else:
76
+ del self._tokens[url]
77
+ for scope, token in self._tokens.items():
78
+ if token.valid_for_scope(url):
79
+ return token
80
+ return atom.http_interface.GenericToken()
81
+
82
+ def remove_token(self, token):
83
+ """Removes the token from the token_store.
84
+
85
+ This method is used when a token is determined to be invalid. If the
86
+ token was found by find_token, but resulted in a 401 or 403 error stating
87
+ that the token was invlid, then the token should be removed to prevent
88
+ future use.
89
+
90
+ Returns:
91
+ True if a token was found and then removed from the token
92
+ store. False if the token was not in the TokenStore.
93
+ """
94
+ token_found = False
95
+ scopes_to_delete = []
96
+ for scope, stored_token in self._tokens.items():
97
+ if stored_token == token:
98
+ scopes_to_delete.append(scope)
99
+ token_found = True
100
+ for scope in scopes_to_delete:
101
+ del self._tokens[scope]
102
+ return token_found
103
+
104
+ def remove_all_tokens(self):
105
+ self._tokens = {}
gam/atom/url.py ADDED
@@ -0,0 +1,130 @@
1
+ #
2
+ # Copyright (C) 2008 Google Inc.
3
+ #
4
+ # Licensed under the Apache License 2.0;
5
+
6
+
7
+
8
+ # __author__ = 'api.jscudder (Jeff Scudder)'
9
+
10
+ import urllib.error
11
+ import urllib.parse
12
+ import urllib.parse
13
+ import urllib.request
14
+
15
+ DEFAULT_PROTOCOL = 'http'
16
+ DEFAULT_PORT = 80
17
+
18
+
19
+ def parse_url(url_string):
20
+ """Creates a Url object which corresponds to the URL string.
21
+
22
+ This method can accept partial URLs, but it will leave missing
23
+ members of the Url unset.
24
+ """
25
+ parts = urllib.parse.urlparse(url_string)
26
+ url = Url()
27
+ if parts[0]:
28
+ url.protocol = parts[0]
29
+ if parts[1]:
30
+ host_parts = parts[1].split(':')
31
+ if host_parts[0]:
32
+ url.host = host_parts[0]
33
+ if len(host_parts) > 1:
34
+ url.port = host_parts[1]
35
+ if parts[2]:
36
+ url.path = parts[2]
37
+ if parts[4]:
38
+ param_pairs = parts[4].split('&')
39
+ for pair in param_pairs:
40
+ pair_parts = pair.split('=')
41
+ if len(pair_parts) > 1:
42
+ url.params[urllib.parse.unquote_plus(pair_parts[0])] = (
43
+ urllib.parse.unquote_plus(pair_parts[1]))
44
+ elif len(pair_parts) == 1:
45
+ url.params[urllib.parse.unquote_plus(pair_parts[0])] = None
46
+ return url
47
+
48
+
49
+ class Url(object):
50
+ """Represents a URL and implements comparison logic.
51
+
52
+ URL strings which are not identical can still be equivalent, so this object
53
+ provides a better interface for comparing and manipulating URLs than
54
+ strings. URL parameters are represented as a dictionary of strings, and
55
+ defaults are used for the protocol (http) and port (80) if not provided.
56
+ """
57
+
58
+ def __init__(self, protocol=None, host=None, port=None, path=None,
59
+ params=None):
60
+ self.protocol = protocol
61
+ self.host = host
62
+ self.port = port
63
+ self.path = path
64
+ self.params = params or {}
65
+
66
+ def to_string(self):
67
+ url_parts = ['', '', '', '', '', '']
68
+ if self.protocol:
69
+ url_parts[0] = self.protocol
70
+ if self.host:
71
+ if self.port:
72
+ url_parts[1] = ':'.join((self.host, str(self.port)))
73
+ else:
74
+ url_parts[1] = self.host
75
+ if self.path:
76
+ url_parts[2] = self.path
77
+ if self.params:
78
+ url_parts[4] = self.get_param_string()
79
+ return urllib.parse.urlunparse(url_parts)
80
+
81
+ def get_param_string(self):
82
+ param_pairs = []
83
+ for key, value in self.params.items():
84
+ param_pairs.append('='.join((urllib.parse.quote_plus(key),
85
+ urllib.parse.quote_plus(str(value)))))
86
+ return '&'.join(param_pairs)
87
+
88
+ def get_request_uri(self):
89
+ """Returns the path with the parameters escaped and appended."""
90
+ param_string = self.get_param_string()
91
+ if param_string:
92
+ return '?'.join([self.path, param_string])
93
+ else:
94
+ return self.path
95
+
96
+ def __cmp__(self, other):
97
+ if not isinstance(other, Url):
98
+ return cmp(self.to_string(), str(other))
99
+ difference = 0
100
+ # Compare the protocol
101
+ if self.protocol and other.protocol:
102
+ difference = cmp(self.protocol, other.protocol)
103
+ elif self.protocol and not other.protocol:
104
+ difference = cmp(self.protocol, DEFAULT_PROTOCOL)
105
+ elif not self.protocol and other.protocol:
106
+ difference = cmp(DEFAULT_PROTOCOL, other.protocol)
107
+ if difference != 0:
108
+ return difference
109
+ # Compare the host
110
+ difference = cmp(self.host, other.host)
111
+ if difference != 0:
112
+ return difference
113
+ # Compare the port
114
+ if self.port and other.port:
115
+ difference = cmp(self.port, other.port)
116
+ elif self.port and not other.port:
117
+ difference = cmp(self.port, DEFAULT_PORT)
118
+ elif not self.port and other.port:
119
+ difference = cmp(DEFAULT_PORT, other.port)
120
+ if difference != 0:
121
+ return difference
122
+ # Compare the path
123
+ difference = cmp(self.path, other.path)
124
+ if difference != 0:
125
+ return difference
126
+ # Compare the parameters
127
+ return cmp(self.params, other.params)
128
+
129
+ def __str__(self):
130
+ return self.to_string()