@@ -24,6 +24,34 @@ class Connection(object):
2424
2525 Subclasses should understand only the basic types in method arguments,
2626 however they should be capable of returning advanced types.
27+
28+ If no value is passed in for ``http``, a :class:`httplib2.Http` object
29+ will be created and authorized with the ``credentials``. If not, the
30+ ``credentials`` and ``http`` need not be related.
31+
32+ Subclasses may seek to use the private key from ``credentials`` to sign
33+ data.
34+
35+ A custom (non-``httplib2``) HTTP object must have a ``request`` method
36+ which accepts the following arguments:
37+
38+ * ``uri``
39+ * ``method``
40+ * ``body``
41+ * ``headers``
42+
43+ In addition, ``redirections`` and ``connection_type`` may be used.
44+
45+ Without the use of ``credentials.authorize(http)``, a custom ``http``
46+ object will also need to be able to add a bearer token to API
47+ requests and handle token refresh on 401 errors.
48+
49+ :type credentials: :class:`oauth2client.client.OAuth2Credentials` or
50+ :class:`NoneType`
51+ :param credentials: The OAuth2 Credentials to use for this connection.
52+
53+ :type http: :class:`httplib2.Http` or class that defines ``request()``.
54+ :param http: An optional HTTP object to make requests.
2755 """
2856
2957 API_BASE_URL = 'https://www.googleapis.com'
@@ -35,14 +63,8 @@ class Connection(object):
3563 USER_AGENT = "gcloud-python/{0}" .format (get_distribution ('gcloud' ).version )
3664 """The user agent for gcloud-python requests."""
3765
38- def __init__ (self , credentials = None ):
39- """Constructor for Connection.
40-
41- :type credentials: :class:`oauth2client.client.OAuth2Credentials` or
42- :class:`NoneType`
43- :param credentials: The OAuth2 Credentials to use for this connection.
44- """
45- self ._http = None
66+ def __init__ (self , credentials = None , http = None ):
67+ self ._http = http
4668 self ._credentials = credentials
4769
4870 @property
0 commit comments