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

Commit 672d821

Browse files
feat: add common resource path helpers; expose client transport; remove 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
1 parent 1a1d3df commit 672d821

File tree

20 files changed

+748
-237
lines changed

20 files changed

+748
-237
lines changed

docs/executions_v1beta/types.rst

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ Types for Google Cloud Workflows Executions v1beta API
33

44
.. automodule:: google.cloud.workflows.executions_v1beta.types
55
:members:
6+
:show-inheritance:

docs/workflows_v1beta/types.rst

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ Types for Google Cloud Workflows v1beta API
33

44
.. automodule:: google.cloud.workflows_v1beta.types
55
:members:
6+
:show-inheritance:

google/cloud/workflows/executions_v1beta/services/executions/async_client.py

+42-4
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,44 @@ class ExecutionsAsyncClient:
5050

5151
execution_path = staticmethod(ExecutionsClient.execution_path)
5252
parse_execution_path = staticmethod(ExecutionsClient.parse_execution_path)
53+
workflow_path = staticmethod(ExecutionsClient.workflow_path)
54+
parse_workflow_path = staticmethod(ExecutionsClient.parse_workflow_path)
55+
56+
common_billing_account_path = staticmethod(
57+
ExecutionsClient.common_billing_account_path
58+
)
59+
parse_common_billing_account_path = staticmethod(
60+
ExecutionsClient.parse_common_billing_account_path
61+
)
62+
63+
common_folder_path = staticmethod(ExecutionsClient.common_folder_path)
64+
parse_common_folder_path = staticmethod(ExecutionsClient.parse_common_folder_path)
65+
66+
common_organization_path = staticmethod(ExecutionsClient.common_organization_path)
67+
parse_common_organization_path = staticmethod(
68+
ExecutionsClient.parse_common_organization_path
69+
)
70+
71+
common_project_path = staticmethod(ExecutionsClient.common_project_path)
72+
parse_common_project_path = staticmethod(ExecutionsClient.parse_common_project_path)
73+
74+
common_location_path = staticmethod(ExecutionsClient.common_location_path)
75+
parse_common_location_path = staticmethod(
76+
ExecutionsClient.parse_common_location_path
77+
)
5378

5479
from_service_account_file = ExecutionsClient.from_service_account_file
5580
from_service_account_json = from_service_account_file
5681

82+
@property
83+
def transport(self) -> ExecutionsTransport:
84+
"""Return the transport used by the client instance.
85+
86+
Returns:
87+
ExecutionsTransport: The transport used by the client instance.
88+
"""
89+
return self._client.transport
90+
5791
get_transport_class = functools.partial(
5892
type(ExecutionsClient).get_transport_class, type(ExecutionsClient)
5993
)
@@ -154,7 +188,8 @@ async def list_executions(
154188
# Create or coerce a protobuf request object.
155189
# Sanity check: If we got a request object, we should *not* have
156190
# gotten any keyword arguments that map to the request.
157-
if request is not None and any([parent]):
191+
has_flattened_params = any([parent])
192+
if request is not None and has_flattened_params:
158193
raise ValueError(
159194
"If the `request` argument is set, then none of "
160195
"the individual field arguments should be set."
@@ -243,7 +278,8 @@ async def create_execution(
243278
# Create or coerce a protobuf request object.
244279
# Sanity check: If we got a request object, we should *not* have
245280
# gotten any keyword arguments that map to the request.
246-
if request is not None and any([parent, execution]):
281+
has_flattened_params = any([parent, execution])
282+
if request is not None and has_flattened_params:
247283
raise ValueError(
248284
"If the `request` argument is set, then none of "
249285
"the individual field arguments should be set."
@@ -318,7 +354,8 @@ async def get_execution(
318354
# Create or coerce a protobuf request object.
319355
# Sanity check: If we got a request object, we should *not* have
320356
# gotten any keyword arguments that map to the request.
321-
if request is not None and any([name]):
357+
has_flattened_params = any([name])
358+
if request is not None and has_flattened_params:
322359
raise ValueError(
323360
"If the `request` argument is set, then none of "
324361
"the individual field arguments should be set."
@@ -391,7 +428,8 @@ async def cancel_execution(
391428
# Create or coerce a protobuf request object.
392429
# Sanity check: If we got a request object, we should *not* have
393430
# gotten any keyword arguments that map to the request.
394-
if request is not None and any([name]):
431+
has_flattened_params = any([name])
432+
if request is not None and has_flattened_params:
395433
raise ValueError(
396434
"If the `request` argument is set, then none of "
397435
"the individual field arguments should be set."

google/cloud/workflows/executions_v1beta/services/executions/client.py

+88-4
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,15 @@ def from_service_account_file(cls, filename: str, *args, **kwargs):
132132

133133
from_service_account_json = from_service_account_file
134134

135+
@property
136+
def transport(self) -> ExecutionsTransport:
137+
"""Return the transport used by the client instance.
138+
139+
Returns:
140+
ExecutionsTransport: The transport used by the client instance.
141+
"""
142+
return self._transport
143+
135144
@staticmethod
136145
def execution_path(
137146
project: str, location: str, workflow: str, execution: str,
@@ -150,6 +159,81 @@ def parse_execution_path(path: str) -> Dict[str, str]:
150159
)
151160
return m.groupdict() if m else {}
152161

162+
@staticmethod
163+
def workflow_path(project: str, location: str, workflow: str,) -> str:
164+
"""Return a fully-qualified workflow string."""
165+
return "projects/{project}/locations/{location}/workflows/{workflow}".format(
166+
project=project, location=location, workflow=workflow,
167+
)
168+
169+
@staticmethod
170+
def parse_workflow_path(path: str) -> Dict[str, str]:
171+
"""Parse a workflow path into its component segments."""
172+
m = re.match(
173+
r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)/workflows/(?P<workflow>.+?)$",
174+
path,
175+
)
176+
return m.groupdict() if m else {}
177+
178+
@staticmethod
179+
def common_billing_account_path(billing_account: str,) -> str:
180+
"""Return a fully-qualified billing_account string."""
181+
return "billingAccounts/{billing_account}".format(
182+
billing_account=billing_account,
183+
)
184+
185+
@staticmethod
186+
def parse_common_billing_account_path(path: str) -> Dict[str, str]:
187+
"""Parse a billing_account path into its component segments."""
188+
m = re.match(r"^billingAccounts/(?P<billing_account>.+?)$", path)
189+
return m.groupdict() if m else {}
190+
191+
@staticmethod
192+
def common_folder_path(folder: str,) -> str:
193+
"""Return a fully-qualified folder string."""
194+
return "folders/{folder}".format(folder=folder,)
195+
196+
@staticmethod
197+
def parse_common_folder_path(path: str) -> Dict[str, str]:
198+
"""Parse a folder path into its component segments."""
199+
m = re.match(r"^folders/(?P<folder>.+?)$", path)
200+
return m.groupdict() if m else {}
201+
202+
@staticmethod
203+
def common_organization_path(organization: str,) -> str:
204+
"""Return a fully-qualified organization string."""
205+
return "organizations/{organization}".format(organization=organization,)
206+
207+
@staticmethod
208+
def parse_common_organization_path(path: str) -> Dict[str, str]:
209+
"""Parse a organization path into its component segments."""
210+
m = re.match(r"^organizations/(?P<organization>.+?)$", path)
211+
return m.groupdict() if m else {}
212+
213+
@staticmethod
214+
def common_project_path(project: str,) -> str:
215+
"""Return a fully-qualified project string."""
216+
return "projects/{project}".format(project=project,)
217+
218+
@staticmethod
219+
def parse_common_project_path(path: str) -> Dict[str, str]:
220+
"""Parse a project path into its component segments."""
221+
m = re.match(r"^projects/(?P<project>.+?)$", path)
222+
return m.groupdict() if m else {}
223+
224+
@staticmethod
225+
def common_location_path(project: str, location: str,) -> str:
226+
"""Return a fully-qualified location string."""
227+
return "projects/{project}/locations/{location}".format(
228+
project=project, location=location,
229+
)
230+
231+
@staticmethod
232+
def parse_common_location_path(path: str) -> Dict[str, str]:
233+
"""Parse a location path into its component segments."""
234+
m = re.match(r"^projects/(?P<project>.+?)/locations/(?P<location>.+?)$", path)
235+
return m.groupdict() if m else {}
236+
153237
def __init__(
154238
self,
155239
*,
@@ -185,10 +269,10 @@ def __init__(
185269
not provided, the default SSL client certificate will be used if
186270
present. If GOOGLE_API_USE_CLIENT_CERTIFICATE is "false" or not
187271
set, no client certificate will be used.
188-
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
189-
The client info used to send a user-agent string along with
190-
API requests. If ``None``, then default info will be used.
191-
Generally, you only need to set this if you're developing
272+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
273+
The client info used to send a user-agent string along with
274+
API requests. If ``None``, then default info will be used.
275+
Generally, you only need to set this if you're developing
192276
your own client library.
193277
194278
Raises:

google/cloud/workflows/executions_v1beta/services/executions/transports/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
_transport_registry["grpc"] = ExecutionsGrpcTransport
2929
_transport_registry["grpc_asyncio"] = ExecutionsGrpcAsyncIOTransport
3030

31-
3231
__all__ = (
3332
"ExecutionsTransport",
3433
"ExecutionsGrpcTransport",

google/cloud/workflows/executions_v1beta/services/executions/transports/grpc.py

+18-10
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,10 @@ def __init__(
9191
for grpc channel. It is ignored if ``channel`` is provided.
9292
quota_project_id (Optional[str]): An optional project to use for billing
9393
and quota.
94-
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
95-
The client info used to send a user-agent string along with
96-
API requests. If ``None``, then default info will be used.
97-
Generally, you only need to set this if you're developing
94+
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
95+
The client info used to send a user-agent string along with
96+
API requests. If ``None``, then default info will be used.
97+
Generally, you only need to set this if you're developing
9898
your own client library.
9999
100100
Raises:
@@ -103,13 +103,16 @@ def __init__(
103103
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
104104
and ``credentials_file`` are passed.
105105
"""
106+
self._ssl_channel_credentials = ssl_channel_credentials
107+
106108
if channel:
107109
# Sanity check: Ensure that channel and credentials are not both
108110
# provided.
109111
credentials = False
110112

111113
# If a channel was explicitly provided, set it.
112114
self._grpc_channel = channel
115+
self._ssl_channel_credentials = None
113116
elif api_mtls_endpoint:
114117
warnings.warn(
115118
"api_mtls_endpoint and client_cert_source are deprecated",
@@ -145,7 +148,12 @@ def __init__(
145148
ssl_credentials=ssl_credentials,
146149
scopes=scopes or self.AUTH_SCOPES,
147150
quota_project_id=quota_project_id,
151+
options=[
152+
("grpc.max_send_message_length", -1),
153+
("grpc.max_receive_message_length", -1),
154+
],
148155
)
156+
self._ssl_channel_credentials = ssl_credentials
149157
else:
150158
host = host if ":" in host else host + ":443"
151159

@@ -162,6 +170,10 @@ def __init__(
162170
ssl_credentials=ssl_channel_credentials,
163171
scopes=scopes or self.AUTH_SCOPES,
164172
quota_project_id=quota_project_id,
173+
options=[
174+
("grpc.max_send_message_length", -1),
175+
("grpc.max_receive_message_length", -1),
176+
],
165177
)
166178

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

224236
@property
225237
def grpc_channel(self) -> grpc.Channel:
226-
"""Create the channel designed to connect to this service.
227-
228-
This property caches on the instance; repeated calls return
229-
the same channel.
238+
"""Return the channel designed to connect to this service.
230239
"""
231-
# Return the channel from cache.
232240
return self._grpc_channel
233241

234242
@property

google/cloud/workflows/executions_v1beta/services/executions/transports/grpc_asyncio.py

+12
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,16 @@ def __init__(
148148
google.api_core.exceptions.DuplicateCredentialArgs: If both ``credentials``
149149
and ``credentials_file`` are passed.
150150
"""
151+
self._ssl_channel_credentials = ssl_channel_credentials
152+
151153
if channel:
152154
# Sanity check: Ensure that channel and credentials are not both
153155
# provided.
154156
credentials = False
155157

156158
# If a channel was explicitly provided, set it.
157159
self._grpc_channel = channel
160+
self._ssl_channel_credentials = None
158161
elif api_mtls_endpoint:
159162
warnings.warn(
160163
"api_mtls_endpoint and client_cert_source are deprecated",
@@ -190,7 +193,12 @@ def __init__(
190193
ssl_credentials=ssl_credentials,
191194
scopes=scopes or self.AUTH_SCOPES,
192195
quota_project_id=quota_project_id,
196+
options=[
197+
("grpc.max_send_message_length", -1),
198+
("grpc.max_receive_message_length", -1),
199+
],
193200
)
201+
self._ssl_channel_credentials = ssl_credentials
194202
else:
195203
host = host if ":" in host else host + ":443"
196204

@@ -207,6 +215,10 @@ def __init__(
207215
ssl_credentials=ssl_channel_credentials,
208216
scopes=scopes or self.AUTH_SCOPES,
209217
quota_project_id=quota_project_id,
218+
options=[
219+
("grpc.max_send_message_length", -1),
220+
("grpc.max_receive_message_length", -1),
221+
],
210222
)
211223

212224
# Run the base constructor.

google/cloud/workflows/executions_v1beta/types/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,15 @@
2222
CreateExecutionRequest,
2323
GetExecutionRequest,
2424
CancelExecutionRequest,
25+
ExecutionView,
2526
)
2627

27-
2828
__all__ = (
2929
"Execution",
3030
"ListExecutionsRequest",
3131
"ListExecutionsResponse",
3232
"CreateExecutionRequest",
3333
"GetExecutionRequest",
3434
"CancelExecutionRequest",
35+
"ExecutionView",
3536
)

google/cloud/workflows/executions_v1beta/types/executions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ class ListExecutionsResponse(proto.Message):
176176
def raw_page(self):
177177
return self
178178

179-
executions = proto.RepeatedField(proto.MESSAGE, number=1, message=Execution,)
179+
executions = proto.RepeatedField(proto.MESSAGE, number=1, message="Execution",)
180180

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

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

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

202-
execution = proto.Field(proto.MESSAGE, number=2, message=Execution,)
202+
execution = proto.Field(proto.MESSAGE, number=2, message="Execution",)
203203

204204

205205
class GetExecutionRequest(proto.Message):

0 commit comments

Comments
 (0)