Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit b6a6aa0

Browse files
authored
Merge branch 'main' into update-docs-build
2 parents 2bd72d6 + 8a705c5 commit b6a6aa0

File tree

147 files changed

+8016
-2403
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+8016
-2403
lines changed

.bazelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
# New boringssl requires C++14
2-
build --repo_env=BAZEL_CXXOPTS="-std=c++14"
1+
# New protobuf requires C++17
2+
build --repo_env=BAZEL_CXXOPTS="-std=c++17"

.github/sync-repo-settings.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,11 @@ branchProtectionRules:
1515
- 'mypy (3.13)'
1616
- 'showcase (3.7, showcase)'
1717
- 'showcase (3.13, showcase)'
18-
- 'showcase (3.7, showcase_alternative_templates)'
19-
- 'showcase (3.13, showcase_alternative_templates)'
2018
- 'showcase (3.7, showcase_w_rest_async)'
2119
- 'showcase (3.13, showcase_w_rest_async)'
2220
# TODO(dovs): reenable these when the mtls tests have been debugged and fixed
2321
# See #1218 for details
2422
# - 'showcase-mtls (showcase_mtls)'
25-
# - 'showcase-mtls (showcase_mtls_alternative_templates)'
2623
- 'showcase-mypy'
2724
- 'showcase-mypy (_alternative_templates)'
2825
- 'showcase-unit (3.7)'

.github/workflows/tests.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ jobs:
7272
matrix:
7373
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2121) Remove `showcase_w_rest_async` target when async rest is GA.
7474
python: ["3.7", "3.13"]
75-
target: [showcase, showcase_alternative_templates, showcase_w_rest_async]
75+
target: [showcase, showcase_w_rest_async]
7676
logging_scope: ["", "google"]
7777

7878
# TODO(https://github.com/googleapis/gapic-generator-python/issues/2303): use `ubuntu-latest` once this bug is fixed.
@@ -117,7 +117,7 @@ jobs:
117117
if: ${{ false }} # TODO(dovs): reenable when #1218 is fixed
118118
strategy:
119119
matrix:
120-
target: [showcase_mtls, showcase_mtls_alternative_templates]
120+
target: [showcase_mtls]
121121
max-parallel: 1
122122
runs-on: ubuntu-latest
123123
steps:

CHANGELOG.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,33 @@
11
# Changelog
22

33

4+
## [1.25.0](https://github.com/googleapis/gapic-generator-python/compare/v1.24.1...v1.25.0) (2025-05-06)
5+
6+
7+
### Features
8+
9+
* Add protobuf runtime version to `x-goog-api-client` header ([#2368](https://github.com/googleapis/gapic-generator-python/issues/2368)) ([9c05dbe](https://github.com/googleapis/gapic-generator-python/commit/9c05dbeb9285919f45924be09c445b707cb85b54))
10+
11+
## [1.24.1](https://github.com/googleapis/gapic-generator-python/compare/v1.24.0...v1.24.1) (2025-04-17)
12+
13+
14+
### Bug Fixes
15+
16+
* Update generated docs to match synthtool templates ([3f62f31](https://github.com/googleapis/gapic-generator-python/commit/3f62f31d5146147c4bc6393fbeef18ce1d9a1a42))
17+
18+
## [1.24.0](https://github.com/googleapis/gapic-generator-python/compare/v1.23.6...v1.24.0) (2025-04-11)
19+
20+
21+
### Features
22+
23+
* Adds augmented pagination to account for BQ family of APIs ([#2372](https://github.com/googleapis/gapic-generator-python/issues/2372)) ([30cd1a4](https://github.com/googleapis/gapic-generator-python/commit/30cd1a49353048fc190114cfb7a73e14ec2eff31))
24+
25+
26+
### Bug Fixes
27+
28+
* Fixed internal method generation naming issues ([#2365](https://github.com/googleapis/gapic-generator-python/issues/2365)) ([868f201](https://github.com/googleapis/gapic-generator-python/commit/868f201957b271c9390bf41374897a2ce728a5e2))
29+
* Missing DEFAULT_HOST should still result in compiling code ([#2051](https://github.com/googleapis/gapic-generator-python/issues/2051)) ([dc6d4f7](https://github.com/googleapis/gapic-generator-python/commit/dc6d4f7ec0853557bb7c25a8276fbe262c5bda5d))
30+
431
## [1.23.6](https://github.com/googleapis/gapic-generator-python/compare/v1.23.5...v1.23.6) (2025-03-17)
532

633

WORKSPACE

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,9 @@ gapic_generator_python()
6060

6161
gapic_generator_register_toolchains()
6262

63-
_grpc_version = "1.67.1"
63+
_grpc_version = "1.71.0"
6464

65-
_grpc_sha256 = "f83aedc91b84d4c396d30b0b2a30f7113c651fe5bc180c8ac08a5f0ff7dcffd2"
65+
_grpc_sha256 = "9313c3f8f4dd3341597f152d506a50caf571fe40f886e24ea9078891990df285"
6666

6767
http_archive(
6868
name = "com_github_grpc_grpc",
@@ -71,29 +71,38 @@ http_archive(
7171
urls = ["https://github.com/grpc/grpc/archive/v%s.zip" % _grpc_version],
7272
)
7373
# instantiated in grpc_deps().
74+
75+
_protobuf_version = "30.2"
76+
77+
_protobuf_sha256 = "07a43d88fe5a38e434c7f94129cad56a4c43a51f99336074d0799c2f7d4e44c5"
78+
7479
http_archive(
7580
name = "com_google_protobuf",
76-
sha256 = "008a11cc56f9b96679b4c285fd05f46d317d685be3ab524b2a310be0fbad987e",
77-
strip_prefix = "protobuf-29.3",
78-
urls = ["https://github.com/protocolbuffers/protobuf/archive/v29.3.tar.gz"],
81+
sha256 = _protobuf_sha256,
82+
strip_prefix = "protobuf-%s" % _protobuf_version,
83+
urls = ["https://github.com/protocolbuffers/protobuf/archive/v%s.tar.gz" % _protobuf_version],
7984
)
8085
load("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_deps")
8186

8287
grpc_deps()
8388

84-
# Pin the version of rules_cc to the version that is present in
85-
# https://github.com/protocolbuffers/protobuf/blob/29.x/protobuf_deps.bzl#L92-L98
8689
http_archive(
8790
name = "rules_cc",
88-
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.0.16/rules_cc-0.0.16.tar.gz"],
89-
sha256 = "bbf1ae2f83305b7053b11e4467d317a7ba3517a12cef608543c1b1c5bf48a4df",
90-
strip_prefix = "rules_cc-0.0.16",
91+
urls = ["https://github.com/bazelbuild/rules_cc/releases/download/0.1.1/rules_cc-0.1.1.tar.gz"],
92+
sha256 = "712d77868b3152dd618c4d64faaddefcc5965f90f5de6e6dd1d5ddcd0be82d42",
93+
strip_prefix = "rules_cc-0.1.1",
9194
)
9295

9396
load("@com_google_protobuf//:protobuf_deps.bzl", "protobuf_deps", "PROTOBUF_MAVEN_ARTIFACTS")
9497
# This is actually already done within grpc_deps but calling this for Bazel convention.
9598
protobuf_deps()
9699

100+
# Add rules_java to resolve the following error
101+
# `The repository '@compatibility_proxy' could not be resolved: Repository '@compatibility_proxy' is not defined`
102+
load("@rules_java//java:rules_java_deps.bzl", "rules_java_dependencies")
103+
104+
rules_java_dependencies()
105+
97106
# gRPC enforces a specific version of Go toolchain which conflicts with our build.
98107
# All the relevant parts of grpc_extra_deps() are imported in this WORKSPACE file
99108
# explicitly, that is why we do not call grpc_extra_deps() here and call

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
# If your documentation needs a minimal Sphinx version, state it here.
4242
#
43-
# needs_sphinx = '1.0'
43+
needs_sphinx = "4.5.0"
4444

4545
# Add any Sphinx extension module names here, as strings. They can be
4646
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom

gapic/ads-templates/docs/conf.py.j2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ __version__ = "0.1.0"
2828
# -- General configuration ------------------------------------------------
2929

3030
# If your documentation needs a minimal Sphinx version, state it here.
31-
needs_sphinx = "4.0.1"
31+
needs_sphinx = "4.5.0"
3232

3333
# Add any Sphinx extension module names here, as strings. They can be
3434
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom

gapic/schema/wrappers.py

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1830,13 +1830,34 @@ def ident(self) -> metadata.Address:
18301830
"""Return the identifier data to be used in templates."""
18311831
return self.meta.address
18321832

1833+
def _validate_paged_field_size_type(self, page_field_size) -> bool:
1834+
"""Validates allowed paged_field_size type(s).
1835+
1836+
Confirms whether the paged_field_size.type is an allowed wrapper type:
1837+
The norm is for type to be int, but an additional check is included to
1838+
account for BigQuery legacy APIs which allowed UInt32Value and
1839+
Int32Value.
1840+
"""
1841+
1842+
pb_type = page_field_size.type
1843+
1844+
return pb_type == int or (
1845+
isinstance(pb_type, MessageType)
1846+
and pb_type.message_pb.name in {"UInt32Value", "Int32Value"}
1847+
)
1848+
18331849
@utils.cached_property
18341850
def paged_result_field(self) -> Optional[Field]:
1835-
"""Return the response pagination field if the method is paginated."""
1836-
# If the request field lacks any of the expected pagination fields,
1837-
# then the method is not paginated.
1851+
"""Return the response pagination field if the method is paginated.
1852+
1853+
The request field must have a page_token field and a page_size field (or
1854+
for legacy APIs, a max_results field) and the response field
1855+
must have a next_token_field and a repeated field.
1856+
1857+
For the purposes of supporting legacy APIs, additional wrapper types are
1858+
allowed.
1859+
"""
18381860

1839-
# The request must have page_token and next_page_token as they keep track of pages
18401861
for source, source_type, name in (
18411862
(self.input, str, "page_token"),
18421863
(self.output, str, "next_page_token"),
@@ -1845,13 +1866,18 @@ def paged_result_field(self) -> Optional[Field]:
18451866
if not field or field.type != source_type:
18461867
return None
18471868

1848-
# The request must have max_results or page_size
1869+
# The request must have page_size (or max_results if legacy API)
18491870
page_fields = (
18501871
self.input.fields.get("max_results", None),
18511872
self.input.fields.get("page_size", None),
18521873
)
18531874
page_field_size = next((field for field in page_fields if field), None)
1854-
if not page_field_size or page_field_size.type != int:
1875+
1876+
if not page_field_size:
1877+
return None
1878+
1879+
# Confirm whether the paged_field_size is an allowed type.
1880+
if not self._validate_paged_field_size_type(page_field_size=page_field_size):
18551881
return None
18561882

18571883
# Return the first repeated field.

gapic/templates/%namespace/%name_%version/%sub/services/%service/_shared_macros.j2

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,42 @@ def _get_http_options():
264264
{% endmacro %}
265265

266266

267+
{% macro unary_request_interceptor_common(service) %}
268+
logging_enabled = CLIENT_LOGGING_SUPPORTED and _LOGGER.isEnabledFor(std_logging.DEBUG)
269+
if logging_enabled: # pragma: NO COVER
270+
request_metadata = client_call_details.metadata
271+
if isinstance(request, proto.Message):
272+
{# TODO(https://github.com/googleapis/gapic-generator-python/issues/2293): Investigate if we can improve this logic
273+
or wait for next gen protobuf.
274+
#}
275+
request_payload = type(request).to_json(request)
276+
elif isinstance(request, google.protobuf.message.Message):
277+
request_payload = MessageToJson(request)
278+
else:
279+
request_payload = f"{type(request).__name__}: {pickle.dumps(request)}"
280+
281+
request_metadata = {
282+
key: value.decode("utf-8") if isinstance(value, bytes) else value
283+
for key, value in request_metadata
284+
}
285+
grpc_request = {
286+
"payload": request_payload,
287+
"requestMethod": "grpc",
288+
"metadata": dict(request_metadata),
289+
}
290+
_LOGGER.debug(
291+
f"Sending request for {client_call_details.method}",
292+
extra = {
293+
"serviceName": "{{ service.meta.address.proto }}",
294+
"rpcName": str(client_call_details.method),
295+
"request": grpc_request,
296+
{# TODO(https://github.com/googleapis/gapic-generator-python/issues/2275): logging `metadata` seems repetitive and may need to be cleaned up. We're including it within "request" for consistency with REST transport. #}
297+
"metadata": grpc_request["metadata"],
298+
},
299+
)
300+
{%- endmacro %}
301+
302+
267303
{% macro prep_wrapped_messages_async_method(api, service) %}
268304
def _prep_wrapped_messages(self, client_info):
269305
""" Precompute the wrapped methods, overriding the base class method to use async wrappers."""

gapic/templates/%namespace/%name_%version/%sub/services/%service/async_client.py.j2

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ from google.api_core import gapic_v1
2424
from google.api_core import retry_async as retries
2525
from google.auth import credentials as ga_credentials # type: ignore
2626
from google.oauth2 import service_account # type: ignore
27+
import google.protobuf
2728

2829
{{ shared_macros.add_google_api_core_version_header_import(service.version) }}
2930
try:
@@ -726,6 +727,9 @@ class {{ service.async_client_name }}:
726727

727728
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(gapic_version=package_version.__version__)
728729

730+
if hasattr(DEFAULT_CLIENT_INFO, "protobuf_runtime_version"): # pragma: NO COVER
731+
DEFAULT_CLIENT_INFO.protobuf_runtime_version = google.protobuf.__version__
732+
729733

730734
__all__ = (
731735
"{{ service.async_client_name }}",

0 commit comments

Comments
 (0)