google-genai 1.7.0__py3-none-any.whl → 1.9.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.
google/genai/files.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.
@@ -56,28 +56,6 @@ def _ListFilesConfig_to_mldev(
56
56
  return to_object
57
57
 
58
58
 
59
- def _ListFilesConfig_to_vertex(
60
- api_client: BaseApiClient,
61
- from_object: Union[dict, object],
62
- parent_object: Optional[dict] = None,
63
- ) -> dict:
64
- to_object: dict[str, Any] = {}
65
-
66
- if getv(from_object, ['page_size']) is not None:
67
- setv(
68
- parent_object, ['_query', 'pageSize'], getv(from_object, ['page_size'])
69
- )
70
-
71
- if getv(from_object, ['page_token']) is not None:
72
- setv(
73
- parent_object,
74
- ['_query', 'pageToken'],
75
- getv(from_object, ['page_token']),
76
- )
77
-
78
- return to_object
79
-
80
-
81
59
  def _ListFilesParameters_to_mldev(
82
60
  api_client: BaseApiClient,
83
61
  from_object: Union[dict, object],
@@ -96,18 +74,6 @@ def _ListFilesParameters_to_mldev(
96
74
  return to_object
97
75
 
98
76
 
99
- def _ListFilesParameters_to_vertex(
100
- api_client: BaseApiClient,
101
- from_object: Union[dict, object],
102
- parent_object: Optional[dict] = None,
103
- ) -> dict:
104
- to_object: dict[str, Any] = {}
105
- if getv(from_object, ['config']) is not None:
106
- raise ValueError('config parameter is not supported in Vertex AI.')
107
-
108
- return to_object
109
-
110
-
111
77
  def _FileStatus_to_mldev(
112
78
  api_client: BaseApiClient,
113
79
  from_object: Union[dict, object],
@@ -126,24 +92,6 @@ def _FileStatus_to_mldev(
126
92
  return to_object
127
93
 
128
94
 
129
- def _FileStatus_to_vertex(
130
- api_client: BaseApiClient,
131
- from_object: Union[dict, object],
132
- parent_object: Optional[dict] = None,
133
- ) -> dict:
134
- to_object: dict[str, Any] = {}
135
- if getv(from_object, ['details']) is not None:
136
- raise ValueError('details parameter is not supported in Vertex AI.')
137
-
138
- if getv(from_object, ['message']) is not None:
139
- raise ValueError('message parameter is not supported in Vertex AI.')
140
-
141
- if getv(from_object, ['code']) is not None:
142
- raise ValueError('code parameter is not supported in Vertex AI.')
143
-
144
- return to_object
145
-
146
-
147
95
  def _File_to_mldev(
148
96
  api_client: BaseApiClient,
149
97
  from_object: Union[dict, object],
@@ -201,57 +149,6 @@ def _File_to_mldev(
201
149
  return to_object
202
150
 
203
151
 
204
- def _File_to_vertex(
205
- api_client: BaseApiClient,
206
- from_object: Union[dict, object],
207
- parent_object: Optional[dict] = None,
208
- ) -> dict:
209
- to_object: dict[str, Any] = {}
210
- if getv(from_object, ['name']) is not None:
211
- raise ValueError('name parameter is not supported in Vertex AI.')
212
-
213
- if getv(from_object, ['display_name']) is not None:
214
- raise ValueError('display_name parameter is not supported in Vertex AI.')
215
-
216
- if getv(from_object, ['mime_type']) is not None:
217
- raise ValueError('mime_type parameter is not supported in Vertex AI.')
218
-
219
- if getv(from_object, ['size_bytes']) is not None:
220
- raise ValueError('size_bytes parameter is not supported in Vertex AI.')
221
-
222
- if getv(from_object, ['create_time']) is not None:
223
- raise ValueError('create_time parameter is not supported in Vertex AI.')
224
-
225
- if getv(from_object, ['expiration_time']) is not None:
226
- raise ValueError('expiration_time parameter is not supported in Vertex AI.')
227
-
228
- if getv(from_object, ['update_time']) is not None:
229
- raise ValueError('update_time parameter is not supported in Vertex AI.')
230
-
231
- if getv(from_object, ['sha256_hash']) is not None:
232
- raise ValueError('sha256_hash parameter is not supported in Vertex AI.')
233
-
234
- if getv(from_object, ['uri']) is not None:
235
- raise ValueError('uri parameter is not supported in Vertex AI.')
236
-
237
- if getv(from_object, ['download_uri']) is not None:
238
- raise ValueError('download_uri parameter is not supported in Vertex AI.')
239
-
240
- if getv(from_object, ['state']) is not None:
241
- raise ValueError('state parameter is not supported in Vertex AI.')
242
-
243
- if getv(from_object, ['source']) is not None:
244
- raise ValueError('source parameter is not supported in Vertex AI.')
245
-
246
- if getv(from_object, ['video_metadata']) is not None:
247
- raise ValueError('video_metadata parameter is not supported in Vertex AI.')
248
-
249
- if getv(from_object, ['error']) is not None:
250
- raise ValueError('error parameter is not supported in Vertex AI.')
251
-
252
- return to_object
253
-
254
-
255
152
  def _CreateFileParameters_to_mldev(
256
153
  api_client: BaseApiClient,
257
154
  from_object: Union[dict, object],
@@ -271,21 +168,6 @@ def _CreateFileParameters_to_mldev(
271
168
  return to_object
272
169
 
273
170
 
274
- def _CreateFileParameters_to_vertex(
275
- api_client: BaseApiClient,
276
- from_object: Union[dict, object],
277
- parent_object: Optional[dict] = None,
278
- ) -> dict:
279
- to_object: dict[str, Any] = {}
280
- if getv(from_object, ['file']) is not None:
281
- raise ValueError('file parameter is not supported in Vertex AI.')
282
-
283
- if getv(from_object, ['config']) is not None:
284
- raise ValueError('config parameter is not supported in Vertex AI.')
285
-
286
- return to_object
287
-
288
-
289
171
  def _GetFileParameters_to_mldev(
290
172
  api_client: BaseApiClient,
291
173
  from_object: Union[dict, object],
@@ -305,21 +187,6 @@ def _GetFileParameters_to_mldev(
305
187
  return to_object
306
188
 
307
189
 
308
- def _GetFileParameters_to_vertex(
309
- api_client: BaseApiClient,
310
- from_object: Union[dict, object],
311
- parent_object: Optional[dict] = None,
312
- ) -> dict:
313
- to_object: dict[str, Any] = {}
314
- if getv(from_object, ['name']) is not None:
315
- raise ValueError('name parameter is not supported in Vertex AI.')
316
-
317
- if getv(from_object, ['config']) is not None:
318
- raise ValueError('config parameter is not supported in Vertex AI.')
319
-
320
- return to_object
321
-
322
-
323
190
  def _DeleteFileParameters_to_mldev(
324
191
  api_client: BaseApiClient,
325
192
  from_object: Union[dict, object],
@@ -339,31 +206,6 @@ def _DeleteFileParameters_to_mldev(
339
206
  return to_object
340
207
 
341
208
 
342
- def _DeleteFileParameters_to_vertex(
343
- api_client: BaseApiClient,
344
- from_object: Union[dict, object],
345
- parent_object: Optional[dict] = None,
346
- ) -> dict:
347
- to_object: dict[str, Any] = {}
348
- if getv(from_object, ['name']) is not None:
349
- raise ValueError('name parameter is not supported in Vertex AI.')
350
-
351
- if getv(from_object, ['config']) is not None:
352
- raise ValueError('config parameter is not supported in Vertex AI.')
353
-
354
- return to_object
355
-
356
-
357
- def _FileState_to_vertex_enum_validate(enum_value: Any):
358
- if enum_value in set(['STATE_UNSPECIFIED', 'PROCESSING', 'ACTIVE', 'FAILED']):
359
- raise ValueError(f'{enum_value} enum value is not supported in Vertex AI.')
360
-
361
-
362
- def _FileSource_to_vertex_enum_validate(enum_value: Any):
363
- if enum_value in set(['SOURCE_UNSPECIFIED', 'UPLOADED', 'GENERATED']):
364
- raise ValueError(f'{enum_value} enum value is not supported in Vertex AI.')
365
-
366
-
367
209
  def _FileStatus_from_mldev(
368
210
  api_client: BaseApiClient,
369
211
  from_object: Union[dict, object],
@@ -382,16 +224,6 @@ def _FileStatus_from_mldev(
382
224
  return to_object
383
225
 
384
226
 
385
- def _FileStatus_from_vertex(
386
- api_client: BaseApiClient,
387
- from_object: Union[dict, object],
388
- parent_object: Optional[dict] = None,
389
- ) -> dict:
390
- to_object: dict[str, Any] = {}
391
-
392
- return to_object
393
-
394
-
395
227
  def _File_from_mldev(
396
228
  api_client: BaseApiClient,
397
229
  from_object: Union[dict, object],
@@ -449,16 +281,6 @@ def _File_from_mldev(
449
281
  return to_object
450
282
 
451
283
 
452
- def _File_from_vertex(
453
- api_client: BaseApiClient,
454
- from_object: Union[dict, object],
455
- parent_object: Optional[dict] = None,
456
- ) -> dict:
457
- to_object: dict[str, Any] = {}
458
-
459
- return to_object
460
-
461
-
462
284
  def _ListFilesResponse_from_mldev(
463
285
  api_client: BaseApiClient,
464
286
  from_object: Union[dict, object],
@@ -481,16 +303,6 @@ def _ListFilesResponse_from_mldev(
481
303
  return to_object
482
304
 
483
305
 
484
- def _ListFilesResponse_from_vertex(
485
- api_client: BaseApiClient,
486
- from_object: Union[dict, object],
487
- parent_object: Optional[dict] = None,
488
- ) -> dict:
489
- to_object: dict[str, Any] = {}
490
-
491
- return to_object
492
-
493
-
494
306
  def _CreateFileResponse_from_mldev(
495
307
  api_client: BaseApiClient,
496
308
  from_object: Union[dict, object],
@@ -503,18 +315,6 @@ def _CreateFileResponse_from_mldev(
503
315
  return to_object
504
316
 
505
317
 
506
- def _CreateFileResponse_from_vertex(
507
- api_client: BaseApiClient,
508
- from_object: Union[dict, object],
509
- parent_object: Optional[dict] = None,
510
- ) -> dict:
511
- to_object: dict[str, Any] = {}
512
- if getv(from_object, ['httpHeaders']) is not None:
513
- setv(to_object, ['http_headers'], getv(from_object, ['httpHeaders']))
514
-
515
- return to_object
516
-
517
-
518
318
  def _DeleteFileResponse_from_mldev(
519
319
  api_client: BaseApiClient,
520
320
  from_object: Union[dict, object],
@@ -525,16 +325,6 @@ def _DeleteFileResponse_from_mldev(
525
325
  return to_object
526
326
 
527
327
 
528
- def _DeleteFileResponse_from_vertex(
529
- api_client: BaseApiClient,
530
- from_object: Union[dict, object],
531
- parent_object: Optional[dict] = None,
532
- ) -> dict:
533
- to_object: dict[str, Any] = {}
534
-
535
- return to_object
536
-
537
-
538
328
  class Files(_api_module.BaseModule):
539
329
 
540
330
  def _list(
@@ -563,7 +353,9 @@ class Files(_api_module.BaseModule):
563
353
 
564
354
  request_url_dict: Optional[dict[str, str]]
565
355
  if self._api_client.vertexai:
566
- raise ValueError('This method is only supported in the default client.')
356
+ raise ValueError(
357
+ 'This method is only supported in the Gemini Developer client.'
358
+ )
567
359
  else:
568
360
  request_dict = _ListFilesParameters_to_mldev(
569
361
  self._api_client, parameter_model
@@ -580,11 +372,12 @@ class Files(_api_module.BaseModule):
580
372
  # TODO: remove the hack that pops config.
581
373
  request_dict.pop('config', None)
582
374
 
583
- http_options: Optional[types.HttpOptionsOrDict] = None
584
- if isinstance(config, dict):
585
- http_options = config.get('http_options', None)
586
- elif hasattr(config, 'http_options') and config is not None:
587
- http_options = config.http_options
375
+ http_options: Optional[types.HttpOptions] = None
376
+ if (
377
+ parameter_model.config is not None
378
+ and parameter_model.config.http_options is not None
379
+ ):
380
+ http_options = parameter_model.config.http_options
588
381
 
589
382
  request_dict = _common.convert_to_dict(request_dict)
590
383
  request_dict = _common.encode_unserializable_types(request_dict)
@@ -593,11 +386,7 @@ class Files(_api_module.BaseModule):
593
386
  'get', path, request_dict, http_options
594
387
  )
595
388
 
596
- if self._api_client.vertexai:
597
- response_dict = _ListFilesResponse_from_vertex(
598
- self._api_client, response_dict
599
- )
600
- else:
389
+ if not self._api_client.vertexai:
601
390
  response_dict = _ListFilesResponse_from_mldev(
602
391
  self._api_client, response_dict
603
392
  )
@@ -621,7 +410,9 @@ class Files(_api_module.BaseModule):
621
410
 
622
411
  request_url_dict: Optional[dict[str, str]]
623
412
  if self._api_client.vertexai:
624
- raise ValueError('This method is only supported in the default client.')
413
+ raise ValueError(
414
+ 'This method is only supported in the Gemini Developer client.'
415
+ )
625
416
  else:
626
417
  request_dict = _CreateFileParameters_to_mldev(
627
418
  self._api_client, parameter_model
@@ -638,11 +429,12 @@ class Files(_api_module.BaseModule):
638
429
  # TODO: remove the hack that pops config.
639
430
  request_dict.pop('config', None)
640
431
 
641
- http_options: Optional[types.HttpOptionsOrDict] = None
642
- if isinstance(config, dict):
643
- http_options = config.get('http_options', None)
644
- elif hasattr(config, 'http_options') and config is not None:
645
- http_options = config.http_options
432
+ http_options: Optional[types.HttpOptions] = None
433
+ if (
434
+ parameter_model.config is not None
435
+ and parameter_model.config.http_options is not None
436
+ ):
437
+ http_options = parameter_model.config.http_options
646
438
 
647
439
  request_dict = _common.convert_to_dict(request_dict)
648
440
  request_dict = _common.encode_unserializable_types(request_dict)
@@ -651,11 +443,7 @@ class Files(_api_module.BaseModule):
651
443
  'post', path, request_dict, http_options
652
444
  )
653
445
 
654
- if self._api_client.vertexai:
655
- response_dict = _CreateFileResponse_from_vertex(
656
- self._api_client, response_dict
657
- )
658
- else:
446
+ if not self._api_client.vertexai:
659
447
  response_dict = _CreateFileResponse_from_mldev(
660
448
  self._api_client, response_dict
661
449
  )
@@ -693,7 +481,9 @@ class Files(_api_module.BaseModule):
693
481
 
694
482
  request_url_dict: Optional[dict[str, str]]
695
483
  if self._api_client.vertexai:
696
- raise ValueError('This method is only supported in the default client.')
484
+ raise ValueError(
485
+ 'This method is only supported in the Gemini Developer client.'
486
+ )
697
487
  else:
698
488
  request_dict = _GetFileParameters_to_mldev(
699
489
  self._api_client, parameter_model
@@ -710,11 +500,12 @@ class Files(_api_module.BaseModule):
710
500
  # TODO: remove the hack that pops config.
711
501
  request_dict.pop('config', None)
712
502
 
713
- http_options: Optional[types.HttpOptionsOrDict] = None
714
- if isinstance(config, dict):
715
- http_options = config.get('http_options', None)
716
- elif hasattr(config, 'http_options') and config is not None:
717
- http_options = config.http_options
503
+ http_options: Optional[types.HttpOptions] = None
504
+ if (
505
+ parameter_model.config is not None
506
+ and parameter_model.config.http_options is not None
507
+ ):
508
+ http_options = parameter_model.config.http_options
718
509
 
719
510
  request_dict = _common.convert_to_dict(request_dict)
720
511
  request_dict = _common.encode_unserializable_types(request_dict)
@@ -723,9 +514,7 @@ class Files(_api_module.BaseModule):
723
514
  'get', path, request_dict, http_options
724
515
  )
725
516
 
726
- if self._api_client.vertexai:
727
- response_dict = _File_from_vertex(self._api_client, response_dict)
728
- else:
517
+ if not self._api_client.vertexai:
729
518
  response_dict = _File_from_mldev(self._api_client, response_dict)
730
519
 
731
520
  return_value = types.File._from_response(
@@ -737,7 +526,7 @@ class Files(_api_module.BaseModule):
737
526
  def delete(
738
527
  self, *, name: str, config: Optional[types.DeleteFileConfigOrDict] = None
739
528
  ) -> types.DeleteFileResponse:
740
- """Deletes an existing file from the service.
529
+ """Deletes a remotely stored file.
741
530
 
742
531
  Args:
743
532
  name (str): The name identifier for the file to delete.
@@ -760,7 +549,9 @@ class Files(_api_module.BaseModule):
760
549
 
761
550
  request_url_dict: Optional[dict[str, str]]
762
551
  if self._api_client.vertexai:
763
- raise ValueError('This method is only supported in the default client.')
552
+ raise ValueError(
553
+ 'This method is only supported in the Gemini Developer client.'
554
+ )
764
555
  else:
765
556
  request_dict = _DeleteFileParameters_to_mldev(
766
557
  self._api_client, parameter_model
@@ -777,11 +568,12 @@ class Files(_api_module.BaseModule):
777
568
  # TODO: remove the hack that pops config.
778
569
  request_dict.pop('config', None)
779
570
 
780
- http_options: Optional[types.HttpOptionsOrDict] = None
781
- if isinstance(config, dict):
782
- http_options = config.get('http_options', None)
783
- elif hasattr(config, 'http_options') and config is not None:
784
- http_options = config.http_options
571
+ http_options: Optional[types.HttpOptions] = None
572
+ if (
573
+ parameter_model.config is not None
574
+ and parameter_model.config.http_options is not None
575
+ ):
576
+ http_options = parameter_model.config.http_options
785
577
 
786
578
  request_dict = _common.convert_to_dict(request_dict)
787
579
  request_dict = _common.encode_unserializable_types(request_dict)
@@ -790,11 +582,7 @@ class Files(_api_module.BaseModule):
790
582
  'delete', path, request_dict, http_options
791
583
  )
792
584
 
793
- if self._api_client.vertexai:
794
- response_dict = _DeleteFileResponse_from_vertex(
795
- self._api_client, response_dict
796
- )
797
- else:
585
+ if not self._api_client.vertexai:
798
586
  response_dict = _DeleteFileResponse_from_mldev(
799
587
  self._api_client, response_dict
800
588
  )
@@ -823,8 +611,7 @@ class Files(_api_module.BaseModule):
823
611
  """
824
612
  if self._api_client.vertexai:
825
613
  raise ValueError(
826
- 'Vertex AI does not support creating files. You can upload files to'
827
- ' GCS files instead.'
614
+ 'This method is only supported in the Gemini Developer client.'
828
615
  )
829
616
  config_model = types.UploadFileConfig()
830
617
  if config:
@@ -906,7 +693,7 @@ class Files(_api_module.BaseModule):
906
693
  )
907
694
 
908
695
  return types.File._from_response(
909
- response=_File_from_mldev(self._api_client, return_file['file']),
696
+ response=_File_from_mldev(self._api_client, return_file.json['file']),
910
697
  kwargs=config_model.model_dump() if config else {},
911
698
  )
912
699
 
@@ -963,7 +750,7 @@ class Files(_api_module.BaseModule):
963
750
  """
964
751
  if self._api_client.vertexai:
965
752
  raise ValueError(
966
- 'Vertex AI does not support the Files API. Use GCS files instead.'
753
+ 'This method is only supported in the Gemini Developer client.'
967
754
  )
968
755
 
969
756
  config_model = None
@@ -1030,7 +817,9 @@ class AsyncFiles(_api_module.BaseModule):
1030
817
 
1031
818
  request_url_dict: Optional[dict[str, str]]
1032
819
  if self._api_client.vertexai:
1033
- raise ValueError('This method is only supported in the default client.')
820
+ raise ValueError(
821
+ 'This method is only supported in the Gemini Developer client.'
822
+ )
1034
823
  else:
1035
824
  request_dict = _ListFilesParameters_to_mldev(
1036
825
  self._api_client, parameter_model
@@ -1047,11 +836,12 @@ class AsyncFiles(_api_module.BaseModule):
1047
836
  # TODO: remove the hack that pops config.
1048
837
  request_dict.pop('config', None)
1049
838
 
1050
- http_options: Optional[types.HttpOptionsOrDict] = None
1051
- if isinstance(config, dict):
1052
- http_options = config.get('http_options', None)
1053
- elif hasattr(config, 'http_options') and config is not None:
1054
- http_options = config.http_options
839
+ http_options: Optional[types.HttpOptions] = None
840
+ if (
841
+ parameter_model.config is not None
842
+ and parameter_model.config.http_options is not None
843
+ ):
844
+ http_options = parameter_model.config.http_options
1055
845
 
1056
846
  request_dict = _common.convert_to_dict(request_dict)
1057
847
  request_dict = _common.encode_unserializable_types(request_dict)
@@ -1060,11 +850,7 @@ class AsyncFiles(_api_module.BaseModule):
1060
850
  'get', path, request_dict, http_options
1061
851
  )
1062
852
 
1063
- if self._api_client.vertexai:
1064
- response_dict = _ListFilesResponse_from_vertex(
1065
- self._api_client, response_dict
1066
- )
1067
- else:
853
+ if not self._api_client.vertexai:
1068
854
  response_dict = _ListFilesResponse_from_mldev(
1069
855
  self._api_client, response_dict
1070
856
  )
@@ -1088,7 +874,9 @@ class AsyncFiles(_api_module.BaseModule):
1088
874
 
1089
875
  request_url_dict: Optional[dict[str, str]]
1090
876
  if self._api_client.vertexai:
1091
- raise ValueError('This method is only supported in the default client.')
877
+ raise ValueError(
878
+ 'This method is only supported in the Gemini Developer client.'
879
+ )
1092
880
  else:
1093
881
  request_dict = _CreateFileParameters_to_mldev(
1094
882
  self._api_client, parameter_model
@@ -1105,11 +893,12 @@ class AsyncFiles(_api_module.BaseModule):
1105
893
  # TODO: remove the hack that pops config.
1106
894
  request_dict.pop('config', None)
1107
895
 
1108
- http_options: Optional[types.HttpOptionsOrDict] = None
1109
- if isinstance(config, dict):
1110
- http_options = config.get('http_options', None)
1111
- elif hasattr(config, 'http_options') and config is not None:
1112
- http_options = config.http_options
896
+ http_options: Optional[types.HttpOptions] = None
897
+ if (
898
+ parameter_model.config is not None
899
+ and parameter_model.config.http_options is not None
900
+ ):
901
+ http_options = parameter_model.config.http_options
1113
902
 
1114
903
  request_dict = _common.convert_to_dict(request_dict)
1115
904
  request_dict = _common.encode_unserializable_types(request_dict)
@@ -1118,11 +907,7 @@ class AsyncFiles(_api_module.BaseModule):
1118
907
  'post', path, request_dict, http_options
1119
908
  )
1120
909
 
1121
- if self._api_client.vertexai:
1122
- response_dict = _CreateFileResponse_from_vertex(
1123
- self._api_client, response_dict
1124
- )
1125
- else:
910
+ if not self._api_client.vertexai:
1126
911
  response_dict = _CreateFileResponse_from_mldev(
1127
912
  self._api_client, response_dict
1128
913
  )
@@ -1160,7 +945,9 @@ class AsyncFiles(_api_module.BaseModule):
1160
945
 
1161
946
  request_url_dict: Optional[dict[str, str]]
1162
947
  if self._api_client.vertexai:
1163
- raise ValueError('This method is only supported in the default client.')
948
+ raise ValueError(
949
+ 'This method is only supported in the Gemini Developer client.'
950
+ )
1164
951
  else:
1165
952
  request_dict = _GetFileParameters_to_mldev(
1166
953
  self._api_client, parameter_model
@@ -1177,11 +964,12 @@ class AsyncFiles(_api_module.BaseModule):
1177
964
  # TODO: remove the hack that pops config.
1178
965
  request_dict.pop('config', None)
1179
966
 
1180
- http_options: Optional[types.HttpOptionsOrDict] = None
1181
- if isinstance(config, dict):
1182
- http_options = config.get('http_options', None)
1183
- elif hasattr(config, 'http_options') and config is not None:
1184
- http_options = config.http_options
967
+ http_options: Optional[types.HttpOptions] = None
968
+ if (
969
+ parameter_model.config is not None
970
+ and parameter_model.config.http_options is not None
971
+ ):
972
+ http_options = parameter_model.config.http_options
1185
973
 
1186
974
  request_dict = _common.convert_to_dict(request_dict)
1187
975
  request_dict = _common.encode_unserializable_types(request_dict)
@@ -1190,9 +978,7 @@ class AsyncFiles(_api_module.BaseModule):
1190
978
  'get', path, request_dict, http_options
1191
979
  )
1192
980
 
1193
- if self._api_client.vertexai:
1194
- response_dict = _File_from_vertex(self._api_client, response_dict)
1195
- else:
981
+ if not self._api_client.vertexai:
1196
982
  response_dict = _File_from_mldev(self._api_client, response_dict)
1197
983
 
1198
984
  return_value = types.File._from_response(
@@ -1204,7 +990,7 @@ class AsyncFiles(_api_module.BaseModule):
1204
990
  async def delete(
1205
991
  self, *, name: str, config: Optional[types.DeleteFileConfigOrDict] = None
1206
992
  ) -> types.DeleteFileResponse:
1207
- """Deletes an existing file from the service.
993
+ """Deletes a remotely stored file.
1208
994
 
1209
995
  Args:
1210
996
  name (str): The name identifier for the file to delete.
@@ -1227,7 +1013,9 @@ class AsyncFiles(_api_module.BaseModule):
1227
1013
 
1228
1014
  request_url_dict: Optional[dict[str, str]]
1229
1015
  if self._api_client.vertexai:
1230
- raise ValueError('This method is only supported in the default client.')
1016
+ raise ValueError(
1017
+ 'This method is only supported in the Gemini Developer client.'
1018
+ )
1231
1019
  else:
1232
1020
  request_dict = _DeleteFileParameters_to_mldev(
1233
1021
  self._api_client, parameter_model
@@ -1244,11 +1032,12 @@ class AsyncFiles(_api_module.BaseModule):
1244
1032
  # TODO: remove the hack that pops config.
1245
1033
  request_dict.pop('config', None)
1246
1034
 
1247
- http_options: Optional[types.HttpOptionsOrDict] = None
1248
- if isinstance(config, dict):
1249
- http_options = config.get('http_options', None)
1250
- elif hasattr(config, 'http_options') and config is not None:
1251
- http_options = config.http_options
1035
+ http_options: Optional[types.HttpOptions] = None
1036
+ if (
1037
+ parameter_model.config is not None
1038
+ and parameter_model.config.http_options is not None
1039
+ ):
1040
+ http_options = parameter_model.config.http_options
1252
1041
 
1253
1042
  request_dict = _common.convert_to_dict(request_dict)
1254
1043
  request_dict = _common.encode_unserializable_types(request_dict)
@@ -1257,11 +1046,7 @@ class AsyncFiles(_api_module.BaseModule):
1257
1046
  'delete', path, request_dict, http_options
1258
1047
  )
1259
1048
 
1260
- if self._api_client.vertexai:
1261
- response_dict = _DeleteFileResponse_from_vertex(
1262
- self._api_client, response_dict
1263
- )
1264
- else:
1049
+ if not self._api_client.vertexai:
1265
1050
  response_dict = _DeleteFileResponse_from_mldev(
1266
1051
  self._api_client, response_dict
1267
1052
  )
@@ -1290,8 +1075,7 @@ class AsyncFiles(_api_module.BaseModule):
1290
1075
  """
1291
1076
  if self._api_client.vertexai:
1292
1077
  raise ValueError(
1293
- 'Vertex AI does not support creating files. You can upload files to'
1294
- ' GCS files instead.'
1078
+ 'This method is only supported in the Gemini Developer client.'
1295
1079
  )
1296
1080
  config_model = types.UploadFileConfig()
1297
1081
  if config:
@@ -1372,7 +1156,7 @@ class AsyncFiles(_api_module.BaseModule):
1372
1156
  )
1373
1157
 
1374
1158
  return types.File._from_response(
1375
- response=_File_from_mldev(self._api_client, return_file['file']),
1159
+ response=_File_from_mldev(self._api_client, return_file.json['file']),
1376
1160
  kwargs=config_model.model_dump() if config else {},
1377
1161
  )
1378
1162
 
@@ -1423,7 +1207,7 @@ class AsyncFiles(_api_module.BaseModule):
1423
1207
  """
1424
1208
  if self._api_client.vertexai:
1425
1209
  raise ValueError(
1426
- 'Vertex AI does not support the Files API. Use GCS files instead.'
1210
+ 'This method is only supported in the Gemini Developer client.'
1427
1211
  )
1428
1212
 
1429
1213
  config_model = None