Skip to content

Commit

Permalink
Merge pull request #2968 from dhermes/generic-hygiene
Browse files Browse the repository at this point in the history
Renaming JSONClient -> ClientWithProject.
  • Loading branch information
dhermes authored Jan 26, 2017
2 parents a70815d + b53be84 commit 9e6f2df
Show file tree
Hide file tree
Showing 12 changed files with 25 additions and 31 deletions.
4 changes: 2 additions & 2 deletions bigquery/google/cloud/bigquery/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"""Client for interacting with the Google BigQuery API."""


from google.cloud.client import JSONClient
from google.cloud.client import ClientWithProject
from google.cloud.bigquery._http import Connection
from google.cloud.bigquery.dataset import Dataset
from google.cloud.bigquery.job import CopyJob
Expand Down Expand Up @@ -50,7 +50,7 @@ def from_api_repr(cls, resource):
resource['id'], resource['numericId'], resource['friendlyName'])


class Client(JSONClient):
class Client(ClientWithProject):
"""Client to bundle configuration needed for API requests.
:type project: str
Expand Down
9 changes: 3 additions & 6 deletions core/google/cloud/_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ def _name_from_project_path(path, project, template):
return match.group('name')


def make_secure_channel(credentials, user_agent, host, extra_options=None):
def make_secure_channel(credentials, user_agent, host, extra_options=()):
"""Makes a secure channel for an RPC service.
Uses / depends on gRPC.
Expand All @@ -538,10 +538,7 @@ def make_secure_channel(credentials, user_agent, host, extra_options=None):
http_request = google_auth_httplib2.Request(http=httplib2.Http())

user_agent_option = ('grpc.primary_user_agent', user_agent)
if extra_options is not None:
options = (user_agent_option,) + extra_options
else:
options = (user_agent_option,)
options = (user_agent_option,) + extra_options
return google.auth.transport.grpc.secure_authorized_channel(
credentials,
http_request,
Expand All @@ -550,7 +547,7 @@ def make_secure_channel(credentials, user_agent, host, extra_options=None):


def make_secure_stub(credentials, user_agent, stub_class, host,
extra_options=None):
extra_options=()):
"""Makes a secure stub for an RPC service.
Uses / depends on gRPC.
Expand Down
7 changes: 2 additions & 5 deletions core/google/cloud/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,11 +129,8 @@ def _determine_default(project):
return _determine_default_project(project)


class JSONClient(Client, _ClientProjectMixin):
"""Client for Google JSON-based API.
Assumes such APIs use the ``project`` and the client needs to store this
value.
class ClientWithProject(Client, _ClientProjectMixin):
"""Client that also stores a project.
:type project: str
:param project: the project which the client acts on behalf of. If not
Expand Down
2 changes: 1 addition & 1 deletion core/unit_tests/test__helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ def mock_channel(*args, **kwargs):
credentials = object()
user_agent = 'you-sir-age-int'
host = 'localhost'
extra_options = {'extra_options': None}
extra_options = {'extra_options': ()}
with _Monkey(MUT, make_secure_channel=mock_channel):
stub = self._call_fut(credentials, user_agent,
stub_class, host)
Expand Down
6 changes: 3 additions & 3 deletions core/unit_tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,13 @@ def test_from_service_account_json_bad_args(self):
mock.sentinel.filename, credentials=mock.sentinel.credentials)


class TestJSONClient(unittest.TestCase):
class TestClientWithProject(unittest.TestCase):

@staticmethod
def _get_target_class():
from google.cloud.client import JSONClient
from google.cloud.client import ClientWithProject

return JSONClient
return ClientWithProject

def _make_one(self, *args, **kw):
return self._get_target_class()(*args, **kw)
Expand Down
4 changes: 2 additions & 2 deletions dns/google/cloud/dns/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"""Client for interacting with the Google Cloud DNS API."""


from google.cloud.client import JSONClient
from google.cloud.client import ClientWithProject
from google.cloud.dns.connection import Connection
from google.cloud.dns.zone import ManagedZone
from google.cloud.iterator import HTTPIterator


class Client(JSONClient):
class Client(ClientWithProject):
"""Client to bundle configuration needed for API requests.
:type project: str
Expand Down
4 changes: 2 additions & 2 deletions logging/google/cloud/logging/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
else:
_HAVE_GAX = True

from google.cloud.client import JSONClient
from google.cloud.client import ClientWithProject
from google.cloud.environment_vars import DISABLE_GRPC
from google.cloud.logging._http import Connection
from google.cloud.logging._http import _LoggingAPI as JSONLoggingAPI
Expand Down Expand Up @@ -59,7 +59,7 @@
"""Environment variable set in a Google Container Engine environment."""


class Client(JSONClient):
class Client(ClientWithProject):
"""Client to bundle configuration needed for API requests.
:type project: str
Expand Down
4 changes: 2 additions & 2 deletions monitoring/google/cloud/monitoring/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import datetime

from google.cloud._helpers import _datetime_to_rfc3339
from google.cloud.client import JSONClient
from google.cloud.client import ClientWithProject
from google.cloud.monitoring.connection import Connection
from google.cloud.monitoring.group import Group
from google.cloud.monitoring.metric import Metric
Expand All @@ -47,7 +47,7 @@
_UTCNOW = datetime.datetime.utcnow # To be replaced by tests.


class Client(JSONClient):
class Client(ClientWithProject):
"""Client to bundle configuration needed for API requests.
:type project: str
Expand Down
4 changes: 2 additions & 2 deletions pubsub/google/cloud/pubsub/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import os

from google.cloud.client import JSONClient
from google.cloud.client import ClientWithProject
from google.cloud.environment_vars import DISABLE_GRPC
from google.cloud.pubsub._http import Connection
from google.cloud.pubsub._http import _PublisherAPI as JSONPublisherAPI
Expand All @@ -43,7 +43,7 @@
_USE_GAX = _HAVE_GAX and not _DISABLE_GAX


class Client(JSONClient):
class Client(ClientWithProject):
"""Client to bundle configuration needed for API requests.
:type project: str
Expand Down
4 changes: 2 additions & 2 deletions runtimeconfig/google/cloud/runtimeconfig/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
"""Client for interacting with the Google Cloud RuntimeConfig API."""


from google.cloud.client import JSONClient
from google.cloud.client import ClientWithProject
from google.cloud.runtimeconfig.connection import Connection
from google.cloud.runtimeconfig.config import Config


class Client(JSONClient):
class Client(ClientWithProject):
"""Client to bundle configuration needed for API requests.
:type project: str
Expand Down
4 changes: 2 additions & 2 deletions storage/google/cloud/storage/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@


from google.cloud._helpers import _LocalStack
from google.cloud.client import JSONClient
from google.cloud.client import ClientWithProject
from google.cloud.exceptions import NotFound
from google.cloud.iterator import HTTPIterator
from google.cloud.storage._http import Connection
from google.cloud.storage.batch import Batch
from google.cloud.storage.bucket import Bucket


class Client(JSONClient):
class Client(ClientWithProject):
"""Client to bundle configuration needed for API requests.
:type project: str
Expand Down
4 changes: 2 additions & 2 deletions vision/google/cloud/vision/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import os

from google.cloud.client import JSONClient
from google.cloud.client import ClientWithProject
from google.cloud.environment_vars import DISABLE_GRPC

from google.cloud.vision._gax import _GAPICVisionAPI
Expand All @@ -28,7 +28,7 @@
_USE_GAX = not os.getenv(DISABLE_GRPC, False)


class Client(JSONClient):
class Client(ClientWithProject):
"""Client to bundle configuration needed for API requests.
:type project: str
Expand Down

0 comments on commit 9e6f2df

Please sign in to comment.