Skip to content

Commit

Permalink
Merge pull request #2690 from dhermes/make-connection-non-public
Browse files Browse the repository at this point in the history
Renaming connection module as _http in 5 packages.
  • Loading branch information
dhermes authored Nov 7, 2016
2 parents 8b899d1 + d31f65e commit a52010e
Show file tree
Hide file tree
Showing 32 changed files with 57 additions and 117 deletions.
4 changes: 0 additions & 4 deletions bigquery/google/cloud/bigquery/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,7 @@


from google.cloud.bigquery.client import Client
from google.cloud.bigquery.connection import Connection
from google.cloud.bigquery.dataset import AccessGrant
from google.cloud.bigquery.dataset import Dataset
from google.cloud.bigquery.schema import SchemaField
from google.cloud.bigquery.table import Table


SCOPE = Connection.SCOPE
File renamed without changes.
2 changes: 1 addition & 1 deletion bigquery/google/cloud/bigquery/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@


from google.cloud.client import JSONClient
from google.cloud.bigquery.connection import Connection
from google.cloud.bigquery._http import Connection
from google.cloud.bigquery.dataset import Dataset
from google.cloud.bigquery.job import CopyJob
from google.cloud.bigquery.job import ExtractTableToStorageJob
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class TestConnection(unittest.TestCase):

def _getTargetClass(self):
from google.cloud.bigquery.connection import Connection
from google.cloud.bigquery._http import Connection
return Connection

def _makeOne(self, *args, **kw):
Expand Down
2 changes: 1 addition & 1 deletion bigquery/unit_tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def _makeOne(self, *args, **kw):
return self._getTargetClass()(*args, **kw)

def test_ctor(self):
from google.cloud.bigquery.connection import Connection
from google.cloud.bigquery._http import Connection
PROJECT = 'PROJECT'
creds = _Credentials()
http = object()
Expand Down
8 changes: 0 additions & 8 deletions datastore/google/cloud/datastore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@
The main concepts with this API are:
- :class:`~google.cloud.datastore.connection.Connection`
which represents a connection between your machine and the Cloud Datastore
API.
- :class:`~google.cloud.datastore.client.Client`
which represents a project (string) and namespace (string) bundled with
a connection and has convenience methods for constructing objects with that
Expand All @@ -54,12 +50,8 @@


from google.cloud.datastore.batch import Batch
from google.cloud.datastore.connection import Connection
from google.cloud.datastore.client import Client
from google.cloud.datastore.entity import Entity
from google.cloud.datastore.key import Key
from google.cloud.datastore.query import Query
from google.cloud.datastore.transaction import Transaction


SCOPE = Connection.SCOPE
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class _DatastoreAPIOverHttp(object):
Methods make bare API requests without any helpers for constructing
the requests or parsing the responses.
:type connection: :class:`google.cloud.datastore.connection.Connection`
:type connection: :class:`Connection`
:param connection: A connection object that contains helpful
information for making requests.
"""
Expand Down Expand Up @@ -268,7 +268,7 @@ class _DatastoreAPIOverGRPC(object):
Methods make bare API requests without any helpers for constructing
the requests or parsing the responses.
:type connection: :class:`google.cloud.datastore.connection.Connection`
:type connection: :class:`Connection`
:param connection: A connection object that contains helpful
information for making requests.
Expand Down
2 changes: 1 addition & 1 deletion datastore/google/cloud/datastore/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def namespace(self):
def connection(self):
"""Getter for connection over which the batch will run.
:rtype: :class:`google.cloud.datastore.connection.Connection`
:rtype: :class:`google.cloud.datastore._http.Connection`
:returns: The connection over which the batch will run.
"""
return self._client.connection
Expand Down
4 changes: 2 additions & 2 deletions datastore/google/cloud/datastore/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
_determine_default_project as _base_default_project)
from google.cloud.client import _ClientProjectMixin
from google.cloud.client import Client as _BaseClient
from google.cloud.datastore._http import Connection
from google.cloud.datastore import helpers
from google.cloud.datastore.connection import Connection
from google.cloud.datastore.batch import Batch
from google.cloud.datastore.entity import Entity
from google.cloud.datastore.key import Key
Expand Down Expand Up @@ -72,7 +72,7 @@ def _extended_lookup(connection, project, key_pbs,
Helper function for :meth:`Client.get_multi`.
:type connection: :class:`google.cloud.datastore.connection.Connection`
:type connection: :class:`google.cloud.datastore._http.Connection`
:param connection: The connection used to connect to datastore.
:type project: str
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@

import unittest

from google.cloud.datastore.connection import _HAVE_GRPC
from google.cloud.datastore._http import _HAVE_GRPC


class Test_DatastoreAPIOverHttp(unittest.TestCase):

def _getTargetClass(self):
from google.cloud.datastore.connection import _DatastoreAPIOverHttp
from google.cloud.datastore._http import _DatastoreAPIOverHttp
return _DatastoreAPIOverHttp

def _makeOne(self, *args, **kw):
Expand Down Expand Up @@ -110,7 +110,7 @@ def test__request_not_200(self):
class Test__grpc_catch_rendezvous(unittest.TestCase):

def _callFUT(self):
from google.cloud.datastore.connection import _grpc_catch_rendezvous
from google.cloud.datastore._http import _grpc_catch_rendezvous
return _grpc_catch_rendezvous()

@staticmethod
Expand Down Expand Up @@ -175,12 +175,12 @@ def test_commit_failure_non_grpc_err(self):
class Test_DatastoreAPIOverGRPC(unittest.TestCase):

def _getTargetClass(self):
from google.cloud.datastore.connection import _DatastoreAPIOverGRPC
from google.cloud.datastore._http import _DatastoreAPIOverGRPC
return _DatastoreAPIOverGRPC

def _makeOne(self, stub, connection=None, secure=True, mock_args=None):
from google.cloud._testing import _Monkey
from google.cloud.datastore import connection as MUT
from google.cloud.datastore import _http as MUT

if connection is None:
connection = _Connection(None)
Expand All @@ -202,7 +202,7 @@ def mock_make_stub(*args):
return self._getTargetClass()(connection, secure)

def test_constructor(self):
from google.cloud.datastore import connection as MUT
from google.cloud.datastore import _http as MUT

conn = _Connection(None)
conn.credentials = object()
Expand All @@ -222,7 +222,7 @@ def test_constructor(self):
)])

def test_constructor_insecure(self):
from google.cloud.datastore import connection as MUT
from google.cloud.datastore import _http as MUT

conn = _Connection(None)
conn.credentials = object()
Expand Down Expand Up @@ -351,7 +351,7 @@ def test_allocate_ids(self):
class TestConnection(unittest.TestCase):

def _getTargetClass(self):
from google.cloud.datastore.connection import Connection
from google.cloud.datastore._http import Connection

return Connection

Expand All @@ -370,7 +370,7 @@ def _make_query_pb(self, kind):

def _makeOne(self, credentials=None, http=None, use_grpc=False):
from google.cloud._testing import _Monkey
from google.cloud.datastore import connection as MUT
from google.cloud.datastore import _http as MUT
with _Monkey(MUT, _USE_GRPC=use_grpc):
return self._getTargetClass()(credentials=credentials, http=http)

Expand Down Expand Up @@ -408,7 +408,7 @@ def test_ctor_defaults(self):

def test_ctor_without_grpc(self):
from google.cloud._testing import _Monkey
from google.cloud.datastore import connection as MUT
from google.cloud.datastore import _http as MUT

connections = []
return_val = object()
Expand All @@ -426,7 +426,7 @@ def mock_api(connection):

def test_ctor_with_grpc(self):
from google.cloud._testing import _Monkey
from google.cloud.datastore import connection as MUT
from google.cloud.datastore import _http as MUT

api_args = []
return_val = object()
Expand Down Expand Up @@ -921,7 +921,7 @@ def test_begin_transaction(self):
def test_commit_wo_transaction(self):
from google.cloud._testing import _Monkey
from google.cloud.datastore._generated import datastore_pb2
from google.cloud.datastore import connection as MUT
from google.cloud.datastore import _http as MUT
from google.cloud.datastore.helpers import _new_value_pb

PROJECT = 'PROJECT'
Expand Down Expand Up @@ -967,7 +967,7 @@ def mock_parse(response):
def test_commit_w_transaction(self):
from google.cloud._testing import _Monkey
from google.cloud.datastore._generated import datastore_pb2
from google.cloud.datastore import connection as MUT
from google.cloud.datastore import _http as MUT
from google.cloud.datastore.helpers import _new_value_pb

PROJECT = 'PROJECT'
Expand Down Expand Up @@ -1091,7 +1091,7 @@ def test_allocate_ids_non_empty(self):
class Test__parse_commit_response(unittest.TestCase):

def _callFUT(self, commit_response_pb):
from google.cloud.datastore.connection import _parse_commit_response
from google.cloud.datastore._http import _parse_commit_response
return _parse_commit_response(commit_response_pb)

def test_it(self):
Expand Down
7 changes: 0 additions & 7 deletions docs/bigquery-client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,3 @@ BigQuery Client
.. automodule:: google.cloud.bigquery.client
:members:
:show-inheritance:

Connection
~~~~~~~~~~

.. automodule:: google.cloud.bigquery.connection
:members:
:show-inheritance:
7 changes: 0 additions & 7 deletions docs/datastore-client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,3 @@ Datastore Client
.. automodule:: google.cloud.datastore.client
:members:
:show-inheritance:

Connection
~~~~~~~~~~

.. automodule:: google.cloud.datastore.connection
:members:
:show-inheritance:
7 changes: 0 additions & 7 deletions docs/logging-client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,3 @@ Stackdriver Logging Client
.. automodule:: google.cloud.logging.client
:members:
:show-inheritance:

Connection
~~~~~~~~~~

.. automodule:: google.cloud.logging.connection
:members:
:show-inheritance:
7 changes: 0 additions & 7 deletions docs/pubsub-client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,3 @@ Pub/Sub Client
.. automodule:: google.cloud.pubsub.client
:members:
:show-inheritance:

Connection
~~~~~~~~~~

.. automodule:: google.cloud.pubsub.connection
:members:
:show-inheritance:
7 changes: 0 additions & 7 deletions docs/storage-client.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,3 @@ Storage Client
.. automodule:: google.cloud.storage.client
:members:
:show-inheritance:

Connection
~~~~~~~~~~

.. automodule:: google.cloud.storage.connection
:members:
:show-inheritance:
2 changes: 0 additions & 2 deletions logging/google/cloud/logging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,8 @@


from google.cloud.logging.client import Client
from google.cloud.logging.connection import Connection


SCOPE = Connection.SCOPE
ASCENDING = 'timestamp asc'
"""Query string to order by ascending timestamps."""
DESCENDING = 'timestamp desc'
Expand Down
File renamed without changes.
8 changes: 4 additions & 4 deletions logging/google/cloud/logging/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@

from google.cloud.client import JSONClient
from google.cloud.environment_vars import DISABLE_GRPC
from google.cloud.logging.connection import Connection
from google.cloud.logging.connection import _LoggingAPI as JSONLoggingAPI
from google.cloud.logging.connection import _MetricsAPI as JSONMetricsAPI
from google.cloud.logging.connection import _SinksAPI as JSONSinksAPI
from google.cloud.logging._http import Connection
from google.cloud.logging._http import _LoggingAPI as JSONLoggingAPI
from google.cloud.logging._http import _MetricsAPI as JSONMetricsAPI
from google.cloud.logging._http import _SinksAPI as JSONSinksAPI
from google.cloud.logging.logger import Logger
from google.cloud.logging.metric import Metric
from google.cloud.logging.sink import Sink
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class TestConnection(unittest.TestCase):
FILTER = 'logName:syslog AND severity>=ERROR'

def _getTargetClass(self):
from google.cloud.logging.connection import Connection
from google.cloud.logging._http import Connection
return Connection

def _makeOne(self, *args, **kw):
Expand All @@ -43,7 +43,7 @@ class Test_LoggingAPI(unittest.TestCase):
FILTER = 'logName:syslog AND severity>=ERROR'

def _getTargetClass(self):
from google.cloud.logging.connection import _LoggingAPI
from google.cloud.logging._http import _LoggingAPI
return _LoggingAPI

def _makeOne(self, *args, **kw):
Expand Down Expand Up @@ -292,7 +292,7 @@ class Test_SinksAPI(unittest.TestCase):
DESTINATION_URI = 'faux.googleapis.com/destination'

def _getTargetClass(self):
from google.cloud.logging.connection import _SinksAPI
from google.cloud.logging._http import _SinksAPI
return _SinksAPI

def _makeOne(self, *args, **kw):
Expand Down Expand Up @@ -533,7 +533,7 @@ class Test_MetricsAPI(unittest.TestCase):
DESCRIPTION = 'DESCRIPTION'

def _getTargetClass(self):
from google.cloud.logging.connection import _MetricsAPI
from google.cloud.logging._http import _MetricsAPI
return _MetricsAPI

def _makeOne(self, *args, **kw):
Expand Down
8 changes: 4 additions & 4 deletions logging/unit_tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def test_ctor(self):
self.assertEqual(client.project, self.PROJECT)

def test_logging_api_wo_gax(self):
from google.cloud.logging.connection import _LoggingAPI
from google.cloud.logging._http import _LoggingAPI

client = self._makeOne(self.PROJECT, credentials=_Credentials(),
use_gax=False)
Expand Down Expand Up @@ -79,7 +79,7 @@ def make_api(client_obj):
def test_no_gax_ctor(self):
from google.cloud._testing import _Monkey
from google.cloud.logging import client as MUT
from google.cloud.logging.connection import _LoggingAPI
from google.cloud.logging._http import _LoggingAPI

creds = _Credentials()
with _Monkey(MUT, _USE_GAX=True):
Expand All @@ -90,7 +90,7 @@ def test_no_gax_ctor(self):
self.assertIsInstance(api, _LoggingAPI)

def test_sinks_api_wo_gax(self):
from google.cloud.logging.connection import _SinksAPI
from google.cloud.logging._http import _SinksAPI
from google.cloud.logging import client as MUT
from google.cloud._testing import _Monkey

Expand Down Expand Up @@ -131,7 +131,7 @@ def make_api(client_obj):
self.assertIs(again, api)

def test_metrics_api_wo_gax(self):
from google.cloud.logging.connection import _MetricsAPI
from google.cloud.logging._http import _MetricsAPI
from google.cloud.logging import client as MUT
from google.cloud._testing import _Monkey

Expand Down
4 changes: 0 additions & 4 deletions pubsub/google/cloud/pubsub/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,5 @@


from google.cloud.pubsub.client import Client
from google.cloud.pubsub.connection import Connection
from google.cloud.pubsub.subscription import Subscription
from google.cloud.pubsub.topic import Topic


SCOPE = Connection.SCOPE
Loading

0 comments on commit a52010e

Please sign in to comment.