Skip to content

Commit eb08c77

Browse files
committed
fix(generator): add storagebatchoperations goldens missing files
1 parent ebc6bd9 commit eb08c77

3 files changed

Lines changed: 56 additions & 6 deletions

File tree

  • packages/gapic-generator/tests/integration/goldens/storagebatchoperations/google/cloud/storagebatchoperations_v1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2026 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
17+
import uuid
18+
19+
try:
20+
from google.api_core.gapic_v1.request import setup_request_id # type: ignore
21+
except ImportError:
22+
def setup_request_id(request, field_name: str, is_proto3_optional: bool):
23+
"""Populate a UUID4 field in the request if it is not already set.
24+
25+
Args:
26+
request (Union[google.protobuf.message.Message, dict]): The request object.
27+
field_name (str): The name of the field to populate.
28+
is_proto3_optional (bool): Whether the field is proto3 optional.
29+
"""
30+
if request is None:
31+
return
32+
33+
request_id_val = str(uuid.uuid4())
34+
35+
if isinstance(request, dict):
36+
if is_proto3_optional:
37+
if field_name not in request or request[field_name] is None:
38+
request[field_name] = request_id_val
39+
elif not request.get(field_name):
40+
request[field_name] = request_id_val
41+
return
42+
43+
if is_proto3_optional:
44+
try:
45+
# Pure protobuf messages
46+
if not request.HasField(field_name):
47+
setattr(request, field_name, request_id_val)
48+
except (AttributeError, ValueError):
49+
# Proto-plus messages or other objects
50+
if not getattr(request, field_name, None):
51+
setattr(request, field_name, request_id_val)
52+
else:
53+
if not getattr(request, field_name, None):
54+
setattr(request, field_name, request_id_val)

packages/gapic-generator/tests/integration/goldens/storagebatchoperations/google/cloud/storagebatchoperations_v1/services/storage_batch_operations/async_client.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from typing import Dict, Callable, Mapping, MutableMapping, MutableSequence, Optional, Sequence, Tuple, Type, Union
2020
from google.cloud.storagebatchoperations_v1 import gapic_version as package_version
2121

22+
from google.cloud.storagebatchoperations_v1._compat import setup_request_id
2223
from google.api_core.client_options import ClientOptions
2324
from google.api_core import exceptions as core_exceptions
2425
from google.api_core import gapic_v1

packages/gapic-generator/tests/integration/goldens/storagebatchoperations/google/cloud/storagebatchoperations_v1/services/storage_batch_operations/client.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,7 @@ def _validate_universe_domain(self):
472472
# NOTE (b/349488459): universe validation is disabled until further notice.
473473
return True
474474

475-
Args:
476-
request (Union[google.protobuf.message.Message, dict]): The request object.
477-
field_name (str): The name of the field to populate.
478-
is_proto3_optional (bool): Whether the field is proto3 optional.
479-
"""
480-
setup_request_id(request, field_name, is_proto3_optional)
475+
481476

482477
def _add_cred_info_for_auth_errors(
483478
self,

0 commit comments

Comments
 (0)