Skip to content

Commit c68d8cb

Browse files
yoshi-automationtseaver
authored andcommitted
Pick up fixes in GAPIC generator. (#6489)
Includes fixes from these `gapic-generator` PRs: - googleapis/gapic-generator#2407 - googleapis/gapic-generator#2396
1 parent 86bf8d9 commit c68d8cb

File tree

4 files changed

+53
-22
lines changed

4 files changed

+53
-22
lines changed

packages/google-cloud-asset/google/cloud/asset_v1beta1/gapic/asset_service_client.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def __init__(self,
8484
transport=None,
8585
channel=None,
8686
credentials=None,
87-
client_config=asset_service_client_config.config,
87+
client_config=None,
8888
client_info=None):
8989
"""Constructor.
9090
@@ -117,13 +117,20 @@ def __init__(self,
117117
your own client library.
118118
"""
119119
# Raise deprecation warnings for things we want to go away.
120-
if client_config:
121-
warnings.warn('The `client_config` argument is deprecated.',
122-
PendingDeprecationWarning)
120+
if client_config is not None:
121+
warnings.warn(
122+
'The `client_config` argument is deprecated.',
123+
PendingDeprecationWarning,
124+
stacklevel=2)
125+
else:
126+
client_config = asset_service_client_config.config
127+
123128
if channel:
124129
warnings.warn(
125130
'The `channel` argument is deprecated; use '
126-
'`transport` instead.', PendingDeprecationWarning)
131+
'`transport` instead.',
132+
PendingDeprecationWarning,
133+
stacklevel=2)
127134

128135
# Instantiate the transport.
129136
# The transport is responsible for handling serialization and

packages/google-cloud-asset/google/cloud/asset_v1beta1/gapic/enums.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,6 @@
1818
import enum
1919

2020

21-
class NullValue(enum.IntEnum):
22-
"""
23-
``NullValue`` is a singleton enumeration to represent the null value for
24-
the ``Value`` type union.
25-
26-
The JSON representation for ``NullValue`` is JSON ``null``.
27-
28-
Attributes:
29-
NULL_VALUE (int): Null value.
30-
"""
31-
NULL_VALUE = 0
32-
33-
3421
class ContentType(enum.IntEnum):
3522
"""
3623
Asset content type.
@@ -43,3 +30,16 @@ class ContentType(enum.IntEnum):
4330
CONTENT_TYPE_UNSPECIFIED = 0
4431
RESOURCE = 1
4532
IAM_POLICY = 2
33+
34+
35+
class NullValue(enum.IntEnum):
36+
"""
37+
``NullValue`` is a singleton enumeration to represent the null value for
38+
the ``Value`` type union.
39+
40+
The JSON representation for ``NullValue`` is JSON ``null``.
41+
42+
Attributes:
43+
NULL_VALUE (int): Null value.
44+
"""
45+
NULL_VALUE = 0

packages/google-cloud-asset/google/cloud/asset_v1beta1/gapic/transports/asset_service_grpc_transport.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ def __init__(self,
6363
credentials=credentials,
6464
)
6565

66+
self._channel = channel
67+
6668
# gRPC uses objects called "stubs" that are bound to the
6769
# channel and provide a basic method for each RPC.
6870
self._stubs = {
@@ -99,6 +101,15 @@ def create_channel(cls,
99101
scopes=cls._OAUTH_SCOPES,
100102
)
101103

104+
@property
105+
def channel(self):
106+
"""The gRPC channel used by the transport.
107+
108+
Returns:
109+
grpc.Channel: A gRPC channel object.
110+
"""
111+
return self._channel
112+
102113
@property
103114
def export_assets(self):
104115
"""Return the gRPC stub for {$apiMethod.name}.

packages/google-cloud-asset/tests/unit/gapic/v1beta1/test_asset_service_client_v1beta1.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# limitations under the License.
1616
"""Unit tests."""
1717

18+
import mock
1819
import pytest
1920

2021
from google.rpc import status_pb2
@@ -77,7 +78,10 @@ def test_export_assets(self):
7778

7879
# Mock the API response
7980
channel = ChannelStub(responses=[operation])
80-
client = asset_v1beta1.AssetServiceClient(channel=channel)
81+
patch = mock.patch('google.api_core.grpc_helpers.create_channel')
82+
with patch as create_channel:
83+
create_channel.return_value = channel
84+
client = asset_v1beta1.AssetServiceClient()
8185

8286
# Setup Request
8387
parent = client.project_path('[PROJECT]')
@@ -102,7 +106,10 @@ def test_export_assets_exception(self):
102106

103107
# Mock the API response
104108
channel = ChannelStub(responses=[operation])
105-
client = asset_v1beta1.AssetServiceClient(channel=channel)
109+
patch = mock.patch('google.api_core.grpc_helpers.create_channel')
110+
with patch as create_channel:
111+
create_channel.return_value = channel
112+
client = asset_v1beta1.AssetServiceClient()
106113

107114
# Setup Request
108115
parent = client.project_path('[PROJECT]')
@@ -120,7 +127,10 @@ def test_batch_get_assets_history(self):
120127

121128
# Mock the API response
122129
channel = ChannelStub(responses=[expected_response])
123-
client = asset_v1beta1.AssetServiceClient(channel=channel)
130+
patch = mock.patch('google.api_core.grpc_helpers.create_channel')
131+
with patch as create_channel:
132+
create_channel.return_value = channel
133+
client = asset_v1beta1.AssetServiceClient()
124134

125135
# Setup Request
126136
parent = client.project_path('[PROJECT]')
@@ -142,7 +152,10 @@ def test_batch_get_assets_history(self):
142152
def test_batch_get_assets_history_exception(self):
143153
# Mock the API response
144154
channel = ChannelStub(responses=[CustomException()])
145-
client = asset_v1beta1.AssetServiceClient(channel=channel)
155+
patch = mock.patch('google.api_core.grpc_helpers.create_channel')
156+
with patch as create_channel:
157+
create_channel.return_value = channel
158+
client = asset_v1beta1.AssetServiceClient()
146159

147160
# Setup request
148161
parent = client.project_path('[PROJECT]')

0 commit comments

Comments
 (0)