@@ -1836,7 +1836,8 @@ def paged_result_field(self) -> Optional[Field]:
18361836 # If the request field lacks any of the expected pagination fields,
18371837 # then the method is not paginated.
18381838
1839- # The request must have page_token and next_page_token as they keep track of pages
1839+ # The request must have page_token and response must have next_page_token fields
1840+ # because those fields keep track of pagination progress.
18401841 for source , source_type , name in (
18411842 (self .input , str , "page_token" ),
18421843 (self .output , str , "next_page_token" ),
@@ -1851,7 +1852,24 @@ def paged_result_field(self) -> Optional[Field]:
18511852 self .input .fields .get ("page_size" , None ),
18521853 )
18531854 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 :
1855+ if not page_field_size :
1856+ return None
1857+
1858+ # The datatype for page_size/max_results must be one of the following:
1859+ # int (page_size) or UInt32Value, Int32Value (max_results)
1860+ if page_field_size .type == int or (
1861+ # The following additional checks are for several members of the BQ family of
1862+ # APIs, which use legacy wrapper types: "UInt32Value" and "Int32Value"}
1863+ # for max_results.
1864+ # NOTE:
1865+ # bigquery_v2 should be paginated
1866+ # but bigquery_connection_v1beta1 should NOT be paginated
1867+ isinstance (page_field_size .type , MessageType )
1868+ and page_field_size .type .message_pb .name in {"UInt32Value" , "Int32Value" }
1869+ and self .input .message_pb .name not in {"ListConnectionsRequest" }
1870+ ):
1871+ pass
1872+ else :
18551873 return None
18561874
18571875 # Return the first repeated field.
0 commit comments