google-genai 1.7.0__py3-none-any.whl → 1.53.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. google/genai/__init__.py +4 -2
  2. google/genai/_adapters.py +55 -0
  3. google/genai/_api_client.py +1301 -299
  4. google/genai/_api_module.py +1 -1
  5. google/genai/_automatic_function_calling_util.py +54 -33
  6. google/genai/_base_transformers.py +26 -0
  7. google/genai/_base_url.py +50 -0
  8. google/genai/_common.py +560 -59
  9. google/genai/_extra_utils.py +371 -38
  10. google/genai/_live_converters.py +1467 -0
  11. google/genai/_local_tokenizer_loader.py +214 -0
  12. google/genai/_mcp_utils.py +117 -0
  13. google/genai/_operations_converters.py +394 -0
  14. google/genai/_replay_api_client.py +204 -92
  15. google/genai/_test_api_client.py +1 -1
  16. google/genai/_tokens_converters.py +520 -0
  17. google/genai/_transformers.py +633 -233
  18. google/genai/batches.py +1733 -538
  19. google/genai/caches.py +678 -1012
  20. google/genai/chats.py +48 -38
  21. google/genai/client.py +142 -15
  22. google/genai/documents.py +532 -0
  23. google/genai/errors.py +141 -35
  24. google/genai/file_search_stores.py +1296 -0
  25. google/genai/files.py +312 -744
  26. google/genai/live.py +617 -367
  27. google/genai/live_music.py +197 -0
  28. google/genai/local_tokenizer.py +395 -0
  29. google/genai/models.py +3598 -3116
  30. google/genai/operations.py +201 -362
  31. google/genai/pagers.py +23 -7
  32. google/genai/py.typed +1 -0
  33. google/genai/tokens.py +362 -0
  34. google/genai/tunings.py +1274 -496
  35. google/genai/types.py +14535 -5454
  36. google/genai/version.py +2 -2
  37. {google_genai-1.7.0.dist-info → google_genai-1.53.0.dist-info}/METADATA +736 -234
  38. google_genai-1.53.0.dist-info/RECORD +41 -0
  39. {google_genai-1.7.0.dist-info → google_genai-1.53.0.dist-info}/WHEEL +1 -1
  40. google_genai-1.7.0.dist-info/RECORD +0 -27
  41. {google_genai-1.7.0.dist-info → google_genai-1.53.0.dist-info/licenses}/LICENSE +0 -0
  42. {google_genai-1.7.0.dist-info → google_genai-1.53.0.dist-info}/top_level.txt +0 -0
google/genai/caches.py CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2024 Google LLC
1
+ # Copyright 2025 Google LLC
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -15,9 +15,11 @@
15
15
 
16
16
  # Code generated by the Google Gen AI SDK generator DO NOT EDIT.
17
17
 
18
+ import json
18
19
  import logging
19
20
  from typing import Any, Optional, Union
20
21
  from urllib.parse import urlencode
22
+
21
23
  from . import _api_module
22
24
  from . import _common
23
25
  from . import _transformers as t
@@ -25,620 +27,54 @@ from . import types
25
27
  from ._api_client import BaseApiClient
26
28
  from ._common import get_value_by_path as getv
27
29
  from ._common import set_value_by_path as setv
28
- from .pagers import AsyncPager, Pager
29
-
30
- logger = logging.getLogger('google_genai.caches')
31
-
32
-
33
- def _Part_to_mldev(
34
- api_client: BaseApiClient,
35
- from_object: Union[dict, object],
36
- parent_object: Optional[dict] = None,
37
- ) -> dict:
38
- to_object: dict[str, Any] = {}
39
- if getv(from_object, ['video_metadata']) is not None:
40
- raise ValueError('video_metadata parameter is not supported in Gemini API.')
41
-
42
- if getv(from_object, ['thought']) is not None:
43
- setv(to_object, ['thought'], getv(from_object, ['thought']))
44
-
45
- if getv(from_object, ['code_execution_result']) is not None:
46
- setv(
47
- to_object,
48
- ['codeExecutionResult'],
49
- getv(from_object, ['code_execution_result']),
50
- )
51
-
52
- if getv(from_object, ['executable_code']) is not None:
53
- setv(to_object, ['executableCode'], getv(from_object, ['executable_code']))
54
-
55
- if getv(from_object, ['file_data']) is not None:
56
- setv(to_object, ['fileData'], getv(from_object, ['file_data']))
57
-
58
- if getv(from_object, ['function_call']) is not None:
59
- setv(to_object, ['functionCall'], getv(from_object, ['function_call']))
60
-
61
- if getv(from_object, ['function_response']) is not None:
62
- setv(
63
- to_object,
64
- ['functionResponse'],
65
- getv(from_object, ['function_response']),
66
- )
67
-
68
- if getv(from_object, ['inline_data']) is not None:
69
- setv(to_object, ['inlineData'], getv(from_object, ['inline_data']))
70
-
71
- if getv(from_object, ['text']) is not None:
72
- setv(to_object, ['text'], getv(from_object, ['text']))
73
-
74
- return to_object
75
-
76
-
77
- def _Part_to_vertex(
78
- api_client: BaseApiClient,
79
- from_object: Union[dict, object],
80
- parent_object: Optional[dict] = None,
81
- ) -> dict:
82
- to_object: dict[str, Any] = {}
83
- if getv(from_object, ['video_metadata']) is not None:
84
- setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata']))
85
-
86
- if getv(from_object, ['thought']) is not None:
87
- setv(to_object, ['thought'], getv(from_object, ['thought']))
88
-
89
- if getv(from_object, ['code_execution_result']) is not None:
90
- setv(
91
- to_object,
92
- ['codeExecutionResult'],
93
- getv(from_object, ['code_execution_result']),
94
- )
95
-
96
- if getv(from_object, ['executable_code']) is not None:
97
- setv(to_object, ['executableCode'], getv(from_object, ['executable_code']))
98
-
99
- if getv(from_object, ['file_data']) is not None:
100
- setv(to_object, ['fileData'], getv(from_object, ['file_data']))
101
-
102
- if getv(from_object, ['function_call']) is not None:
103
- setv(to_object, ['functionCall'], getv(from_object, ['function_call']))
104
-
105
- if getv(from_object, ['function_response']) is not None:
106
- setv(
107
- to_object,
108
- ['functionResponse'],
109
- getv(from_object, ['function_response']),
110
- )
111
-
112
- if getv(from_object, ['inline_data']) is not None:
113
- setv(to_object, ['inlineData'], getv(from_object, ['inline_data']))
114
-
115
- if getv(from_object, ['text']) is not None:
116
- setv(to_object, ['text'], getv(from_object, ['text']))
117
-
118
- return to_object
119
-
120
-
121
- def _Content_to_mldev(
122
- api_client: BaseApiClient,
123
- from_object: Union[dict, object],
124
- parent_object: Optional[dict] = None,
125
- ) -> dict:
126
- to_object: dict[str, Any] = {}
127
- if getv(from_object, ['parts']) is not None:
128
- setv(
129
- to_object,
130
- ['parts'],
131
- [
132
- _Part_to_mldev(api_client, item, to_object)
133
- for item in getv(from_object, ['parts'])
134
- ],
135
- )
136
-
137
- if getv(from_object, ['role']) is not None:
138
- setv(to_object, ['role'], getv(from_object, ['role']))
139
-
140
- return to_object
141
-
142
-
143
- def _Content_to_vertex(
144
- api_client: BaseApiClient,
145
- from_object: Union[dict, object],
146
- parent_object: Optional[dict] = None,
147
- ) -> dict:
148
- to_object: dict[str, Any] = {}
149
- if getv(from_object, ['parts']) is not None:
150
- setv(
151
- to_object,
152
- ['parts'],
153
- [
154
- _Part_to_vertex(api_client, item, to_object)
155
- for item in getv(from_object, ['parts'])
156
- ],
157
- )
158
-
159
- if getv(from_object, ['role']) is not None:
160
- setv(to_object, ['role'], getv(from_object, ['role']))
161
-
162
- return to_object
163
-
164
-
165
- def _Schema_to_mldev(
166
- api_client: BaseApiClient,
167
- from_object: Union[dict, object],
168
- parent_object: Optional[dict] = None,
169
- ) -> dict:
170
- to_object: dict[str, Any] = {}
171
- if getv(from_object, ['example']) is not None:
172
- raise ValueError('example parameter is not supported in Gemini API.')
173
-
174
- if getv(from_object, ['pattern']) is not None:
175
- raise ValueError('pattern parameter is not supported in Gemini API.')
176
-
177
- if getv(from_object, ['default']) is not None:
178
- raise ValueError('default parameter is not supported in Gemini API.')
179
-
180
- if getv(from_object, ['max_length']) is not None:
181
- raise ValueError('max_length parameter is not supported in Gemini API.')
182
-
183
- if getv(from_object, ['title']) is not None:
184
- raise ValueError('title parameter is not supported in Gemini API.')
185
-
186
- if getv(from_object, ['min_length']) is not None:
187
- raise ValueError('min_length parameter is not supported in Gemini API.')
188
-
189
- if getv(from_object, ['min_properties']) is not None:
190
- raise ValueError('min_properties parameter is not supported in Gemini API.')
191
-
192
- if getv(from_object, ['max_properties']) is not None:
193
- raise ValueError('max_properties parameter is not supported in Gemini API.')
194
-
195
- if getv(from_object, ['any_of']) is not None:
196
- setv(to_object, ['anyOf'], getv(from_object, ['any_of']))
197
-
198
- if getv(from_object, ['description']) is not None:
199
- setv(to_object, ['description'], getv(from_object, ['description']))
200
-
201
- if getv(from_object, ['enum']) is not None:
202
- setv(to_object, ['enum'], getv(from_object, ['enum']))
203
-
204
- if getv(from_object, ['format']) is not None:
205
- setv(to_object, ['format'], getv(from_object, ['format']))
206
-
207
- if getv(from_object, ['items']) is not None:
208
- setv(to_object, ['items'], getv(from_object, ['items']))
209
-
210
- if getv(from_object, ['max_items']) is not None:
211
- setv(to_object, ['maxItems'], getv(from_object, ['max_items']))
212
-
213
- if getv(from_object, ['maximum']) is not None:
214
- setv(to_object, ['maximum'], getv(from_object, ['maximum']))
215
-
216
- if getv(from_object, ['min_items']) is not None:
217
- setv(to_object, ['minItems'], getv(from_object, ['min_items']))
218
-
219
- if getv(from_object, ['minimum']) is not None:
220
- setv(to_object, ['minimum'], getv(from_object, ['minimum']))
221
-
222
- if getv(from_object, ['nullable']) is not None:
223
- setv(to_object, ['nullable'], getv(from_object, ['nullable']))
224
-
225
- if getv(from_object, ['properties']) is not None:
226
- setv(to_object, ['properties'], getv(from_object, ['properties']))
227
-
228
- if getv(from_object, ['property_ordering']) is not None:
229
- setv(
230
- to_object,
231
- ['propertyOrdering'],
232
- getv(from_object, ['property_ordering']),
233
- )
234
-
235
- if getv(from_object, ['required']) is not None:
236
- setv(to_object, ['required'], getv(from_object, ['required']))
237
-
238
- if getv(from_object, ['type']) is not None:
239
- setv(to_object, ['type'], getv(from_object, ['type']))
240
-
241
- return to_object
242
-
243
-
244
- def _Schema_to_vertex(
245
- api_client: BaseApiClient,
246
- from_object: Union[dict, object],
247
- parent_object: Optional[dict] = None,
248
- ) -> dict:
249
- to_object: dict[str, Any] = {}
250
- if getv(from_object, ['example']) is not None:
251
- setv(to_object, ['example'], getv(from_object, ['example']))
252
-
253
- if getv(from_object, ['pattern']) is not None:
254
- setv(to_object, ['pattern'], getv(from_object, ['pattern']))
255
-
256
- if getv(from_object, ['default']) is not None:
257
- setv(to_object, ['default'], getv(from_object, ['default']))
258
-
259
- if getv(from_object, ['max_length']) is not None:
260
- setv(to_object, ['maxLength'], getv(from_object, ['max_length']))
261
-
262
- if getv(from_object, ['title']) is not None:
263
- setv(to_object, ['title'], getv(from_object, ['title']))
264
-
265
- if getv(from_object, ['min_length']) is not None:
266
- setv(to_object, ['minLength'], getv(from_object, ['min_length']))
267
-
268
- if getv(from_object, ['min_properties']) is not None:
269
- setv(to_object, ['minProperties'], getv(from_object, ['min_properties']))
270
-
271
- if getv(from_object, ['max_properties']) is not None:
272
- setv(to_object, ['maxProperties'], getv(from_object, ['max_properties']))
273
-
274
- if getv(from_object, ['any_of']) is not None:
275
- setv(to_object, ['anyOf'], getv(from_object, ['any_of']))
276
-
277
- if getv(from_object, ['description']) is not None:
278
- setv(to_object, ['description'], getv(from_object, ['description']))
279
-
280
- if getv(from_object, ['enum']) is not None:
281
- setv(to_object, ['enum'], getv(from_object, ['enum']))
282
-
283
- if getv(from_object, ['format']) is not None:
284
- setv(to_object, ['format'], getv(from_object, ['format']))
285
-
286
- if getv(from_object, ['items']) is not None:
287
- setv(to_object, ['items'], getv(from_object, ['items']))
288
-
289
- if getv(from_object, ['max_items']) is not None:
290
- setv(to_object, ['maxItems'], getv(from_object, ['max_items']))
291
-
292
- if getv(from_object, ['maximum']) is not None:
293
- setv(to_object, ['maximum'], getv(from_object, ['maximum']))
294
-
295
- if getv(from_object, ['min_items']) is not None:
296
- setv(to_object, ['minItems'], getv(from_object, ['min_items']))
297
-
298
- if getv(from_object, ['minimum']) is not None:
299
- setv(to_object, ['minimum'], getv(from_object, ['minimum']))
300
-
301
- if getv(from_object, ['nullable']) is not None:
302
- setv(to_object, ['nullable'], getv(from_object, ['nullable']))
303
-
304
- if getv(from_object, ['properties']) is not None:
305
- setv(to_object, ['properties'], getv(from_object, ['properties']))
306
-
307
- if getv(from_object, ['property_ordering']) is not None:
308
- setv(
309
- to_object,
310
- ['propertyOrdering'],
311
- getv(from_object, ['property_ordering']),
312
- )
313
-
314
- if getv(from_object, ['required']) is not None:
315
- setv(to_object, ['required'], getv(from_object, ['required']))
316
-
317
- if getv(from_object, ['type']) is not None:
318
- setv(to_object, ['type'], getv(from_object, ['type']))
319
-
320
- return to_object
321
-
322
-
323
- def _FunctionDeclaration_to_mldev(
324
- api_client: BaseApiClient,
325
- from_object: Union[dict, object],
326
- parent_object: Optional[dict] = None,
327
- ) -> dict:
328
- to_object: dict[str, Any] = {}
329
- if getv(from_object, ['response']) is not None:
330
- raise ValueError('response parameter is not supported in Gemini API.')
331
-
332
- if getv(from_object, ['description']) is not None:
333
- setv(to_object, ['description'], getv(from_object, ['description']))
334
-
335
- if getv(from_object, ['name']) is not None:
336
- setv(to_object, ['name'], getv(from_object, ['name']))
337
-
338
- if getv(from_object, ['parameters']) is not None:
339
- setv(to_object, ['parameters'], getv(from_object, ['parameters']))
340
-
341
- return to_object
342
-
343
-
344
- def _FunctionDeclaration_to_vertex(
345
- api_client: BaseApiClient,
346
- from_object: Union[dict, object],
347
- parent_object: Optional[dict] = None,
348
- ) -> dict:
349
- to_object: dict[str, Any] = {}
350
- if getv(from_object, ['response']) is not None:
351
- setv(
352
- to_object,
353
- ['response'],
354
- _Schema_to_vertex(
355
- api_client, getv(from_object, ['response']), to_object
356
- ),
357
- )
358
-
359
- if getv(from_object, ['description']) is not None:
360
- setv(to_object, ['description'], getv(from_object, ['description']))
361
-
362
- if getv(from_object, ['name']) is not None:
363
- setv(to_object, ['name'], getv(from_object, ['name']))
364
-
365
- if getv(from_object, ['parameters']) is not None:
366
- setv(to_object, ['parameters'], getv(from_object, ['parameters']))
367
-
368
- return to_object
369
-
370
-
371
- def _GoogleSearch_to_mldev(
372
- api_client: BaseApiClient,
373
- from_object: Union[dict, object],
374
- parent_object: Optional[dict] = None,
375
- ) -> dict:
376
- to_object: dict[str, Any] = {}
377
-
378
- return to_object
379
-
380
-
381
- def _GoogleSearch_to_vertex(
382
- api_client: BaseApiClient,
383
- from_object: Union[dict, object],
384
- parent_object: Optional[dict] = None,
385
- ) -> dict:
386
- to_object: dict[str, Any] = {}
387
-
388
- return to_object
389
-
390
-
391
- def _DynamicRetrievalConfig_to_mldev(
392
- api_client: BaseApiClient,
393
- from_object: Union[dict, object],
394
- parent_object: Optional[dict] = None,
395
- ) -> dict:
396
- to_object: dict[str, Any] = {}
397
- if getv(from_object, ['mode']) is not None:
398
- setv(to_object, ['mode'], getv(from_object, ['mode']))
399
-
400
- if getv(from_object, ['dynamic_threshold']) is not None:
401
- setv(
402
- to_object,
403
- ['dynamicThreshold'],
404
- getv(from_object, ['dynamic_threshold']),
405
- )
406
-
407
- return to_object
408
-
409
-
410
- def _DynamicRetrievalConfig_to_vertex(
411
- api_client: BaseApiClient,
412
- from_object: Union[dict, object],
413
- parent_object: Optional[dict] = None,
414
- ) -> dict:
415
- to_object: dict[str, Any] = {}
416
- if getv(from_object, ['mode']) is not None:
417
- setv(to_object, ['mode'], getv(from_object, ['mode']))
418
-
419
- if getv(from_object, ['dynamic_threshold']) is not None:
420
- setv(
421
- to_object,
422
- ['dynamicThreshold'],
423
- getv(from_object, ['dynamic_threshold']),
424
- )
425
-
426
- return to_object
427
-
428
-
429
- def _GoogleSearchRetrieval_to_mldev(
430
- api_client: BaseApiClient,
431
- from_object: Union[dict, object],
432
- parent_object: Optional[dict] = None,
433
- ) -> dict:
434
- to_object: dict[str, Any] = {}
435
- if getv(from_object, ['dynamic_retrieval_config']) is not None:
436
- setv(
437
- to_object,
438
- ['dynamicRetrievalConfig'],
439
- _DynamicRetrievalConfig_to_mldev(
440
- api_client,
441
- getv(from_object, ['dynamic_retrieval_config']),
442
- to_object,
443
- ),
444
- )
445
-
446
- return to_object
447
-
448
-
449
- def _GoogleSearchRetrieval_to_vertex(
450
- api_client: BaseApiClient,
451
- from_object: Union[dict, object],
452
- parent_object: Optional[dict] = None,
453
- ) -> dict:
454
- to_object: dict[str, Any] = {}
455
- if getv(from_object, ['dynamic_retrieval_config']) is not None:
456
- setv(
457
- to_object,
458
- ['dynamicRetrievalConfig'],
459
- _DynamicRetrievalConfig_to_vertex(
460
- api_client,
461
- getv(from_object, ['dynamic_retrieval_config']),
462
- to_object,
463
- ),
464
- )
465
-
466
- return to_object
467
-
468
-
469
- def _Tool_to_mldev(
470
- api_client: BaseApiClient,
471
- from_object: Union[dict, object],
472
- parent_object: Optional[dict] = None,
473
- ) -> dict:
474
- to_object: dict[str, Any] = {}
475
- if getv(from_object, ['function_declarations']) is not None:
476
- setv(
477
- to_object,
478
- ['functionDeclarations'],
479
- [
480
- _FunctionDeclaration_to_mldev(api_client, item, to_object)
481
- for item in getv(from_object, ['function_declarations'])
482
- ],
483
- )
484
-
485
- if getv(from_object, ['retrieval']) is not None:
486
- raise ValueError('retrieval parameter is not supported in Gemini API.')
487
-
488
- if getv(from_object, ['google_search']) is not None:
489
- setv(
490
- to_object,
491
- ['googleSearch'],
492
- _GoogleSearch_to_mldev(
493
- api_client, getv(from_object, ['google_search']), to_object
494
- ),
495
- )
496
-
497
- if getv(from_object, ['google_search_retrieval']) is not None:
498
- setv(
499
- to_object,
500
- ['googleSearchRetrieval'],
501
- _GoogleSearchRetrieval_to_mldev(
502
- api_client,
503
- getv(from_object, ['google_search_retrieval']),
504
- to_object,
505
- ),
506
- )
507
-
508
- if getv(from_object, ['code_execution']) is not None:
509
- setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
510
-
511
- return to_object
512
-
513
-
514
- def _Tool_to_vertex(
515
- api_client: BaseApiClient,
516
- from_object: Union[dict, object],
517
- parent_object: Optional[dict] = None,
518
- ) -> dict:
519
- to_object: dict[str, Any] = {}
520
- if getv(from_object, ['function_declarations']) is not None:
521
- setv(
522
- to_object,
523
- ['functionDeclarations'],
524
- [
525
- _FunctionDeclaration_to_vertex(api_client, item, to_object)
526
- for item in getv(from_object, ['function_declarations'])
527
- ],
528
- )
529
-
530
- if getv(from_object, ['retrieval']) is not None:
531
- setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
532
-
533
- if getv(from_object, ['google_search']) is not None:
534
- setv(
535
- to_object,
536
- ['googleSearch'],
537
- _GoogleSearch_to_vertex(
538
- api_client, getv(from_object, ['google_search']), to_object
539
- ),
540
- )
541
-
542
- if getv(from_object, ['google_search_retrieval']) is not None:
543
- setv(
544
- to_object,
545
- ['googleSearchRetrieval'],
546
- _GoogleSearchRetrieval_to_vertex(
547
- api_client,
548
- getv(from_object, ['google_search_retrieval']),
549
- to_object,
550
- ),
551
- )
552
-
553
- if getv(from_object, ['code_execution']) is not None:
554
- setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
555
-
556
- return to_object
557
-
558
-
559
- def _FunctionCallingConfig_to_mldev(
560
- api_client: BaseApiClient,
561
- from_object: Union[dict, object],
562
- parent_object: Optional[dict] = None,
563
- ) -> dict:
564
- to_object: dict[str, Any] = {}
565
- if getv(from_object, ['mode']) is not None:
566
- setv(to_object, ['mode'], getv(from_object, ['mode']))
567
-
568
- if getv(from_object, ['allowed_function_names']) is not None:
569
- setv(
570
- to_object,
571
- ['allowedFunctionNames'],
572
- getv(from_object, ['allowed_function_names']),
573
- )
574
-
575
- return to_object
576
-
577
-
578
- def _FunctionCallingConfig_to_vertex(
579
- api_client: BaseApiClient,
580
- from_object: Union[dict, object],
581
- parent_object: Optional[dict] = None,
582
- ) -> dict:
583
- to_object: dict[str, Any] = {}
584
- if getv(from_object, ['mode']) is not None:
585
- setv(to_object, ['mode'], getv(from_object, ['mode']))
586
-
587
- if getv(from_object, ['allowed_function_names']) is not None:
588
- setv(
589
- to_object,
590
- ['allowedFunctionNames'],
591
- getv(from_object, ['allowed_function_names']),
592
- )
30
+ from .pagers import AsyncPager, Pager
593
31
 
594
- return to_object
595
32
 
33
+ logger = logging.getLogger('google_genai.caches')
596
34
 
597
- def _ToolConfig_to_mldev(
598
- api_client: BaseApiClient,
599
- from_object: Union[dict, object],
600
- parent_object: Optional[dict] = None,
601
- ) -> dict:
35
+
36
+ def _Blob_to_mldev(
37
+ from_object: Union[dict[str, Any], object],
38
+ parent_object: Optional[dict[str, Any]] = None,
39
+ ) -> dict[str, Any]:
602
40
  to_object: dict[str, Any] = {}
603
- if getv(from_object, ['function_calling_config']) is not None:
604
- setv(
605
- to_object,
606
- ['functionCallingConfig'],
607
- _FunctionCallingConfig_to_mldev(
608
- api_client,
609
- getv(from_object, ['function_calling_config']),
610
- to_object,
611
- ),
612
- )
41
+ if getv(from_object, ['data']) is not None:
42
+ setv(to_object, ['data'], getv(from_object, ['data']))
43
+
44
+ if getv(from_object, ['display_name']) is not None:
45
+ raise ValueError('display_name parameter is not supported in Gemini API.')
46
+
47
+ if getv(from_object, ['mime_type']) is not None:
48
+ setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
613
49
 
614
50
  return to_object
615
51
 
616
52
 
617
- def _ToolConfig_to_vertex(
618
- api_client: BaseApiClient,
619
- from_object: Union[dict, object],
620
- parent_object: Optional[dict] = None,
621
- ) -> dict:
53
+ def _Content_to_mldev(
54
+ from_object: Union[dict[str, Any], object],
55
+ parent_object: Optional[dict[str, Any]] = None,
56
+ ) -> dict[str, Any]:
622
57
  to_object: dict[str, Any] = {}
623
- if getv(from_object, ['function_calling_config']) is not None:
58
+ if getv(from_object, ['parts']) is not None:
624
59
  setv(
625
60
  to_object,
626
- ['functionCallingConfig'],
627
- _FunctionCallingConfig_to_vertex(
628
- api_client,
629
- getv(from_object, ['function_calling_config']),
630
- to_object,
631
- ),
61
+ ['parts'],
62
+ [
63
+ _Part_to_mldev(item, to_object)
64
+ for item in getv(from_object, ['parts'])
65
+ ],
632
66
  )
633
67
 
68
+ if getv(from_object, ['role']) is not None:
69
+ setv(to_object, ['role'], getv(from_object, ['role']))
70
+
634
71
  return to_object
635
72
 
636
73
 
637
74
  def _CreateCachedContentConfig_to_mldev(
638
- api_client: BaseApiClient,
639
- from_object: Union[dict, object],
640
- parent_object: Optional[dict] = None,
641
- ) -> dict:
75
+ from_object: Union[dict[str, Any], object],
76
+ parent_object: Optional[dict[str, Any]] = None,
77
+ ) -> dict[str, Any]:
642
78
  to_object: dict[str, Any] = {}
643
79
 
644
80
  if getv(from_object, ['ttl']) is not None:
@@ -655,10 +91,8 @@ def _CreateCachedContentConfig_to_mldev(
655
91
  parent_object,
656
92
  ['contents'],
657
93
  [
658
- _Content_to_mldev(api_client, item, to_object)
659
- for item in t.t_contents(
660
- api_client, getv(from_object, ['contents'])
661
- )
94
+ _Content_to_mldev(item, to_object)
95
+ for item in t.t_contents(getv(from_object, ['contents']))
662
96
  ],
663
97
  )
664
98
 
@@ -667,9 +101,7 @@ def _CreateCachedContentConfig_to_mldev(
667
101
  parent_object,
668
102
  ['systemInstruction'],
669
103
  _Content_to_mldev(
670
- api_client,
671
- t.t_content(api_client, getv(from_object, ['system_instruction'])),
672
- to_object,
104
+ t.t_content(getv(from_object, ['system_instruction'])), to_object
673
105
  ),
674
106
  )
675
107
 
@@ -678,7 +110,7 @@ def _CreateCachedContentConfig_to_mldev(
678
110
  parent_object,
679
111
  ['tools'],
680
112
  [
681
- _Tool_to_mldev(api_client, item, to_object)
113
+ _Tool_to_mldev(item, to_object)
682
114
  for item in getv(from_object, ['tools'])
683
115
  ],
684
116
  )
@@ -687,19 +119,19 @@ def _CreateCachedContentConfig_to_mldev(
687
119
  setv(
688
120
  parent_object,
689
121
  ['toolConfig'],
690
- _ToolConfig_to_mldev(
691
- api_client, getv(from_object, ['tool_config']), to_object
692
- ),
122
+ _ToolConfig_to_mldev(getv(from_object, ['tool_config']), to_object),
693
123
  )
694
124
 
125
+ if getv(from_object, ['kms_key_name']) is not None:
126
+ raise ValueError('kms_key_name parameter is not supported in Gemini API.')
127
+
695
128
  return to_object
696
129
 
697
130
 
698
131
  def _CreateCachedContentConfig_to_vertex(
699
- api_client: BaseApiClient,
700
- from_object: Union[dict, object],
701
- parent_object: Optional[dict] = None,
702
- ) -> dict:
132
+ from_object: Union[dict[str, Any], object],
133
+ parent_object: Optional[dict[str, Any]] = None,
134
+ ) -> dict[str, Any]:
703
135
  to_object: dict[str, Any] = {}
704
136
 
705
137
  if getv(from_object, ['ttl']) is not None:
@@ -715,23 +147,14 @@ def _CreateCachedContentConfig_to_vertex(
715
147
  setv(
716
148
  parent_object,
717
149
  ['contents'],
718
- [
719
- _Content_to_vertex(api_client, item, to_object)
720
- for item in t.t_contents(
721
- api_client, getv(from_object, ['contents'])
722
- )
723
- ],
150
+ [item for item in t.t_contents(getv(from_object, ['contents']))],
724
151
  )
725
152
 
726
153
  if getv(from_object, ['system_instruction']) is not None:
727
154
  setv(
728
155
  parent_object,
729
156
  ['systemInstruction'],
730
- _Content_to_vertex(
731
- api_client,
732
- t.t_content(api_client, getv(from_object, ['system_instruction'])),
733
- to_object,
734
- ),
157
+ t.t_content(getv(from_object, ['system_instruction'])),
735
158
  )
736
159
 
737
160
  if getv(from_object, ['tools']) is not None:
@@ -739,18 +162,19 @@ def _CreateCachedContentConfig_to_vertex(
739
162
  parent_object,
740
163
  ['tools'],
741
164
  [
742
- _Tool_to_vertex(api_client, item, to_object)
165
+ _Tool_to_vertex(item, to_object)
743
166
  for item in getv(from_object, ['tools'])
744
167
  ],
745
168
  )
746
169
 
747
170
  if getv(from_object, ['tool_config']) is not None:
171
+ setv(parent_object, ['toolConfig'], getv(from_object, ['tool_config']))
172
+
173
+ if getv(from_object, ['kms_key_name']) is not None:
748
174
  setv(
749
175
  parent_object,
750
- ['toolConfig'],
751
- _ToolConfig_to_vertex(
752
- api_client, getv(from_object, ['tool_config']), to_object
753
- ),
176
+ ['encryption_spec', 'kmsKeyName'],
177
+ getv(from_object, ['kms_key_name']),
754
178
  )
755
179
 
756
180
  return to_object
@@ -758,9 +182,9 @@ def _CreateCachedContentConfig_to_vertex(
758
182
 
759
183
  def _CreateCachedContentParameters_to_mldev(
760
184
  api_client: BaseApiClient,
761
- from_object: Union[dict, object],
762
- parent_object: Optional[dict] = None,
763
- ) -> dict:
185
+ from_object: Union[dict[str, Any], object],
186
+ parent_object: Optional[dict[str, Any]] = None,
187
+ ) -> dict[str, Any]:
764
188
  to_object: dict[str, Any] = {}
765
189
  if getv(from_object, ['model']) is not None:
766
190
  setv(
@@ -770,12 +194,8 @@ def _CreateCachedContentParameters_to_mldev(
770
194
  )
771
195
 
772
196
  if getv(from_object, ['config']) is not None:
773
- setv(
774
- to_object,
775
- ['config'],
776
- _CreateCachedContentConfig_to_mldev(
777
- api_client, getv(from_object, ['config']), to_object
778
- ),
197
+ _CreateCachedContentConfig_to_mldev(
198
+ getv(from_object, ['config']), to_object
779
199
  )
780
200
 
781
201
  return to_object
@@ -783,9 +203,9 @@ def _CreateCachedContentParameters_to_mldev(
783
203
 
784
204
  def _CreateCachedContentParameters_to_vertex(
785
205
  api_client: BaseApiClient,
786
- from_object: Union[dict, object],
787
- parent_object: Optional[dict] = None,
788
- ) -> dict:
206
+ from_object: Union[dict[str, Any], object],
207
+ parent_object: Optional[dict[str, Any]] = None,
208
+ ) -> dict[str, Any]:
789
209
  to_object: dict[str, Any] = {}
790
210
  if getv(from_object, ['model']) is not None:
791
211
  setv(
@@ -795,22 +215,18 @@ def _CreateCachedContentParameters_to_vertex(
795
215
  )
796
216
 
797
217
  if getv(from_object, ['config']) is not None:
798
- setv(
799
- to_object,
800
- ['config'],
801
- _CreateCachedContentConfig_to_vertex(
802
- api_client, getv(from_object, ['config']), to_object
803
- ),
218
+ _CreateCachedContentConfig_to_vertex(
219
+ getv(from_object, ['config']), to_object
804
220
  )
805
221
 
806
222
  return to_object
807
223
 
808
224
 
809
- def _GetCachedContentParameters_to_mldev(
225
+ def _DeleteCachedContentParameters_to_mldev(
810
226
  api_client: BaseApiClient,
811
- from_object: Union[dict, object],
812
- parent_object: Optional[dict] = None,
813
- ) -> dict:
227
+ from_object: Union[dict[str, Any], object],
228
+ parent_object: Optional[dict[str, Any]] = None,
229
+ ) -> dict[str, Any]:
814
230
  to_object: dict[str, Any] = {}
815
231
  if getv(from_object, ['name']) is not None:
816
232
  setv(
@@ -819,17 +235,14 @@ def _GetCachedContentParameters_to_mldev(
819
235
  t.t_cached_content_name(api_client, getv(from_object, ['name'])),
820
236
  )
821
237
 
822
- if getv(from_object, ['config']) is not None:
823
- setv(to_object, ['config'], getv(from_object, ['config']))
824
-
825
238
  return to_object
826
239
 
827
240
 
828
- def _GetCachedContentParameters_to_vertex(
241
+ def _DeleteCachedContentParameters_to_vertex(
829
242
  api_client: BaseApiClient,
830
- from_object: Union[dict, object],
831
- parent_object: Optional[dict] = None,
832
- ) -> dict:
243
+ from_object: Union[dict[str, Any], object],
244
+ parent_object: Optional[dict[str, Any]] = None,
245
+ ) -> dict[str, Any]:
833
246
  to_object: dict[str, Any] = {}
834
247
  if getv(from_object, ['name']) is not None:
835
248
  setv(
@@ -838,17 +251,141 @@ def _GetCachedContentParameters_to_vertex(
838
251
  t.t_cached_content_name(api_client, getv(from_object, ['name'])),
839
252
  )
840
253
 
841
- if getv(from_object, ['config']) is not None:
842
- setv(to_object, ['config'], getv(from_object, ['config']))
254
+ return to_object
255
+
256
+
257
+ def _DeleteCachedContentResponse_from_mldev(
258
+ from_object: Union[dict[str, Any], object],
259
+ parent_object: Optional[dict[str, Any]] = None,
260
+ ) -> dict[str, Any]:
261
+ to_object: dict[str, Any] = {}
262
+ if getv(from_object, ['sdkHttpResponse']) is not None:
263
+ setv(
264
+ to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
265
+ )
843
266
 
844
267
  return to_object
845
268
 
846
269
 
847
- def _DeleteCachedContentParameters_to_mldev(
270
+ def _DeleteCachedContentResponse_from_vertex(
271
+ from_object: Union[dict[str, Any], object],
272
+ parent_object: Optional[dict[str, Any]] = None,
273
+ ) -> dict[str, Any]:
274
+ to_object: dict[str, Any] = {}
275
+ if getv(from_object, ['sdkHttpResponse']) is not None:
276
+ setv(
277
+ to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
278
+ )
279
+
280
+ return to_object
281
+
282
+
283
+ def _FileData_to_mldev(
284
+ from_object: Union[dict[str, Any], object],
285
+ parent_object: Optional[dict[str, Any]] = None,
286
+ ) -> dict[str, Any]:
287
+ to_object: dict[str, Any] = {}
288
+ if getv(from_object, ['display_name']) is not None:
289
+ raise ValueError('display_name parameter is not supported in Gemini API.')
290
+
291
+ if getv(from_object, ['file_uri']) is not None:
292
+ setv(to_object, ['fileUri'], getv(from_object, ['file_uri']))
293
+
294
+ if getv(from_object, ['mime_type']) is not None:
295
+ setv(to_object, ['mimeType'], getv(from_object, ['mime_type']))
296
+
297
+ return to_object
298
+
299
+
300
+ def _FunctionCall_to_mldev(
301
+ from_object: Union[dict[str, Any], object],
302
+ parent_object: Optional[dict[str, Any]] = None,
303
+ ) -> dict[str, Any]:
304
+ to_object: dict[str, Any] = {}
305
+ if getv(from_object, ['id']) is not None:
306
+ setv(to_object, ['id'], getv(from_object, ['id']))
307
+
308
+ if getv(from_object, ['args']) is not None:
309
+ setv(to_object, ['args'], getv(from_object, ['args']))
310
+
311
+ if getv(from_object, ['name']) is not None:
312
+ setv(to_object, ['name'], getv(from_object, ['name']))
313
+
314
+ if getv(from_object, ['partial_args']) is not None:
315
+ raise ValueError('partial_args parameter is not supported in Gemini API.')
316
+
317
+ if getv(from_object, ['will_continue']) is not None:
318
+ raise ValueError('will_continue parameter is not supported in Gemini API.')
319
+
320
+ return to_object
321
+
322
+
323
+ def _FunctionCallingConfig_to_mldev(
324
+ from_object: Union[dict[str, Any], object],
325
+ parent_object: Optional[dict[str, Any]] = None,
326
+ ) -> dict[str, Any]:
327
+ to_object: dict[str, Any] = {}
328
+ if getv(from_object, ['mode']) is not None:
329
+ setv(to_object, ['mode'], getv(from_object, ['mode']))
330
+
331
+ if getv(from_object, ['allowed_function_names']) is not None:
332
+ setv(
333
+ to_object,
334
+ ['allowedFunctionNames'],
335
+ getv(from_object, ['allowed_function_names']),
336
+ )
337
+
338
+ if getv(from_object, ['stream_function_call_arguments']) is not None:
339
+ raise ValueError(
340
+ 'stream_function_call_arguments parameter is not supported in Gemini'
341
+ ' API.'
342
+ )
343
+
344
+ return to_object
345
+
346
+
347
+ def _FunctionDeclaration_to_vertex(
348
+ from_object: Union[dict[str, Any], object],
349
+ parent_object: Optional[dict[str, Any]] = None,
350
+ ) -> dict[str, Any]:
351
+ to_object: dict[str, Any] = {}
352
+ if getv(from_object, ['behavior']) is not None:
353
+ raise ValueError('behavior parameter is not supported in Vertex AI.')
354
+
355
+ if getv(from_object, ['description']) is not None:
356
+ setv(to_object, ['description'], getv(from_object, ['description']))
357
+
358
+ if getv(from_object, ['name']) is not None:
359
+ setv(to_object, ['name'], getv(from_object, ['name']))
360
+
361
+ if getv(from_object, ['parameters']) is not None:
362
+ setv(to_object, ['parameters'], getv(from_object, ['parameters']))
363
+
364
+ if getv(from_object, ['parameters_json_schema']) is not None:
365
+ setv(
366
+ to_object,
367
+ ['parametersJsonSchema'],
368
+ getv(from_object, ['parameters_json_schema']),
369
+ )
370
+
371
+ if getv(from_object, ['response']) is not None:
372
+ setv(to_object, ['response'], getv(from_object, ['response']))
373
+
374
+ if getv(from_object, ['response_json_schema']) is not None:
375
+ setv(
376
+ to_object,
377
+ ['responseJsonSchema'],
378
+ getv(from_object, ['response_json_schema']),
379
+ )
380
+
381
+ return to_object
382
+
383
+
384
+ def _GetCachedContentParameters_to_mldev(
848
385
  api_client: BaseApiClient,
849
- from_object: Union[dict, object],
850
- parent_object: Optional[dict] = None,
851
- ) -> dict:
386
+ from_object: Union[dict[str, Any], object],
387
+ parent_object: Optional[dict[str, Any]] = None,
388
+ ) -> dict[str, Any]:
852
389
  to_object: dict[str, Any] = {}
853
390
  if getv(from_object, ['name']) is not None:
854
391
  setv(
@@ -857,17 +394,14 @@ def _DeleteCachedContentParameters_to_mldev(
857
394
  t.t_cached_content_name(api_client, getv(from_object, ['name'])),
858
395
  )
859
396
 
860
- if getv(from_object, ['config']) is not None:
861
- setv(to_object, ['config'], getv(from_object, ['config']))
862
-
863
397
  return to_object
864
398
 
865
399
 
866
- def _DeleteCachedContentParameters_to_vertex(
400
+ def _GetCachedContentParameters_to_vertex(
867
401
  api_client: BaseApiClient,
868
- from_object: Union[dict, object],
869
- parent_object: Optional[dict] = None,
870
- ) -> dict:
402
+ from_object: Union[dict[str, Any], object],
403
+ parent_object: Optional[dict[str, Any]] = None,
404
+ ) -> dict[str, Any]:
871
405
  to_object: dict[str, Any] = {}
872
406
  if getv(from_object, ['name']) is not None:
873
407
  setv(
@@ -876,293 +410,423 @@ def _DeleteCachedContentParameters_to_vertex(
876
410
  t.t_cached_content_name(api_client, getv(from_object, ['name'])),
877
411
  )
878
412
 
413
+ return to_object
414
+
415
+
416
+ def _GoogleMaps_to_mldev(
417
+ from_object: Union[dict[str, Any], object],
418
+ parent_object: Optional[dict[str, Any]] = None,
419
+ ) -> dict[str, Any]:
420
+ to_object: dict[str, Any] = {}
421
+ if getv(from_object, ['auth_config']) is not None:
422
+ raise ValueError('auth_config parameter is not supported in Gemini API.')
423
+
424
+ if getv(from_object, ['enable_widget']) is not None:
425
+ setv(to_object, ['enableWidget'], getv(from_object, ['enable_widget']))
426
+
427
+ return to_object
428
+
429
+
430
+ def _GoogleSearch_to_mldev(
431
+ from_object: Union[dict[str, Any], object],
432
+ parent_object: Optional[dict[str, Any]] = None,
433
+ ) -> dict[str, Any]:
434
+ to_object: dict[str, Any] = {}
435
+ if getv(from_object, ['exclude_domains']) is not None:
436
+ raise ValueError(
437
+ 'exclude_domains parameter is not supported in Gemini API.'
438
+ )
439
+
440
+ if getv(from_object, ['blocking_confidence']) is not None:
441
+ raise ValueError(
442
+ 'blocking_confidence parameter is not supported in Gemini API.'
443
+ )
444
+
445
+ if getv(from_object, ['time_range_filter']) is not None:
446
+ setv(
447
+ to_object, ['timeRangeFilter'], getv(from_object, ['time_range_filter'])
448
+ )
449
+
450
+ return to_object
451
+
452
+
453
+ def _ListCachedContentsConfig_to_mldev(
454
+ from_object: Union[dict[str, Any], object],
455
+ parent_object: Optional[dict[str, Any]] = None,
456
+ ) -> dict[str, Any]:
457
+ to_object: dict[str, Any] = {}
458
+
459
+ if getv(from_object, ['page_size']) is not None:
460
+ setv(
461
+ parent_object, ['_query', 'pageSize'], getv(from_object, ['page_size'])
462
+ )
463
+
464
+ if getv(from_object, ['page_token']) is not None:
465
+ setv(
466
+ parent_object,
467
+ ['_query', 'pageToken'],
468
+ getv(from_object, ['page_token']),
469
+ )
470
+
471
+ return to_object
472
+
473
+
474
+ def _ListCachedContentsConfig_to_vertex(
475
+ from_object: Union[dict[str, Any], object],
476
+ parent_object: Optional[dict[str, Any]] = None,
477
+ ) -> dict[str, Any]:
478
+ to_object: dict[str, Any] = {}
479
+
480
+ if getv(from_object, ['page_size']) is not None:
481
+ setv(
482
+ parent_object, ['_query', 'pageSize'], getv(from_object, ['page_size'])
483
+ )
484
+
485
+ if getv(from_object, ['page_token']) is not None:
486
+ setv(
487
+ parent_object,
488
+ ['_query', 'pageToken'],
489
+ getv(from_object, ['page_token']),
490
+ )
491
+
492
+ return to_object
493
+
494
+
495
+ def _ListCachedContentsParameters_to_mldev(
496
+ from_object: Union[dict[str, Any], object],
497
+ parent_object: Optional[dict[str, Any]] = None,
498
+ ) -> dict[str, Any]:
499
+ to_object: dict[str, Any] = {}
500
+ if getv(from_object, ['config']) is not None:
501
+ _ListCachedContentsConfig_to_mldev(getv(from_object, ['config']), to_object)
502
+
503
+ return to_object
504
+
505
+
506
+ def _ListCachedContentsParameters_to_vertex(
507
+ from_object: Union[dict[str, Any], object],
508
+ parent_object: Optional[dict[str, Any]] = None,
509
+ ) -> dict[str, Any]:
510
+ to_object: dict[str, Any] = {}
879
511
  if getv(from_object, ['config']) is not None:
880
- setv(to_object, ['config'], getv(from_object, ['config']))
512
+ _ListCachedContentsConfig_to_vertex(
513
+ getv(from_object, ['config']), to_object
514
+ )
881
515
 
882
516
  return to_object
883
517
 
884
518
 
885
- def _UpdateCachedContentConfig_to_mldev(
886
- api_client: BaseApiClient,
887
- from_object: Union[dict, object],
888
- parent_object: Optional[dict] = None,
889
- ) -> dict:
519
+ def _ListCachedContentsResponse_from_mldev(
520
+ from_object: Union[dict[str, Any], object],
521
+ parent_object: Optional[dict[str, Any]] = None,
522
+ ) -> dict[str, Any]:
890
523
  to_object: dict[str, Any] = {}
524
+ if getv(from_object, ['sdkHttpResponse']) is not None:
525
+ setv(
526
+ to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
527
+ )
891
528
 
892
- if getv(from_object, ['ttl']) is not None:
893
- setv(parent_object, ['ttl'], getv(from_object, ['ttl']))
529
+ if getv(from_object, ['nextPageToken']) is not None:
530
+ setv(to_object, ['next_page_token'], getv(from_object, ['nextPageToken']))
894
531
 
895
- if getv(from_object, ['expire_time']) is not None:
896
- setv(parent_object, ['expireTime'], getv(from_object, ['expire_time']))
532
+ if getv(from_object, ['cachedContents']) is not None:
533
+ setv(
534
+ to_object,
535
+ ['cached_contents'],
536
+ [item for item in getv(from_object, ['cachedContents'])],
537
+ )
897
538
 
898
539
  return to_object
899
540
 
900
541
 
901
- def _UpdateCachedContentConfig_to_vertex(
902
- api_client: BaseApiClient,
903
- from_object: Union[dict, object],
904
- parent_object: Optional[dict] = None,
905
- ) -> dict:
542
+ def _ListCachedContentsResponse_from_vertex(
543
+ from_object: Union[dict[str, Any], object],
544
+ parent_object: Optional[dict[str, Any]] = None,
545
+ ) -> dict[str, Any]:
906
546
  to_object: dict[str, Any] = {}
547
+ if getv(from_object, ['sdkHttpResponse']) is not None:
548
+ setv(
549
+ to_object, ['sdk_http_response'], getv(from_object, ['sdkHttpResponse'])
550
+ )
907
551
 
908
- if getv(from_object, ['ttl']) is not None:
909
- setv(parent_object, ['ttl'], getv(from_object, ['ttl']))
552
+ if getv(from_object, ['nextPageToken']) is not None:
553
+ setv(to_object, ['next_page_token'], getv(from_object, ['nextPageToken']))
910
554
 
911
- if getv(from_object, ['expire_time']) is not None:
912
- setv(parent_object, ['expireTime'], getv(from_object, ['expire_time']))
555
+ if getv(from_object, ['cachedContents']) is not None:
556
+ setv(
557
+ to_object,
558
+ ['cached_contents'],
559
+ [item for item in getv(from_object, ['cachedContents'])],
560
+ )
561
+
562
+ return to_object
563
+
564
+
565
+ def _Part_to_mldev(
566
+ from_object: Union[dict[str, Any], object],
567
+ parent_object: Optional[dict[str, Any]] = None,
568
+ ) -> dict[str, Any]:
569
+ to_object: dict[str, Any] = {}
570
+ if getv(from_object, ['media_resolution']) is not None:
571
+ setv(
572
+ to_object, ['mediaResolution'], getv(from_object, ['media_resolution'])
573
+ )
574
+
575
+ if getv(from_object, ['code_execution_result']) is not None:
576
+ setv(
577
+ to_object,
578
+ ['codeExecutionResult'],
579
+ getv(from_object, ['code_execution_result']),
580
+ )
581
+
582
+ if getv(from_object, ['executable_code']) is not None:
583
+ setv(to_object, ['executableCode'], getv(from_object, ['executable_code']))
584
+
585
+ if getv(from_object, ['file_data']) is not None:
586
+ setv(
587
+ to_object,
588
+ ['fileData'],
589
+ _FileData_to_mldev(getv(from_object, ['file_data']), to_object),
590
+ )
913
591
 
914
- return to_object
592
+ if getv(from_object, ['function_call']) is not None:
593
+ setv(
594
+ to_object,
595
+ ['functionCall'],
596
+ _FunctionCall_to_mldev(getv(from_object, ['function_call']), to_object),
597
+ )
915
598
 
599
+ if getv(from_object, ['function_response']) is not None:
600
+ setv(
601
+ to_object,
602
+ ['functionResponse'],
603
+ getv(from_object, ['function_response']),
604
+ )
916
605
 
917
- def _UpdateCachedContentParameters_to_mldev(
918
- api_client: BaseApiClient,
919
- from_object: Union[dict, object],
920
- parent_object: Optional[dict] = None,
921
- ) -> dict:
922
- to_object: dict[str, Any] = {}
923
- if getv(from_object, ['name']) is not None:
606
+ if getv(from_object, ['inline_data']) is not None:
924
607
  setv(
925
608
  to_object,
926
- ['_url', 'name'],
927
- t.t_cached_content_name(api_client, getv(from_object, ['name'])),
609
+ ['inlineData'],
610
+ _Blob_to_mldev(getv(from_object, ['inline_data']), to_object),
928
611
  )
929
612
 
930
- if getv(from_object, ['config']) is not None:
613
+ if getv(from_object, ['text']) is not None:
614
+ setv(to_object, ['text'], getv(from_object, ['text']))
615
+
616
+ if getv(from_object, ['thought']) is not None:
617
+ setv(to_object, ['thought'], getv(from_object, ['thought']))
618
+
619
+ if getv(from_object, ['thought_signature']) is not None:
931
620
  setv(
932
621
  to_object,
933
- ['config'],
934
- _UpdateCachedContentConfig_to_mldev(
935
- api_client, getv(from_object, ['config']), to_object
936
- ),
622
+ ['thoughtSignature'],
623
+ getv(from_object, ['thought_signature']),
937
624
  )
938
625
 
626
+ if getv(from_object, ['video_metadata']) is not None:
627
+ setv(to_object, ['videoMetadata'], getv(from_object, ['video_metadata']))
628
+
939
629
  return to_object
940
630
 
941
631
 
942
- def _UpdateCachedContentParameters_to_vertex(
943
- api_client: BaseApiClient,
944
- from_object: Union[dict, object],
945
- parent_object: Optional[dict] = None,
946
- ) -> dict:
632
+ def _ToolConfig_to_mldev(
633
+ from_object: Union[dict[str, Any], object],
634
+ parent_object: Optional[dict[str, Any]] = None,
635
+ ) -> dict[str, Any]:
947
636
  to_object: dict[str, Any] = {}
948
- if getv(from_object, ['name']) is not None:
637
+ if getv(from_object, ['function_calling_config']) is not None:
949
638
  setv(
950
639
  to_object,
951
- ['_url', 'name'],
952
- t.t_cached_content_name(api_client, getv(from_object, ['name'])),
640
+ ['functionCallingConfig'],
641
+ _FunctionCallingConfig_to_mldev(
642
+ getv(from_object, ['function_calling_config']), to_object
643
+ ),
953
644
  )
954
645
 
955
- if getv(from_object, ['config']) is not None:
646
+ if getv(from_object, ['retrieval_config']) is not None:
956
647
  setv(
957
- to_object,
958
- ['config'],
959
- _UpdateCachedContentConfig_to_vertex(
960
- api_client, getv(from_object, ['config']), to_object
961
- ),
648
+ to_object, ['retrievalConfig'], getv(from_object, ['retrieval_config'])
962
649
  )
963
650
 
964
651
  return to_object
965
652
 
966
653
 
967
- def _ListCachedContentsConfig_to_mldev(
968
- api_client: BaseApiClient,
969
- from_object: Union[dict, object],
970
- parent_object: Optional[dict] = None,
971
- ) -> dict:
654
+ def _Tool_to_mldev(
655
+ from_object: Union[dict[str, Any], object],
656
+ parent_object: Optional[dict[str, Any]] = None,
657
+ ) -> dict[str, Any]:
972
658
  to_object: dict[str, Any] = {}
973
-
974
- if getv(from_object, ['page_size']) is not None:
659
+ if getv(from_object, ['function_declarations']) is not None:
975
660
  setv(
976
- parent_object, ['_query', 'pageSize'], getv(from_object, ['page_size'])
661
+ to_object,
662
+ ['functionDeclarations'],
663
+ [item for item in getv(from_object, ['function_declarations'])],
977
664
  )
978
665
 
979
- if getv(from_object, ['page_token']) is not None:
666
+ if getv(from_object, ['retrieval']) is not None:
667
+ raise ValueError('retrieval parameter is not supported in Gemini API.')
668
+
669
+ if getv(from_object, ['google_search_retrieval']) is not None:
980
670
  setv(
981
- parent_object,
982
- ['_query', 'pageToken'],
983
- getv(from_object, ['page_token']),
671
+ to_object,
672
+ ['googleSearchRetrieval'],
673
+ getv(from_object, ['google_search_retrieval']),
984
674
  )
985
675
 
986
- return to_object
676
+ if getv(from_object, ['computer_use']) is not None:
677
+ setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
987
678
 
679
+ if getv(from_object, ['file_search']) is not None:
680
+ setv(to_object, ['fileSearch'], getv(from_object, ['file_search']))
988
681
 
989
- def _ListCachedContentsConfig_to_vertex(
990
- api_client: BaseApiClient,
991
- from_object: Union[dict, object],
992
- parent_object: Optional[dict] = None,
993
- ) -> dict:
994
- to_object: dict[str, Any] = {}
682
+ if getv(from_object, ['code_execution']) is not None:
683
+ setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
995
684
 
996
- if getv(from_object, ['page_size']) is not None:
997
- setv(
998
- parent_object, ['_query', 'pageSize'], getv(from_object, ['page_size'])
685
+ if getv(from_object, ['enterprise_web_search']) is not None:
686
+ raise ValueError(
687
+ 'enterprise_web_search parameter is not supported in Gemini API.'
999
688
  )
1000
689
 
1001
- if getv(from_object, ['page_token']) is not None:
690
+ if getv(from_object, ['google_maps']) is not None:
1002
691
  setv(
1003
- parent_object,
1004
- ['_query', 'pageToken'],
1005
- getv(from_object, ['page_token']),
692
+ to_object,
693
+ ['googleMaps'],
694
+ _GoogleMaps_to_mldev(getv(from_object, ['google_maps']), to_object),
1006
695
  )
1007
696
 
1008
- return to_object
1009
-
1010
-
1011
- def _ListCachedContentsParameters_to_mldev(
1012
- api_client: BaseApiClient,
1013
- from_object: Union[dict, object],
1014
- parent_object: Optional[dict] = None,
1015
- ) -> dict:
1016
- to_object: dict[str, Any] = {}
1017
- if getv(from_object, ['config']) is not None:
697
+ if getv(from_object, ['google_search']) is not None:
1018
698
  setv(
1019
699
  to_object,
1020
- ['config'],
1021
- _ListCachedContentsConfig_to_mldev(
1022
- api_client, getv(from_object, ['config']), to_object
1023
- ),
700
+ ['googleSearch'],
701
+ _GoogleSearch_to_mldev(getv(from_object, ['google_search']), to_object),
1024
702
  )
1025
703
 
704
+ if getv(from_object, ['url_context']) is not None:
705
+ setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
706
+
1026
707
  return to_object
1027
708
 
1028
709
 
1029
- def _ListCachedContentsParameters_to_vertex(
1030
- api_client: BaseApiClient,
1031
- from_object: Union[dict, object],
1032
- parent_object: Optional[dict] = None,
1033
- ) -> dict:
710
+ def _Tool_to_vertex(
711
+ from_object: Union[dict[str, Any], object],
712
+ parent_object: Optional[dict[str, Any]] = None,
713
+ ) -> dict[str, Any]:
1034
714
  to_object: dict[str, Any] = {}
1035
- if getv(from_object, ['config']) is not None:
715
+ if getv(from_object, ['function_declarations']) is not None:
1036
716
  setv(
1037
717
  to_object,
1038
- ['config'],
1039
- _ListCachedContentsConfig_to_vertex(
1040
- api_client, getv(from_object, ['config']), to_object
1041
- ),
718
+ ['functionDeclarations'],
719
+ [
720
+ _FunctionDeclaration_to_vertex(item, to_object)
721
+ for item in getv(from_object, ['function_declarations'])
722
+ ],
1042
723
  )
1043
724
 
1044
- return to_object
725
+ if getv(from_object, ['retrieval']) is not None:
726
+ setv(to_object, ['retrieval'], getv(from_object, ['retrieval']))
1045
727
 
728
+ if getv(from_object, ['google_search_retrieval']) is not None:
729
+ setv(
730
+ to_object,
731
+ ['googleSearchRetrieval'],
732
+ getv(from_object, ['google_search_retrieval']),
733
+ )
1046
734
 
1047
- def _CachedContent_from_mldev(
1048
- api_client: BaseApiClient,
1049
- from_object: Union[dict, object],
1050
- parent_object: Optional[dict] = None,
1051
- ) -> dict:
1052
- to_object: dict[str, Any] = {}
1053
- if getv(from_object, ['name']) is not None:
1054
- setv(to_object, ['name'], getv(from_object, ['name']))
735
+ if getv(from_object, ['computer_use']) is not None:
736
+ setv(to_object, ['computerUse'], getv(from_object, ['computer_use']))
1055
737
 
1056
- if getv(from_object, ['displayName']) is not None:
1057
- setv(to_object, ['display_name'], getv(from_object, ['displayName']))
738
+ if getv(from_object, ['file_search']) is not None:
739
+ raise ValueError('file_search parameter is not supported in Vertex AI.')
1058
740
 
1059
- if getv(from_object, ['model']) is not None:
1060
- setv(to_object, ['model'], getv(from_object, ['model']))
741
+ if getv(from_object, ['code_execution']) is not None:
742
+ setv(to_object, ['codeExecution'], getv(from_object, ['code_execution']))
1061
743
 
1062
- if getv(from_object, ['createTime']) is not None:
1063
- setv(to_object, ['create_time'], getv(from_object, ['createTime']))
744
+ if getv(from_object, ['enterprise_web_search']) is not None:
745
+ setv(
746
+ to_object,
747
+ ['enterpriseWebSearch'],
748
+ getv(from_object, ['enterprise_web_search']),
749
+ )
1064
750
 
1065
- if getv(from_object, ['updateTime']) is not None:
1066
- setv(to_object, ['update_time'], getv(from_object, ['updateTime']))
751
+ if getv(from_object, ['google_maps']) is not None:
752
+ setv(to_object, ['googleMaps'], getv(from_object, ['google_maps']))
1067
753
 
1068
- if getv(from_object, ['expireTime']) is not None:
1069
- setv(to_object, ['expire_time'], getv(from_object, ['expireTime']))
754
+ if getv(from_object, ['google_search']) is not None:
755
+ setv(to_object, ['googleSearch'], getv(from_object, ['google_search']))
1070
756
 
1071
- if getv(from_object, ['usageMetadata']) is not None:
1072
- setv(to_object, ['usage_metadata'], getv(from_object, ['usageMetadata']))
757
+ if getv(from_object, ['url_context']) is not None:
758
+ setv(to_object, ['urlContext'], getv(from_object, ['url_context']))
1073
759
 
1074
760
  return to_object
1075
761
 
1076
762
 
1077
- def _CachedContent_from_vertex(
1078
- api_client: BaseApiClient,
1079
- from_object: Union[dict, object],
1080
- parent_object: Optional[dict] = None,
1081
- ) -> dict:
763
+ def _UpdateCachedContentConfig_to_mldev(
764
+ from_object: Union[dict[str, Any], object],
765
+ parent_object: Optional[dict[str, Any]] = None,
766
+ ) -> dict[str, Any]:
1082
767
  to_object: dict[str, Any] = {}
1083
- if getv(from_object, ['name']) is not None:
1084
- setv(to_object, ['name'], getv(from_object, ['name']))
1085
-
1086
- if getv(from_object, ['displayName']) is not None:
1087
- setv(to_object, ['display_name'], getv(from_object, ['displayName']))
1088
768
 
1089
- if getv(from_object, ['model']) is not None:
1090
- setv(to_object, ['model'], getv(from_object, ['model']))
1091
-
1092
- if getv(from_object, ['createTime']) is not None:
1093
- setv(to_object, ['create_time'], getv(from_object, ['createTime']))
1094
-
1095
- if getv(from_object, ['updateTime']) is not None:
1096
- setv(to_object, ['update_time'], getv(from_object, ['updateTime']))
1097
-
1098
- if getv(from_object, ['expireTime']) is not None:
1099
- setv(to_object, ['expire_time'], getv(from_object, ['expireTime']))
769
+ if getv(from_object, ['ttl']) is not None:
770
+ setv(parent_object, ['ttl'], getv(from_object, ['ttl']))
1100
771
 
1101
- if getv(from_object, ['usageMetadata']) is not None:
1102
- setv(to_object, ['usage_metadata'], getv(from_object, ['usageMetadata']))
772
+ if getv(from_object, ['expire_time']) is not None:
773
+ setv(parent_object, ['expireTime'], getv(from_object, ['expire_time']))
1103
774
 
1104
775
  return to_object
1105
776
 
1106
777
 
1107
- def _DeleteCachedContentResponse_from_mldev(
1108
- api_client: BaseApiClient,
1109
- from_object: Union[dict, object],
1110
- parent_object: Optional[dict] = None,
1111
- ) -> dict:
778
+ def _UpdateCachedContentConfig_to_vertex(
779
+ from_object: Union[dict[str, Any], object],
780
+ parent_object: Optional[dict[str, Any]] = None,
781
+ ) -> dict[str, Any]:
1112
782
  to_object: dict[str, Any] = {}
1113
783
 
1114
- return to_object
1115
-
784
+ if getv(from_object, ['ttl']) is not None:
785
+ setv(parent_object, ['ttl'], getv(from_object, ['ttl']))
1116
786
 
1117
- def _DeleteCachedContentResponse_from_vertex(
1118
- api_client: BaseApiClient,
1119
- from_object: Union[dict, object],
1120
- parent_object: Optional[dict] = None,
1121
- ) -> dict:
1122
- to_object: dict[str, Any] = {}
787
+ if getv(from_object, ['expire_time']) is not None:
788
+ setv(parent_object, ['expireTime'], getv(from_object, ['expire_time']))
1123
789
 
1124
790
  return to_object
1125
791
 
1126
792
 
1127
- def _ListCachedContentsResponse_from_mldev(
793
+ def _UpdateCachedContentParameters_to_mldev(
1128
794
  api_client: BaseApiClient,
1129
- from_object: Union[dict, object],
1130
- parent_object: Optional[dict] = None,
1131
- ) -> dict:
795
+ from_object: Union[dict[str, Any], object],
796
+ parent_object: Optional[dict[str, Any]] = None,
797
+ ) -> dict[str, Any]:
1132
798
  to_object: dict[str, Any] = {}
1133
- if getv(from_object, ['nextPageToken']) is not None:
1134
- setv(to_object, ['next_page_token'], getv(from_object, ['nextPageToken']))
1135
-
1136
- if getv(from_object, ['cachedContents']) is not None:
799
+ if getv(from_object, ['name']) is not None:
1137
800
  setv(
1138
801
  to_object,
1139
- ['cached_contents'],
1140
- [
1141
- _CachedContent_from_mldev(api_client, item, to_object)
1142
- for item in getv(from_object, ['cachedContents'])
1143
- ],
802
+ ['_url', 'name'],
803
+ t.t_cached_content_name(api_client, getv(from_object, ['name'])),
804
+ )
805
+
806
+ if getv(from_object, ['config']) is not None:
807
+ _UpdateCachedContentConfig_to_mldev(
808
+ getv(from_object, ['config']), to_object
1144
809
  )
1145
810
 
1146
811
  return to_object
1147
812
 
1148
813
 
1149
- def _ListCachedContentsResponse_from_vertex(
814
+ def _UpdateCachedContentParameters_to_vertex(
1150
815
  api_client: BaseApiClient,
1151
- from_object: Union[dict, object],
1152
- parent_object: Optional[dict] = None,
1153
- ) -> dict:
816
+ from_object: Union[dict[str, Any], object],
817
+ parent_object: Optional[dict[str, Any]] = None,
818
+ ) -> dict[str, Any]:
1154
819
  to_object: dict[str, Any] = {}
1155
- if getv(from_object, ['nextPageToken']) is not None:
1156
- setv(to_object, ['next_page_token'], getv(from_object, ['nextPageToken']))
1157
-
1158
- if getv(from_object, ['cachedContents']) is not None:
820
+ if getv(from_object, ['name']) is not None:
1159
821
  setv(
1160
822
  to_object,
1161
- ['cached_contents'],
1162
- [
1163
- _CachedContent_from_vertex(api_client, item, to_object)
1164
- for item in getv(from_object, ['cachedContents'])
1165
- ],
823
+ ['_url', 'name'],
824
+ t.t_cached_content_name(api_client, getv(from_object, ['name'])),
825
+ )
826
+
827
+ if getv(from_object, ['config']) is not None:
828
+ _UpdateCachedContentConfig_to_vertex(
829
+ getv(from_object, ['config']), to_object
1166
830
  )
1167
831
 
1168
832
  return to_object
@@ -1225,29 +889,26 @@ class Caches(_api_module.BaseModule):
1225
889
  # TODO: remove the hack that pops config.
1226
890
  request_dict.pop('config', None)
1227
891
 
1228
- http_options: Optional[types.HttpOptionsOrDict] = None
1229
- if isinstance(config, dict):
1230
- http_options = config.get('http_options', None)
1231
- elif hasattr(config, 'http_options') and config is not None:
1232
- http_options = config.http_options
892
+ http_options: Optional[types.HttpOptions] = None
893
+ if (
894
+ parameter_model.config is not None
895
+ and parameter_model.config.http_options is not None
896
+ ):
897
+ http_options = parameter_model.config.http_options
1233
898
 
1234
899
  request_dict = _common.convert_to_dict(request_dict)
1235
900
  request_dict = _common.encode_unserializable_types(request_dict)
1236
901
 
1237
- response_dict = self._api_client.request(
902
+ response = self._api_client.request(
1238
903
  'post', path, request_dict, http_options
1239
904
  )
1240
905
 
1241
- if self._api_client.vertexai:
1242
- response_dict = _CachedContent_from_vertex(
1243
- self._api_client, response_dict
1244
- )
1245
- else:
1246
- response_dict = _CachedContent_from_mldev(self._api_client, response_dict)
906
+ response_dict = {} if not response.body else json.loads(response.body)
1247
907
 
1248
908
  return_value = types.CachedContent._from_response(
1249
909
  response=response_dict, kwargs=parameter_model.model_dump()
1250
910
  )
911
+
1251
912
  self._api_client._verify_response(return_value)
1252
913
  return return_value
1253
914
 
@@ -1295,29 +956,24 @@ class Caches(_api_module.BaseModule):
1295
956
  # TODO: remove the hack that pops config.
1296
957
  request_dict.pop('config', None)
1297
958
 
1298
- http_options: Optional[types.HttpOptionsOrDict] = None
1299
- if isinstance(config, dict):
1300
- http_options = config.get('http_options', None)
1301
- elif hasattr(config, 'http_options') and config is not None:
1302
- http_options = config.http_options
959
+ http_options: Optional[types.HttpOptions] = None
960
+ if (
961
+ parameter_model.config is not None
962
+ and parameter_model.config.http_options is not None
963
+ ):
964
+ http_options = parameter_model.config.http_options
1303
965
 
1304
966
  request_dict = _common.convert_to_dict(request_dict)
1305
967
  request_dict = _common.encode_unserializable_types(request_dict)
1306
968
 
1307
- response_dict = self._api_client.request(
1308
- 'get', path, request_dict, http_options
1309
- )
969
+ response = self._api_client.request('get', path, request_dict, http_options)
1310
970
 
1311
- if self._api_client.vertexai:
1312
- response_dict = _CachedContent_from_vertex(
1313
- self._api_client, response_dict
1314
- )
1315
- else:
1316
- response_dict = _CachedContent_from_mldev(self._api_client, response_dict)
971
+ response_dict = {} if not response.body else json.loads(response.body)
1317
972
 
1318
973
  return_value = types.CachedContent._from_response(
1319
974
  response=response_dict, kwargs=parameter_model.model_dump()
1320
975
  )
976
+
1321
977
  self._api_client._verify_response(return_value)
1322
978
  return return_value
1323
979
 
@@ -1367,31 +1023,34 @@ class Caches(_api_module.BaseModule):
1367
1023
  # TODO: remove the hack that pops config.
1368
1024
  request_dict.pop('config', None)
1369
1025
 
1370
- http_options: Optional[types.HttpOptionsOrDict] = None
1371
- if isinstance(config, dict):
1372
- http_options = config.get('http_options', None)
1373
- elif hasattr(config, 'http_options') and config is not None:
1374
- http_options = config.http_options
1026
+ http_options: Optional[types.HttpOptions] = None
1027
+ if (
1028
+ parameter_model.config is not None
1029
+ and parameter_model.config.http_options is not None
1030
+ ):
1031
+ http_options = parameter_model.config.http_options
1375
1032
 
1376
1033
  request_dict = _common.convert_to_dict(request_dict)
1377
1034
  request_dict = _common.encode_unserializable_types(request_dict)
1378
1035
 
1379
- response_dict = self._api_client.request(
1036
+ response = self._api_client.request(
1380
1037
  'delete', path, request_dict, http_options
1381
1038
  )
1382
1039
 
1040
+ response_dict = {} if not response.body else json.loads(response.body)
1041
+
1383
1042
  if self._api_client.vertexai:
1384
- response_dict = _DeleteCachedContentResponse_from_vertex(
1385
- self._api_client, response_dict
1386
- )
1387
- else:
1388
- response_dict = _DeleteCachedContentResponse_from_mldev(
1389
- self._api_client, response_dict
1390
- )
1043
+ response_dict = _DeleteCachedContentResponse_from_vertex(response_dict)
1044
+
1045
+ if not self._api_client.vertexai:
1046
+ response_dict = _DeleteCachedContentResponse_from_mldev(response_dict)
1391
1047
 
1392
1048
  return_value = types.DeleteCachedContentResponse._from_response(
1393
1049
  response=response_dict, kwargs=parameter_model.model_dump()
1394
1050
  )
1051
+ return_value.sdk_http_response = types.HttpResponse(
1052
+ headers=response.headers
1053
+ )
1395
1054
  self._api_client._verify_response(return_value)
1396
1055
  return return_value
1397
1056
 
@@ -1444,44 +1103,32 @@ class Caches(_api_module.BaseModule):
1444
1103
  # TODO: remove the hack that pops config.
1445
1104
  request_dict.pop('config', None)
1446
1105
 
1447
- http_options: Optional[types.HttpOptionsOrDict] = None
1448
- if isinstance(config, dict):
1449
- http_options = config.get('http_options', None)
1450
- elif hasattr(config, 'http_options') and config is not None:
1451
- http_options = config.http_options
1106
+ http_options: Optional[types.HttpOptions] = None
1107
+ if (
1108
+ parameter_model.config is not None
1109
+ and parameter_model.config.http_options is not None
1110
+ ):
1111
+ http_options = parameter_model.config.http_options
1452
1112
 
1453
1113
  request_dict = _common.convert_to_dict(request_dict)
1454
1114
  request_dict = _common.encode_unserializable_types(request_dict)
1455
1115
 
1456
- response_dict = self._api_client.request(
1116
+ response = self._api_client.request(
1457
1117
  'patch', path, request_dict, http_options
1458
1118
  )
1459
1119
 
1460
- if self._api_client.vertexai:
1461
- response_dict = _CachedContent_from_vertex(
1462
- self._api_client, response_dict
1463
- )
1464
- else:
1465
- response_dict = _CachedContent_from_mldev(self._api_client, response_dict)
1120
+ response_dict = {} if not response.body else json.loads(response.body)
1466
1121
 
1467
1122
  return_value = types.CachedContent._from_response(
1468
1123
  response=response_dict, kwargs=parameter_model.model_dump()
1469
1124
  )
1125
+
1470
1126
  self._api_client._verify_response(return_value)
1471
1127
  return return_value
1472
1128
 
1473
1129
  def _list(
1474
1130
  self, *, config: Optional[types.ListCachedContentsConfigOrDict] = None
1475
1131
  ) -> types.ListCachedContentsResponse:
1476
- """Lists cached content configurations.
1477
-
1478
- .. code-block:: python
1479
-
1480
- cached_contents = client.caches.list(config={'page_size': 2})
1481
- for cached_content in cached_contents:
1482
- print(cached_content)
1483
- """
1484
-
1485
1132
  parameter_model = types._ListCachedContentsParameters(
1486
1133
  config=config,
1487
1134
  )
@@ -1489,18 +1136,14 @@ class Caches(_api_module.BaseModule):
1489
1136
  request_url_dict: Optional[dict[str, str]]
1490
1137
 
1491
1138
  if self._api_client.vertexai:
1492
- request_dict = _ListCachedContentsParameters_to_vertex(
1493
- self._api_client, parameter_model
1494
- )
1139
+ request_dict = _ListCachedContentsParameters_to_vertex(parameter_model)
1495
1140
  request_url_dict = request_dict.get('_url')
1496
1141
  if request_url_dict:
1497
1142
  path = 'cachedContents'.format_map(request_url_dict)
1498
1143
  else:
1499
1144
  path = 'cachedContents'
1500
1145
  else:
1501
- request_dict = _ListCachedContentsParameters_to_mldev(
1502
- self._api_client, parameter_model
1503
- )
1146
+ request_dict = _ListCachedContentsParameters_to_mldev(parameter_model)
1504
1147
  request_url_dict = request_dict.get('_url')
1505
1148
  if request_url_dict:
1506
1149
  path = 'cachedContents'.format_map(request_url_dict)
@@ -1512,40 +1155,60 @@ class Caches(_api_module.BaseModule):
1512
1155
  # TODO: remove the hack that pops config.
1513
1156
  request_dict.pop('config', None)
1514
1157
 
1515
- http_options: Optional[types.HttpOptionsOrDict] = None
1516
- if isinstance(config, dict):
1517
- http_options = config.get('http_options', None)
1518
- elif hasattr(config, 'http_options') and config is not None:
1519
- http_options = config.http_options
1158
+ http_options: Optional[types.HttpOptions] = None
1159
+ if (
1160
+ parameter_model.config is not None
1161
+ and parameter_model.config.http_options is not None
1162
+ ):
1163
+ http_options = parameter_model.config.http_options
1520
1164
 
1521
1165
  request_dict = _common.convert_to_dict(request_dict)
1522
1166
  request_dict = _common.encode_unserializable_types(request_dict)
1523
1167
 
1524
- response_dict = self._api_client.request(
1525
- 'get', path, request_dict, http_options
1526
- )
1168
+ response = self._api_client.request('get', path, request_dict, http_options)
1169
+
1170
+ response_dict = {} if not response.body else json.loads(response.body)
1527
1171
 
1528
1172
  if self._api_client.vertexai:
1529
- response_dict = _ListCachedContentsResponse_from_vertex(
1530
- self._api_client, response_dict
1531
- )
1532
- else:
1533
- response_dict = _ListCachedContentsResponse_from_mldev(
1534
- self._api_client, response_dict
1535
- )
1173
+ response_dict = _ListCachedContentsResponse_from_vertex(response_dict)
1174
+
1175
+ if not self._api_client.vertexai:
1176
+ response_dict = _ListCachedContentsResponse_from_mldev(response_dict)
1536
1177
 
1537
1178
  return_value = types.ListCachedContentsResponse._from_response(
1538
1179
  response=response_dict, kwargs=parameter_model.model_dump()
1539
1180
  )
1181
+ return_value.sdk_http_response = types.HttpResponse(
1182
+ headers=response.headers
1183
+ )
1540
1184
  self._api_client._verify_response(return_value)
1541
1185
  return return_value
1542
1186
 
1543
1187
  def list(
1544
1188
  self, *, config: Optional[types.ListCachedContentsConfigOrDict] = None
1545
1189
  ) -> 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
1546
1209
  return Pager(
1547
1210
  'cached_contents',
1548
- self._list,
1211
+ list_request,
1549
1212
  self._list(config=config),
1550
1213
  config,
1551
1214
  )
@@ -1608,29 +1271,26 @@ class AsyncCaches(_api_module.BaseModule):
1608
1271
  # TODO: remove the hack that pops config.
1609
1272
  request_dict.pop('config', None)
1610
1273
 
1611
- http_options: Optional[types.HttpOptionsOrDict] = None
1612
- if isinstance(config, dict):
1613
- http_options = config.get('http_options', None)
1614
- elif hasattr(config, 'http_options') and config is not None:
1615
- http_options = config.http_options
1274
+ http_options: Optional[types.HttpOptions] = None
1275
+ if (
1276
+ parameter_model.config is not None
1277
+ and parameter_model.config.http_options is not None
1278
+ ):
1279
+ http_options = parameter_model.config.http_options
1616
1280
 
1617
1281
  request_dict = _common.convert_to_dict(request_dict)
1618
1282
  request_dict = _common.encode_unserializable_types(request_dict)
1619
1283
 
1620
- response_dict = await self._api_client.async_request(
1284
+ response = await self._api_client.async_request(
1621
1285
  'post', path, request_dict, http_options
1622
1286
  )
1623
1287
 
1624
- if self._api_client.vertexai:
1625
- response_dict = _CachedContent_from_vertex(
1626
- self._api_client, response_dict
1627
- )
1628
- else:
1629
- response_dict = _CachedContent_from_mldev(self._api_client, response_dict)
1288
+ response_dict = {} if not response.body else json.loads(response.body)
1630
1289
 
1631
1290
  return_value = types.CachedContent._from_response(
1632
1291
  response=response_dict, kwargs=parameter_model.model_dump()
1633
1292
  )
1293
+
1634
1294
  self._api_client._verify_response(return_value)
1635
1295
  return return_value
1636
1296
 
@@ -1679,29 +1339,26 @@ class AsyncCaches(_api_module.BaseModule):
1679
1339
  # TODO: remove the hack that pops config.
1680
1340
  request_dict.pop('config', None)
1681
1341
 
1682
- http_options: Optional[types.HttpOptionsOrDict] = None
1683
- if isinstance(config, dict):
1684
- http_options = config.get('http_options', None)
1685
- elif hasattr(config, 'http_options') and config is not None:
1686
- http_options = config.http_options
1342
+ http_options: Optional[types.HttpOptions] = None
1343
+ if (
1344
+ parameter_model.config is not None
1345
+ and parameter_model.config.http_options is not None
1346
+ ):
1347
+ http_options = parameter_model.config.http_options
1687
1348
 
1688
1349
  request_dict = _common.convert_to_dict(request_dict)
1689
1350
  request_dict = _common.encode_unserializable_types(request_dict)
1690
1351
 
1691
- response_dict = await self._api_client.async_request(
1352
+ response = await self._api_client.async_request(
1692
1353
  'get', path, request_dict, http_options
1693
1354
  )
1694
1355
 
1695
- if self._api_client.vertexai:
1696
- response_dict = _CachedContent_from_vertex(
1697
- self._api_client, response_dict
1698
- )
1699
- else:
1700
- response_dict = _CachedContent_from_mldev(self._api_client, response_dict)
1356
+ response_dict = {} if not response.body else json.loads(response.body)
1701
1357
 
1702
1358
  return_value = types.CachedContent._from_response(
1703
1359
  response=response_dict, kwargs=parameter_model.model_dump()
1704
1360
  )
1361
+
1705
1362
  self._api_client._verify_response(return_value)
1706
1363
  return return_value
1707
1364
 
@@ -1752,31 +1409,34 @@ class AsyncCaches(_api_module.BaseModule):
1752
1409
  # TODO: remove the hack that pops config.
1753
1410
  request_dict.pop('config', None)
1754
1411
 
1755
- http_options: Optional[types.HttpOptionsOrDict] = None
1756
- if isinstance(config, dict):
1757
- http_options = config.get('http_options', None)
1758
- elif hasattr(config, 'http_options') and config is not None:
1759
- http_options = config.http_options
1412
+ http_options: Optional[types.HttpOptions] = None
1413
+ if (
1414
+ parameter_model.config is not None
1415
+ and parameter_model.config.http_options is not None
1416
+ ):
1417
+ http_options = parameter_model.config.http_options
1760
1418
 
1761
1419
  request_dict = _common.convert_to_dict(request_dict)
1762
1420
  request_dict = _common.encode_unserializable_types(request_dict)
1763
1421
 
1764
- response_dict = await self._api_client.async_request(
1422
+ response = await self._api_client.async_request(
1765
1423
  'delete', path, request_dict, http_options
1766
1424
  )
1767
1425
 
1426
+ response_dict = {} if not response.body else json.loads(response.body)
1427
+
1768
1428
  if self._api_client.vertexai:
1769
- response_dict = _DeleteCachedContentResponse_from_vertex(
1770
- self._api_client, response_dict
1771
- )
1772
- else:
1773
- response_dict = _DeleteCachedContentResponse_from_mldev(
1774
- self._api_client, response_dict
1775
- )
1429
+ response_dict = _DeleteCachedContentResponse_from_vertex(response_dict)
1430
+
1431
+ if not self._api_client.vertexai:
1432
+ response_dict = _DeleteCachedContentResponse_from_mldev(response_dict)
1776
1433
 
1777
1434
  return_value = types.DeleteCachedContentResponse._from_response(
1778
1435
  response=response_dict, kwargs=parameter_model.model_dump()
1779
1436
  )
1437
+ return_value.sdk_http_response = types.HttpResponse(
1438
+ headers=response.headers
1439
+ )
1780
1440
  self._api_client._verify_response(return_value)
1781
1441
  return return_value
1782
1442
 
@@ -1829,44 +1489,32 @@ class AsyncCaches(_api_module.BaseModule):
1829
1489
  # TODO: remove the hack that pops config.
1830
1490
  request_dict.pop('config', None)
1831
1491
 
1832
- http_options: Optional[types.HttpOptionsOrDict] = None
1833
- if isinstance(config, dict):
1834
- http_options = config.get('http_options', None)
1835
- elif hasattr(config, 'http_options') and config is not None:
1836
- http_options = config.http_options
1492
+ http_options: Optional[types.HttpOptions] = None
1493
+ if (
1494
+ parameter_model.config is not None
1495
+ and parameter_model.config.http_options is not None
1496
+ ):
1497
+ http_options = parameter_model.config.http_options
1837
1498
 
1838
1499
  request_dict = _common.convert_to_dict(request_dict)
1839
1500
  request_dict = _common.encode_unserializable_types(request_dict)
1840
1501
 
1841
- response_dict = await self._api_client.async_request(
1502
+ response = await self._api_client.async_request(
1842
1503
  'patch', path, request_dict, http_options
1843
1504
  )
1844
1505
 
1845
- if self._api_client.vertexai:
1846
- response_dict = _CachedContent_from_vertex(
1847
- self._api_client, response_dict
1848
- )
1849
- else:
1850
- response_dict = _CachedContent_from_mldev(self._api_client, response_dict)
1506
+ response_dict = {} if not response.body else json.loads(response.body)
1851
1507
 
1852
1508
  return_value = types.CachedContent._from_response(
1853
1509
  response=response_dict, kwargs=parameter_model.model_dump()
1854
1510
  )
1511
+
1855
1512
  self._api_client._verify_response(return_value)
1856
1513
  return return_value
1857
1514
 
1858
1515
  async def _list(
1859
1516
  self, *, config: Optional[types.ListCachedContentsConfigOrDict] = None
1860
1517
  ) -> types.ListCachedContentsResponse:
1861
- """Lists cached content configurations.
1862
-
1863
- .. code-block:: python
1864
-
1865
- cached_contents = await client.aio.caches.list(config={'page_size': 2})
1866
- async for cached_content in cached_contents:
1867
- print(cached_content)
1868
- """
1869
-
1870
1518
  parameter_model = types._ListCachedContentsParameters(
1871
1519
  config=config,
1872
1520
  )
@@ -1874,18 +1522,14 @@ class AsyncCaches(_api_module.BaseModule):
1874
1522
  request_url_dict: Optional[dict[str, str]]
1875
1523
 
1876
1524
  if self._api_client.vertexai:
1877
- request_dict = _ListCachedContentsParameters_to_vertex(
1878
- self._api_client, parameter_model
1879
- )
1525
+ request_dict = _ListCachedContentsParameters_to_vertex(parameter_model)
1880
1526
  request_url_dict = request_dict.get('_url')
1881
1527
  if request_url_dict:
1882
1528
  path = 'cachedContents'.format_map(request_url_dict)
1883
1529
  else:
1884
1530
  path = 'cachedContents'
1885
1531
  else:
1886
- request_dict = _ListCachedContentsParameters_to_mldev(
1887
- self._api_client, parameter_model
1888
- )
1532
+ request_dict = _ListCachedContentsParameters_to_mldev(parameter_model)
1889
1533
  request_url_dict = request_dict.get('_url')
1890
1534
  if request_url_dict:
1891
1535
  path = 'cachedContents'.format_map(request_url_dict)
@@ -1897,40 +1541,62 @@ class AsyncCaches(_api_module.BaseModule):
1897
1541
  # TODO: remove the hack that pops config.
1898
1542
  request_dict.pop('config', None)
1899
1543
 
1900
- http_options: Optional[types.HttpOptionsOrDict] = None
1901
- if isinstance(config, dict):
1902
- http_options = config.get('http_options', None)
1903
- elif hasattr(config, 'http_options') and config is not None:
1904
- http_options = config.http_options
1544
+ http_options: Optional[types.HttpOptions] = None
1545
+ if (
1546
+ parameter_model.config is not None
1547
+ and parameter_model.config.http_options is not None
1548
+ ):
1549
+ http_options = parameter_model.config.http_options
1905
1550
 
1906
1551
  request_dict = _common.convert_to_dict(request_dict)
1907
1552
  request_dict = _common.encode_unserializable_types(request_dict)
1908
1553
 
1909
- response_dict = await self._api_client.async_request(
1554
+ response = await self._api_client.async_request(
1910
1555
  'get', path, request_dict, http_options
1911
1556
  )
1912
1557
 
1558
+ response_dict = {} if not response.body else json.loads(response.body)
1559
+
1913
1560
  if self._api_client.vertexai:
1914
- response_dict = _ListCachedContentsResponse_from_vertex(
1915
- self._api_client, response_dict
1916
- )
1917
- else:
1918
- response_dict = _ListCachedContentsResponse_from_mldev(
1919
- self._api_client, response_dict
1920
- )
1561
+ response_dict = _ListCachedContentsResponse_from_vertex(response_dict)
1562
+
1563
+ if not self._api_client.vertexai:
1564
+ response_dict = _ListCachedContentsResponse_from_mldev(response_dict)
1921
1565
 
1922
1566
  return_value = types.ListCachedContentsResponse._from_response(
1923
1567
  response=response_dict, kwargs=parameter_model.model_dump()
1924
1568
  )
1569
+ return_value.sdk_http_response = types.HttpResponse(
1570
+ headers=response.headers
1571
+ )
1925
1572
  self._api_client._verify_response(return_value)
1926
1573
  return return_value
1927
1574
 
1928
1575
  async def list(
1929
1576
  self, *, config: Optional[types.ListCachedContentsConfigOrDict] = None
1930
1577
  ) -> 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
1931
1597
  return AsyncPager(
1932
1598
  'cached_contents',
1933
- self._list,
1599
+ list_request,
1934
1600
  await self._list(config=config),
1935
1601
  config,
1936
1602
  )