Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1.8k
Remove connection from base Client class#2870
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -19,7 +19,6 @@ | ||
| import six | ||
| from google.cloud._helpers import _determine_default_project | ||
| from google.cloud._http import Connection | ||
| from google.cloud.credentials import get_credentials | ||
| @@ -72,33 +71,32 @@ def from_service_account_json(cls, json_credentials_path, *args, **kwargs): | ||
| class Client(_ClientFactoryMixin): | ||
| """Client to bundle configuration needed for API requests. | ||
| Assumes that the associated ``_connection_class`` only accepts | ||
| ``http`` and ``credentials`` in its constructor. | ||
| Stores ``credentials`` and ``http`` object so that subclasses | ||
| can pass them along to a connection class. | ||
| :type credentials: :class:`google.auth.credentials.Credentials` or | ||
| :class:`NoneType` | ||
| :param credentials: The OAuth2 Credentials to use for the connection | ||
| owned by this client. If not passed (and if no ``http`` | ||
| object is passed), falls back to the default inferred | ||
| from the environment. | ||
| :type credentials: :class:`~google.auth.credentials.Credentials` | ||
| :param credentials: (Optional) The OAuth2 Credentials to use for this | ||
| client. If not passed (and if no ``http`` object is | ||
| passed), falls back to the default inferred from the | ||
| environment. | ||
| :type http: :class:`httplib2.Http` or class that defines ``request()``. | ||
| :param http: An optional HTTP object to make requests. If not passed, an | ||
| :type http: :class:`~httplib2.Http` | ||
| :param http: (Optional) HTTP object to make requests. Can be any object | ||
| that defines ``request()`` with the same interface as | ||
| :meth:`~httplib2.Http.request`. If not passed, an | ||
| ``http`` object is created that is bound to the | ||
| ``credentials`` for the current object. | ||
| """ | ||
| _connection_class = Connection | ||
| def __init__(self, credentials=None, http=None): | ||
| if (credentials is not None and | ||
| not isinstance( | ||
| credentials, google.auth.credentials.Credentials)): | ||
| raise ValueError(_GOOGLE_AUTH_CREDENTIALS_HELP) | ||
| if credentials is None and http is None: | ||
| credentials = get_credentials() | ||
| self._connection = self._connection_class( | ||
| credentials=credentials, http=http) | ||
| self._credentials = credentials | ||
| self._http = http | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page.
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| class _ClientProjectMixin(object): | ||
| @@ -142,15 +140,16 @@ class JSONClient(Client, _ClientProjectMixin): | ||
| passed falls back to the default inferred from the | ||
| environment. | ||
| :type credentials: :class:`google.auth.credentials.Credentials` or | ||
| :class:`NoneType` | ||
| :param credentials: The OAuth2 Credentials to use for the connection | ||
| owned by this client. If not passed (and if no ``http`` | ||
| object is passed), falls back to the default inferred | ||
| from the environment. | ||
| :type credentials: :class:`~google.auth.credentials.Credentials` | ||
| :param credentials: (Optional) The OAuth2 Credentials to use for this | ||
| client. If not passed (and if no ``http`` object is | ||
| passed), falls back to the default inferred from the | ||
| environment. | ||
| :type http: :class:`httplib2.Http` or class that defines ``request()``. | ||
| :param http: An optional HTTP object to make requests. If not passed, an | ||
| :type http: :class:`~httplib2.Http` | ||
| :param http: (Optional) HTTP object to make requests. Can be any object | ||
| that defines ``request()`` with the same interface as | ||
| :meth:`~httplib2.Http.request`. If not passed, an | ||
| ``http`` object is created that is bound to the | ||
| ``credentials`` for the current object. | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -4,7 +4,7 @@ envlist = | ||
| [testing] | ||
| deps = | ||
| grpcio >= 1.0.2rc0 | ||
| grpcio >= 1.0.2 | ||
| mock | ||
| pytest | ||
| covercmd = | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -157,26 +157,29 @@ class Client(_BaseClient, _ClientProjectMixin): | ||
| :type namespace: str | ||
| :param namespace: (optional) namespace to pass to proxied API methods. | ||
| :type credentials: :class:`oauth2client.client.OAuth2Credentials` or | ||
| :class:`NoneType` | ||
| :param credentials: The OAuth2 Credentials to use for the connection | ||
| owned by this client. If not passed (and if no ``http`` | ||
| object is passed), falls back to the default inferred | ||
| from the environment. | ||
| :type http: :class:`httplib2.Http` or class that defines ``request()``. | ||
| :param http: An optional HTTP object to make requests. If not passed, an | ||
| :type credentials: :class:`~google.auth.credentials.Credentials` | ||
| :param credentials: (Optional) The OAuth2 Credentials to use for this | ||
| client. If not passed (and if no ``http`` object is | ||
| passed), falls back to the default inferred from the | ||
| environment. | ||
| :type http: :class:`~httplib2.Http` | ||
| :param http: (Optional) HTTP object to make requests. Can be any object | ||
| that defines ``request()`` with the same interface as | ||
| :meth:`~httplib2.Http.request`. If not passed, an | ||
| ``http`` object is created that is bound to the | ||
| ``credentials`` for the current object. | ||
| """ | ||
| _connection_class = Connection | ||
| def __init__(self, project=None, namespace=None, | ||
| credentials=None, http=None): | ||
| _ClientProjectMixin.__init__(self, project=project) | ||
This comment was marked as spam.Sorry, something went wrong. Uh oh!There was an error while loading. Please reload this page. | ||
| _BaseClient.__init__(self, credentials=credentials, http=http) | ||
| self._connection = Connection( | ||
| credentials=self._credentials, http=self._http) | ||
| self.namespace = namespace | ||
| self._batch_stack = _LocalStack() | ||
| super(Client, self).__init__(credentials, http) | ||
| @staticmethod | ||
| def _determine_default(project): | ||
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This comment was marked as spam.
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.