Skip to content
This repository has been archived by the owner on Feb 28, 2024. It is now read-only.

[CHANGE ME] Re-generated to pick up changes from self. #85

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions google/cloud/asset/__init__.py
Expand Up @@ -30,10 +30,13 @@
from google.cloud.asset_v1.types.asset_service import Feed
from google.cloud.asset_v1.types.asset_service import FeedOutputConfig
from google.cloud.asset_v1.types.asset_service import GcsDestination
from google.cloud.asset_v1.types.asset_service import GcsOutputResult
from google.cloud.asset_v1.types.asset_service import GetFeedRequest
from google.cloud.asset_v1.types.asset_service import ListFeedsRequest
from google.cloud.asset_v1.types.asset_service import ListFeedsResponse
from google.cloud.asset_v1.types.asset_service import OutputConfig
from google.cloud.asset_v1.types.asset_service import OutputResult
from google.cloud.asset_v1.types.asset_service import PartitionSpec
from google.cloud.asset_v1.types.asset_service import PubsubDestination
from google.cloud.asset_v1.types.asset_service import SearchAllIamPoliciesRequest
from google.cloud.asset_v1.types.asset_service import SearchAllIamPoliciesResponse
Expand Down Expand Up @@ -62,11 +65,14 @@
"Feed",
"FeedOutputConfig",
"GcsDestination",
"GcsOutputResult",
"GetFeedRequest",
"IamPolicySearchResult",
"ListFeedsRequest",
"ListFeedsResponse",
"OutputConfig",
"OutputResult",
"PartitionSpec",
"PubsubDestination",
"Resource",
"ResourceSearchResult",
Expand Down
6 changes: 6 additions & 0 deletions google/cloud/asset_v1/__init__.py
Expand Up @@ -27,10 +27,13 @@
from .types.asset_service import Feed
from .types.asset_service import FeedOutputConfig
from .types.asset_service import GcsDestination
from .types.asset_service import GcsOutputResult
from .types.asset_service import GetFeedRequest
from .types.asset_service import ListFeedsRequest
from .types.asset_service import ListFeedsResponse
from .types.asset_service import OutputConfig
from .types.asset_service import OutputResult
from .types.asset_service import PartitionSpec
from .types.asset_service import PubsubDestination
from .types.asset_service import SearchAllIamPoliciesRequest
from .types.asset_service import SearchAllIamPoliciesResponse
Expand Down Expand Up @@ -58,11 +61,14 @@
"Feed",
"FeedOutputConfig",
"GcsDestination",
"GcsOutputResult",
"GetFeedRequest",
"IamPolicySearchResult",
"ListFeedsRequest",
"ListFeedsResponse",
"OutputConfig",
"OutputResult",
"PartitionSpec",
"PubsubDestination",
"Resource",
"ResourceSearchResult",
Expand Down
213 changes: 118 additions & 95 deletions google/cloud/asset_v1/services/asset_service/async_client.py

Large diffs are not rendered by default.

246 changes: 145 additions & 101 deletions google/cloud/asset_v1/services/asset_service/client.py

Large diffs are not rendered by default.

34 changes: 20 additions & 14 deletions google/cloud/asset_v1/services/asset_service/transports/base.py
Expand Up @@ -19,7 +19,7 @@
import typing
import pkg_resources

from google import auth
from google import auth # type: ignore
from google.api_core import exceptions # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google.api_core import retry as retries # type: ignore
Expand All @@ -32,11 +32,11 @@


try:
_client_info = gapic_v1.client_info.ClientInfo(
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution("google-cloud-asset",).version,
)
except pkg_resources.DistributionNotFound:
_client_info = gapic_v1.client_info.ClientInfo()
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()


class AssetServiceTransport(abc.ABC):
Expand All @@ -52,6 +52,7 @@ def __init__(
credentials_file: typing.Optional[str] = None,
scopes: typing.Optional[typing.Sequence[str]] = AUTH_SCOPES,
quota_project_id: typing.Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
**kwargs,
) -> None:
"""Instantiate the transport.
Expand All @@ -69,6 +70,11 @@ def __init__(
scope (Optional[Sequence[str]]): A list of scopes.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
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.
"""
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
if ":" not in host:
Expand Down Expand Up @@ -96,13 +102,13 @@ def __init__(
self._credentials = credentials

# Lifted into its own function so it can be stubbed out during tests.
self._prep_wrapped_messages()
self._prep_wrapped_messages(client_info)

def _prep_wrapped_messages(self):
def _prep_wrapped_messages(self, client_info):
# Precompute the wrapped methods.
self._wrapped_methods = {
self.export_assets: gapic_v1.method.wrap_method(
self.export_assets, default_timeout=60.0, client_info=_client_info,
self.export_assets, default_timeout=60.0, client_info=client_info,
),
self.batch_get_assets_history: gapic_v1.method.wrap_method(
self.batch_get_assets_history,
Expand All @@ -115,10 +121,10 @@ def _prep_wrapped_messages(self):
),
),
default_timeout=60.0,
client_info=_client_info,
client_info=client_info,
),
self.create_feed: gapic_v1.method.wrap_method(
self.create_feed, default_timeout=60.0, client_info=_client_info,
self.create_feed, default_timeout=60.0, client_info=client_info,
),
self.get_feed: gapic_v1.method.wrap_method(
self.get_feed,
Expand All @@ -131,7 +137,7 @@ def _prep_wrapped_messages(self):
),
),
default_timeout=60.0,
client_info=_client_info,
client_info=client_info,
),
self.list_feeds: gapic_v1.method.wrap_method(
self.list_feeds,
Expand All @@ -144,10 +150,10 @@ def _prep_wrapped_messages(self):
),
),
default_timeout=60.0,
client_info=_client_info,
client_info=client_info,
),
self.update_feed: gapic_v1.method.wrap_method(
self.update_feed, default_timeout=60.0, client_info=_client_info,
self.update_feed, default_timeout=60.0, client_info=client_info,
),
self.delete_feed: gapic_v1.method.wrap_method(
self.delete_feed,
Expand All @@ -160,7 +166,7 @@ def _prep_wrapped_messages(self):
),
),
default_timeout=60.0,
client_info=_client_info,
client_info=client_info,
),
self.search_all_resources: gapic_v1.method.wrap_method(
self.search_all_resources,
Expand All @@ -173,7 +179,7 @@ def _prep_wrapped_messages(self):
),
),
default_timeout=15.0,
client_info=_client_info,
client_info=client_info,
),
self.search_all_iam_policies: gapic_v1.method.wrap_method(
self.search_all_iam_policies,
Expand All @@ -186,7 +192,7 @@ def _prep_wrapped_messages(self):
),
),
default_timeout=15.0,
client_info=_client_info,
client_info=client_info,
),
}

Expand Down
80 changes: 52 additions & 28 deletions google/cloud/asset_v1/services/asset_service/transports/grpc.py
Expand Up @@ -15,22 +15,23 @@
# limitations under the License.
#

import warnings
from typing import Callable, Dict, Optional, Sequence, Tuple

from google.api_core import grpc_helpers # type: ignore
from google.api_core import operations_v1 # type: ignore
from google.api_core import gapic_v1 # type: ignore
from google import auth # type: ignore
from google.auth import credentials # type: ignore
from google.auth.transport.grpc import SslCredentials # type: ignore


import grpc # type: ignore

from google.cloud.asset_v1.types import asset_service
from google.longrunning import operations_pb2 as operations # type: ignore
from google.protobuf import empty_pb2 as empty # type: ignore

from .base import AssetServiceTransport
from .base import AssetServiceTransport, DEFAULT_CLIENT_INFO


class AssetServiceGrpcTransport(AssetServiceTransport):
Expand Down Expand Up @@ -58,7 +59,9 @@ def __init__(
channel: grpc.Channel = None,
api_mtls_endpoint: str = None,
client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None
ssl_channel_credentials: grpc.ChannelCredentials = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
"""Instantiate the transport.

Expand All @@ -77,16 +80,23 @@ def __init__(
ignored if ``channel`` is provided.
channel (Optional[grpc.Channel]): A ``Channel`` instance through
which to make calls.
api_mtls_endpoint (Optional[str]): The mutual TLS endpoint. If
provided, it overrides the ``host`` argument and tries to create
api_mtls_endpoint (Optional[str]): Deprecated. The mutual TLS endpoint.
If provided, it overrides the ``host`` argument and tries to create
a mutual TLS channel with client SSL credentials from
``client_cert_source`` or applicatin default SSL credentials.
client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]): A
callback to provide client SSL certificate bytes and private key
bytes, both in PEM format. It is ignored if ``api_mtls_endpoint``
is None.
client_cert_source (Optional[Callable[[], Tuple[bytes, bytes]]]):
Deprecated. A callback to provide client SSL certificate bytes and
private key bytes, both in PEM format. It is ignored if
``api_mtls_endpoint`` is None.
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
for grpc channel. It is ignored if ``channel`` is provided.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
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.

Raises:
google.auth.exceptions.MutualTLSChannelError: If mutual TLS transport
Expand All @@ -102,6 +112,11 @@ def __init__(
# If a channel was explicitly provided, set it.
self._grpc_channel = channel
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
DeprecationWarning,
)

host = (
api_mtls_endpoint
if ":" in api_mtls_endpoint
Expand Down Expand Up @@ -132,6 +147,23 @@ def __init__(
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
)
else:
host = host if ":" in host else host + ":443"

if credentials is None:
credentials, _ = auth.default(
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
)

# create a new channel. The provided one is ignored.
self._grpc_channel = type(self).create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
)

self._stubs = {} # type: Dict[str, Callable]

Expand All @@ -142,6 +174,7 @@ def __init__(
credentials_file=credentials_file,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
client_info=client_info,
)

@classmethod
Expand All @@ -152,7 +185,7 @@ def create_channel(
credentials_file: str = None,
scopes: Optional[Sequence[str]] = None,
quota_project_id: Optional[str] = None,
**kwargs
**kwargs,
) -> grpc.Channel:
"""Create and return a gRPC channel object.
Args:
Expand Down Expand Up @@ -186,7 +219,7 @@ def create_channel(
credentials_file=credentials_file,
scopes=scopes,
quota_project_id=quota_project_id,
**kwargs
**kwargs,
)

@property
Expand All @@ -196,13 +229,6 @@ def grpc_channel(self) -> grpc.Channel:
This property caches on the instance; repeated calls return
the same channel.
"""
# Sanity check: Only create a new channel if we do not already
# have one.
if not hasattr(self, "_grpc_channel"):
self._grpc_channel = self.create_channel(
self._host, credentials=self._credentials,
)

# Return the channel from cache.
return self._grpc_channel

Expand Down Expand Up @@ -433,11 +459,10 @@ def search_all_resources(
]:
r"""Return a callable for the search all resources method over gRPC.

Searches all the resources within the given
accessible scope (e.g., a project, a folder or an
organization). Callers should have
cloud.assets.SearchAllResources permission upon the
requested scope, otherwise the request will be rejected.
Searches all Cloud resources within the specified scope, such as
a project, folder, or organization. The caller must be granted
the ``cloudasset.assets.searchAllResources`` permission on the
desired scope, otherwise the request will be rejected.

Returns:
Callable[[~.SearchAllResourcesRequest],
Expand Down Expand Up @@ -466,11 +491,10 @@ def search_all_iam_policies(
]:
r"""Return a callable for the search all iam policies method over gRPC.

Searches all the IAM policies within the given
accessible scope (e.g., a project, a folder or an
organization). Callers should have
cloud.assets.SearchAllIamPolicies permission upon the
requested scope, otherwise the request will be rejected.
Searches all IAM policies within the specified scope, such as a
project, folder, or organization. The caller must be granted the
``cloudasset.assets.searchAllIamPolicies`` permission on the
desired scope, otherwise the request will be rejected.

Returns:
Callable[[~.SearchAllIamPoliciesRequest],
Expand Down