Content-Length: 647024 | pFad | http://github.com/googleapis/google-cloud-python/commit/c6ecf19fb05cf60860608ce3b3b98495ecd8c11e

64 feat(trace): add `client_options` to constructor (#9154) · googleapis/google-cloud-python@c6ecf19 · GitHub
Skip to content

Commit c6ecf19

Browse files
authored
feat(trace): add client_options to constructor (#9154)
1 parent 91a929f commit c6ecf19

File tree

8 files changed

+48
-10
lines changed

8 files changed

+48
-10
lines changed

trace/google/cloud/trace/_gapic.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,8 @@ def make_trace_api(client):
314314
proper configurations.
315315
"""
316316
generated = trace_service_client.TraceServiceClient(
317-
credentials=client._credentials, client_info=client._client_info
317+
credentials=client._credentials,
318+
client_info=client._client_info,
319+
client_options=client._client_options,
318320
)
319321
return _TraceAPI(generated, client)

trace/google/cloud/trace/client.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class Client(ClientWithProject):
3939
requests. If ``None``, then default info will be used. Generally,
4040
you only need to set this if you're developing your own library
4141
or partner tool.
42+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
43+
Client options used to set user options on the client. API Endpoint
44+
should be set through client_options.
4245
"""
4346

4447
SCOPE = (
@@ -49,9 +52,16 @@ class Client(ClientWithProject):
4952

5053
_trace_api = None
5154

52-
def __init__(self, project=None, credentials=None, client_info=_CLIENT_INFO):
55+
def __init__(
56+
self,
57+
project=None,
58+
credentials=None,
59+
client_info=_CLIENT_INFO,
60+
client_options=None,
61+
):
5362
super(Client, self).__init__(project=project, credentials=credentials)
5463
self._client_info = client_info
64+
self._client_options = client_options
5565

5666
@property
5767
def trace_api(self):

trace/google/cloud/trace/v1/_gapic.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ def make_trace_api(client):
178178
proper configurations.
179179
"""
180180
generated = trace_service_client.TraceServiceClient(
181-
credentials=client._credentials, client_info=client._client_info
181+
credentials=client._credentials,
182+
client_info=client._client_info,
183+
client_options=client._client_options,
182184
)
183185
return _TraceAPI(generated, client)
184186

trace/google/cloud/trace/v1/client.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ class Client(ClientWithProject):
4141
requests. If ``None``, then default info will be used. Generally,
4242
you only need to set this if you're developing your own library
4343
or partner tool.
44+
client_options (Union[dict, google.api_core.client_options.ClientOptions]):
45+
Client options used to set user options on the client. API Endpoint
46+
should be set through client_options.
4447
"""
4548

4649
SCOPE = (
@@ -51,9 +54,16 @@ class Client(ClientWithProject):
5154

5255
_trace_api = None
5356

54-
def __init__(self, project=None, credentials=None, client_info=_CLIENT_INFO):
57+
def __init__(
58+
self,
59+
project=None,
60+
credentials=None,
61+
client_info=_CLIENT_INFO,
62+
client_options=None,
63+
):
5564
super(Client, self).__init__(project=project, credentials=credentials)
5665
self._client_info = client_info
66+
self._client_options = client_options
5767

5868
@property
5969
def trace_api(self):

trace/tests/unit/v1/test__gapic_v1.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def _call_fut(self, client):
227227
def test_it(self):
228228
from google.cloud.trace.v1._gapic import _TraceAPI
229229

230-
client = mock.Mock(spec=["_credentials", "_client_info"])
230+
client = mock.Mock(spec=["_credentials", "_client_info", "_client_options"])
231231

232232
patch_api = mock.patch(
233233
"google.cloud.trace.v1._gapic.trace_service_client.TraceServiceClient"
@@ -237,7 +237,9 @@ def test_it(self):
237237
trace_api = self._call_fut(client)
238238

239239
patched.assert_called_once_with(
240-
credentials=client._credentials, client_info=client._client_info
240+
credentials=client._credentials,
241+
client_info=client._client_info,
242+
client_options=client._client_options,
241243
)
242244

243245
self.assertIsInstance(trace_api, _TraceAPI)

trace/tests/unit/v1/test_client_v1.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,16 @@ def test_constructor_defaults(self):
4747
def test_constructor_explicit(self):
4848
credentials = _make_credentials()
4949
client_info = mock.Mock()
50+
client_options = mock.Mock()
5051
client = self._make_one(
51-
project=self.project, credentials=credentials, client_info=client_info
52+
project=self.project,
53+
credentials=credentials,
54+
client_info=client_info,
55+
client_options=client_options,
5256
)
5357
self.assertEqual(client.project, self.project)
5458
self.assertIs(client._client_info, client_info)
59+
self.assertIs(client._client_options, client_options)
5560

5661
def test_trace_api(self):
5762
clients = []

trace/tests/unit/v2/test__gapic_v2.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ def _call_fut(self, client):
272272
def test_it(self):
273273
from google.cloud.trace._gapic import _TraceAPI
274274

275-
client = mock.Mock(spec=["_credentials", "_client_info"])
275+
client = mock.Mock(spec=["_credentials", "_client_info", "_client_options"])
276276

277277
patch_api = mock.patch(
278278
"google.cloud.trace._gapic.trace_service_client.TraceServiceClient"
@@ -282,7 +282,9 @@ def test_it(self):
282282
trace_api = self._call_fut(client)
283283

284284
patched.assert_called_once_with(
285-
credentials=client._credentials, client_info=client._client_info
285+
credentials=client._credentials,
286+
client_info=client._client_info,
287+
client_options=client._client_options,
286288
)
287289

288290
self.assertIsInstance(trace_api, _TraceAPI)

trace/tests/unit/v2/test_client_v2.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,15 @@ def test_constructor_defaults(self):
4747
def test_constructor_explicit(self):
4848
credentials = _make_credentials()
4949
client_info = mock.Mock()
50+
client_options = mock.Mock()
5051
client = self._make_one(
51-
project=self.project, credentials=credentials, client_info=client_info
52+
project=self.project,
53+
credentials=credentials,
54+
client_info=client_info,
55+
client_options=client_options,
5256
)
5357
self.assertEqual(client.project, self.project)
58+
self.assertIs(client._client_options, client_options)
5459

5560
def test_trace_api(self):
5661
clients = []

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/googleapis/google-cloud-python/commit/c6ecf19fb05cf60860608ce3b3b98495ecd8c11e

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy