Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 12 additions & 5 deletions asset/google/cloud/asset_v1beta1/gapic/asset_service_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(self,
transport=None,
channel=None,
credentials=None,
client_config=asset_service_client_config.config,
client_config=None,
client_info=None):
"""Constructor.

Expand Down Expand Up @@ -117,13 +117,20 @@ def __init__(self,
your own client library.
"""
# Raise deprecation warnings for things we want to go away.
if client_config:
warnings.warn('The `client_config` argument is deprecated.',
PendingDeprecationWarning)
if client_config is not None:
warnings.warn(
'The `client_config` argument is deprecated.',
PendingDeprecationWarning,
stacklevel=2)
else:
client_config = asset_service_client_config.config

if channel:
warnings.warn(
'The `channel` argument is deprecated; use '
'`transport` instead.', PendingDeprecationWarning)
'`transport` instead.',
PendingDeprecationWarning,
stacklevel=2)

# Instantiate the transport.
# The transport is responsible for handling serialization and
Expand Down
26 changes: 13 additions & 13 deletions asset/google/cloud/asset_v1beta1/gapic/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,6 @@
import enum


class NullValue(enum.IntEnum):
"""
``NullValue`` is a singleton enumeration to represent the null value for
the ``Value`` type union.

The JSON representation for ``NullValue`` is JSON ``null``.

Attributes:
NULL_VALUE (int): Null value.
"""
NULL_VALUE = 0


class ContentType(enum.IntEnum):
"""
Asset content type.
Expand All @@ -43,3 +30,16 @@ class ContentType(enum.IntEnum):
CONTENT_TYPE_UNSPECIFIED = 0
RESOURCE = 1
IAM_POLICY = 2


class NullValue(enum.IntEnum):
"""
``NullValue`` is a singleton enumeration to represent the null value for
the ``Value`` type union.

The JSON representation for ``NullValue`` is JSON ``null``.

Attributes:
NULL_VALUE (int): Null value.
"""
NULL_VALUE = 0
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ def __init__(self,
credentials=credentials,
)

self._channel = channel

# gRPC uses objects called "stubs" that are bound to the
# channel and provide a basic method for each RPC.
self._stubs = {
Expand Down Expand Up @@ -99,6 +101,15 @@ def create_channel(cls,
scopes=cls._OAUTH_SCOPES,
)

@property
def channel(self):
"""The gRPC channel used by the transport.

Returns:
grpc.Channel: A gRPC channel object.
"""
return self._channel

@property
def export_assets(self):
"""Return the gRPC stub for {$apiMethod.name}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
# limitations under the License.
"""Unit tests."""

import mock
import pytest

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

# Mock the API response
channel = ChannelStub(responses=[operation])
client = asset_v1beta1.AssetServiceClient(channel=channel)
patch = mock.patch('google.api_core.grpc_helpers.create_channel')
with patch as create_channel:
create_channel.return_value = channel
client = asset_v1beta1.AssetServiceClient()

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

# Mock the API response
channel = ChannelStub(responses=[operation])
client = asset_v1beta1.AssetServiceClient(channel=channel)
patch = mock.patch('google.api_core.grpc_helpers.create_channel')
with patch as create_channel:
create_channel.return_value = channel
client = asset_v1beta1.AssetServiceClient()

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

# Mock the API response
channel = ChannelStub(responses=[expected_response])
client = asset_v1beta1.AssetServiceClient(channel=channel)
patch = mock.patch('google.api_core.grpc_helpers.create_channel')
with patch as create_channel:
create_channel.return_value = channel
client = asset_v1beta1.AssetServiceClient()

# Setup Request
parent = client.project_path('[PROJECT]')
Expand All @@ -142,7 +152,10 @@ def test_batch_get_assets_history(self):
def test_batch_get_assets_history_exception(self):
# Mock the API response
channel = ChannelStub(responses=[CustomException()])
client = asset_v1beta1.AssetServiceClient(channel=channel)
patch = mock.patch('google.api_core.grpc_helpers.create_channel')
with patch as create_channel:
create_channel.return_value = channel
client = asset_v1beta1.AssetServiceClient()

# Setup request
parent = client.project_path('[PROJECT]')
Expand Down