Skip to content

Commit f31b49d

Browse files
speedstorm1copybara-github
authored andcommitted
chore: internal change to autogenerate list methods in Python, Java, and Go SDKs
FUTURE_COPYBARA_INTEGRATE_REVIEW=#1727 from googleapis:release-please--branches--main a129caf PiperOrigin-RevId: 835385775
1 parent 4b5720a commit f31b49d

File tree

7 files changed

+259
-257
lines changed

7 files changed

+259
-257
lines changed

google/genai/batches.py

Lines changed: 55 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -1902,6 +1902,34 @@ def delete(
19021902
self._api_client._verify_response(return_value)
19031903
return return_value
19041904

1905+
def list(
1906+
self, *, config: Optional[types.ListBatchJobsConfigOrDict] = None
1907+
) -> Pager[types.BatchJob]:
1908+
"""Lists batch jobs.
1909+
1910+
Args:
1911+
config (ListBatchJobsConfig): Optional configuration for the list request.
1912+
1913+
Returns:
1914+
A Pager object that contains one page of batch jobs. When iterating over
1915+
the pager, it automatically fetches the next page if there are more.
1916+
1917+
Usage:
1918+
1919+
.. code-block:: python
1920+
config = {'page_size': 10}
1921+
for batch_job in client.batches.list(config):
1922+
print(batch_job.name)
1923+
"""
1924+
1925+
list_request = self._list
1926+
return Pager(
1927+
'batch_jobs',
1928+
list_request,
1929+
self._list(config=config),
1930+
config,
1931+
)
1932+
19051933
def create(
19061934
self,
19071935
*,
@@ -1997,35 +2025,6 @@ def create_embeddings(
19972025
else:
19982026
return self._create_embeddings(model=model, src=src, config=config)
19992027

2000-
def list(
2001-
self, *, config: Optional[types.ListBatchJobsConfigOrDict] = None
2002-
) -> Pager[types.BatchJob]:
2003-
"""Lists batch jobs.
2004-
2005-
Args:
2006-
config (ListBatchJobsConfig): Optional configuration for the list request.
2007-
2008-
Returns:
2009-
A Pager object that contains one page of batch jobs. When iterating over
2010-
the pager, it automatically fetches the next page if there are more.
2011-
2012-
Usage:
2013-
2014-
.. code-block:: python
2015-
2016-
batch_jobs = client.batches.list(config={"page_size": 10})
2017-
for batch_job in batch_jobs:
2018-
print(f"Batch job: {batch_job.name}, state {batch_job.state}")
2019-
"""
2020-
if config is None:
2021-
config = types.ListBatchJobsConfig()
2022-
return Pager(
2023-
'batch_jobs',
2024-
self._list,
2025-
self._list(config=config),
2026-
config,
2027-
)
2028-
20292028

20302029
class AsyncBatches(_api_module.BaseModule):
20312030

@@ -2452,6 +2451,33 @@ async def delete(
24522451
self._api_client._verify_response(return_value)
24532452
return return_value
24542453

2454+
async def list(
2455+
self, *, config: Optional[types.ListBatchJobsConfigOrDict] = None
2456+
) -> AsyncPager[types.BatchJob]:
2457+
"""Lists batch jobs asynchronously.
2458+
2459+
Args:
2460+
config (ListBatchJobsConfig): Optional configuration for the list request.
2461+
2462+
Returns:
2463+
A Pager object that contains one page of batch jobs. When iterating over
2464+
the pager, it automatically fetches the next page if there are more.
2465+
2466+
Usage:
2467+
2468+
.. code-block:: python
2469+
async for batch_job in await client.aio.batches.list():
2470+
print(batch_job.name)
2471+
"""
2472+
2473+
list_request = self._list
2474+
return AsyncPager(
2475+
'batch_jobs',
2476+
list_request,
2477+
await self._list(config=config),
2478+
config,
2479+
)
2480+
24552481
async def create(
24562482
self,
24572483
*,
@@ -2552,33 +2578,3 @@ async def create_embeddings(
25522578
raise ValueError('Vertex AI does not support batches.create_embeddings.')
25532579
else:
25542580
return await self._create_embeddings(model=model, src=src, config=config)
2555-
2556-
async def list(
2557-
self, *, config: Optional[types.ListBatchJobsConfigOrDict] = None
2558-
) -> AsyncPager[types.BatchJob]:
2559-
"""Lists batch jobs asynchronously.
2560-
2561-
Args:
2562-
config (ListBatchJobsConfig): Optional configuration for the list request.
2563-
2564-
Returns:
2565-
A Pager object that contains one page of batch jobs. When iterating over
2566-
the pager, it automatically fetches the next page if there are more.
2567-
2568-
Usage:
2569-
2570-
.. code-block:: python
2571-
2572-
batch_jobs = await client.aio.batches.list(config={'page_size': 5})
2573-
print(f"current page: {batch_jobs.page}")
2574-
await batch_jobs_pager.next_page()
2575-
print(f"next page: {batch_jobs_pager.page}")
2576-
"""
2577-
if config is None:
2578-
config = types.ListBatchJobsConfig()
2579-
return AsyncPager(
2580-
'batch_jobs',
2581-
self._list,
2582-
await self._list(config=config),
2583-
config,
2584-
)

google/genai/caches.py

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,15 +1129,6 @@ def update(
11291129
def _list(
11301130
self, *, config: Optional[types.ListCachedContentsConfigOrDict] = None
11311131
) -> types.ListCachedContentsResponse:
1132-
"""Lists cached content configurations.
1133-
1134-
.. code-block:: python
1135-
1136-
cached_contents = client.caches.list(config={'page_size': 2})
1137-
for cached_content in cached_contents:
1138-
print(cached_content)
1139-
"""
1140-
11411132
parameter_model = types._ListCachedContentsParameters(
11421133
config=config,
11431134
)
@@ -1196,9 +1187,28 @@ def _list(
11961187
def list(
11971188
self, *, config: Optional[types.ListCachedContentsConfigOrDict] = None
11981189
) -> Pager[types.CachedContent]:
1190+
"""Lists cached contents.
1191+
1192+
Args:
1193+
config (ListCachedContentsConfig): Optional configuration for the list
1194+
request.
1195+
1196+
Returns:
1197+
A Pager object that contains one page of cached contents. When iterating
1198+
over
1199+
the pager, it automatically fetches the next page if there are more.
1200+
1201+
Usage:
1202+
1203+
.. code-block:: python
1204+
for cached_content in client.caches.list():
1205+
print(cached_content.name)
1206+
"""
1207+
1208+
list_request = self._list
11991209
return Pager(
12001210
'cached_contents',
1201-
self._list,
1211+
list_request,
12021212
self._list(config=config),
12031213
config,
12041214
)
@@ -1505,15 +1515,6 @@ async def update(
15051515
async def _list(
15061516
self, *, config: Optional[types.ListCachedContentsConfigOrDict] = None
15071517
) -> types.ListCachedContentsResponse:
1508-
"""Lists cached content configurations.
1509-
1510-
.. code-block:: python
1511-
1512-
cached_contents = await client.aio.caches.list(config={'page_size': 2})
1513-
async for cached_content in cached_contents:
1514-
print(cached_content)
1515-
"""
1516-
15171518
parameter_model = types._ListCachedContentsParameters(
15181519
config=config,
15191520
)
@@ -1574,9 +1575,28 @@ async def _list(
15741575
async def list(
15751576
self, *, config: Optional[types.ListCachedContentsConfigOrDict] = None
15761577
) -> AsyncPager[types.CachedContent]:
1578+
"""Lists cached contents asynchronously.
1579+
1580+
Args:
1581+
config (ListCachedContentsConfig): Optional configuration for the list
1582+
request.
1583+
1584+
Returns:
1585+
A Pager object that contains one page of cached contents. When iterating
1586+
over
1587+
the pager, it automatically fetches the next page if there are more.
1588+
1589+
Usage:
1590+
1591+
.. code-block:: python
1592+
async for cached_content in await client.aio.caches.list():
1593+
print(cached_content.name)
1594+
"""
1595+
1596+
list_request = self._list
15771597
return AsyncPager(
15781598
'cached_contents',
1579-
self._list,
1599+
list_request,
15801600
await self._list(config=config),
15811601
config,
15821602
)

google/genai/documents.py

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -249,17 +249,6 @@ def _list(
249249
parent: str,
250250
config: Optional[types.ListDocumentsConfigOrDict] = None,
251251
) -> types.ListDocumentsResponse:
252-
"""Lists all Documents in a FileSearchStore.
253-
254-
Args:
255-
parent (str): The name of the FileSearchStore containing the Documents.
256-
config (ListDocumentsConfig | None): Optional parameters for the request,
257-
such as page_size.
258-
259-
Returns:
260-
ListDocumentsResponse: A paginated list of Documents.
261-
"""
262-
263252
parameter_model = types._ListDocumentsParameters(
264253
parent=parent,
265254
config=config,
@@ -328,6 +317,7 @@ def list(
328317
for document in client.documents.list(parent='rag_store_name'):
329318
print(f"document: {document.name} - {document.display_name}")
330319
"""
320+
331321
list_request = partial(self._list, parent=parent)
332322
return Pager(
333323
'documents',
@@ -461,17 +451,6 @@ async def _list(
461451
parent: str,
462452
config: Optional[types.ListDocumentsConfigOrDict] = None,
463453
) -> types.ListDocumentsResponse:
464-
"""Lists all Documents in a FileSearchStore.
465-
466-
Args:
467-
parent (str): The name of the FileSearchStore containing the Documents.
468-
config (ListDocumentsConfig | None): Optional parameters for the request,
469-
such as page_size.
470-
471-
Returns:
472-
ListDocumentsResponse: A paginated list of Documents.
473-
"""
474-
475454
parameter_model = types._ListDocumentsParameters(
476455
parent=parent,
477456
config=config,
@@ -540,9 +519,10 @@ async def list(
540519
Usage:
541520
.. code-block:: python
542521
async for document in await
543-
client.documents.list(parent='rag_store_name'):
522+
client.aio.documents.list(parent='rag_store_name'):
544523
print(f"document: {document.name} - {document.display_name}")
545524
"""
525+
546526
list_request = partial(self._list, parent=parent)
547527
return AsyncPager(
548528
'documents',

0 commit comments

Comments
 (0)