diff --git a/docs/gapic/v1p5beta1/api.rst b/docs/gapic/v1p5beta1/api.rst new file mode 100644 index 00000000..bbb03e40 --- /dev/null +++ b/docs/gapic/v1p5beta1/api.rst @@ -0,0 +1,6 @@ +Client for Cloud Asset API +========================== + +.. automodule:: google.cloud.asset_v1p5beta1 + :members: + :inherited-members: \ No newline at end of file diff --git a/docs/gapic/v1p5beta1/types.rst b/docs/gapic/v1p5beta1/types.rst new file mode 100644 index 00000000..951aa3ab --- /dev/null +++ b/docs/gapic/v1p5beta1/types.rst @@ -0,0 +1,5 @@ +Types for Cloud Asset API Client +================================ + +.. automodule:: google.cloud.asset_v1p5beta1.types + :members: \ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index 2647d988..a78971d6 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -8,13 +8,13 @@ Api Reference This package includes clients for multiple versions of the Cloud Asset API. By default, you will get ``v1`` the latest stable version. -v1 +v1 ~~~~~~~~~ .. toctree:: :maxdepth: 2 - gapic/v1/api - gapic/v1/types + Client (v1) + Types (v1) Beta releases with additional features over the current stable version. These are expected to move into the stable release soon; until then, the usual beta admonishment (changes are possible, etc.) applies. @@ -27,8 +27,8 @@ v1p1beta1 .. toctree:: :maxdepth: 2 - gapic/v1p1beta1/api - gapic/v1p1beta1/types + Client (v1p1beta1) + Types (v1p1beta1) v1p2beta1 @@ -36,8 +36,8 @@ v1p2beta1 .. toctree:: :maxdepth: 2 - gapic/v1p2beta1/api - gapic/v1p2beta1/types + Client (v1p1beta1) + Types (v1p1beta1) v1p4beta1 @@ -45,18 +45,26 @@ v1p4beta1 .. toctree:: :maxdepth: 2 - gapic/v1p4beta1/api - gapic/v1p4beta1/types + Client (v1p4beta1) + Types (v1p4beta1) +v1p5beta1 +~~~~~~~~~ +.. toctree:: + :maxdepth: 2 + + Client (v1p5beta1) + Types (v1p5beta1) + v1beta1 ~~~~~~~~~ .. toctree:: :maxdepth: 2 - gapic/v1beta1/api - gapic/v1beta1/types + Client (v1beta1) + Types (v1beta1) Changelog diff --git a/google/cloud/asset_v1p5beta1/__init__.py b/google/cloud/asset_v1p5beta1/__init__.py new file mode 100644 index 00000000..fad23f62 --- /dev/null +++ b/google/cloud/asset_v1p5beta1/__init__.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +from __future__ import absolute_import +import sys +import warnings + +from google.cloud.asset_v1p5beta1 import types +from google.cloud.asset_v1p5beta1.gapic import asset_service_client +from google.cloud.asset_v1p5beta1.gapic import enums + + +if sys.version_info[:2] == (2, 7): + message = ( + "A future version of this library will drop support for Python 2.7. " + "More details about Python 2 support for Google Cloud Client Libraries " + "can be found at https://cloud.google.com/python/docs/python2-sunset/" + ) + warnings.warn(message, DeprecationWarning) + + +class AssetServiceClient(asset_service_client.AssetServiceClient): + __doc__ = asset_service_client.AssetServiceClient.__doc__ + enums = enums + + +__all__ = ("enums", "types", "AssetServiceClient") diff --git a/google/cloud/asset_v1p5beta1/gapic/__init__.py b/google/cloud/asset_v1p5beta1/gapic/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/google/cloud/asset_v1p5beta1/gapic/asset_service_client.py b/google/cloud/asset_v1p5beta1/gapic/asset_service_client.py new file mode 100644 index 00000000..d079daa3 --- /dev/null +++ b/google/cloud/asset_v1p5beta1/gapic/asset_service_client.py @@ -0,0 +1,316 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Accesses the google.cloud.asset.v1p5beta1 AssetService API.""" + +import functools +import pkg_resources +import warnings + +from google.oauth2 import service_account +import google.api_core.client_options +import google.api_core.gapic_v1.client_info +import google.api_core.gapic_v1.config +import google.api_core.gapic_v1.method +import google.api_core.gapic_v1.routing_header +import google.api_core.grpc_helpers +import google.api_core.page_iterator +import grpc + +from google.cloud.asset_v1p5beta1.gapic import asset_service_client_config +from google.cloud.asset_v1p5beta1.gapic import enums +from google.cloud.asset_v1p5beta1.gapic.transports import asset_service_grpc_transport +from google.cloud.asset_v1p5beta1.proto import asset_service_pb2 +from google.cloud.asset_v1p5beta1.proto import asset_service_pb2_grpc +from google.protobuf import timestamp_pb2 + + +_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution("google-cloud-asset").version + + +class AssetServiceClient(object): + """Asset service definition.""" + + SERVICE_ADDRESS = "cloudasset.googleapis.com:443" + """The default address of the service.""" + + # The name of the interface for this client. This is the key used to + # find the method configuration in the client_config dictionary. + _INTERFACE_NAME = "google.cloud.asset.v1p5beta1.AssetService" + + @classmethod + def from_service_account_file(cls, filename, *args, **kwargs): + """Creates an instance of this client using the provided credentials + file. + + Args: + filename (str): The path to the service account private key json + file. + args: Additional arguments to pass to the constructor. + kwargs: Additional arguments to pass to the constructor. + + Returns: + AssetServiceClient: The constructed client. + """ + credentials = service_account.Credentials.from_service_account_file(filename) + kwargs["credentials"] = credentials + return cls(*args, **kwargs) + + from_service_account_json = from_service_account_file + + def __init__( + self, + transport=None, + channel=None, + credentials=None, + client_config=None, + client_info=None, + client_options=None, + ): + """Constructor. + + Args: + transport (Union[~.AssetServiceGrpcTransport, + Callable[[~.Credentials, type], ~.AssetServiceGrpcTransport]): A transport + instance, responsible for actually making the API calls. + The default transport uses the gRPC protocol. + This argument may also be a callable which returns a + transport instance. Callables will be sent the credentials + as the first argument and the default transport class as + the second argument. + channel (grpc.Channel): DEPRECATED. A ``Channel`` instance + through which to make calls. This argument is mutually exclusive + with ``credentials``; providing both will raise an exception. + credentials (google.auth.credentials.Credentials): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If none + are specified, the client will attempt to ascertain the + credentials from the environment. + This argument is mutually exclusive with providing a + transport instance to ``transport``; doing so will raise + an exception. + client_config (dict): DEPRECATED. A dictionary of call options for + each method. If not specified, the default configuration is used. + client_info (google.api_core.gapic_v1.client_info.ClientInfo): + The client info used to send a user-agent string along with + API requests. If ``None``, then default info will be used. + Generally, you only need to set this if you're developing + your own client library. + client_options (Union[dict, google.api_core.client_options.ClientOptions]): + Client options used to set user options on the client. API Endpoint + should be set through client_options. + """ + # Raise deprecation warnings for things we want to go away. + 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, + stacklevel=2, + ) + + api_endpoint = self.SERVICE_ADDRESS + if client_options: + if type(client_options) == dict: + client_options = google.api_core.client_options.from_dict( + client_options + ) + if client_options.api_endpoint: + api_endpoint = client_options.api_endpoint + + # Instantiate the transport. + # The transport is responsible for handling serialization and + # deserialization and actually sending data to the service. + if transport: + if callable(transport): + self.transport = transport( + credentials=credentials, + default_class=asset_service_grpc_transport.AssetServiceGrpcTransport, + address=api_endpoint, + ) + else: + if credentials: + raise ValueError( + "Received both a transport instance and " + "credentials; these are mutually exclusive." + ) + self.transport = transport + else: + self.transport = asset_service_grpc_transport.AssetServiceGrpcTransport( + address=api_endpoint, channel=channel, credentials=credentials + ) + + if client_info is None: + client_info = google.api_core.gapic_v1.client_info.ClientInfo( + gapic_version=_GAPIC_LIBRARY_VERSION + ) + else: + client_info.gapic_version = _GAPIC_LIBRARY_VERSION + self._client_info = client_info + + # Parse out the default settings for retry and timeout for each RPC + # from the client configuration. + # (Ordinarily, these are the defaults specified in the `*_config.py` + # file next to this one.) + self._method_configs = google.api_core.gapic_v1.config.parse_method_configs( + client_config["interfaces"][self._INTERFACE_NAME] + ) + + # Save a dictionary of cached API call functions. + # These are the actual callables which invoke the proper + # transport methods, wrapped with `wrap_method` to add retry, + # timeout, and the like. + self._inner_api_calls = {} + + # Service calls + def list_assets( + self, + parent, + read_time=None, + asset_types=None, + content_type=None, + page_size=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): + """ + Lists assets with time and resource types and returns paged results in + response. + + Example: + >>> from google.cloud import asset_v1p5beta1 + >>> + >>> client = asset_v1p5beta1.AssetServiceClient() + >>> + >>> # TODO: Initialize `parent`: + >>> parent = '' + >>> + >>> # Iterate over all results + >>> for element in client.list_assets(parent): + ... # process element + ... pass + >>> + >>> + >>> # Alternatively: + >>> + >>> # Iterate over results one page at a time + >>> for page in client.list_assets(parent).pages: + ... for element in page: + ... # process element + ... pass + + Args: + parent (str): Required. Name of the organization or project the assets belong to. + Format: "organizations/[organization-number]" (such as + "organizations/123"), "projects/[project-number]" (such as + "projects/my-project-id"), or "projects/[project-id]" (such as + "projects/12345"). + read_time (Union[dict, ~google.cloud.asset_v1p5beta1.types.Timestamp]): Timestamp to take an asset snapshot. This can only be set to a timestamp + between 2018-10-02 UTC (inclusive) and the current time. If not specified, + the current time will be used. Due to delays in resource data collection + and indexing, there is a volatile window during which running the same + query may get different results. + + If a dict is provided, it must be of the same form as the protobuf + message :class:`~google.cloud.asset_v1p5beta1.types.Timestamp` + asset_types (list[str]): A list of asset types of which to take a snapshot for. For example: + "compute.googleapis.com/Disk". If specified, only matching assets will + be returned. See `Introduction to Cloud Asset + Inventory `__ + for all supported asset types. + content_type (~google.cloud.asset_v1p5beta1.types.ContentType): Asset content type. If not specified, no content but the asset name will + be returned. + page_size (int): The maximum number of resources contained in the + underlying API response. If page streaming is performed per- + resource, this parameter does not affect the return value. If page + streaming is performed per-page, this determines the maximum number + of resources in a page. + retry (Optional[google.api_core.retry.Retry]): A retry object used + to retry requests. If ``None`` is specified, requests will + be retried using a default configuration. + timeout (Optional[float]): The amount of time, in seconds, to wait + for the request to complete. Note that if ``retry`` is + specified, the timeout applies to each individual attempt. + metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata + that is provided to the method. + + Returns: + A :class:`~google.api_core.page_iterator.PageIterator` instance. + An iterable of :class:`~google.cloud.asset_v1p5beta1.types.Asset` instances. + You can also iterate over the pages of the response + using its `pages` property. + + Raises: + google.api_core.exceptions.GoogleAPICallError: If the request + failed for any reason. + google.api_core.exceptions.RetryError: If the request failed due + to a retryable error and retry attempts failed. + ValueError: If the parameters are invalid. + """ + # Wrap the transport method to add retry and timeout logic. + if "list_assets" not in self._inner_api_calls: + self._inner_api_calls[ + "list_assets" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.list_assets, + default_retry=self._method_configs["ListAssets"].retry, + default_timeout=self._method_configs["ListAssets"].timeout, + client_info=self._client_info, + ) + + request = asset_service_pb2.ListAssetsRequest( + parent=parent, + read_time=read_time, + asset_types=asset_types, + content_type=content_type, + page_size=page_size, + ) + if metadata is None: + metadata = [] + metadata = list(metadata) + try: + routing_header = [("parent", parent)] + except AttributeError: + pass + else: + routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata( + routing_header + ) + metadata.append(routing_metadata) + + iterator = google.api_core.page_iterator.GRPCIterator( + client=None, + method=functools.partial( + self._inner_api_calls["list_assets"], + retry=retry, + timeout=timeout, + metadata=metadata, + ), + request=request, + items_field="assets", + request_token_field="page_token", + response_token_field="next_page_token", + ) + return iterator diff --git a/google/cloud/asset_v1p5beta1/gapic/asset_service_client_config.py b/google/cloud/asset_v1p5beta1/gapic/asset_service_client_config.py new file mode 100644 index 00000000..ae4705f6 --- /dev/null +++ b/google/cloud/asset_v1p5beta1/gapic/asset_service_client_config.py @@ -0,0 +1,28 @@ +config = { + "interfaces": { + "google.cloud.asset.v1p5beta1.AssetService": { + "retry_codes": { + "idempotent": ["DEADLINE_EXCEEDED", "UNAVAILABLE"], + "non_idempotent": [], + }, + "retry_params": { + "default": { + "initial_retry_delay_millis": 100, + "retry_delay_multiplier": 1.3, + "max_retry_delay_millis": 60000, + "initial_rpc_timeout_millis": 20000, + "rpc_timeout_multiplier": 1.0, + "max_rpc_timeout_millis": 20000, + "total_timeout_millis": 600000, + } + }, + "methods": { + "ListAssets": { + "timeout_millis": 600000, + "retry_codes_name": "idempotent", + "retry_params_name": "default", + } + }, + } + } +} diff --git a/google/cloud/asset_v1p5beta1/gapic/enums.py b/google/cloud/asset_v1p5beta1/gapic/enums.py new file mode 100644 index 00000000..bc92bd1d --- /dev/null +++ b/google/cloud/asset_v1p5beta1/gapic/enums.py @@ -0,0 +1,181 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Wrappers for protocol buffer enum types.""" + +import enum + + +class ContentType(enum.IntEnum): + """ + Asset content type. + + Attributes: + CONTENT_TYPE_UNSPECIFIED (int): Unspecified content type. + RESOURCE (int): Resource metadata. + IAM_POLICY (int): The actual IAM policy set on a resource. + ORG_POLICY (int): The Cloud Organization Policy set on an asset. + ACCESS_POLICY (int): The Cloud Access context mananger Policy set on an asset. + """ + + CONTENT_TYPE_UNSPECIFIED = 0 + RESOURCE = 1 + IAM_POLICY = 2 + ORG_POLICY = 4 + ACCESS_POLICY = 5 + + +class DeviceEncryptionStatus(enum.IntEnum): + """ + The encryption state of the device. + + Attributes: + ENCRYPTION_UNSPECIFIED (int): The encryption status of the device is not specified or not known. + ENCRYPTION_UNSUPPORTED (int): The device does not support encryption. + UNENCRYPTED (int): The device supports encryption, but is currently unencrypted. + ENCRYPTED (int): The device is encrypted. + """ + + ENCRYPTION_UNSPECIFIED = 0 + ENCRYPTION_UNSUPPORTED = 1 + UNENCRYPTED = 2 + ENCRYPTED = 3 + + +class DeviceManagementLevel(enum.IntEnum): + """ + The degree to which the device is managed by the Cloud organization. + + Attributes: + MANAGEMENT_UNSPECIFIED (int): The device's management level is not specified or not known. + NONE (int): The device is not managed. + BASIC (int): Basic management is enabled, which is generally limited to monitoring and + wiping the corporate account. + COMPLETE (int): Complete device management. This includes more thorough monitoring and the + ability to directly manage the device (such as remote wiping). This can be + enabled through the Android Enterprise Platform. + """ + + MANAGEMENT_UNSPECIFIED = 0 + NONE = 1 + BASIC = 2 + COMPLETE = 3 + + +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 OsType(enum.IntEnum): + """ + The operating system type of the device. + Next id: 7 + + Attributes: + OS_UNSPECIFIED (int): The operating system of the device is not specified or not known. + DESKTOP_MAC (int): A desktop Mac operating system. + DESKTOP_WINDOWS (int): A desktop Windows operating system. + DESKTOP_LINUX (int): A desktop Linux operating system. + DESKTOP_CHROME_OS (int): A desktop ChromeOS operating system. + ANDROID (int): An Android operating system. + IOS (int): An iOS operating system. + """ + + OS_UNSPECIFIED = 0 + DESKTOP_MAC = 1 + DESKTOP_WINDOWS = 2 + DESKTOP_LINUX = 3 + DESKTOP_CHROME_OS = 6 + ANDROID = 4 + IOS = 5 + + +class BasicLevel(object): + class ConditionCombiningFunction(enum.IntEnum): + """ + Options for how the ``conditions`` list should be combined to + determine if this ``AccessLevel`` is applied. Default is AND. + + Attributes: + AND (int): All ``Conditions`` must be true for the ``BasicLevel`` to be true. + OR (int): If at least one ``Condition`` is true, then the ``BasicLevel`` is + true. + """ + + AND = 0 + OR = 1 + + +class Policy(object): + class ListPolicy(object): + class AllValues(enum.IntEnum): + """ + This enum can be used to set ``Policies`` that apply to all possible + configuration values rather than specific values in ``allowed_values`` + or ``denied_values``. + + Settting this to ``ALLOW`` will mean this ``Policy`` allows all values. + Similarly, setting it to ``DENY`` will mean no values are allowed. If + set to either ``ALLOW`` or + ``DENY,``\ allowed_values\ ``and``\ denied_values\ ``must be unset. Setting this to``\ ALL_VALUES_UNSPECIFIED\ ``allows for setting``\ allowed_values\ ``and``\ denied_values`. + + Attributes: + ALL_VALUES_UNSPECIFIED (int): Indicates that allowed_values or denied_values must be set. + ALLOW (int): A policy with this set allows all values. + DENY (int): A policy with this set denies all values. + """ + + ALL_VALUES_UNSPECIFIED = 0 + ALLOW = 1 + DENY = 2 + + +class ServicePerimeter(object): + class PerimeterType(enum.IntEnum): + """ + Specifies the type of the Perimeter. There are two types: regular and + bridge. Regular Service Perimeter contains resources, access levels, and + restricted services. Every resource can be in at most ONE + regular Service Perimeter. + + In addition to being in a regular service perimeter, a resource can also + be in zero or more perimeter bridges. A perimeter bridge only contains + resources. Cross project operations are permitted if all effected + resources share some perimeter (whether bridge or regular). Perimeter + Bridge does not contain access levels or services: those are governed + entirely by the regular perimeter that resource is in. + + Perimeter Bridges are typically useful when building more complex toplogies + with many independent perimeters that need to share some data with a common + perimeter, but should not be able to share data among themselves. + + Attributes: + PERIMETER_TYPE_REGULAR (int): Regular Perimeter. + PERIMETER_TYPE_BRIDGE (int): Perimeter Bridge. + """ + + PERIMETER_TYPE_REGULAR = 0 + PERIMETER_TYPE_BRIDGE = 1 diff --git a/google/cloud/asset_v1p5beta1/gapic/transports/__init__.py b/google/cloud/asset_v1p5beta1/gapic/transports/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/google/cloud/asset_v1p5beta1/gapic/transports/asset_service_grpc_transport.py b/google/cloud/asset_v1p5beta1/gapic/transports/asset_service_grpc_transport.py new file mode 100644 index 00000000..2114cd9d --- /dev/null +++ b/google/cloud/asset_v1p5beta1/gapic/transports/asset_service_grpc_transport.py @@ -0,0 +1,122 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +import google.api_core.grpc_helpers + +from google.cloud.asset_v1p5beta1.proto import asset_service_pb2_grpc + + +class AssetServiceGrpcTransport(object): + """gRPC transport class providing stubs for + google.cloud.asset.v1p5beta1 AssetService API. + + The transport provides access to the raw gRPC stubs, + which can be used to take advantage of advanced + features of gRPC. + """ + + # The scopes needed to make gRPC calls to all of the methods defined + # in this service. + _OAUTH_SCOPES = ("https://www.googleapis.com/auth/cloud-platform",) + + def __init__( + self, channel=None, credentials=None, address="cloudasset.googleapis.com:443" + ): + """Instantiate the transport class. + + Args: + channel (grpc.Channel): A ``Channel`` instance through + which to make calls. This argument is mutually exclusive + with ``credentials``; providing both will raise an exception. + credentials (google.auth.credentials.Credentials): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If none + are specified, the client will attempt to ascertain the + credentials from the environment. + address (str): The address where the service is hosted. + """ + # If both `channel` and `credentials` are specified, raise an + # exception (channels come with credentials baked in already). + if channel is not None and credentials is not None: + raise ValueError( + "The `channel` and `credentials` arguments are mutually " "exclusive." + ) + + # Create the channel. + if channel is None: + channel = self.create_channel( + address=address, + credentials=credentials, + options={ + "grpc.max_send_message_length": -1, + "grpc.max_receive_message_length": -1, + }.items(), + ) + + self._channel = channel + + # gRPC uses objects called "stubs" that are bound to the + # channel and provide a basic method for each RPC. + self._stubs = { + "asset_service_stub": asset_service_pb2_grpc.AssetServiceStub(channel) + } + + @classmethod + def create_channel( + cls, address="cloudasset.googleapis.com:443", credentials=None, **kwargs + ): + """Create and return a gRPC channel object. + + Args: + address (str): The host for the channel to use. + credentials (~.Credentials): The + authorization credentials to attach to requests. These + credentials identify this application to the service. If + none are specified, the client will attempt to ascertain + the credentials from the environment. + kwargs (dict): Keyword arguments, which are passed to the + channel creation. + + Returns: + grpc.Channel: A gRPC channel object. + """ + return google.api_core.grpc_helpers.create_channel( + address, credentials=credentials, scopes=cls._OAUTH_SCOPES, **kwargs + ) + + @property + def channel(self): + """The gRPC channel used by the transport. + + Returns: + grpc.Channel: A gRPC channel object. + """ + return self._channel + + @property + def list_assets(self): + """Return the gRPC stub for :meth:`AssetServiceClient.list_assets`. + + Lists assets with time and resource types and returns paged results in + response. + + Returns: + Callable: A callable which accepts the appropriate + deserialized request object and returns a + deserialized response object. + """ + return self._stubs["asset_service_stub"].ListAssets diff --git a/google/cloud/asset_v1p5beta1/proto/__init__.py b/google/cloud/asset_v1p5beta1/proto/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/google/cloud/asset_v1p5beta1/proto/asset_service_pb2.py b/google/cloud/asset_v1p5beta1/proto/asset_service_pb2.py new file mode 100644 index 00000000..0ba91d04 --- /dev/null +++ b/google/cloud/asset_v1p5beta1/proto/asset_service_pb2.py @@ -0,0 +1,432 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/asset_v1p5beta1/proto/asset_service.proto + +from google.protobuf.internal import enum_type_wrapper +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database + +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.api import client_pb2 as google_dot_api_dot_client__pb2 +from google.api import field_behavior_pb2 as google_dot_api_dot_field__behavior__pb2 +from google.cloud.asset_v1p5beta1.proto import ( + assets_pb2 as google_dot_cloud_dot_asset__v1p5beta1_dot_proto_dot_assets__pb2, +) +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name="google/cloud/asset_v1p5beta1/proto/asset_service.proto", + package="google.cloud.asset.v1p5beta1", + syntax="proto3", + serialized_options=b"\n com.google.cloud.asset.v1p5beta1B\021AssetServiceProtoP\001ZAgoogle.golang.org/genproto/googleapis/cloud/asset/v1p5beta1;asset\252\002\034Google.Cloud.Asset.V1P5Beta1\312\002\034Google\\Cloud\\Asset\\V1p5beta1", + create_key=_descriptor._internal_create_key, + serialized_pb=b'\n6google/cloud/asset_v1p5beta1/proto/asset_service.proto\x12\x1cgoogle.cloud.asset.v1p5beta1\x1a\x1cgoogle/api/annotations.proto\x1a\x17google/api/client.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a/google/cloud/asset_v1p5beta1/proto/assets.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\xd4\x01\n\x11ListAssetsRequest\x12\x13\n\x06parent\x18\x01 \x01(\tB\x03\xe0\x41\x02\x12-\n\tread_time\x18\x02 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x13\n\x0b\x61sset_types\x18\x03 \x03(\t\x12?\n\x0c\x63ontent_type\x18\x04 \x01(\x0e\x32).google.cloud.asset.v1p5beta1.ContentType\x12\x11\n\tpage_size\x18\x05 \x01(\x05\x12\x12\n\npage_token\x18\x06 \x01(\t"\x91\x01\n\x12ListAssetsResponse\x12-\n\tread_time\x18\x01 \x01(\x0b\x32\x1a.google.protobuf.Timestamp\x12\x33\n\x06\x61ssets\x18\x02 \x03(\x0b\x32#.google.cloud.asset.v1p5beta1.Asset\x12\x17\n\x0fnext_page_token\x18\x03 \x01(\t*l\n\x0b\x43ontentType\x12\x1c\n\x18\x43ONTENT_TYPE_UNSPECIFIED\x10\x00\x12\x0c\n\x08RESOURCE\x10\x01\x12\x0e\n\nIAM_POLICY\x10\x02\x12\x0e\n\nORG_POLICY\x10\x04\x12\x11\n\rACCESS_POLICY\x10\x05\x32\xf7\x01\n\x0c\x41ssetService\x12\x97\x01\n\nListAssets\x12/.google.cloud.asset.v1p5beta1.ListAssetsRequest\x1a\x30.google.cloud.asset.v1p5beta1.ListAssetsResponse"&\x82\xd3\xe4\x93\x02 \x12\x1e/v1p5beta1/{parent=*/*}/assets\x1aM\xca\x41\x19\x63loudasset.googleapis.com\xd2\x41.https://www.googleapis.com/auth/cloud-platformB\xb8\x01\n com.google.cloud.asset.v1p5beta1B\x11\x41ssetServiceProtoP\x01ZAgoogle.golang.org/genproto/googleapis/cloud/asset/v1p5beta1;asset\xaa\x02\x1cGoogle.Cloud.Asset.V1P5Beta1\xca\x02\x1cGoogle\\Cloud\\Asset\\V1p5beta1b\x06proto3', + dependencies=[ + google_dot_api_dot_annotations__pb2.DESCRIPTOR, + google_dot_api_dot_client__pb2.DESCRIPTOR, + google_dot_api_dot_field__behavior__pb2.DESCRIPTOR, + google_dot_cloud_dot_asset__v1p5beta1_dot_proto_dot_assets__pb2.DESCRIPTOR, + google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR, + ], +) + +_CONTENTTYPE = _descriptor.EnumDescriptor( + name="ContentType", + full_name="google.cloud.asset.v1p5beta1.ContentType", + filename=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + values=[ + _descriptor.EnumValueDescriptor( + name="CONTENT_TYPE_UNSPECIFIED", + index=0, + number=0, + serialized_options=None, + type=None, + create_key=_descriptor._internal_create_key, + ), + _descriptor.EnumValueDescriptor( + name="RESOURCE", + index=1, + number=1, + serialized_options=None, + type=None, + create_key=_descriptor._internal_create_key, + ), + _descriptor.EnumValueDescriptor( + name="IAM_POLICY", + index=2, + number=2, + serialized_options=None, + type=None, + create_key=_descriptor._internal_create_key, + ), + _descriptor.EnumValueDescriptor( + name="ORG_POLICY", + index=3, + number=4, + serialized_options=None, + type=None, + create_key=_descriptor._internal_create_key, + ), + _descriptor.EnumValueDescriptor( + name="ACCESS_POLICY", + index=4, + number=5, + serialized_options=None, + type=None, + create_key=_descriptor._internal_create_key, + ), + ], + containing_type=None, + serialized_options=None, + serialized_start=621, + serialized_end=729, +) +_sym_db.RegisterEnumDescriptor(_CONTENTTYPE) + +ContentType = enum_type_wrapper.EnumTypeWrapper(_CONTENTTYPE) +CONTENT_TYPE_UNSPECIFIED = 0 +RESOURCE = 1 +IAM_POLICY = 2 +ORG_POLICY = 4 +ACCESS_POLICY = 5 + + +_LISTASSETSREQUEST = _descriptor.Descriptor( + name="ListAssetsRequest", + full_name="google.cloud.asset.v1p5beta1.ListAssetsRequest", + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name="parent", + full_name="google.cloud.asset.v1p5beta1.ListAssetsRequest.parent", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=b"".decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=b"\340A\002", + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + _descriptor.FieldDescriptor( + name="read_time", + full_name="google.cloud.asset.v1p5beta1.ListAssetsRequest.read_time", + index=1, + number=2, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + _descriptor.FieldDescriptor( + name="asset_types", + full_name="google.cloud.asset.v1p5beta1.ListAssetsRequest.asset_types", + index=2, + number=3, + type=9, + cpp_type=9, + label=3, + has_default_value=False, + default_value=[], + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + _descriptor.FieldDescriptor( + name="content_type", + full_name="google.cloud.asset.v1p5beta1.ListAssetsRequest.content_type", + index=3, + number=4, + type=14, + cpp_type=8, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + _descriptor.FieldDescriptor( + name="page_size", + full_name="google.cloud.asset.v1p5beta1.ListAssetsRequest.page_size", + index=4, + number=5, + type=5, + cpp_type=1, + label=1, + has_default_value=False, + default_value=0, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + _descriptor.FieldDescriptor( + name="page_token", + full_name="google.cloud.asset.v1p5beta1.ListAssetsRequest.page_token", + index=5, + number=6, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=b"".decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=259, + serialized_end=471, +) + + +_LISTASSETSRESPONSE = _descriptor.Descriptor( + name="ListAssetsResponse", + full_name="google.cloud.asset.v1p5beta1.ListAssetsResponse", + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name="read_time", + full_name="google.cloud.asset.v1p5beta1.ListAssetsResponse.read_time", + index=0, + number=1, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + _descriptor.FieldDescriptor( + name="assets", + full_name="google.cloud.asset.v1p5beta1.ListAssetsResponse.assets", + index=1, + number=2, + type=11, + cpp_type=10, + label=3, + has_default_value=False, + default_value=[], + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + _descriptor.FieldDescriptor( + name="next_page_token", + full_name="google.cloud.asset.v1p5beta1.ListAssetsResponse.next_page_token", + index=2, + number=3, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=b"".decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=474, + serialized_end=619, +) + +_LISTASSETSREQUEST.fields_by_name[ + "read_time" +].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_LISTASSETSREQUEST.fields_by_name["content_type"].enum_type = _CONTENTTYPE +_LISTASSETSRESPONSE.fields_by_name[ + "read_time" +].message_type = google_dot_protobuf_dot_timestamp__pb2._TIMESTAMP +_LISTASSETSRESPONSE.fields_by_name[ + "assets" +].message_type = google_dot_cloud_dot_asset__v1p5beta1_dot_proto_dot_assets__pb2._ASSET +DESCRIPTOR.message_types_by_name["ListAssetsRequest"] = _LISTASSETSREQUEST +DESCRIPTOR.message_types_by_name["ListAssetsResponse"] = _LISTASSETSRESPONSE +DESCRIPTOR.enum_types_by_name["ContentType"] = _CONTENTTYPE +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +ListAssetsRequest = _reflection.GeneratedProtocolMessageType( + "ListAssetsRequest", + (_message.Message,), + { + "DESCRIPTOR": _LISTASSETSREQUEST, + "__module__": "google.cloud.asset_v1p5beta1.proto.asset_service_pb2", + "__doc__": """ListAssets request. + + Attributes: + parent: + Required. Name of the organization or project the assets + belong to. Format: “organizations/[organization-number]” (such + as “organizations/123”), “projects/[project-number]” (such as + “projects/my-project-id”), or “projects/[project-id]” (such as + “projects/12345”). + read_time: + Timestamp to take an asset snapshot. This can only be set to a + timestamp between 2018-10-02 UTC (inclusive) and the current + time. If not specified, the current time will be used. Due to + delays in resource data collection and indexing, there is a + volatile window during which running the same query may get + different results. + asset_types: + A list of asset types of which to take a snapshot for. For + example: “compute.googleapis.com/Disk”. If specified, only + matching assets will be returned. See `Introduction to Cloud + Asset Inventory `__ for all + supported asset types. + content_type: + Asset content type. If not specified, no content but the asset + name will be returned. + page_size: + The maximum number of assets to be returned in a single + response. Default is 100, minimum is 1, and maximum is 1000. + page_token: + The ``next_page_token`` returned from the previous + ``ListAssetsResponse``, or unspecified for the first + ``ListAssetsRequest``. It is a continuation of a prior + ``ListAssets`` call, and the API should return the next page + of assets. + """, + # @@protoc_insertion_point(class_scope:google.cloud.asset.v1p5beta1.ListAssetsRequest) + }, +) +_sym_db.RegisterMessage(ListAssetsRequest) + +ListAssetsResponse = _reflection.GeneratedProtocolMessageType( + "ListAssetsResponse", + (_message.Message,), + { + "DESCRIPTOR": _LISTASSETSRESPONSE, + "__module__": "google.cloud.asset_v1p5beta1.proto.asset_service_pb2", + "__doc__": """ListAssets response. + + Attributes: + read_time: + Time the snapshot was taken. + assets: + Assets. + next_page_token: + Token to retrieve the next page of results. Set to empty if + there are no remaining results. + """, + # @@protoc_insertion_point(class_scope:google.cloud.asset.v1p5beta1.ListAssetsResponse) + }, +) +_sym_db.RegisterMessage(ListAssetsResponse) + + +DESCRIPTOR._options = None +_LISTASSETSREQUEST.fields_by_name["parent"]._options = None + +_ASSETSERVICE = _descriptor.ServiceDescriptor( + name="AssetService", + full_name="google.cloud.asset.v1p5beta1.AssetService", + file=DESCRIPTOR, + index=0, + serialized_options=b"\312A\031cloudasset.googleapis.com\322A.https://www.googleapis.com/auth/cloud-platform", + create_key=_descriptor._internal_create_key, + serialized_start=732, + serialized_end=979, + methods=[ + _descriptor.MethodDescriptor( + name="ListAssets", + full_name="google.cloud.asset.v1p5beta1.AssetService.ListAssets", + index=0, + containing_service=None, + input_type=_LISTASSETSREQUEST, + output_type=_LISTASSETSRESPONSE, + serialized_options=b"\202\323\344\223\002 \022\036/v1p5beta1/{parent=*/*}/assets", + create_key=_descriptor._internal_create_key, + ) + ], +) +_sym_db.RegisterServiceDescriptor(_ASSETSERVICE) + +DESCRIPTOR.services_by_name["AssetService"] = _ASSETSERVICE + +# @@protoc_insertion_point(module_scope) diff --git a/google/cloud/asset_v1p5beta1/proto/asset_service_pb2_grpc.py b/google/cloud/asset_v1p5beta1/proto/asset_service_pb2_grpc.py new file mode 100644 index 00000000..6c00309e --- /dev/null +++ b/google/cloud/asset_v1p5beta1/proto/asset_service_pb2_grpc.py @@ -0,0 +1,50 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc + +from google.cloud.asset_v1p5beta1.proto import ( + asset_service_pb2 as google_dot_cloud_dot_asset__v1p5beta1_dot_proto_dot_asset__service__pb2, +) + + +class AssetServiceStub(object): + """Asset service definition. + """ + + def __init__(self, channel): + """Constructor. + + Args: + channel: A grpc.Channel. + """ + self.ListAssets = channel.unary_unary( + "/google.cloud.asset.v1p5beta1.AssetService/ListAssets", + request_serializer=google_dot_cloud_dot_asset__v1p5beta1_dot_proto_dot_asset__service__pb2.ListAssetsRequest.SerializeToString, + response_deserializer=google_dot_cloud_dot_asset__v1p5beta1_dot_proto_dot_asset__service__pb2.ListAssetsResponse.FromString, + ) + + +class AssetServiceServicer(object): + """Asset service definition. + """ + + def ListAssets(self, request, context): + """Lists assets with time and resource types and returns paged results in + response. + """ + context.set_code(grpc.StatusCode.UNIMPLEMENTED) + context.set_details("Method not implemented!") + raise NotImplementedError("Method not implemented!") + + +def add_AssetServiceServicer_to_server(servicer, server): + rpc_method_handlers = { + "ListAssets": grpc.unary_unary_rpc_method_handler( + servicer.ListAssets, + request_deserializer=google_dot_cloud_dot_asset__v1p5beta1_dot_proto_dot_asset__service__pb2.ListAssetsRequest.FromString, + response_serializer=google_dot_cloud_dot_asset__v1p5beta1_dot_proto_dot_asset__service__pb2.ListAssetsResponse.SerializeToString, + ) + } + generic_handler = grpc.method_handlers_generic_handler( + "google.cloud.asset.v1p5beta1.AssetService", rpc_method_handlers + ) + server.add_generic_rpc_handlers((generic_handler,)) diff --git a/google/cloud/asset_v1p5beta1/proto/assets_pb2.py b/google/cloud/asset_v1p5beta1/proto/assets_pb2.py new file mode 100644 index 00000000..75f10fe1 --- /dev/null +++ b/google/cloud/asset_v1p5beta1/proto/assets_pb2.py @@ -0,0 +1,534 @@ +# -*- coding: utf-8 -*- +# Generated by the protocol buffer compiler. DO NOT EDIT! +# source: google/cloud/asset_v1p5beta1/proto/assets.proto + +from google.protobuf import descriptor as _descriptor +from google.protobuf import message as _message +from google.protobuf import reflection as _reflection +from google.protobuf import symbol_database as _symbol_database + +# @@protoc_insertion_point(imports) + +_sym_db = _symbol_database.Default() + + +from google.api import annotations_pb2 as google_dot_api_dot_annotations__pb2 +from google.api import resource_pb2 as google_dot_api_dot_resource__pb2 +from google.cloud.orgpolicy.v1 import ( + orgpolicy_pb2 as google_dot_cloud_dot_orgpolicy_dot_v1_dot_orgpolicy__pb2, +) +from google.iam.v1 import iam_policy_pb2 as google_dot_iam_dot_v1_dot_policy__pb2 +from google.identity.accesscontextmanager.v1 import ( + access_level_pb2 as google_dot_identity_dot_accesscontextmanager_dot_v1_dot_access__level__pb2, +) +from google.identity.accesscontextmanager.v1 import ( + access_policy_pb2 as google_dot_identity_dot_accesscontextmanager_dot_v1_dot_access__policy__pb2, +) +from google.identity.accesscontextmanager.v1 import ( + service_perimeter_pb2 as google_dot_identity_dot_accesscontextmanager_dot_v1_dot_service__perimeter__pb2, +) +from google.protobuf import any_pb2 as google_dot_protobuf_dot_any__pb2 +from google.protobuf import struct_pb2 as google_dot_protobuf_dot_struct__pb2 +from google.protobuf import timestamp_pb2 as google_dot_protobuf_dot_timestamp__pb2 + + +DESCRIPTOR = _descriptor.FileDescriptor( + name="google/cloud/asset_v1p5beta1/proto/assets.proto", + package="google.cloud.asset.v1p5beta1", + syntax="proto3", + serialized_options=b"\n com.google.cloud.asset.v1p5beta1B\nAssetProtoP\001ZAgoogle.golang.org/genproto/googleapis/cloud/asset/v1p5beta1;asset\370\001\001\252\002\034Google.Cloud.Asset.V1p5Beta1\312\002\034Google\\Cloud\\Asset\\V1p5beta1", + create_key=_descriptor._internal_create_key, + serialized_pb=b'\n/google/cloud/asset_v1p5beta1/proto/assets.proto\x12\x1cgoogle.cloud.asset.v1p5beta1\x1a\x1cgoogle/api/annotations.proto\x1a\x19google/api/resource.proto\x1a)google/cloud/orgpolicy/v1/orgpolicy.proto\x1a\x1agoogle/iam/v1/policy.proto\x1a:google/identity/accesscontextmanager/v1/access_level.proto\x1a;google/identity/accesscontextmanager/v1/access_policy.proto\x1a?google/identity/accesscontextmanager/v1/service_perimeter.proto\x1a\x19google/protobuf/any.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1fgoogle/protobuf/timestamp.proto"\x90\x04\n\x05\x41sset\x12\x0c\n\x04name\x18\x01 \x01(\t\x12\x12\n\nasset_type\x18\x02 \x01(\t\x12\x38\n\x08resource\x18\x03 \x01(\x0b\x32&.google.cloud.asset.v1p5beta1.Resource\x12)\n\niam_policy\x18\x04 \x01(\x0b\x32\x15.google.iam.v1.Policy\x12\x35\n\norg_policy\x18\x06 \x03(\x0b\x32!.google.cloud.orgpolicy.v1.Policy\x12N\n\raccess_policy\x18\x07 \x01(\x0b\x32\x35.google.identity.accesscontextmanager.v1.AccessPolicyH\x00\x12L\n\x0c\x61\x63\x63\x65ss_level\x18\x08 \x01(\x0b\x32\x34.google.identity.accesscontextmanager.v1.AccessLevelH\x00\x12V\n\x11service_perimeter\x18\t \x01(\x0b\x32\x39.google.identity.accesscontextmanager.v1.ServicePerimeterH\x00\x12\x11\n\tancestors\x18\n \x03(\t:\'\xea\x41$\n\x1f\x63loudasset.googleapis.com/Asset\x12\x01*B\x17\n\x15\x61\x63\x63\x65ss_context_policy"\xa0\x01\n\x08Resource\x12\x0f\n\x07version\x18\x01 \x01(\t\x12\x1e\n\x16\x64iscovery_document_uri\x18\x02 \x01(\t\x12\x16\n\x0e\x64iscovery_name\x18\x03 \x01(\t\x12\x14\n\x0cresource_url\x18\x04 \x01(\t\x12\x0e\n\x06parent\x18\x05 \x01(\t\x12%\n\x04\x64\x61ta\x18\x06 \x01(\x0b\x32\x17.google.protobuf.StructB\xb4\x01\n com.google.cloud.asset.v1p5beta1B\nAssetProtoP\x01ZAgoogle.golang.org/genproto/googleapis/cloud/asset/v1p5beta1;asset\xf8\x01\x01\xaa\x02\x1cGoogle.Cloud.Asset.V1p5Beta1\xca\x02\x1cGoogle\\Cloud\\Asset\\V1p5beta1b\x06proto3', + dependencies=[ + google_dot_api_dot_annotations__pb2.DESCRIPTOR, + google_dot_api_dot_resource__pb2.DESCRIPTOR, + google_dot_cloud_dot_orgpolicy_dot_v1_dot_orgpolicy__pb2.DESCRIPTOR, + google_dot_iam_dot_v1_dot_policy__pb2.DESCRIPTOR, + google_dot_identity_dot_accesscontextmanager_dot_v1_dot_access__level__pb2.DESCRIPTOR, + google_dot_identity_dot_accesscontextmanager_dot_v1_dot_access__policy__pb2.DESCRIPTOR, + google_dot_identity_dot_accesscontextmanager_dot_v1_dot_service__perimeter__pb2.DESCRIPTOR, + google_dot_protobuf_dot_any__pb2.DESCRIPTOR, + google_dot_protobuf_dot_struct__pb2.DESCRIPTOR, + google_dot_protobuf_dot_timestamp__pb2.DESCRIPTOR, + ], +) + + +_ASSET = _descriptor.Descriptor( + name="Asset", + full_name="google.cloud.asset.v1p5beta1.Asset", + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name="name", + full_name="google.cloud.asset.v1p5beta1.Asset.name", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=b"".decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + _descriptor.FieldDescriptor( + name="asset_type", + full_name="google.cloud.asset.v1p5beta1.Asset.asset_type", + index=1, + number=2, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=b"".decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + _descriptor.FieldDescriptor( + name="resource", + full_name="google.cloud.asset.v1p5beta1.Asset.resource", + index=2, + number=3, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + _descriptor.FieldDescriptor( + name="iam_policy", + full_name="google.cloud.asset.v1p5beta1.Asset.iam_policy", + index=3, + number=4, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + _descriptor.FieldDescriptor( + name="org_policy", + full_name="google.cloud.asset.v1p5beta1.Asset.org_policy", + index=4, + number=6, + type=11, + cpp_type=10, + label=3, + has_default_value=False, + default_value=[], + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + _descriptor.FieldDescriptor( + name="access_policy", + full_name="google.cloud.asset.v1p5beta1.Asset.access_policy", + index=5, + number=7, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + _descriptor.FieldDescriptor( + name="access_level", + full_name="google.cloud.asset.v1p5beta1.Asset.access_level", + index=6, + number=8, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + _descriptor.FieldDescriptor( + name="service_perimeter", + full_name="google.cloud.asset.v1p5beta1.Asset.service_perimeter", + index=7, + number=9, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + _descriptor.FieldDescriptor( + name="ancestors", + full_name="google.cloud.asset.v1p5beta1.Asset.ancestors", + index=8, + number=10, + type=9, + cpp_type=9, + label=3, + has_default_value=False, + default_value=[], + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=b"\352A$\n\037cloudasset.googleapis.com/Asset\022\001*", + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[ + _descriptor.OneofDescriptor( + name="access_context_policy", + full_name="google.cloud.asset.v1p5beta1.Asset.access_context_policy", + index=0, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[], + ) + ], + serialized_start=486, + serialized_end=1014, +) + + +_RESOURCE = _descriptor.Descriptor( + name="Resource", + full_name="google.cloud.asset.v1p5beta1.Resource", + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name="version", + full_name="google.cloud.asset.v1p5beta1.Resource.version", + index=0, + number=1, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=b"".decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + _descriptor.FieldDescriptor( + name="discovery_document_uri", + full_name="google.cloud.asset.v1p5beta1.Resource.discovery_document_uri", + index=1, + number=2, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=b"".decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + _descriptor.FieldDescriptor( + name="discovery_name", + full_name="google.cloud.asset.v1p5beta1.Resource.discovery_name", + index=2, + number=3, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=b"".decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + _descriptor.FieldDescriptor( + name="resource_url", + full_name="google.cloud.asset.v1p5beta1.Resource.resource_url", + index=3, + number=4, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=b"".decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + _descriptor.FieldDescriptor( + name="parent", + full_name="google.cloud.asset.v1p5beta1.Resource.parent", + index=4, + number=5, + type=9, + cpp_type=9, + label=1, + has_default_value=False, + default_value=b"".decode("utf-8"), + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + _descriptor.FieldDescriptor( + name="data", + full_name="google.cloud.asset.v1p5beta1.Resource.data", + index=5, + number=6, + type=11, + cpp_type=10, + label=1, + has_default_value=False, + default_value=None, + message_type=None, + enum_type=None, + containing_type=None, + is_extension=False, + extension_scope=None, + serialized_options=None, + file=DESCRIPTOR, + create_key=_descriptor._internal_create_key, + ), + ], + extensions=[], + nested_types=[], + enum_types=[], + serialized_options=None, + is_extendable=False, + syntax="proto3", + extension_ranges=[], + oneofs=[], + serialized_start=1017, + serialized_end=1177, +) + +_ASSET.fields_by_name["resource"].message_type = _RESOURCE +_ASSET.fields_by_name[ + "iam_policy" +].message_type = ( + google_dot_iam_dot_v1_dot_policy__pb2.google_dot_iam_dot_v1_dot_policy__pb2._POLICY +) +_ASSET.fields_by_name[ + "org_policy" +].message_type = google_dot_cloud_dot_orgpolicy_dot_v1_dot_orgpolicy__pb2._POLICY +_ASSET.fields_by_name[ + "access_policy" +].message_type = ( + google_dot_identity_dot_accesscontextmanager_dot_v1_dot_access__policy__pb2._ACCESSPOLICY +) +_ASSET.fields_by_name[ + "access_level" +].message_type = ( + google_dot_identity_dot_accesscontextmanager_dot_v1_dot_access__level__pb2._ACCESSLEVEL +) +_ASSET.fields_by_name[ + "service_perimeter" +].message_type = ( + google_dot_identity_dot_accesscontextmanager_dot_v1_dot_service__perimeter__pb2._SERVICEPERIMETER +) +_ASSET.oneofs_by_name["access_context_policy"].fields.append( + _ASSET.fields_by_name["access_policy"] +) +_ASSET.fields_by_name["access_policy"].containing_oneof = _ASSET.oneofs_by_name[ + "access_context_policy" +] +_ASSET.oneofs_by_name["access_context_policy"].fields.append( + _ASSET.fields_by_name["access_level"] +) +_ASSET.fields_by_name["access_level"].containing_oneof = _ASSET.oneofs_by_name[ + "access_context_policy" +] +_ASSET.oneofs_by_name["access_context_policy"].fields.append( + _ASSET.fields_by_name["service_perimeter"] +) +_ASSET.fields_by_name["service_perimeter"].containing_oneof = _ASSET.oneofs_by_name[ + "access_context_policy" +] +_RESOURCE.fields_by_name[ + "data" +].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT +DESCRIPTOR.message_types_by_name["Asset"] = _ASSET +DESCRIPTOR.message_types_by_name["Resource"] = _RESOURCE +_sym_db.RegisterFileDescriptor(DESCRIPTOR) + +Asset = _reflection.GeneratedProtocolMessageType( + "Asset", + (_message.Message,), + { + "DESCRIPTOR": _ASSET, + "__module__": "google.cloud.asset_v1p5beta1.proto.assets_pb2", + "__doc__": """Cloud asset. This includes all Google Cloud Platform resources, Cloud + IAM policies, and other non-GCP assets. + + Attributes: + name: + + The full name of the asset. For example: + ``//compute.googleapis.com/projects/my_project_123/zones/zone1/instances/instance1``. + See https://cloud.google.com/apis/design/resource_names#full_resource_name + for more information. + asset_type: + Type of the asset. Example: “compute.googleapis.com/Disk”. + resource: + Representation of the resource. + iam_policy: + Representation of the actual Cloud IAM policy set on a cloud + resource. For each resource, there must be at most one Cloud + IAM policy set on it. + org_policy: + Representation of the Cloud Organization Policy set on an + asset. For each asset, there could be multiple Organization + policies with different constraints. + access_context_policy: + Representation of the Cloud Organization access policy. + ancestors: + Asset’s ancestry path in Cloud Resource Manager (CRM) + hierarchy, represented as a list of relative resource names. + Ancestry path starts with the closest CRM ancestor and ends at + root. If the asset is a CRM project/folder/organization, this + starts from the asset itself. Example: [“projects/123456789”, + “folders/5432”, “organizations/1234”] + """, + # @@protoc_insertion_point(class_scope:google.cloud.asset.v1p5beta1.Asset) + }, +) +_sym_db.RegisterMessage(Asset) + +Resource = _reflection.GeneratedProtocolMessageType( + "Resource", + (_message.Message,), + { + "DESCRIPTOR": _RESOURCE, + "__module__": "google.cloud.asset_v1p5beta1.proto.assets_pb2", + "__doc__": """Representation of a cloud resource. + + Attributes: + version: + The API version. Example: “v1”. + discovery_document_uri: + The URL of the discovery document containing the resource’s + JSON schema. For example: ``"https://www.googleapis.com/discov + ery/v1/apis/compute/v1/rest"``. It will be left unspecified + for resources without a discovery-based API, such as Cloud + Bigtable. + discovery_name: + The JSON schema name listed in the discovery document. + Example: “Project”. It will be left unspecified for resources + (such as Cloud Bigtable) without a discovery-based API. + resource_url: + The REST URL for accessing the resource. An HTTP GET operation + using this URL returns the resource itself. Example: + ``https://cloudresourcemanager.googleapis.com/v1/projects/my- + project-123``. It will be left unspecified for resources + without a REST API. + parent: + The full name of the immediate parent of this resource. See + `Resource Names `__ for more information. For GCP + assets, it is the parent resource defined in the `Cloud IAM + policy hierarchy `__. For example: ``"//cloudresourcemanager.go + ogleapis.com/projects/my_project_123"``. For third-party + assets, it is up to the users to define. + data: + The content of the resource, in which some sensitive fields + are scrubbed away and may not be present. + """, + # @@protoc_insertion_point(class_scope:google.cloud.asset.v1p5beta1.Resource) + }, +) +_sym_db.RegisterMessage(Resource) + + +DESCRIPTOR._options = None +_ASSET._options = None +# @@protoc_insertion_point(module_scope) diff --git a/google/cloud/asset_v1p5beta1/proto/assets_pb2_grpc.py b/google/cloud/asset_v1p5beta1/proto/assets_pb2_grpc.py new file mode 100644 index 00000000..07cb78fe --- /dev/null +++ b/google/cloud/asset_v1p5beta1/proto/assets_pb2_grpc.py @@ -0,0 +1,2 @@ +# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! +import grpc diff --git a/google/cloud/asset_v1p5beta1/types.py b/google/cloud/asset_v1p5beta1/types.py new file mode 100644 index 00000000..fd1222cb --- /dev/null +++ b/google/cloud/asset_v1p5beta1/types.py @@ -0,0 +1,61 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +from __future__ import absolute_import +import sys + +from google.api_core.protobuf_helpers import get_messages + +from google.identity.accesscontextmanager.v1 import access_level_pb2 +from google.identity.accesscontextmanager.v1 import access_policy_pb2 +from google.cloud.asset_v1p5beta1.proto import asset_service_pb2 +from google.cloud.asset_v1p5beta1.proto import assets_pb2 +from google.cloud.orgpolicy.v1 import orgpolicy_pb2 +from google.identity.accesscontextmanager.v1 import service_perimeter_pb2 +from google.iam.v1 import policy_pb2 +from google.protobuf import struct_pb2 +from google.protobuf import timestamp_pb2 +from google.type import expr_pb2 + + +_shared_modules = [ + access_level_pb2, + access_policy_pb2, + orgpolicy_pb2, + service_perimeter_pb2, + policy_pb2, + struct_pb2, + timestamp_pb2, + expr_pb2, +] + +_local_modules = [asset_service_pb2, assets_pb2] + +names = [] + +for module in _shared_modules: # pragma: NO COVER + for name, message in get_messages(module).items(): + setattr(sys.modules[__name__], name, message) + names.append(name) +for module in _local_modules: + for name, message in get_messages(module).items(): + message.__module__ = "google.cloud.asset_v1p5beta1.types" + setattr(sys.modules[__name__], name, message) + names.append(name) + + +__all__ = tuple(sorted(names)) diff --git a/samples/AUTHORING_GUIDE.md b/samples/AUTHORING_GUIDE.md new file mode 100644 index 00000000..55c97b32 --- /dev/null +++ b/samples/AUTHORING_GUIDE.md @@ -0,0 +1 @@ +See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/AUTHORING_GUIDE.md \ No newline at end of file diff --git a/samples/CONTRIBUTING.md b/samples/CONTRIBUTING.md new file mode 100644 index 00000000..34c882b6 --- /dev/null +++ b/samples/CONTRIBUTING.md @@ -0,0 +1 @@ +See https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/CONTRIBUTING.md \ No newline at end of file diff --git a/synth.metadata b/synth.metadata index 41f13089..8ed80398 100644 --- a/synth.metadata +++ b/synth.metadata @@ -3,8 +3,8 @@ { "git": { "name": ".", - "remote": "https://github.com/googleapis/python-asset.git", - "sha": "e089e865904c755e5a395934cbcefa02ea09fd10" + "remote": "git@github.com:googleapis/python-asset.git", + "sha": "f786ab34a70355da4d6714e2313932840033d30e" } }, { @@ -19,14 +19,14 @@ "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "cf2eff09d0f5319a4dc5cdce2b6356d85af4a798" + "sha": "db4f15fedc76e04018e6e43ec403e804e1142158" } }, { "git": { "name": "synthtool", "remote": "https://github.com/googleapis/synthtool.git", - "sha": "cf2eff09d0f5319a4dc5cdce2b6356d85af4a798" + "sha": "db4f15fedc76e04018e6e43ec403e804e1142158" } } ], @@ -67,6 +67,15 @@ "generator": "bazel" } }, + { + "client": { + "source": "googleapis", + "apiName": "asset", + "apiVersion": "v1p5beta1", + "language": "python", + "generator": "bazel" + } + }, { "client": { "source": "googleapis", diff --git a/synth.py b/synth.py index 413aec92..6b1d01e4 100644 --- a/synth.py +++ b/synth.py @@ -19,7 +19,7 @@ gapic = gcp.GAPICBazel() common = gcp.CommonTemplates() -versions = ["v1beta1", "v1p1beta1", "v1p2beta1", "v1p4beta1", "v1"] +versions = ["v1beta1", "v1p1beta1", "v1p2beta1", "v1p4beta1", "v1p5beta1", "v1"] excludes = ["setup.py", "nox*.py", "README.rst", "docs/conf.py", "docs/index.rst"] @@ -108,14 +108,14 @@ # Fix accesscontextmanager and orgpolicy imports s.replace( - "google/cloud/asset_v1/types.py", - "from google\.cloud\.asset_v1\.proto import ((access_level_pb2)|(service_perimeter_pb2)|(access_policy_pb2))", - "from google.identity.accesscontextmanager.v1 import \g<1>", + "google/cloud/asset_v*/types.py", + "from google\.cloud\.asset_(v.*)\.proto import ((access_level_pb2)|(service_perimeter_pb2)|(access_policy_pb2))", + "from google.identity.accesscontextmanager.v1 import \g<2>", ) s.replace( - "google/cloud/asset_v1/types.py", - "from google\.cloud\.asset_v1\.proto import orgpolicy_pb2", + "google/cloud/asset_v*/types.py", + "from google\.cloud\.asset_v.*\.proto import orgpolicy_pb2", "from google.cloud.orgpolicy.v1 import orgpolicy_pb2", ) @@ -171,10 +171,10 @@ def project_path(cls, project): # ---------------------------------------------------------------------------- # Add templated files # ---------------------------------------------------------------------------- -templated_files = gcp.CommonTemplates().py_library(unit_cov_level=79, cov_level=80) +templated_files = gcp.CommonTemplates().py_library(unit_cov_level=79, cov_level=80, samples=False) s.move(templated_files) # TODO(busunkim): Use latest sphinx after microgenerator transition -s.replace("noxfile.py", "'sphinx'", '"sphinx<3.0.0"') +s.replace("noxfile.py", '''["']sphinx["']''', '"sphinx<3.0.0"') s.shell.run(["nox", "-s", "blacken"], hide_output=False) diff --git a/tests/unit/gapic/v1p5beta1/test_asset_service_client_v1p5beta1.py b/tests/unit/gapic/v1p5beta1/test_asset_service_client_v1p5beta1.py new file mode 100644 index 00000000..db1b1600 --- /dev/null +++ b/tests/unit/gapic/v1p5beta1/test_asset_service_client_v1p5beta1.py @@ -0,0 +1,105 @@ +# -*- coding: utf-8 -*- +# +# Copyright 2020 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Unit tests.""" + +import mock +import pytest + +from google.cloud import asset_v1p5beta1 +from google.cloud.asset_v1p5beta1.proto import asset_service_pb2 +from google.cloud.asset_v1p5beta1.proto import assets_pb2 + + +class MultiCallableStub(object): + """Stub for the grpc.UnaryUnaryMultiCallable interface.""" + + def __init__(self, method, channel_stub): + self.method = method + self.channel_stub = channel_stub + + def __call__(self, request, timeout=None, metadata=None, credentials=None): + self.channel_stub.requests.append((self.method, request)) + + response = None + if self.channel_stub.responses: + response = self.channel_stub.responses.pop() + + if isinstance(response, Exception): + raise response + + if response: + return response + + +class ChannelStub(object): + """Stub for the grpc.Channel interface.""" + + def __init__(self, responses=[]): + self.responses = responses + self.requests = [] + + def unary_unary(self, method, request_serializer=None, response_deserializer=None): + return MultiCallableStub(method, self) + + +class CustomException(Exception): + pass + + +class TestAssetServiceClient(object): + def test_list_assets(self): + # Setup Expected Response + next_page_token = "" + assets_element = {} + assets = [assets_element] + expected_response = {"next_page_token": next_page_token, "assets": assets} + expected_response = asset_service_pb2.ListAssetsResponse(**expected_response) + + # Mock the API response + channel = ChannelStub(responses=[expected_response]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = asset_v1p5beta1.AssetServiceClient() + + # Setup Request + parent = "parent-995424086" + + paged_list_response = client.list_assets(parent) + resources = list(paged_list_response) + assert len(resources) == 1 + + assert expected_response.assets[0] == resources[0] + + assert len(channel.requests) == 1 + expected_request = asset_service_pb2.ListAssetsRequest(parent=parent) + actual_request = channel.requests[0][1] + assert expected_request == actual_request + + def test_list_assets_exception(self): + channel = ChannelStub(responses=[CustomException()]) + patch = mock.patch("google.api_core.grpc_helpers.create_channel") + with patch as create_channel: + create_channel.return_value = channel + client = asset_v1p5beta1.AssetServiceClient() + + # Setup request + parent = "parent-995424086" + + paged_list_response = client.list_assets(parent) + with pytest.raises(CustomException): + list(paged_list_response)