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

feat: add AnalyzeIamPolicy and ExportIamPolicyAnalysis; support OSInventory; add common resource helper methods; expose client transport #113

Merged
merged 13 commits into from
Nov 19, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: upgrade to gapic-generator-python 0.35.6
PiperOrigin-RevId: 338489505

Source-Author: Google APIs <[email protected]>
Source-Date: Thu Oct 22 09:36:18 2020 -0700
Source-Repo: googleapis/googleapis
Source-Sha: 4b34a0869404af9d83ae89952d28712a4d29eba6
Source-Link: googleapis/googleapis@4b34a08
  • Loading branch information
yoshi-automation committed Nov 17, 2020
commit 5060c4114594042bf33d28bab8551d6fe1b7ec87
74 changes: 15 additions & 59 deletions google/cloud/asset_v1/services/asset_service/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,48 +48,12 @@ class AssetServiceAsyncClient:
DEFAULT_ENDPOINT = AssetServiceClient.DEFAULT_ENDPOINT
DEFAULT_MTLS_ENDPOINT = AssetServiceClient.DEFAULT_MTLS_ENDPOINT

asset_path = staticmethod(AssetServiceClient.asset_path)
parse_asset_path = staticmethod(AssetServiceClient.parse_asset_path)
feed_path = staticmethod(AssetServiceClient.feed_path)
parse_feed_path = staticmethod(AssetServiceClient.parse_feed_path)

common_billing_account_path = staticmethod(
AssetServiceClient.common_billing_account_path
)
parse_common_billing_account_path = staticmethod(
AssetServiceClient.parse_common_billing_account_path
)

common_folder_path = staticmethod(AssetServiceClient.common_folder_path)
parse_common_folder_path = staticmethod(AssetServiceClient.parse_common_folder_path)

common_organization_path = staticmethod(AssetServiceClient.common_organization_path)
parse_common_organization_path = staticmethod(
AssetServiceClient.parse_common_organization_path
)

common_project_path = staticmethod(AssetServiceClient.common_project_path)
parse_common_project_path = staticmethod(
AssetServiceClient.parse_common_project_path
)

common_location_path = staticmethod(AssetServiceClient.common_location_path)
parse_common_location_path = staticmethod(
AssetServiceClient.parse_common_location_path
)

from_service_account_file = AssetServiceClient.from_service_account_file
from_service_account_json = from_service_account_file

@property
def transport(self) -> AssetServiceTransport:
"""Return the transport used by the client instance.

Returns:
AssetServiceTransport: The transport used by the client instance.
"""
return self._client.transport

get_transport_class = functools.partial(
type(AssetServiceClient).get_transport_class, type(AssetServiceClient)
)
Expand Down Expand Up @@ -262,7 +226,7 @@ async def batch_get_assets_history(
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
exceptions.ServiceUnavailable, exceptions.DeadlineExceeded,
),
),
default_timeout=60.0,
Expand Down Expand Up @@ -331,8 +295,7 @@ async def create_feed(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([parent])
if request is not None and has_flattened_params:
if request is not None and any([parent]):
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -409,8 +372,7 @@ async def get_feed(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
if request is not None and any([name]):
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand All @@ -433,7 +395,7 @@ async def get_feed(
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
exceptions.ServiceUnavailable, exceptions.DeadlineExceeded,
),
),
default_timeout=60.0,
Expand Down Expand Up @@ -491,8 +453,7 @@ async def list_feeds(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([parent])
if request is not None and has_flattened_params:
if request is not None and any([parent]):
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand All @@ -515,7 +476,7 @@ async def list_feeds(
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
exceptions.ServiceUnavailable, exceptions.DeadlineExceeded,
),
),
default_timeout=60.0,
Expand Down Expand Up @@ -578,8 +539,7 @@ async def update_feed(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([feed])
if request is not None and has_flattened_params:
if request is not None and any([feed]):
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -647,8 +607,7 @@ async def delete_feed(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([name])
if request is not None and has_flattened_params:
if request is not None and any([name]):
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand All @@ -671,7 +630,7 @@ async def delete_feed(
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
exceptions.ServiceUnavailable, exceptions.DeadlineExceeded,
),
),
default_timeout=60.0,
Expand Down Expand Up @@ -794,8 +753,7 @@ async def search_all_resources(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([scope, query, asset_types])
if request is not None and has_flattened_params:
if request is not None and any([scope, query, asset_types]):
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand All @@ -810,9 +768,8 @@ async def search_all_resources(
request.scope = scope
if query is not None:
request.query = query

if asset_types:
request.asset_types.extend(asset_types)
if asset_types is not None:
request.asset_types = asset_types

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
Expand All @@ -823,7 +780,7 @@ async def search_all_resources(
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
exceptions.ServiceUnavailable, exceptions.DeadlineExceeded,
),
),
default_timeout=15.0,
Expand Down Expand Up @@ -937,8 +894,7 @@ async def search_all_iam_policies(
# Create or coerce a protobuf request object.
# Sanity check: If we got a request object, we should *not* have
# gotten any keyword arguments that map to the request.
has_flattened_params = any([scope, query])
if request is not None and has_flattened_params:
if request is not None and any([scope, query]):
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand All @@ -963,7 +919,7 @@ async def search_all_iam_policies(
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
exceptions.ServiceUnavailable, exceptions.DeadlineExceeded,
),
),
default_timeout=15.0,
Expand Down
92 changes: 6 additions & 86 deletions google/cloud/asset_v1/services/asset_service/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,26 +132,6 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):

from_service_account_json = from_service_account_file

@property
def transport(self) -> AssetServiceTransport:
"""Return the transport used by the client instance.

Returns:
AssetServiceTransport: The transport used by the client instance.
"""
return self._transport

@staticmethod
def asset_path() -> str:
"""Return a fully-qualified asset string."""
return "*".format()

@staticmethod
def parse_asset_path(path: str) -> Dict[str, str]:
"""Parse a asset path into its component segments."""
m = re.match(r"^*$", path)
return m.groupdict() if m else {}

@staticmethod
def feed_path(project: str, feed: str,) -> str:
"""Return a fully-qualified feed string."""
Expand All @@ -163,65 +143,6 @@ def parse_feed_path(path: str) -> Dict[str, str]:
m = re.match(r"^projects/(?P<project>.+?)/feeds/(?P<feed>.+?)$", path)
return m.groupdict() if m else {}

@staticmethod
def common_billing_account_path(billing_account: str,) -> str:
"""Return a fully-qualified billing_account string."""
return "billingAccounts/{billing_account}".format(
billing_account=billing_account,
)

@staticmethod
def parse_common_billing_account_path(path: str) -> Dict[str, str]:
"""Parse a billing_account path into its component segments."""
m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path)
return m.groupdict() if m else {}

@staticmethod
def common_folder_path(folder: str,) -> str:
"""Return a fully-qualified folder string."""
return "folders/{folder}".format(folder=folder,)

@staticmethod
def parse_common_folder_path(path: str) -> Dict[str, str]:
"""Parse a folder path into its component segments."""
m = re.match(r"^folders/(?P<folder>.+?)$", path)
return m.groupdict() if m else {}

@staticmethod
def common_organization_path(organization: str,) -> str:
"""Return a fully-qualified organization string."""
return "organizations/{organization}".format(organization=organization,)

@staticmethod
def parse_common_organization_path(path: str) -> Dict[str, str]:
"""Parse a organization path into its component segments."""
m = re.match(r"^organizations/(?P<organization>.+?)$", path)
return m.groupdict() if m else {}

@staticmethod
def common_project_path(project: str,) -> str:
"""Return a fully-qualified project string."""
return "projects/{project}".format(project=project,)

@staticmethod
def parse_common_project_path(path: str) -> Dict[str, str]:
"""Parse a project path into its component segments."""
m = re.match(r"^projects/(?P<project>.+?)$", path)
return m.groupdict() if m else {}

@staticmethod
def common_location_path(project: str, location: str,) -> str:
"""Return a fully-qualified location string."""
return "projects/{project}/locations/{location}".format(
project=project, location=location,
)

@staticmethod
def parse_common_location_path(path: str) -> Dict[str, str]:
"""Parse a location path into its component segments."""
m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path)
return m.groupdict() if m else {}

def __init__(
self,
*,
Expand Down Expand Up @@ -257,10 +178,10 @@ def __init__(
not provided, the default SSL client certificate will be used if
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
set, no client certificate will be 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
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:
Expand Down Expand Up @@ -987,9 +908,8 @@ def search_all_resources(
request.scope = scope
if query is not None:
request.query = query

if asset_types:
request.asset_types.extend(asset_types)
if asset_types is not None:
request.asset_types = asset_types

# Wrap the RPC method; this adds retry and timeout information,
# and friendly error handling.
Expand Down
12 changes: 6 additions & 6 deletions google/cloud/asset_v1/services/asset_service/transports/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def _prep_wrapped_messages(self, client_info):
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
exceptions.ServiceUnavailable, exceptions.DeadlineExceeded,
),
),
default_timeout=60.0,
Expand All @@ -133,7 +133,7 @@ def _prep_wrapped_messages(self, client_info):
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
exceptions.ServiceUnavailable, exceptions.DeadlineExceeded,
),
),
default_timeout=60.0,
Expand All @@ -146,7 +146,7 @@ def _prep_wrapped_messages(self, client_info):
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
exceptions.ServiceUnavailable, exceptions.DeadlineExceeded,
),
),
default_timeout=60.0,
Expand All @@ -162,7 +162,7 @@ def _prep_wrapped_messages(self, client_info):
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
exceptions.ServiceUnavailable, exceptions.DeadlineExceeded,
),
),
default_timeout=60.0,
Expand All @@ -175,7 +175,7 @@ def _prep_wrapped_messages(self, client_info):
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
exceptions.ServiceUnavailable, exceptions.DeadlineExceeded,
),
),
default_timeout=15.0,
Expand All @@ -188,7 +188,7 @@ def _prep_wrapped_messages(self, client_info):
maximum=60.0,
multiplier=1.3,
predicate=retries.if_exception_type(
exceptions.DeadlineExceeded, exceptions.ServiceUnavailable,
exceptions.ServiceUnavailable, exceptions.DeadlineExceeded,
),
),
default_timeout=15.0,
Expand Down
14 changes: 9 additions & 5 deletions google/cloud/asset_v1/services/asset_service/transports/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ def __init__(
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
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:
Expand Down Expand Up @@ -224,8 +224,12 @@ def create_channel(

@property
def grpc_channel(self) -> grpc.Channel:
"""Return the channel designed to connect to this service.
"""Create the channel designed to connect to this service.

This property caches on the instance; repeated calls return
the same channel.
"""
# Return the channel from cache.
return self._grpc_channel

@property
Expand Down
Loading