Skip to content
This repository has been archived by the owner on Jul 6, 2023. It is now read-only.

Commit

Permalink
feat: add common resource path helpers; expose client transport; remo…
Browse files Browse the repository at this point in the history
…ve gRPC send/recv limit (#12)

* changes without context

        autosynth cannot find the source of changes triggered by earlier changes in this
        repository, or by version upgrades to tools such as linters.

* feat: Add Java microgen rules to imports

Source-Author: Mira Leung <miraleung@users.noreply.github.com>
Source-Date: Mon Sep 21 18:04:02 2020 -0700
Source-Repo: googleapis/googleapis
Source-Sha: aaac658367398e478d650768344b88acebad50d9
Source-Link: googleapis/googleapis@aaac658

* feat: added ReportInventory RPC

PiperOrigin-RevId: 333583499

Source-Author: Google APIs <noreply@google.com>
Source-Date: Thu Sep 24 13:18:54 2020 -0700
Source-Repo: googleapis/googleapis
Source-Sha: 2987612c6aacc1857ee35468e7aeb1c393460799
Source-Link: googleapis/googleapis@2987612

* feat: Added force option for Purge APIs feat: Added API service description fix!: Renamed ProductLevelConfig enum names in CatalogService BREAKING CHANGE: the renaming is a breaking change but since the API is not used anywhere and client libraries generation has not started, it's a safe change. fix: a few minor API doc changes.

PiperOrigin-RevId: 339268186

Source-Author: Google APIs <noreply@google.com>
Source-Date: Tue Oct 27 09:45:44 2020 -0700
Source-Repo: googleapis/googleapis
Source-Sha: 6516b525ee76094f1de9b7a8b0abaff91f2e5eb2
Source-Link: googleapis/googleapis@6516b52

* chore: upgrade to gapic-generator 0.35.9

PiperOrigin-RevId: 339292950

Source-Author: Google APIs <noreply@google.com>
Source-Date: Tue Oct 27 11:32:46 2020 -0700
Source-Repo: googleapis/googleapis
Source-Sha: 07d41a7e5cade45aba6f0d277c89722b48f2c956
Source-Link: googleapis/googleapis@07d41a7

* fix: remove client recv msg limit fix: add enums to `types/__init__.py`

PiperOrigin-RevId: 347055288

Source-Author: Google APIs <noreply@google.com>
Source-Date: Fri Dec 11 12:44:37 2020 -0800
Source-Repo: googleapis/googleapis
Source-Sha: dd372aa22ded7a8ba6f0e03a80e06358a3fa0907
Source-Link: googleapis/googleapis@dd372aa
  • Loading branch information
yoshi-automation committed Dec 23, 2020
1 parent 1a1d3df commit 672d821
Show file tree
Hide file tree
Showing 20 changed files with 748 additions and 237 deletions.
1 change: 1 addition & 0 deletions docs/executions_v1beta/types.rst
Expand Up @@ -3,3 +3,4 @@ Types for Google Cloud Workflows Executions v1beta API

.. automodule:: google.cloud.workflows.executions_v1beta.types
:members:
:show-inheritance:
1 change: 1 addition & 0 deletions docs/workflows_v1beta/types.rst
Expand Up @@ -3,3 +3,4 @@ Types for Google Cloud Workflows v1beta API

.. automodule:: google.cloud.workflows_v1beta.types
:members:
:show-inheritance:
Expand Up @@ -50,10 +50,44 @@ class ExecutionsAsyncClient:

execution_path = staticmethod(ExecutionsClient.execution_path)
parse_execution_path = staticmethod(ExecutionsClient.parse_execution_path)
workflow_path = staticmethod(ExecutionsClient.workflow_path)
parse_workflow_path = staticmethod(ExecutionsClient.parse_workflow_path)

common_billing_account_path = staticmethod(
ExecutionsClient.common_billing_account_path
)
parse_common_billing_account_path = staticmethod(
ExecutionsClient.parse_common_billing_account_path
)

common_folder_path = staticmethod(ExecutionsClient.common_folder_path)
parse_common_folder_path = staticmethod(ExecutionsClient.parse_common_folder_path)

common_organization_path = staticmethod(ExecutionsClient.common_organization_path)
parse_common_organization_path = staticmethod(
ExecutionsClient.parse_common_organization_path
)

common_project_path = staticmethod(ExecutionsClient.common_project_path)
parse_common_project_path = staticmethod(ExecutionsClient.parse_common_project_path)

common_location_path = staticmethod(ExecutionsClient.common_location_path)
parse_common_location_path = staticmethod(
ExecutionsClient.parse_common_location_path
)

from_service_account_file = ExecutionsClient.from_service_account_file
from_service_account_json = from_service_account_file

@property
def transport(self) -> ExecutionsTransport:
"""Return the transport used by the client instance.
Returns:
ExecutionsTransport: The transport used by the client instance.
"""
return self._client.transport

get_transport_class = functools.partial(
type(ExecutionsClient).get_transport_class, type(ExecutionsClient)
)
Expand Down Expand Up @@ -154,7 +188,8 @@ async def list_executions(
# 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.
if request is not None and any([parent]):
has_flattened_params = any([parent])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -243,7 +278,8 @@ async def create_execution(
# 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.
if request is not None and any([parent, execution]):
has_flattened_params = any([parent, execution])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -318,7 +354,8 @@ async def get_execution(
# 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.
if request is not None and any([name]):
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down Expand Up @@ -391,7 +428,8 @@ async def cancel_execution(
# 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.
if request is not None and any([name]):
has_flattened_params = any([name])
if request is not None and has_flattened_params:
raise ValueError(
"If the `request` argument is set, then none of "
"the individual field arguments should be set."
Expand Down
Expand Up @@ -132,6 +132,15 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):

from_service_account_json = from_service_account_file

@property
def transport(self) -> ExecutionsTransport:
"""Return the transport used by the client instance.
Returns:
ExecutionsTransport: The transport used by the client instance.
"""
return self._transport

@staticmethod
def execution_path(
project: str, location: str, workflow: str, execution: str,
Expand All @@ -150,6 +159,81 @@ def parse_execution_path(path: str) -> Dict[str, str]:
)
return m.groupdict() if m else {}

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

@staticmethod
def parse_workflow_path(path: str) -> Dict[str, str]:
"""Parse a workflow path into its component segments."""
m = re.match(
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/workflows/(?P<workflow>.+?)$",
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 @@ -185,10 +269,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 @@ -28,7 +28,6 @@
_transport_registry["grpc"] = ExecutionsGrpcTransport
_transport_registry["grpc_asyncio"] = ExecutionsGrpcAsyncIOTransport


__all__ = (
"ExecutionsTransport",
"ExecutionsGrpcTransport",
Expand Down
Expand Up @@ -91,10 +91,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 All @@ -103,13 +103,16 @@ def __init__(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
self._ssl_channel_credentials = ssl_channel_credentials

if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
credentials = False

# If a channel was explicitly provided, set it.
self._grpc_channel = channel
self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
Expand Down Expand Up @@ -145,7 +148,12 @@ def __init__(
ssl_credentials=ssl_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
options=[
("grpc.max_send_message_length", -1),
("grpc.max_receive_message_length", -1),
],
)
self._ssl_channel_credentials = ssl_credentials
else:
host = host if ":" in host else host + ":443"

Expand All @@ -162,6 +170,10 @@ def __init__(
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
options=[
("grpc.max_send_message_length", -1),
("grpc.max_receive_message_length", -1),
],
)

self._stubs = {} # type: Dict[str, Callable]
Expand All @@ -188,7 +200,7 @@ def create_channel(
) -> grpc.Channel:
"""Create and return a gRPC channel object.
Args:
address (Optionsl[str]): The host for the channel to use.
address (Optional[str]): The host for the channel to use.
credentials (Optional[~.Credentials]): The
authorization credentials to attach to requests. These
credentials identify this application to the service. If
Expand Down Expand Up @@ -223,12 +235,8 @@ def create_channel(

@property
def grpc_channel(self) -> grpc.Channel:
"""Create the channel designed to connect to this service.
This property caches on the instance; repeated calls return
the same channel.
"""Return the channel designed to connect to this service.
"""
# Return the channel from cache.
return self._grpc_channel

@property
Expand Down
Expand Up @@ -148,13 +148,16 @@ def __init__(
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
and ``credentials_file`` are passed.
"""
self._ssl_channel_credentials = ssl_channel_credentials

if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
credentials = False

# If a channel was explicitly provided, set it.
self._grpc_channel = channel
self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
Expand Down Expand Up @@ -190,7 +193,12 @@ def __init__(
ssl_credentials=ssl_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
options=[
("grpc.max_send_message_length", -1),
("grpc.max_receive_message_length", -1),
],
)
self._ssl_channel_credentials = ssl_credentials
else:
host = host if ":" in host else host + ":443"

Expand All @@ -207,6 +215,10 @@ def __init__(
ssl_credentials=ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
options=[
("grpc.max_send_message_length", -1),
("grpc.max_receive_message_length", -1),
],
)

# Run the base constructor.
Expand Down
3 changes: 2 additions & 1 deletion google/cloud/workflows/executions_v1beta/types/__init__.py
Expand Up @@ -22,14 +22,15 @@
CreateExecutionRequest,
GetExecutionRequest,
CancelExecutionRequest,
ExecutionView,
)


__all__ = (
"Execution",
"ListExecutionsRequest",
"ListExecutionsResponse",
"CreateExecutionRequest",
"GetExecutionRequest",
"CancelExecutionRequest",
"ExecutionView",
)
4 changes: 2 additions & 2 deletions google/cloud/workflows/executions_v1beta/types/executions.py
Expand Up @@ -176,7 +176,7 @@ class ListExecutionsResponse(proto.Message):
def raw_page(self):
return self

executions = proto.RepeatedField(proto.MESSAGE, number=1, message=Execution,)
executions = proto.RepeatedField(proto.MESSAGE, number=1, message="Execution",)

next_page_token = proto.Field(proto.STRING, number=2)

Expand All @@ -199,7 +199,7 @@ class CreateExecutionRequest(proto.Message):

parent = proto.Field(proto.STRING, number=1)

execution = proto.Field(proto.MESSAGE, number=2, message=Execution,)
execution = proto.Field(proto.MESSAGE, number=2, message="Execution",)


class GetExecutionRequest(proto.Message):
Expand Down

0 comments on commit 672d821

Please sign in to comment.