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

Commit 34b6490

Browse files
committed
Updates with validate function
1 parent 2caa968 commit 34b6490

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

gapic/schema/wrappers.py

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1495,8 +1495,6 @@ class Method:
14951495
default_factory=metadata.Metadata,
14961496
)
14971497

1498-
PACKAGES_WITH_ALLOWED_WRAPPERS = {"google.cloud.bigquery.v2"}
1499-
15001498
def __getattr__(self, name):
15011499
return getattr(self.method_pb, name)
15021500

@@ -1832,6 +1830,21 @@ def ident(self) -> metadata.Address:
18321830
"""Return the identifier data to be used in templates."""
18331831
return self.meta.address
18341832

1833+
def _validate_paged_field_size_type(value):
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+
if page_field_size.type == int or (
1843+
isinstance(value.type, MessageType)
1844+
and value.type.message_pb.name in {"UInt32Value", "Int32Value"}
1845+
):
1846+
return True
1847+
18351848
@utils.cached_property
18361849
def paged_result_field(self) -> Optional[Field]:
18371850
"""Return the response pagination field if the method is paginated.
@@ -1861,23 +1874,8 @@ def paged_result_field(self) -> Optional[Field]:
18611874
if not page_field_size:
18621875
return None
18631876

1864-
# If the a legacy API uses the UInt32Value and Int32Value wrappers,
1865-
# the service package must be in the allowlist.
1866-
package_name = self.input.meta.address.proto_package
1867-
1868-
if page_field_size.type == int or (
1869-
# The following additional checks are related to several members of the BQ family of
1870-
# APIs, which use the legacy wrapper types: "UInt32Value" and "Int32Value"}
1871-
# for max_results.
1872-
# NOTE:
1873-
# bigquery_v2 should be paginated
1874-
# but bigquery_connection_v1beta1 should NOT be paginated
1875-
isinstance(page_field_size.type, MessageType)
1876-
and page_field_size.type.message_pb.name in {"UInt32Value", "Int32Value"}
1877-
and package_name in self.PACKAGES_WITH_ALLOWED_WRAPPERS
1878-
):
1879-
pass
1880-
else:
1877+
# Confirm whether the paged_field_size is an allowed type.
1878+
if not _validate_paged_field_size_type(value):
18811879
return None
18821880

18831881
# Return the first repeated field.

0 commit comments

Comments
 (0)