Skip to content

Commit 9e6f2df

Browse files
authored
Merge pull request #2968 from dhermes/generic-hygiene
Renaming JSONClient -> ClientWithProject.
2 parents a70815d + b53be84 commit 9e6f2df

File tree

12 files changed

+25
-31
lines changed

12 files changed

+25
-31
lines changed

bigquery/google/cloud/bigquery/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"""Client for interacting with the Google BigQuery API."""
1616

1717

18-
from google.cloud.client import JSONClient
18+
from google.cloud.client import ClientWithProject
1919
from google.cloud.bigquery._http import Connection
2020
from google.cloud.bigquery.dataset import Dataset
2121
from google.cloud.bigquery.job import CopyJob
@@ -50,7 +50,7 @@ def from_api_repr(cls, resource):
5050
resource['id'], resource['numericId'], resource['friendlyName'])
5151

5252

53-
class Client(JSONClient):
53+
class Client(ClientWithProject):
5454
"""Client to bundle configuration needed for API requests.
5555
5656
:type project: str

core/google/cloud/_helpers.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ def _name_from_project_path(path, project, template):
512512
return match.group('name')
513513

514514

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

540540
user_agent_option = ('grpc.primary_user_agent', user_agent)
541-
if extra_options is not None:
542-
options = (user_agent_option,) + extra_options
543-
else:
544-
options = (user_agent_option,)
541+
options = (user_agent_option,) + extra_options
545542
return google.auth.transport.grpc.secure_authorized_channel(
546543
credentials,
547544
http_request,
@@ -550,7 +547,7 @@ def make_secure_channel(credentials, user_agent, host, extra_options=None):
550547

551548

552549
def make_secure_stub(credentials, user_agent, stub_class, host,
553-
extra_options=None):
550+
extra_options=()):
554551
"""Makes a secure stub for an RPC service.
555552
556553
Uses / depends on gRPC.

core/google/cloud/client.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,8 @@ def _determine_default(project):
129129
return _determine_default_project(project)
130130

131131

132-
class JSONClient(Client, _ClientProjectMixin):
133-
"""Client for Google JSON-based API.
134-
135-
Assumes such APIs use the ``project`` and the client needs to store this
136-
value.
132+
class ClientWithProject(Client, _ClientProjectMixin):
133+
"""Client that also stores a project.
137134
138135
:type project: str
139136
:param project: the project which the client acts on behalf of. If not

core/unit_tests/test__helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -789,7 +789,7 @@ def mock_channel(*args, **kwargs):
789789
credentials = object()
790790
user_agent = 'you-sir-age-int'
791791
host = 'localhost'
792-
extra_options = {'extra_options': None}
792+
extra_options = {'extra_options': ()}
793793
with _Monkey(MUT, make_secure_channel=mock_channel):
794794
stub = self._call_fut(credentials, user_agent,
795795
stub_class, host)

core/unit_tests/test_client.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,13 @@ def test_from_service_account_json_bad_args(self):
104104
mock.sentinel.filename, credentials=mock.sentinel.credentials)
105105

106106

107-
class TestJSONClient(unittest.TestCase):
107+
class TestClientWithProject(unittest.TestCase):
108108

109109
@staticmethod
110110
def _get_target_class():
111-
from google.cloud.client import JSONClient
111+
from google.cloud.client import ClientWithProject
112112

113-
return JSONClient
113+
return ClientWithProject
114114

115115
def _make_one(self, *args, **kw):
116116
return self._get_target_class()(*args, **kw)

dns/google/cloud/dns/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
"""Client for interacting with the Google Cloud DNS API."""
1616

1717

18-
from google.cloud.client import JSONClient
18+
from google.cloud.client import ClientWithProject
1919
from google.cloud.dns.connection import Connection
2020
from google.cloud.dns.zone import ManagedZone
2121
from google.cloud.iterator import HTTPIterator
2222

2323

24-
class Client(JSONClient):
24+
class Client(ClientWithProject):
2525
"""Client to bundle configuration needed for API requests.
2626
2727
:type project: str

logging/google/cloud/logging/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
else:
3030
_HAVE_GAX = True
3131

32-
from google.cloud.client import JSONClient
32+
from google.cloud.client import ClientWithProject
3333
from google.cloud.environment_vars import DISABLE_GRPC
3434
from google.cloud.logging._http import Connection
3535
from google.cloud.logging._http import _LoggingAPI as JSONLoggingAPI
@@ -59,7 +59,7 @@
5959
"""Environment variable set in a Google Container Engine environment."""
6060

6161

62-
class Client(JSONClient):
62+
class Client(ClientWithProject):
6363
"""Client to bundle configuration needed for API requests.
6464
6565
:type project: str

monitoring/google/cloud/monitoring/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import datetime
3232

3333
from google.cloud._helpers import _datetime_to_rfc3339
34-
from google.cloud.client import JSONClient
34+
from google.cloud.client import ClientWithProject
3535
from google.cloud.monitoring.connection import Connection
3636
from google.cloud.monitoring.group import Group
3737
from google.cloud.monitoring.metric import Metric
@@ -47,7 +47,7 @@
4747
_UTCNOW = datetime.datetime.utcnow # To be replaced by tests.
4848

4949

50-
class Client(JSONClient):
50+
class Client(ClientWithProject):
5151
"""Client to bundle configuration needed for API requests.
5252
5353
:type project: str

pubsub/google/cloud/pubsub/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import os
1818

19-
from google.cloud.client import JSONClient
19+
from google.cloud.client import ClientWithProject
2020
from google.cloud.environment_vars import DISABLE_GRPC
2121
from google.cloud.pubsub._http import Connection
2222
from google.cloud.pubsub._http import _PublisherAPI as JSONPublisherAPI
@@ -43,7 +43,7 @@
4343
_USE_GAX = _HAVE_GAX and not _DISABLE_GAX
4444

4545

46-
class Client(JSONClient):
46+
class Client(ClientWithProject):
4747
"""Client to bundle configuration needed for API requests.
4848
4949
:type project: str

runtimeconfig/google/cloud/runtimeconfig/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
"""Client for interacting with the Google Cloud RuntimeConfig API."""
1616

1717

18-
from google.cloud.client import JSONClient
18+
from google.cloud.client import ClientWithProject
1919
from google.cloud.runtimeconfig.connection import Connection
2020
from google.cloud.runtimeconfig.config import Config
2121

2222

23-
class Client(JSONClient):
23+
class Client(ClientWithProject):
2424
"""Client to bundle configuration needed for API requests.
2525
2626
:type project: str

0 commit comments

Comments
 (0)