Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
79f3668
feat(api-core): move request-id auto-population logic to gapic_v1 pub…
hebaalazzeh Jul 16, 2026
62fbcc8
refactor(api-core): rename gapic_v1.method_helpers to gapic_v1.reques…
hebaalazzeh Jul 16, 2026
20adea6
chore: address PR review comments for gapic centralization request ID
hebaalazzeh Jul 16, 2026
f03ac7c
feat(api-core): move request-id auto-population logic to gapic_v1 pub…
hebaalazzeh Jul 16, 2026
2cc27b5
feat: delegate request-id setup to public method_helpers
hebaalazzeh Jul 16, 2026
9c2121c
refactor: use request module instead of method_helpers in gapic-gener…
hebaalazzeh Jul 16, 2026
dbc7307
refactor(api-core): rename gapic_v1.method_helpers to gapic_v1.reques…
hebaalazzeh Jul 16, 2026
5f1b721
chore: address PR review comments for gapic centralization request ID
hebaalazzeh Jul 16, 2026
99cee8e
chore: remove private _setup_request_id and call setup_request_id hel…
hebaalazzeh Jul 16, 2026
4ff1910
test(api-core): update UUID regex in test_request.py
hebaalazzeh Jul 16, 2026
77f97c8
refactor(api-core): rename request.py to requests.py for consistency
hebaalazzeh Jul 17, 2026
7fdf94e
Merge branch 'feat/gapic-centralization-api-core-request-id' into fea…
hebaalazzeh Jul 17, 2026
37ad06f
refactor(generator): update templates and goldens to use requests ins…
hebaalazzeh Jul 17, 2026
b9e2c62
fix(api-core): handle dictionary requests with None value in setup_re…
hebaalazzeh Jul 17, 2026
6bb65bc
merge branch 'feat/gapic-centralization-api-core-request-id' into fea…
hebaalazzeh Jul 17, 2026
0482ae6
fix(api-core): remove redundant request.py and test_request.py, sort …
hebaalazzeh Jul 17, 2026
31ae5ec
Merge remote-tracking branch 'origin/main' into feat/gapic-generator-…
hebaalazzeh Jul 20, 2026
2001c79
feat(generator): add _compat.py fallback for setup_request_id
hebaalazzeh Jul 20, 2026
2d1d2a5
fix(generator): add type ignore to requests import in compat template…
hebaalazzeh Jul 21, 2026
9e169f8
fix(generator): add coverage pragma comments for fallback path in com…
hebaalazzeh Jul 21, 2026
5af5222
Merge remote-tracking branch 'origin/main' into feat/gapic-generator-…
hebaalazzeh Jul 21, 2026
6ef6dd4
Merge remote-tracking branch 'origin/main' into feat/gapic-generator-…
hebaalazzeh Jul 21, 2026
61aaabb
chore(generator): update golden client.py files with setup_request_id…
hebaalazzeh Jul 21, 2026
0b2ceb2
fix(generator): add utf-8 coding header to _compat.py.j2 template
hebaalazzeh Jul 21, 2026
3204cea
chore(generator): update storagebatchoperations client.py and async_c…
hebaalazzeh Jul 21, 2026
3e6b78c
refactor(generator): optimize setup_request_id uuid creation and link…
hebaalazzeh Jul 21, 2026
1e6b56e
docs(generator): update TODO issue link to #17813 in _compat.py
hebaalazzeh Jul 21, 2026
ea8d263
chore: trigger Kokoro system tests build rerun
hebaalazzeh Jul 21, 2026
8e9f505
fix(generator): add pragma no cover to setup_request_id definition in…
hebaalazzeh Jul 21, 2026
142d337
fix(generator): add module level pragma no cover to _compat.py to pre…
hebaalazzeh Jul 21, 2026
e5f8e13
fix(generator): only generate _compat.py if API schema contains auto_…
hebaalazzeh Jul 21, 2026
905d2b1
fix(generator): fix proto-plus field check in setup_request_id fallback
hebaalazzeh Jul 21, 2026
7b7668c
fix(generator): revert goldens without auto_populated_fields and fix …
hebaalazzeh Jul 21, 2026
536a20e
fix(generator): remove encoding and pragma no cover from _compat.py h…
hebaalazzeh Jul 21, 2026
a8105ff
fix(generator): remove unused get_uuid4_re macro
hebaalazzeh Jul 21, 2026
e243bbd
fix(generator): update fallback proto-plus check to exactly match api…
hebaalazzeh Jul 21, 2026
926eb3c
fix(generator): rename requests import to request to match api-core
hebaalazzeh Jul 21, 2026
22d569d
fix(generator): fix broken diff in client.py and duplicate wrapper in…
hebaalazzeh Jul 21, 2026
c4eb2d9
test(generator): add tests for _compat.py fallback
hebaalazzeh Jul 21, 2026
ebc6bd9
fix(generator): update storagebatchoperations goldens to reflect setu…
hebaalazzeh Jul 21, 2026
eb08c77
fix(generator): add storagebatchoperations goldens missing files
hebaalazzeh Jul 21, 2026
e052b61
fix(generator): address remaining PR review comments
hebaalazzeh Jul 21, 2026
44e43ce
fix(generator): always generate _compat.py and remove downstream unit…
hebaalazzeh Jul 21, 2026
6f07478
fix(generator): use unified _compat.py.j2
hebaalazzeh Jul 21, 2026
82aa10c
fix(generator): install local google-api-core in nox test sessions
hebaalazzeh Jul 21, 2026
6eb89f7
fix(generator): address PR review comments for request-id centralizat…
hebaalazzeh Jul 22, 2026
a25e3fb
docs(templates): add explanatory comment for has_auto_populated_field…
hebaalazzeh Jul 22, 2026
9770a1e
refactor(schema): encapsulate has_auto_populated_fields on Service wr…
hebaalazzeh Jul 22, 2026
e09ddec
chore(generator): remove unnecessary session.install('-e', '../google…
hebaalazzeh Jul 22, 2026
e047593
test(schema): add unit test for Service.has_auto_populated_fields to …
hebaalazzeh Jul 22, 2026
f813e56
docs(generator): clarify lower-bound google-api-core version comment …
hebaalazzeh Jul 23, 2026
0aa48cd
docs(templates): clarify google-api-core version comment in _compat.p…
hebaalazzeh Jul 23, 2026
4f6baaa
feat(templates): generate _compat.py for all integration test goldens
hebaalazzeh Jul 23, 2026
c5218d8
fix(templates): resolve UndefinedError by moving auto_populated_field…
hebaalazzeh Jul 23, 2026
4709121
fix(templates): fix setup_request_id import module name and add pragm…
hebaalazzeh Jul 23, 2026
dbd4f5f
feat(templates): remove pragmas from _compat.py and add test_compat.p…
hebaalazzeh Jul 23, 2026
5b77291
fix(test): update test_compat template and goldens for complete branc…
hebaalazzeh Jul 23, 2026
7a22cc3
fix(coverage): add # pragma: NO COVER to compatibility fallback block…
hebaalazzeh Jul 23, 2026
f454c14
ci: add retry flags to curl commands in gapic-generator-tests workflow
hebaalazzeh Jul 23, 2026
fd17594
Merge origin/main into feat/gapic-generator-centralization-request-id
hebaalazzeh Jul 23, 2026
7fbb8f8
fix(compat): add type annotations and ignores to _compat template and…
hebaalazzeh Jul 23, 2026
022f2ad
fix(coverage): add test cases for _pb proto-plus requests in google-a…
hebaalazzeh Jul 23, 2026
0dc81e3
fix(generator): add --no-deps when installing local google-api-core i…
hebaalazzeh Jul 23, 2026
4a279f2
fix(generator): type annotate self._client_options and update workflo…
hebaalazzeh Jul 23, 2026
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
33 changes: 16 additions & 17 deletions .github/workflows/gapic-generator-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@
outputs:
run_generator: ${{ steps.filter.outputs.generator }}
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

Check warning on line 34 in .github/workflows/gapic-generator-tests.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

ref-version-mismatch

gapic-generator-tests.yml:34: action's hash pin has mismatched or missing version comment: points to commit 11d5960a3267
with:
persist-credentials: false
- uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4
- uses: dorny/paths-filter@d1c1ffe0248fe513906c8e24db8ea791d46f8590 # v3
id: filter
with:
filters: |
Expand Down Expand Up @@ -65,11 +65,11 @@
logging_scope: ["", "google"]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

Check warning on line 68 in .github/workflows/gapic-generator-tests.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

ref-version-mismatch

gapic-generator-tests.yml:68: action's hash pin has mismatched or missing version comment: points to commit 11d5960a3267
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "${{ matrix.python }}"
allow-prereleases: true
Expand All @@ -82,7 +82,7 @@
run: |
sudo apt-get update && sudo apt-get install -y curl pandoc unzip
sudo mkdir -p /usr/src/protoc/ && sudo chown -R ${USER} /usr/src/
curl --location https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip --output /usr/src/protoc/protoc.zip
curl --fail --silent --show-error --location --retry 5 --retry-delay 5 --retry-connrefused https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip --output /usr/src/protoc/protoc.zip
cd /usr/src/protoc/ && unzip protoc.zip
sudo ln -s /usr/src/protoc/bin/protoc /usr/local/bin/protoc
- name: Run Nox
Expand All @@ -98,11 +98,11 @@
needs: python_config
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

Check warning on line 101 in .github/workflows/gapic-generator-tests.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

ref-version-mismatch

gapic-generator-tests.yml:101: action's hash pin has mismatched or missing version comment: points to commit 11d5960a3267
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: ${{ needs.python_config.outputs.latest_stable_python }}
- name: Install System Deps
Expand All @@ -117,11 +117,11 @@
needs: python_config
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

Check warning on line 120 in .github/workflows/gapic-generator-tests.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

ref-version-mismatch

gapic-generator-tests.yml:120: action's hash pin has mismatched or missing version comment: points to commit 11d5960a3267
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: ${{ needs.python_config.outputs.latest_stable_python }}
- name: Install System Deps
Expand Down Expand Up @@ -151,11 +151,11 @@
needs: python_config
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

Check warning on line 154 in .github/workflows/gapic-generator-tests.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

ref-version-mismatch

gapic-generator-tests.yml:154: action's hash pin has mismatched or missing version comment: points to commit 11d5960a3267
with:
persist-credentials: false
- name: Set up Python ${{ needs.python_config.outputs.prerelease_python }}
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: ${{ needs.python_config.outputs.prerelease_python }}
allow-prereleases: true
Expand All @@ -181,11 +181,11 @@
python: ${{ fromJSON(needs.python_config.outputs.trimmed_python) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

Check warning on line 184 in .github/workflows/gapic-generator-tests.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

ref-version-mismatch

gapic-generator-tests.yml:184: action's hash pin has mismatched or missing version comment: points to commit 11d5960a3267
with:
persist-credentials: false
- name: Set up Python
uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: ${{ matrix.python }}
allow-prereleases: true
Expand All @@ -198,7 +198,7 @@
run: |
sudo apt-get update && sudo apt-get install -y curl pandoc unzip
sudo mkdir -p /usr/src/protoc/ && sudo chown -R ${USER} /usr/src/
curl --location https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip --output /usr/src/protoc/protoc.zip
curl --fail --silent --show-error --location --retry 5 --retry-delay 5 --retry-connrefused https://github.com/google/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-linux-x86_64.zip --output /usr/src/protoc/protoc.zip
cd /usr/src/protoc/ && unzip protoc.zip
sudo ln -s /usr/src/protoc/bin/protoc /usr/local/bin/protoc
- name: Run Tests
Expand All @@ -221,12 +221,12 @@
runs-on: ubuntu-latest
container: gcr.io/gapic-images/googleapis # zizmor: ignore[unpinned-images]
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4

Check warning on line 224 in .github/workflows/gapic-generator-tests.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

ref-version-mismatch

gapic-generator-tests.yml:224: action's hash pin has mismatched or missing version comment: points to commit 11d5960a3267
with:
persist-credentials: false
- name: Cache Bazel files
id: cache-bazel
uses: actions/cache@caa296126883cff596d87d8935842f9db880ef25 # v5
uses: actions/cache@d4323d455f4799aea6383e50059345091701625f # v4

Check warning on line 229 in .github/workflows/gapic-generator-tests.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

ref-version-mismatch

gapic-generator-tests.yml:229: action's hash pin has mismatched or missing version comment: points to commit 0057852bfaa8

Check failure on line 229 in .github/workflows/gapic-generator-tests.yml

View workflow job for this annotation

GitHub Actions / zizmor-output

impostor-commit

gapic-generator-tests.yml:229: commit with no history in referenced repository: uses a commit that doesn't belong to the specified org/repo
with:
path: ~/.cache/bazel
# Ensure CACHE_VERSION is defined in the mono-repo secrets!
Expand Down Expand Up @@ -261,4 +261,3 @@
exit 1
fi
echo "All checks passed or were successfully skipped."

10 changes: 8 additions & 2 deletions packages/gapic-generator/gapic/generator/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@
from google.protobuf.compiler.plugin_pb2 import CodeGeneratorResponse


ALLOWED_PRIVATE_TEMPLATES = (
"__init__.py.j2",
"_compat.py.j2",
)


class Generator:
"""A protoc code generator for client libraries.

Expand Down Expand Up @@ -118,9 +124,9 @@ def get_response(self, api_schema: api.API, opts: Options) -> CodeGeneratorRespo
# and instead of iterating over it/them, we iterate over samples
# and plug those into the template.
for template_name in client_templates:
# Quick check: Skip "private" templates.
# Quick check: Skip "private" templates except explicitly allowed ones.
filename = template_name.split("/")[-1]
if filename.startswith("_") and filename != "__init__.py.j2":
if filename.startswith("_") and filename not in ALLOWED_PRIVATE_TEMPLATES:
continue

# Append to the output files dictionary.
Expand Down
Loading
Loading