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

Commit 0d02163

Browse files
chore: use gapic-generator-python 1.2.0 (#18)
- [ ] Regenerate this pull request now. PiperOrigin-RevId: 467286830 Source-Link: googleapis/googleapis@e6e875a Source-Link: https://github.com/googleapis/googleapis-gen/commit/0295ea14d9cd4d47ddb23b9ebd39a31e2035e28f Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMDI5NWVhMTRkOWNkNGQ0N2RkYjIzYjllYmQzOWEzMWUyMDM1ZTI4ZiJ9 fix(deps): require google-api-core>=1.32.0,>=2.8.0 chore: use gapic-generator-python 1.1.1 PiperOrigin-RevId: 459095142 Source-Link: googleapis/googleapis@4f1be99 Source-Link: https://github.com/googleapis/googleapis-gen/commit/ae686d9cde4fc3e36d0ac02efb8643b15890c1ed Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYWU2ODZkOWNkZTRmYzNlMzZkMGFjMDJlZmI4NjQzYjE1ODkwYzFlZCJ9 feat: add audience parameter PiperOrigin-RevId: 456827138 Source-Link: googleapis/googleapis@23f1a15 Source-Link: https://github.com/googleapis/googleapis-gen/commit/4075a8514f676691ec156688a5bbf183aa9893ce Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiNDA3NWE4NTE0ZjY3NjY5MWVjMTU2Njg4YTViYmYxODNhYTk4OTNjZSJ9 chore: use gapic-generator-python 1.0.0 PiperOrigin-RevId: 451250442 Source-Link: googleapis/googleapis@cca5e81 Source-Link: https://github.com/googleapis/googleapis-gen/commit/0b219da161a8bdcc3c6f7b2efcd82105182a30ca Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiMGIyMTlkYTE2MWE4YmRjYzNjNmY3YjJlZmNkODIxMDUxODJhMzBjYSJ9 fix: Updates pre-release Cloud Run v2 Preview client libraries to work with the latest API revision PiperOrigin-RevId: 447174265 Source-Link: googleapis/googleapis@185ba8a Source-Link: https://github.com/googleapis/googleapis-gen/commit/e3fa46fe47810698ef9693edeaf5c374dd47e8d7 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiZTNmYTQ2ZmU0NzgxMDY5OGVmOTY5M2VkZWFmNWMzNzRkZDQ3ZThkNyJ9
1 parent 55bf980 commit 0d02163

File tree

22 files changed

+331
-529
lines changed

22 files changed

+331
-529
lines changed

‎google/cloud/run_v2/services/revisions/client.py

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,7 @@ def __init__(
539539
quota_project_id=client_options.quota_project_id,
540540
client_info=client_info,
541541
always_use_jwt_access=True,
542+
api_audience=client_options.api_audience,
542543
)
543544

544545
def get_revision(
@@ -623,11 +624,19 @@ def sample_get_revision():
623624
# and friendly error handling.
624625
rpc = self._transport._wrapped_methods[self._transport.get_revision]
625626

626-
# Certain fields should be provided within the metadata header;
627-
# add these here.
628-
metadata = tuple(metadata) + (
629-
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
627+
header_params = {}
628+
629+
routing_param_regex = re.compile(
630+
"^projects/[^/]+/locations/(?P<location>[^/]+)(?:/.*)?$"
630631
)
632+
regex_match = routing_param_regex.match(request.name)
633+
if regex_match and regex_match.group("location"):
634+
header_params["location"] = regex_match.group("location")
635+
636+
if header_params:
637+
metadata = tuple(metadata) + (
638+
gapic_v1.routing_header.to_grpc_metadata(header_params),
639+
)
631640

632641
# Send the request.
633642
response = rpc(
@@ -726,11 +735,19 @@ def sample_list_revisions():
726735
# and friendly error handling.
727736
rpc = self._transport._wrapped_methods[self._transport.list_revisions]
728737

729-
# Certain fields should be provided within the metadata header;
730-
# add these here.
731-
metadata = tuple(metadata) + (
732-
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
738+
header_params = {}
739+
740+
routing_param_regex = re.compile(
741+
"^projects/[^/]+/locations/(?P<location>[^/]+)(?:/.*)?$"
733742
)
743+
regex_match = routing_param_regex.match(request.parent)
744+
if regex_match and regex_match.group("location"):
745+
header_params["location"] = regex_match.group("location")
746+
747+
if header_params:
748+
metadata = tuple(metadata) + (
749+
gapic_v1.routing_header.to_grpc_metadata(header_params),
750+
)
734751

735752
# Send the request.
736753
response = rpc(
@@ -840,11 +857,19 @@ def sample_delete_revision():
840857
# and friendly error handling.
841858
rpc = self._transport._wrapped_methods[self._transport.delete_revision]
842859

843-
# Certain fields should be provided within the metadata header;
844-
# add these here.
845-
metadata = tuple(metadata) + (
846-
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
860+
header_params = {}
861+
862+
routing_param_regex = re.compile(
863+
"^projects/[^/]+/locations/(?P<location>[^/]+)(?:/.*)?$"
847864
)
865+
regex_match = routing_param_regex.match(request.name)
866+
if regex_match and regex_match.group("location"):
867+
header_params["location"] = regex_match.group("location")
868+
869+
if header_params:
870+
metadata = tuple(metadata) + (
871+
gapic_v1.routing_header.to_grpc_metadata(header_params),
872+
)
848873

849874
# Send the request.
850875
response = rpc(

‎google/cloud/run_v2/services/revisions/transports/base.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def __init__(
5656
quota_project_id: Optional[str] = None,
5757
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
5858
always_use_jwt_access: Optional[bool] = False,
59+
api_audience: Optional[str] = None,
5960
**kwargs,
6061
) -> None:
6162
"""Instantiate the transport.
@@ -83,11 +84,6 @@ def __init__(
8384
be used for service account credentials.
8485
"""
8586

86-
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
87-
if ":" not in host:
88-
host += ":443"
89-
self._host = host
90-
9187
scopes_kwargs = {"scopes": scopes, "default_scopes": self.AUTH_SCOPES}
9288

9389
# Save the scopes.
@@ -108,6 +104,11 @@ def __init__(
108104
credentials, _ = google.auth.default(
109105
**scopes_kwargs, quota_project_id=quota_project_id
110106
)
107+
# Don't apply audience if the credentials file passed from user.
108+
if hasattr(credentials, "with_gdch_audience"):
109+
credentials = credentials.with_gdch_audience(
110+
api_audience if api_audience else host
111+
)
111112

112113
# If the credentials are service account credentials, then always try to use self signed JWT.
113114
if (
@@ -120,6 +121,11 @@ def __init__(
120121
# Save the credentials.
121122
self._credentials = credentials
122123

124+
# Save the hostname. Default to port 443 (HTTPS) if none is specified.
125+
if ":" not in host:
126+
host += ":443"
127+
self._host = host
128+
123129
def _prep_wrapped_messages(self, client_info):
124130
# Precompute the wrapped methods.
125131
self._wrapped_methods = {

‎google/cloud/run_v2/services/revisions/transports/grpc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ def __init__(
6060
quota_project_id: Optional[str] = None,
6161
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
6262
always_use_jwt_access: Optional[bool] = False,
63+
api_audience: Optional[str] = None,
6364
) -> None:
6465
"""Instantiate the transport.
6566
@@ -156,6 +157,7 @@ def __init__(
156157
quota_project_id=quota_project_id,
157158
client_info=client_info,
158159
always_use_jwt_access=always_use_jwt_access,
160+
api_audience=api_audience,
159161
)
160162

161163
if not self._grpc_channel:

‎google/cloud/run_v2/services/revisions/transports/grpc_asyncio.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ def __init__(
105105
quota_project_id=None,
106106
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
107107
always_use_jwt_access: Optional[bool] = False,
108+
api_audience: Optional[str] = None,
108109
) -> None:
109110
"""Instantiate the transport.
110111
@@ -201,6 +202,7 @@ def __init__(
201202
quota_project_id=quota_project_id,
202203
client_info=client_info,
203204
always_use_jwt_access=always_use_jwt_access,
205+
api_audience=api_audience,
204206
)
205207

206208
if not self._grpc_channel:

‎google/cloud/run_v2/services/services/async_client.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
from google.cloud.run_v2.types import vendor_settings
4444
from google.iam.v1 import iam_policy_pb2 # type: ignore
4545
from google.iam.v1 import policy_pb2 # type: ignore
46-
from google.protobuf import field_mask_pb2 # type: ignore
4746
from google.protobuf import timestamp_pb2 # type: ignore
4847
from .transports.base import ServicesTransport, DEFAULT_CLIENT_INFO
4948
from .transports.grpc_asyncio import ServicesGrpcAsyncIOTransport
@@ -592,7 +591,6 @@ async def update_service(
592591
request: Union[gcr_service.UpdateServiceRequest, dict] = None,
593592
*,
594593
service: gcr_service.Service = None,
595-
update_mask: field_mask_pb2.FieldMask = None,
596594
retry: OptionalRetry = gapic_v1.method.DEFAULT,
597595
timeout: float = None,
598596
metadata: Sequence[Tuple[str, str]] = (),
@@ -630,11 +628,6 @@ async def sample_update_service():
630628
This corresponds to the ``service`` field
631629
on the ``request`` instance; if ``request`` is provided, this
632630
should not be set.
633-
update_mask (:class:`google.protobuf.field_mask_pb2.FieldMask`):
634-
The list of fields to be updated.
635-
This corresponds to the ``update_mask`` field
636-
on the ``request`` instance; if ``request`` is provided, this
637-
should not be set.
638631
retry (google.api_core.retry.Retry): Designation of what errors, if any,
639632
should be retried.
640633
timeout (float): The timeout for this request.
@@ -657,7 +650,7 @@ async def sample_update_service():
657650
# Create or coerce a protobuf request object.
658651
# Quick check: If we got a request object, we should *not* have
659652
# gotten any keyword arguments that map to the request.
660-
has_flattened_params = any([service, update_mask])
653+
has_flattened_params = any([service])
661654
if request is not None and has_flattened_params:
662655
raise ValueError(
663656
"If the `request` argument is set, then none of "
@@ -670,8 +663,6 @@ async def sample_update_service():
670663
# request, apply these.
671664
if service is not None:
672665
request.service = service
673-
if update_mask is not None:
674-
request.update_mask = update_mask
675666

676667
# Wrap the RPC method; this adds retry and timeout information,
677668
# and friendly error handling.

‎google/cloud/run_v2/services/services/client.py

Lines changed: 62 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
from google.cloud.run_v2.types import vendor_settings
4747
from google.iam.v1 import iam_policy_pb2 # type: ignore
4848
from google.iam.v1 import policy_pb2 # type: ignore
49-
from google.protobuf import field_mask_pb2 # type: ignore
5049
from google.protobuf import timestamp_pb2 # type: ignore
5150
from .transports.base import ServicesTransport, DEFAULT_CLIENT_INFO
5251
from .transports.grpc import ServicesGrpcTransport
@@ -543,6 +542,7 @@ def __init__(
543542
quota_project_id=client_options.quota_project_id,
544543
client_info=client_info,
545544
always_use_jwt_access=True,
545+
api_audience=client_options.api_audience,
546546
)
547547

548548
def create_service(
@@ -659,11 +659,19 @@ def sample_create_service():
659659
# and friendly error handling.
660660
rpc = self._transport._wrapped_methods[self._transport.create_service]
661661

662-
# Certain fields should be provided within the metadata header;
663-
# add these here.
664-
metadata = tuple(metadata) + (
665-
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
662+
header_params = {}
663+
664+
routing_param_regex = re.compile(
665+
"^projects/[^/]+/locations/(?P<location>[^/]+)$"
666666
)
667+
regex_match = routing_param_regex.match(request.parent)
668+
if regex_match and regex_match.group("location"):
669+
header_params["location"] = regex_match.group("location")
670+
671+
if header_params:
672+
metadata = tuple(metadata) + (
673+
gapic_v1.routing_header.to_grpc_metadata(header_params),
674+
)
667675

668676
# Send the request.
669677
response = rpc(
@@ -770,11 +778,19 @@ def sample_get_service():
770778
# and friendly error handling.
771779
rpc = self._transport._wrapped_methods[self._transport.get_service]
772780

773-
# Certain fields should be provided within the metadata header;
774-
# add these here.
775-
metadata = tuple(metadata) + (
776-
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
781+
header_params = {}
782+
783+
routing_param_regex = re.compile(
784+
"^projects/[^/]+/locations/(?P<location>[^/]+)(?:/.*)?$"
777785
)
786+
regex_match = routing_param_regex.match(request.name)
787+
if regex_match and regex_match.group("location"):
788+
header_params["location"] = regex_match.group("location")
789+
790+
if header_params:
791+
metadata = tuple(metadata) + (
792+
gapic_v1.routing_header.to_grpc_metadata(header_params),
793+
)
778794

779795
# Send the request.
780796
response = rpc(
@@ -872,11 +888,19 @@ def sample_list_services():
872888
# and friendly error handling.
873889
rpc = self._transport._wrapped_methods[self._transport.list_services]
874890

875-
# Certain fields should be provided within the metadata header;
876-
# add these here.
877-
metadata = tuple(metadata) + (
878-
gapic_v1.routing_header.to_grpc_metadata((("parent", request.parent),)),
891+
header_params = {}
892+
893+
routing_param_regex = re.compile(
894+
"^projects/[^/]+/locations/(?P<location>[^/]+)$"
879895
)
896+
regex_match = routing_param_regex.match(request.parent)
897+
if regex_match and regex_match.group("location"):
898+
header_params["location"] = regex_match.group("location")
899+
900+
if header_params:
901+
metadata = tuple(metadata) + (
902+
gapic_v1.routing_header.to_grpc_metadata(header_params),
903+
)
880904

881905
# Send the request.
882906
response = rpc(
@@ -903,7 +927,6 @@ def update_service(
903927
request: Union[gcr_service.UpdateServiceRequest, dict] = None,
904928
*,
905929
service: gcr_service.Service = None,
906-
update_mask: field_mask_pb2.FieldMask = None,
907930
retry: OptionalRetry = gapic_v1.method.DEFAULT,
908931
timeout: float = None,
909932
metadata: Sequence[Tuple[str, str]] = (),
@@ -941,11 +964,6 @@ def sample_update_service():
941964
This corresponds to the ``service`` field
942965
on the ``request`` instance; if ``request`` is provided, this
943966
should not be set.
944-
update_mask (google.protobuf.field_mask_pb2.FieldMask):
945-
The list of fields to be updated.
946-
This corresponds to the ``update_mask`` field
947-
on the ``request`` instance; if ``request`` is provided, this
948-
should not be set.
949967
retry (google.api_core.retry.Retry): Designation of what errors, if any,
950968
should be retried.
951969
timeout (float): The timeout for this request.
@@ -968,7 +986,7 @@ def sample_update_service():
968986
# Create or coerce a protobuf request object.
969987
# Quick check: If we got a request object, we should *not* have
970988
# gotten any keyword arguments that map to the request.
971-
has_flattened_params = any([service, update_mask])
989+
has_flattened_params = any([service])
972990
if request is not None and has_flattened_params:
973991
raise ValueError(
974992
"If the `request` argument is set, then none of "
@@ -985,20 +1003,24 @@ def sample_update_service():
9851003
# request, apply these.
9861004
if service is not None:
9871005
request.service = service
988-
if update_mask is not None:
989-
request.update_mask = update_mask
9901006

9911007
# Wrap the RPC method; this adds retry and timeout information,
9921008
# and friendly error handling.
9931009
rpc = self._transport._wrapped_methods[self._transport.update_service]
9941010

995-
# Certain fields should be provided within the metadata header;
996-
# add these here.
997-
metadata = tuple(metadata) + (
998-
gapic_v1.routing_header.to_grpc_metadata(
999-
(("service.name", request.service.name),)
1000-
),
1011+
header_params = {}
1012+
1013+
routing_param_regex = re.compile(
1014+
"^projects/[^/]+/locations/(?P<location>[^/]+)(?:/.*)?$"
10011015
)
1016+
regex_match = routing_param_regex.match(request.service.name)
1017+
if regex_match and regex_match.group("location"):
1018+
header_params["location"] = regex_match.group("location")
1019+
1020+
if header_params:
1021+
metadata = tuple(metadata) + (
1022+
gapic_v1.routing_header.to_grpc_metadata(header_params),
1023+
)
10021024

10031025
# Send the request.
10041026
response = rpc(
@@ -1111,11 +1133,19 @@ def sample_delete_service():
11111133
# and friendly error handling.
11121134
rpc = self._transport._wrapped_methods[self._transport.delete_service]
11131135

1114-
# Certain fields should be provided within the metadata header;
1115-
# add these here.
1116-
metadata = tuple(metadata) + (
1117-
gapic_v1.routing_header.to_grpc_metadata((("name", request.name),)),
1136+
header_params = {}
1137+
1138+
routing_param_regex = re.compile(
1139+
"^projects/[^/]+/locations/(?P<location>[^/]+)(?:/.*)?$"
11181140
)
1141+
regex_match = routing_param_regex.match(request.name)
1142+
if regex_match and regex_match.group("location"):
1143+
header_params["location"] = regex_match.group("location")
1144+
1145+
if header_params:
1146+
metadata = tuple(metadata) + (
1147+
gapic_v1.routing_header.to_grpc_metadata(header_params),
1148+
)
11191149

11201150
# Send the request.
11211151
response = rpc(

0 commit comments

Comments
 (0)