google-genai 1.2.0__py3-none-any.whl → 1.4.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
@@ -16,6 +16,7 @@
16
16
  # Code generated by the Google Gen AI SDK generator DO NOT EDIT.
17
17
 
18
18
  import io
19
+ import logging
19
20
  import mimetypes
20
21
  import os
21
22
  import pathlib
@@ -25,18 +26,20 @@ from . import _api_module
25
26
  from . import _common
26
27
  from . import _transformers as t
27
28
  from . import types
28
- from ._api_client import ApiClient
29
+ from ._api_client import BaseApiClient
29
30
  from ._common import get_value_by_path as getv
30
31
  from ._common import set_value_by_path as setv
31
32
  from .pagers import AsyncPager, Pager
32
33
 
34
+ logger = logging.getLogger('google_genai.files')
35
+
33
36
 
34
37
  def _ListFilesConfig_to_mldev(
35
- api_client: ApiClient,
38
+ api_client: BaseApiClient,
36
39
  from_object: Union[dict, object],
37
- parent_object: dict = None,
40
+ parent_object: Optional[dict] = None,
38
41
  ) -> dict:
39
- to_object = {}
42
+ to_object: dict[str, Any] = {}
40
43
 
41
44
  if getv(from_object, ['page_size']) is not None:
42
45
  setv(
@@ -54,11 +57,11 @@ def _ListFilesConfig_to_mldev(
54
57
 
55
58
 
56
59
  def _ListFilesConfig_to_vertex(
57
- api_client: ApiClient,
60
+ api_client: BaseApiClient,
58
61
  from_object: Union[dict, object],
59
- parent_object: dict = None,
62
+ parent_object: Optional[dict] = None,
60
63
  ) -> dict:
61
- to_object = {}
64
+ to_object: dict[str, Any] = {}
62
65
 
63
66
  if getv(from_object, ['page_size']) is not None:
64
67
  setv(
@@ -76,11 +79,11 @@ def _ListFilesConfig_to_vertex(
76
79
 
77
80
 
78
81
  def _ListFilesParameters_to_mldev(
79
- api_client: ApiClient,
82
+ api_client: BaseApiClient,
80
83
  from_object: Union[dict, object],
81
- parent_object: dict = None,
84
+ parent_object: Optional[dict] = None,
82
85
  ) -> dict:
83
- to_object = {}
86
+ to_object: dict[str, Any] = {}
84
87
  if getv(from_object, ['config']) is not None:
85
88
  setv(
86
89
  to_object,
@@ -94,11 +97,11 @@ def _ListFilesParameters_to_mldev(
94
97
 
95
98
 
96
99
  def _ListFilesParameters_to_vertex(
97
- api_client: ApiClient,
100
+ api_client: BaseApiClient,
98
101
  from_object: Union[dict, object],
99
- parent_object: dict = None,
102
+ parent_object: Optional[dict] = None,
100
103
  ) -> dict:
101
- to_object = {}
104
+ to_object: dict[str, Any] = {}
102
105
  if getv(from_object, ['config']) is not None:
103
106
  raise ValueError('config parameter is not supported in Vertex AI.')
104
107
 
@@ -106,11 +109,11 @@ def _ListFilesParameters_to_vertex(
106
109
 
107
110
 
108
111
  def _FileStatus_to_mldev(
109
- api_client: ApiClient,
112
+ api_client: BaseApiClient,
110
113
  from_object: Union[dict, object],
111
- parent_object: dict = None,
114
+ parent_object: Optional[dict] = None,
112
115
  ) -> dict:
113
- to_object = {}
116
+ to_object: dict[str, Any] = {}
114
117
  if getv(from_object, ['details']) is not None:
115
118
  setv(to_object, ['details'], getv(from_object, ['details']))
116
119
 
@@ -124,11 +127,11 @@ def _FileStatus_to_mldev(
124
127
 
125
128
 
126
129
  def _FileStatus_to_vertex(
127
- api_client: ApiClient,
130
+ api_client: BaseApiClient,
128
131
  from_object: Union[dict, object],
129
- parent_object: dict = None,
132
+ parent_object: Optional[dict] = None,
130
133
  ) -> dict:
131
- to_object = {}
134
+ to_object: dict[str, Any] = {}
132
135
  if getv(from_object, ['details']) is not None:
133
136
  raise ValueError('details parameter is not supported in Vertex AI.')
134
137
 
@@ -142,11 +145,11 @@ def _FileStatus_to_vertex(
142
145
 
143
146
 
144
147
  def _File_to_mldev(
145
- api_client: ApiClient,
148
+ api_client: BaseApiClient,
146
149
  from_object: Union[dict, object],
147
- parent_object: dict = None,
150
+ parent_object: Optional[dict] = None,
148
151
  ) -> dict:
149
- to_object = {}
152
+ to_object: dict[str, Any] = {}
150
153
  if getv(from_object, ['name']) is not None:
151
154
  setv(to_object, ['name'], getv(from_object, ['name']))
152
155
 
@@ -199,11 +202,11 @@ def _File_to_mldev(
199
202
 
200
203
 
201
204
  def _File_to_vertex(
202
- api_client: ApiClient,
205
+ api_client: BaseApiClient,
203
206
  from_object: Union[dict, object],
204
- parent_object: dict = None,
207
+ parent_object: Optional[dict] = None,
205
208
  ) -> dict:
206
- to_object = {}
209
+ to_object: dict[str, Any] = {}
207
210
  if getv(from_object, ['name']) is not None:
208
211
  raise ValueError('name parameter is not supported in Vertex AI.')
209
212
 
@@ -250,11 +253,11 @@ def _File_to_vertex(
250
253
 
251
254
 
252
255
  def _CreateFileParameters_to_mldev(
253
- api_client: ApiClient,
256
+ api_client: BaseApiClient,
254
257
  from_object: Union[dict, object],
255
- parent_object: dict = None,
258
+ parent_object: Optional[dict] = None,
256
259
  ) -> dict:
257
- to_object = {}
260
+ to_object: dict[str, Any] = {}
258
261
  if getv(from_object, ['file']) is not None:
259
262
  setv(
260
263
  to_object,
@@ -269,11 +272,11 @@ def _CreateFileParameters_to_mldev(
269
272
 
270
273
 
271
274
  def _CreateFileParameters_to_vertex(
272
- api_client: ApiClient,
275
+ api_client: BaseApiClient,
273
276
  from_object: Union[dict, object],
274
- parent_object: dict = None,
277
+ parent_object: Optional[dict] = None,
275
278
  ) -> dict:
276
- to_object = {}
279
+ to_object: dict[str, Any] = {}
277
280
  if getv(from_object, ['file']) is not None:
278
281
  raise ValueError('file parameter is not supported in Vertex AI.')
279
282
 
@@ -284,11 +287,11 @@ def _CreateFileParameters_to_vertex(
284
287
 
285
288
 
286
289
  def _GetFileParameters_to_mldev(
287
- api_client: ApiClient,
290
+ api_client: BaseApiClient,
288
291
  from_object: Union[dict, object],
289
- parent_object: dict = None,
292
+ parent_object: Optional[dict] = None,
290
293
  ) -> dict:
291
- to_object = {}
294
+ to_object: dict[str, Any] = {}
292
295
  if getv(from_object, ['name']) is not None:
293
296
  setv(
294
297
  to_object,
@@ -303,11 +306,11 @@ def _GetFileParameters_to_mldev(
303
306
 
304
307
 
305
308
  def _GetFileParameters_to_vertex(
306
- api_client: ApiClient,
309
+ api_client: BaseApiClient,
307
310
  from_object: Union[dict, object],
308
- parent_object: dict = None,
311
+ parent_object: Optional[dict] = None,
309
312
  ) -> dict:
310
- to_object = {}
313
+ to_object: dict[str, Any] = {}
311
314
  if getv(from_object, ['name']) is not None:
312
315
  raise ValueError('name parameter is not supported in Vertex AI.')
313
316
 
@@ -318,11 +321,11 @@ def _GetFileParameters_to_vertex(
318
321
 
319
322
 
320
323
  def _DeleteFileParameters_to_mldev(
321
- api_client: ApiClient,
324
+ api_client: BaseApiClient,
322
325
  from_object: Union[dict, object],
323
- parent_object: dict = None,
326
+ parent_object: Optional[dict] = None,
324
327
  ) -> dict:
325
- to_object = {}
328
+ to_object: dict[str, Any] = {}
326
329
  if getv(from_object, ['name']) is not None:
327
330
  setv(
328
331
  to_object,
@@ -337,11 +340,11 @@ def _DeleteFileParameters_to_mldev(
337
340
 
338
341
 
339
342
  def _DeleteFileParameters_to_vertex(
340
- api_client: ApiClient,
343
+ api_client: BaseApiClient,
341
344
  from_object: Union[dict, object],
342
- parent_object: dict = None,
345
+ parent_object: Optional[dict] = None,
343
346
  ) -> dict:
344
- to_object = {}
347
+ to_object: dict[str, Any] = {}
345
348
  if getv(from_object, ['name']) is not None:
346
349
  raise ValueError('name parameter is not supported in Vertex AI.')
347
350
 
@@ -362,11 +365,11 @@ def _FileSource_to_vertex_enum_validate(enum_value: Any):
362
365
 
363
366
 
364
367
  def _FileStatus_from_mldev(
365
- api_client: ApiClient,
368
+ api_client: BaseApiClient,
366
369
  from_object: Union[dict, object],
367
- parent_object: dict = None,
370
+ parent_object: Optional[dict] = None,
368
371
  ) -> dict:
369
- to_object = {}
372
+ to_object: dict[str, Any] = {}
370
373
  if getv(from_object, ['details']) is not None:
371
374
  setv(to_object, ['details'], getv(from_object, ['details']))
372
375
 
@@ -380,21 +383,21 @@ def _FileStatus_from_mldev(
380
383
 
381
384
 
382
385
  def _FileStatus_from_vertex(
383
- api_client: ApiClient,
386
+ api_client: BaseApiClient,
384
387
  from_object: Union[dict, object],
385
- parent_object: dict = None,
388
+ parent_object: Optional[dict] = None,
386
389
  ) -> dict:
387
- to_object = {}
390
+ to_object: dict[str, Any] = {}
388
391
 
389
392
  return to_object
390
393
 
391
394
 
392
395
  def _File_from_mldev(
393
- api_client: ApiClient,
396
+ api_client: BaseApiClient,
394
397
  from_object: Union[dict, object],
395
- parent_object: dict = None,
398
+ parent_object: Optional[dict] = None,
396
399
  ) -> dict:
397
- to_object = {}
400
+ to_object: dict[str, Any] = {}
398
401
  if getv(from_object, ['name']) is not None:
399
402
  setv(to_object, ['name'], getv(from_object, ['name']))
400
403
 
@@ -447,21 +450,21 @@ def _File_from_mldev(
447
450
 
448
451
 
449
452
  def _File_from_vertex(
450
- api_client: ApiClient,
453
+ api_client: BaseApiClient,
451
454
  from_object: Union[dict, object],
452
- parent_object: dict = None,
455
+ parent_object: Optional[dict] = None,
453
456
  ) -> dict:
454
- to_object = {}
457
+ to_object: dict[str, Any] = {}
455
458
 
456
459
  return to_object
457
460
 
458
461
 
459
462
  def _ListFilesResponse_from_mldev(
460
- api_client: ApiClient,
463
+ api_client: BaseApiClient,
461
464
  from_object: Union[dict, object],
462
- parent_object: dict = None,
465
+ parent_object: Optional[dict] = None,
463
466
  ) -> dict:
464
- to_object = {}
467
+ to_object: dict[str, Any] = {}
465
468
  if getv(from_object, ['nextPageToken']) is not None:
466
469
  setv(to_object, ['next_page_token'], getv(from_object, ['nextPageToken']))
467
470
 
@@ -479,21 +482,21 @@ def _ListFilesResponse_from_mldev(
479
482
 
480
483
 
481
484
  def _ListFilesResponse_from_vertex(
482
- api_client: ApiClient,
485
+ api_client: BaseApiClient,
483
486
  from_object: Union[dict, object],
484
- parent_object: dict = None,
487
+ parent_object: Optional[dict] = None,
485
488
  ) -> dict:
486
- to_object = {}
489
+ to_object: dict[str, Any] = {}
487
490
 
488
491
  return to_object
489
492
 
490
493
 
491
494
  def _CreateFileResponse_from_mldev(
492
- api_client: ApiClient,
495
+ api_client: BaseApiClient,
493
496
  from_object: Union[dict, object],
494
- parent_object: dict = None,
497
+ parent_object: Optional[dict] = None,
495
498
  ) -> dict:
496
- to_object = {}
499
+ to_object: dict[str, Any] = {}
497
500
  if getv(from_object, ['httpHeaders']) is not None:
498
501
  setv(to_object, ['http_headers'], getv(from_object, ['httpHeaders']))
499
502
 
@@ -501,11 +504,11 @@ def _CreateFileResponse_from_mldev(
501
504
 
502
505
 
503
506
  def _CreateFileResponse_from_vertex(
504
- api_client: ApiClient,
507
+ api_client: BaseApiClient,
505
508
  from_object: Union[dict, object],
506
- parent_object: dict = None,
509
+ parent_object: Optional[dict] = None,
507
510
  ) -> dict:
508
- to_object = {}
511
+ to_object: dict[str, Any] = {}
509
512
  if getv(from_object, ['httpHeaders']) is not None:
510
513
  setv(to_object, ['http_headers'], getv(from_object, ['httpHeaders']))
511
514
 
@@ -513,21 +516,21 @@ def _CreateFileResponse_from_vertex(
513
516
 
514
517
 
515
518
  def _DeleteFileResponse_from_mldev(
516
- api_client: ApiClient,
519
+ api_client: BaseApiClient,
517
520
  from_object: Union[dict, object],
518
- parent_object: dict = None,
521
+ parent_object: Optional[dict] = None,
519
522
  ) -> dict:
520
- to_object = {}
523
+ to_object: dict[str, Any] = {}
521
524
 
522
525
  return to_object
523
526
 
524
527
 
525
528
  def _DeleteFileResponse_from_vertex(
526
- api_client: ApiClient,
529
+ api_client: BaseApiClient,
527
530
  from_object: Union[dict, object],
528
- parent_object: dict = None,
531
+ parent_object: Optional[dict] = None,
529
532
  ) -> dict:
530
- to_object = {}
533
+ to_object: dict[str, Any] = {}
531
534
 
532
535
  return to_object
533
536
 
@@ -558,13 +561,18 @@ class Files(_api_module.BaseModule):
558
561
  config=config,
559
562
  )
560
563
 
564
+ request_url_dict: Optional[dict[str, str]]
561
565
  if self._api_client.vertexai:
562
566
  raise ValueError('This method is only supported in the default client.')
563
567
  else:
564
568
  request_dict = _ListFilesParameters_to_mldev(
565
569
  self._api_client, parameter_model
566
570
  )
567
- path = 'files'.format_map(request_dict.get('_url'))
571
+ request_url_dict = request_dict.get('_url')
572
+ if request_url_dict:
573
+ path = 'files'.format_map(request_url_dict)
574
+ else:
575
+ path = 'files'
568
576
 
569
577
  query_params = request_dict.get('_query')
570
578
  if query_params:
@@ -572,7 +580,7 @@ class Files(_api_module.BaseModule):
572
580
  # TODO: remove the hack that pops config.
573
581
  request_dict.pop('config', None)
574
582
 
575
- http_options = None
583
+ http_options: Optional[types.HttpOptionsOrDict] = None
576
584
  if isinstance(config, dict):
577
585
  http_options = config.get('http_options', None)
578
586
  elif hasattr(config, 'http_options'):
@@ -595,7 +603,7 @@ class Files(_api_module.BaseModule):
595
603
  )
596
604
 
597
605
  return_value = types.ListFilesResponse._from_response(
598
- response=response_dict, kwargs=parameter_model
606
+ response=response_dict, kwargs=parameter_model.model_dump()
599
607
  )
600
608
  self._api_client._verify_response(return_value)
601
609
  return return_value
@@ -611,13 +619,18 @@ class Files(_api_module.BaseModule):
611
619
  config=config,
612
620
  )
613
621
 
622
+ request_url_dict: Optional[dict[str, str]]
614
623
  if self._api_client.vertexai:
615
624
  raise ValueError('This method is only supported in the default client.')
616
625
  else:
617
626
  request_dict = _CreateFileParameters_to_mldev(
618
627
  self._api_client, parameter_model
619
628
  )
620
- path = 'upload/v1beta/files'.format_map(request_dict.get('_url'))
629
+ request_url_dict = request_dict.get('_url')
630
+ if request_url_dict:
631
+ path = 'upload/v1beta/files'.format_map(request_url_dict)
632
+ else:
633
+ path = 'upload/v1beta/files'
621
634
 
622
635
  query_params = request_dict.get('_query')
623
636
  if query_params:
@@ -625,7 +638,7 @@ class Files(_api_module.BaseModule):
625
638
  # TODO: remove the hack that pops config.
626
639
  request_dict.pop('config', None)
627
640
 
628
- http_options = None
641
+ http_options: Optional[types.HttpOptionsOrDict] = None
629
642
  if isinstance(config, dict):
630
643
  http_options = config.get('http_options', None)
631
644
  elif hasattr(config, 'http_options'):
@@ -648,7 +661,7 @@ class Files(_api_module.BaseModule):
648
661
  )
649
662
 
650
663
  return_value = types.CreateFileResponse._from_response(
651
- response=response_dict, kwargs=parameter_model
664
+ response=response_dict, kwargs=parameter_model.model_dump()
652
665
  )
653
666
  self._api_client._verify_response(return_value)
654
667
  return return_value
@@ -678,13 +691,18 @@ class Files(_api_module.BaseModule):
678
691
  config=config,
679
692
  )
680
693
 
694
+ request_url_dict: Optional[dict[str, str]]
681
695
  if self._api_client.vertexai:
682
696
  raise ValueError('This method is only supported in the default client.')
683
697
  else:
684
698
  request_dict = _GetFileParameters_to_mldev(
685
699
  self._api_client, parameter_model
686
700
  )
687
- path = 'files/{file}'.format_map(request_dict.get('_url'))
701
+ request_url_dict = request_dict.get('_url')
702
+ if request_url_dict:
703
+ path = 'files/{file}'.format_map(request_url_dict)
704
+ else:
705
+ path = 'files/{file}'
688
706
 
689
707
  query_params = request_dict.get('_query')
690
708
  if query_params:
@@ -692,7 +710,7 @@ class Files(_api_module.BaseModule):
692
710
  # TODO: remove the hack that pops config.
693
711
  request_dict.pop('config', None)
694
712
 
695
- http_options = None
713
+ http_options: Optional[types.HttpOptionsOrDict] = None
696
714
  if isinstance(config, dict):
697
715
  http_options = config.get('http_options', None)
698
716
  elif hasattr(config, 'http_options'):
@@ -711,7 +729,7 @@ class Files(_api_module.BaseModule):
711
729
  response_dict = _File_from_mldev(self._api_client, response_dict)
712
730
 
713
731
  return_value = types.File._from_response(
714
- response=response_dict, kwargs=parameter_model
732
+ response=response_dict, kwargs=parameter_model.model_dump()
715
733
  )
716
734
  self._api_client._verify_response(return_value)
717
735
  return return_value
@@ -740,13 +758,18 @@ class Files(_api_module.BaseModule):
740
758
  config=config,
741
759
  )
742
760
 
761
+ request_url_dict: Optional[dict[str, str]]
743
762
  if self._api_client.vertexai:
744
763
  raise ValueError('This method is only supported in the default client.')
745
764
  else:
746
765
  request_dict = _DeleteFileParameters_to_mldev(
747
766
  self._api_client, parameter_model
748
767
  )
749
- path = 'files/{file}'.format_map(request_dict.get('_url'))
768
+ request_url_dict = request_dict.get('_url')
769
+ if request_url_dict:
770
+ path = 'files/{file}'.format_map(request_url_dict)
771
+ else:
772
+ path = 'files/{file}'
750
773
 
751
774
  query_params = request_dict.get('_query')
752
775
  if query_params:
@@ -754,7 +777,7 @@ class Files(_api_module.BaseModule):
754
777
  # TODO: remove the hack that pops config.
755
778
  request_dict.pop('config', None)
756
779
 
757
- http_options = None
780
+ http_options: Optional[types.HttpOptionsOrDict] = None
758
781
  if isinstance(config, dict):
759
782
  http_options = config.get('http_options', None)
760
783
  elif hasattr(config, 'http_options'):
@@ -777,7 +800,7 @@ class Files(_api_module.BaseModule):
777
800
  )
778
801
 
779
802
  return_value = types.DeleteFileResponse._from_response(
780
- response=response_dict, kwargs=parameter_model
803
+ response=response_dict, kwargs=parameter_model.model_dump()
781
804
  )
782
805
  self._api_client._verify_response(return_value)
783
806
  return return_value
@@ -845,21 +868,22 @@ class Files(_api_module.BaseModule):
845
868
  ' file\n please set the `mime_type` argument'
846
869
  )
847
870
 
871
+ http_options: types.HttpOptions
848
872
  if config_model and config_model.http_options:
849
873
  http_options = config_model.http_options
850
874
  else:
851
- http_options = {
852
- 'api_version': '', # api-version is set in the path.
853
- 'headers': {
875
+ http_options = types.HttpOptions(
876
+ api_version='',
877
+ headers={
854
878
  'Content-Type': 'application/json',
855
879
  'X-Goog-Upload-Protocol': 'resumable',
856
880
  'X-Goog-Upload-Command': 'start',
857
881
  'X-Goog-Upload-Header-Content-Length': f'{file_obj.size_bytes}',
858
882
  'X-Goog-Upload-Header-Content-Type': f'{file_obj.mime_type}',
859
883
  },
860
- }
884
+ )
861
885
  response = self._create(
862
- file=file_obj, config={'http_options': http_options}
886
+ file=file_obj, config=types.CreateFileConfig(http_options=http_options)
863
887
  )
864
888
 
865
889
  if (
@@ -882,7 +906,8 @@ class Files(_api_module.BaseModule):
882
906
  )
883
907
 
884
908
  return types.File._from_response(
885
- _File_from_mldev(self._api_client, return_file['file']), None
909
+ response=_File_from_mldev(self._api_client, return_file['file']),
910
+ kwargs=None,
886
911
  )
887
912
 
888
913
  def list(
@@ -981,7 +1006,7 @@ class AsyncFiles(_api_module.BaseModule):
981
1006
 
982
1007
  .. code-block:: python
983
1008
 
984
- pager = client.files.list(config={'page_size': 10})
1009
+ pager = await client.aio.files.list(config={'page_size': 10})
985
1010
  for file in pager.page:
986
1011
  print(file.name)
987
1012
  """
@@ -990,13 +1015,18 @@ class AsyncFiles(_api_module.BaseModule):
990
1015
  config=config,
991
1016
  )
992
1017
 
1018
+ request_url_dict: Optional[dict[str, str]]
993
1019
  if self._api_client.vertexai:
994
1020
  raise ValueError('This method is only supported in the default client.')
995
1021
  else:
996
1022
  request_dict = _ListFilesParameters_to_mldev(
997
1023
  self._api_client, parameter_model
998
1024
  )
999
- path = 'files'.format_map(request_dict.get('_url'))
1025
+ request_url_dict = request_dict.get('_url')
1026
+ if request_url_dict:
1027
+ path = 'files'.format_map(request_url_dict)
1028
+ else:
1029
+ path = 'files'
1000
1030
 
1001
1031
  query_params = request_dict.get('_query')
1002
1032
  if query_params:
@@ -1004,7 +1034,7 @@ class AsyncFiles(_api_module.BaseModule):
1004
1034
  # TODO: remove the hack that pops config.
1005
1035
  request_dict.pop('config', None)
1006
1036
 
1007
- http_options = None
1037
+ http_options: Optional[types.HttpOptionsOrDict] = None
1008
1038
  if isinstance(config, dict):
1009
1039
  http_options = config.get('http_options', None)
1010
1040
  elif hasattr(config, 'http_options'):
@@ -1027,7 +1057,7 @@ class AsyncFiles(_api_module.BaseModule):
1027
1057
  )
1028
1058
 
1029
1059
  return_value = types.ListFilesResponse._from_response(
1030
- response=response_dict, kwargs=parameter_model
1060
+ response=response_dict, kwargs=parameter_model.model_dump()
1031
1061
  )
1032
1062
  self._api_client._verify_response(return_value)
1033
1063
  return return_value
@@ -1043,13 +1073,18 @@ class AsyncFiles(_api_module.BaseModule):
1043
1073
  config=config,
1044
1074
  )
1045
1075
 
1076
+ request_url_dict: Optional[dict[str, str]]
1046
1077
  if self._api_client.vertexai:
1047
1078
  raise ValueError('This method is only supported in the default client.')
1048
1079
  else:
1049
1080
  request_dict = _CreateFileParameters_to_mldev(
1050
1081
  self._api_client, parameter_model
1051
1082
  )
1052
- path = 'upload/v1beta/files'.format_map(request_dict.get('_url'))
1083
+ request_url_dict = request_dict.get('_url')
1084
+ if request_url_dict:
1085
+ path = 'upload/v1beta/files'.format_map(request_url_dict)
1086
+ else:
1087
+ path = 'upload/v1beta/files'
1053
1088
 
1054
1089
  query_params = request_dict.get('_query')
1055
1090
  if query_params:
@@ -1057,7 +1092,7 @@ class AsyncFiles(_api_module.BaseModule):
1057
1092
  # TODO: remove the hack that pops config.
1058
1093
  request_dict.pop('config', None)
1059
1094
 
1060
- http_options = None
1095
+ http_options: Optional[types.HttpOptionsOrDict] = None
1061
1096
  if isinstance(config, dict):
1062
1097
  http_options = config.get('http_options', None)
1063
1098
  elif hasattr(config, 'http_options'):
@@ -1080,7 +1115,7 @@ class AsyncFiles(_api_module.BaseModule):
1080
1115
  )
1081
1116
 
1082
1117
  return_value = types.CreateFileResponse._from_response(
1083
- response=response_dict, kwargs=parameter_model
1118
+ response=response_dict, kwargs=parameter_model.model_dump()
1084
1119
  )
1085
1120
  self._api_client._verify_response(return_value)
1086
1121
  return return_value
@@ -1101,7 +1136,7 @@ class AsyncFiles(_api_module.BaseModule):
1101
1136
 
1102
1137
  .. code-block:: python
1103
1138
 
1104
- file = client.files.get(name='files/...')
1139
+ file = await client.aio.files.get(name='files/...')
1105
1140
  print(file.uri)
1106
1141
  """
1107
1142
 
@@ -1110,13 +1145,18 @@ class AsyncFiles(_api_module.BaseModule):
1110
1145
  config=config,
1111
1146
  )
1112
1147
 
1148
+ request_url_dict: Optional[dict[str, str]]
1113
1149
  if self._api_client.vertexai:
1114
1150
  raise ValueError('This method is only supported in the default client.')
1115
1151
  else:
1116
1152
  request_dict = _GetFileParameters_to_mldev(
1117
1153
  self._api_client, parameter_model
1118
1154
  )
1119
- path = 'files/{file}'.format_map(request_dict.get('_url'))
1155
+ request_url_dict = request_dict.get('_url')
1156
+ if request_url_dict:
1157
+ path = 'files/{file}'.format_map(request_url_dict)
1158
+ else:
1159
+ path = 'files/{file}'
1120
1160
 
1121
1161
  query_params = request_dict.get('_query')
1122
1162
  if query_params:
@@ -1124,7 +1164,7 @@ class AsyncFiles(_api_module.BaseModule):
1124
1164
  # TODO: remove the hack that pops config.
1125
1165
  request_dict.pop('config', None)
1126
1166
 
1127
- http_options = None
1167
+ http_options: Optional[types.HttpOptionsOrDict] = None
1128
1168
  if isinstance(config, dict):
1129
1169
  http_options = config.get('http_options', None)
1130
1170
  elif hasattr(config, 'http_options'):
@@ -1143,7 +1183,7 @@ class AsyncFiles(_api_module.BaseModule):
1143
1183
  response_dict = _File_from_mldev(self._api_client, response_dict)
1144
1184
 
1145
1185
  return_value = types.File._from_response(
1146
- response=response_dict, kwargs=parameter_model
1186
+ response=response_dict, kwargs=parameter_model.model_dump()
1147
1187
  )
1148
1188
  self._api_client._verify_response(return_value)
1149
1189
  return return_value
@@ -1164,7 +1204,7 @@ class AsyncFiles(_api_module.BaseModule):
1164
1204
 
1165
1205
  .. code-block:: python
1166
1206
 
1167
- client.files.delete(name='files/...')
1207
+ await client.aio.files.delete(name='files/...')
1168
1208
  """
1169
1209
 
1170
1210
  parameter_model = types._DeleteFileParameters(
@@ -1172,13 +1212,18 @@ class AsyncFiles(_api_module.BaseModule):
1172
1212
  config=config,
1173
1213
  )
1174
1214
 
1215
+ request_url_dict: Optional[dict[str, str]]
1175
1216
  if self._api_client.vertexai:
1176
1217
  raise ValueError('This method is only supported in the default client.')
1177
1218
  else:
1178
1219
  request_dict = _DeleteFileParameters_to_mldev(
1179
1220
  self._api_client, parameter_model
1180
1221
  )
1181
- path = 'files/{file}'.format_map(request_dict.get('_url'))
1222
+ request_url_dict = request_dict.get('_url')
1223
+ if request_url_dict:
1224
+ path = 'files/{file}'.format_map(request_url_dict)
1225
+ else:
1226
+ path = 'files/{file}'
1182
1227
 
1183
1228
  query_params = request_dict.get('_query')
1184
1229
  if query_params:
@@ -1186,7 +1231,7 @@ class AsyncFiles(_api_module.BaseModule):
1186
1231
  # TODO: remove the hack that pops config.
1187
1232
  request_dict.pop('config', None)
1188
1233
 
1189
- http_options = None
1234
+ http_options: Optional[types.HttpOptionsOrDict] = None
1190
1235
  if isinstance(config, dict):
1191
1236
  http_options = config.get('http_options', None)
1192
1237
  elif hasattr(config, 'http_options'):
@@ -1209,7 +1254,7 @@ class AsyncFiles(_api_module.BaseModule):
1209
1254
  )
1210
1255
 
1211
1256
  return_value = types.DeleteFileResponse._from_response(
1212
- response=response_dict, kwargs=parameter_model
1257
+ response=response_dict, kwargs=parameter_model.model_dump()
1213
1258
  )
1214
1259
  self._api_client._verify_response(return_value)
1215
1260
  return return_value
@@ -1277,32 +1322,32 @@ class AsyncFiles(_api_module.BaseModule):
1277
1322
  ' file\n please set the `mime_type` argument'
1278
1323
  )
1279
1324
 
1325
+ http_options: types.HttpOptions
1280
1326
  if config_model and config_model.http_options:
1281
1327
  http_options = config_model.http_options
1282
1328
  else:
1283
- http_options = {
1284
- 'api_version': '', # api-version is set in the path.
1285
- 'headers': {
1329
+ http_options = types.HttpOptions(
1330
+ api_version='',
1331
+ headers={
1286
1332
  'Content-Type': 'application/json',
1287
1333
  'X-Goog-Upload-Protocol': 'resumable',
1288
1334
  'X-Goog-Upload-Command': 'start',
1289
1335
  'X-Goog-Upload-Header-Content-Length': f'{file_obj.size_bytes}',
1290
1336
  'X-Goog-Upload-Header-Content-Type': f'{file_obj.mime_type}',
1291
1337
  },
1292
- }
1338
+ )
1293
1339
  response = await self._create(
1294
- file=file_obj, config={'http_options': http_options}
1340
+ file=file_obj, config=types.CreateFileConfig(http_options=http_options)
1295
1341
  )
1296
-
1297
1342
  if (
1298
1343
  response.http_headers is None
1299
- or 'X-Goog-Upload-URL' not in response.http_headers
1344
+ or 'x-goog-upload-url' not in response.http_headers
1300
1345
  ):
1301
1346
  raise KeyError(
1302
1347
  'Failed to create file. Upload URL did not returned from the create'
1303
1348
  ' file request.'
1304
1349
  )
1305
- upload_url = response.http_headers['X-Goog-Upload-URL']
1350
+ upload_url = response.http_headers['x-goog-upload-url']
1306
1351
 
1307
1352
  if isinstance(file, io.IOBase):
1308
1353
  return_file = await self._api_client.async_upload_file(
@@ -1314,7 +1359,8 @@ class AsyncFiles(_api_module.BaseModule):
1314
1359
  )
1315
1360
 
1316
1361
  return types.File._from_response(
1317
- _File_from_mldev(self._api_client, return_file['file']), None
1362
+ response=_File_from_mldev(self._api_client, return_file['file']),
1363
+ kwargs=None,
1318
1364
  )
1319
1365
 
1320
1366
  async def list(