22
33from __future__ import annotations
44
5- from typing import Mapping , Optional , cast
5+ from typing import Optional
66from typing_extensions import Literal
77
88import httpx
1515 MetaResourceWithStreamingResponse ,
1616 AsyncMetaResourceWithStreamingResponse ,
1717)
18- from ...types import (
19- datasource_list_params ,
20- datasource_create_params ,
21- datasource_update_params ,
22- datasource_create_from_file_params ,
23- )
18+ from ...types import datasource_list_params , datasource_create_params , datasource_update_params
2419from .indexes import (
2520 IndexesResource ,
2621 AsyncIndexesResource ,
2924 IndexesResourceWithStreamingResponse ,
3025 AsyncIndexesResourceWithStreamingResponse ,
3126)
32- from ..._types import NOT_GIVEN , Body , Query , Headers , NotGiven , FileTypes
27+ from ..._types import NOT_GIVEN , Body , Query , Headers , NotGiven
3328from ..._utils import (
34- extract_files ,
3529 maybe_transform ,
36- deepcopy_minimal ,
3730 async_maybe_transform ,
3831)
3932from ..._compat import cached_property
5548)
5649from ..._base_client import AsyncPaginator , make_request_options
5750from ...types .datasource import Datasource
51+ from ...types .datasource_retrieve_response import DatasourceRetrieveResponse
5852
5953__all__ = ["DatasourcesResource" , "AsyncDatasourcesResource" ]
6054
@@ -160,7 +154,7 @@ def retrieve(
160154 extra_query : Query | None = None ,
161155 extra_body : Body | None = None ,
162156 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
163- ) -> Datasource :
157+ ) -> DatasourceRetrieveResponse :
164158 """
165159 根据 id 获取指定数据源
166160
@@ -180,7 +174,7 @@ def retrieve(
180174 options = make_request_options (
181175 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
182176 ),
183- cast_to = Datasource ,
177+ cast_to = DatasourceRetrieveResponse ,
184178 )
185179
186180 def update (
@@ -189,6 +183,10 @@ def update(
189183 * ,
190184 access_config : Optional [datasource_update_params .AccessConfig ] | NotGiven = NOT_GIVEN ,
191185 desc : Optional [str ] | NotGiven = NOT_GIVEN ,
186+ engine : Optional [
187+ Literal ["mysql" , "tidb" , "postgresql" , "oceanbase" , "clickhouse" , "csv" , "excel" , "starrocks" , "hive" ]
188+ ]
189+ | NotGiven = NOT_GIVEN ,
192190 field_count : Optional [int ] | NotGiven = NOT_GIVEN ,
193191 meta_error : Optional [str ] | NotGiven = NOT_GIVEN ,
194192 meta_status : Optional [Literal ["processing" , "failed" , "success" , "unprocessed" ]] | NotGiven = NOT_GIVEN ,
@@ -211,6 +209,8 @@ def update(
211209
212210 desc: 数据源描述
213211
212+ engine: 数据源引擎
213+
214214 field_count: 字段数量
215215
216216 meta_error: 元数据处理错误
@@ -241,6 +241,7 @@ def update(
241241 {
242242 "access_config" : access_config ,
243243 "desc" : desc ,
244+ "engine" : engine ,
244245 "field_count" : field_count ,
245246 "meta_error" : meta_error ,
246247 "meta_status" : meta_status ,
@@ -339,59 +340,6 @@ def delete(
339340 cast_to = object ,
340341 )
341342
342- def create_from_file (
343- self ,
344- * ,
345- file : FileTypes ,
346- async_process_meta : bool | NotGiven = NOT_GIVEN ,
347- name : str | NotGiven = NOT_GIVEN ,
348- value_index : bool | NotGiven = NOT_GIVEN ,
349- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
350- # The extra values given here take precedence over values defined on the client or passed to this method.
351- extra_headers : Headers | None = None ,
352- extra_query : Query | None = None ,
353- extra_body : Body | None = None ,
354- timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
355- ) -> Datasource :
356- """
357- 上传文件并创建数据源
358-
359- Args:
360- extra_headers: Send extra headers
361-
362- extra_query: Add additional query parameters to the request
363-
364- extra_body: Add additional JSON properties to the request
365-
366- timeout: Override the client-level default timeout for this request, in seconds
367- """
368- body = deepcopy_minimal ({"file" : file })
369- files = extract_files (cast (Mapping [str , object ], body ), paths = [["file" ]])
370- # It should be noted that the actual Content-Type header that will be
371- # sent to the server will contain a `boundary` parameter, e.g.
372- # multipart/form-data; boundary=---abc--
373- extra_headers = {"Content-Type" : "multipart/form-data" , ** (extra_headers or {})}
374- return self ._post (
375- "/datasources/file" ,
376- body = maybe_transform (body , datasource_create_from_file_params .DatasourceCreateFromFileParams ),
377- files = files ,
378- options = make_request_options (
379- extra_headers = extra_headers ,
380- extra_query = extra_query ,
381- extra_body = extra_body ,
382- timeout = timeout ,
383- query = maybe_transform (
384- {
385- "async_process_meta" : async_process_meta ,
386- "name" : name ,
387- "value_index" : value_index ,
388- },
389- datasource_create_from_file_params .DatasourceCreateFromFileParams ,
390- ),
391- ),
392- cast_to = Datasource ,
393- )
394-
395343
396344class AsyncDatasourcesResource (AsyncAPIResource ):
397345 @cached_property
@@ -494,7 +442,7 @@ async def retrieve(
494442 extra_query : Query | None = None ,
495443 extra_body : Body | None = None ,
496444 timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
497- ) -> Datasource :
445+ ) -> DatasourceRetrieveResponse :
498446 """
499447 根据 id 获取指定数据源
500448
@@ -514,7 +462,7 @@ async def retrieve(
514462 options = make_request_options (
515463 extra_headers = extra_headers , extra_query = extra_query , extra_body = extra_body , timeout = timeout
516464 ),
517- cast_to = Datasource ,
465+ cast_to = DatasourceRetrieveResponse ,
518466 )
519467
520468 async def update (
@@ -523,6 +471,10 @@ async def update(
523471 * ,
524472 access_config : Optional [datasource_update_params .AccessConfig ] | NotGiven = NOT_GIVEN ,
525473 desc : Optional [str ] | NotGiven = NOT_GIVEN ,
474+ engine : Optional [
475+ Literal ["mysql" , "tidb" , "postgresql" , "oceanbase" , "clickhouse" , "csv" , "excel" , "starrocks" , "hive" ]
476+ ]
477+ | NotGiven = NOT_GIVEN ,
526478 field_count : Optional [int ] | NotGiven = NOT_GIVEN ,
527479 meta_error : Optional [str ] | NotGiven = NOT_GIVEN ,
528480 meta_status : Optional [Literal ["processing" , "failed" , "success" , "unprocessed" ]] | NotGiven = NOT_GIVEN ,
@@ -545,6 +497,8 @@ async def update(
545497
546498 desc: 数据源描述
547499
500+ engine: 数据源引擎
501+
548502 field_count: 字段数量
549503
550504 meta_error: 元数据处理错误
@@ -575,6 +529,7 @@ async def update(
575529 {
576530 "access_config" : access_config ,
577531 "desc" : desc ,
532+ "engine" : engine ,
578533 "field_count" : field_count ,
579534 "meta_error" : meta_error ,
580535 "meta_status" : meta_status ,
@@ -673,59 +628,6 @@ async def delete(
673628 cast_to = object ,
674629 )
675630
676- async def create_from_file (
677- self ,
678- * ,
679- file : FileTypes ,
680- async_process_meta : bool | NotGiven = NOT_GIVEN ,
681- name : str | NotGiven = NOT_GIVEN ,
682- value_index : bool | NotGiven = NOT_GIVEN ,
683- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
684- # The extra values given here take precedence over values defined on the client or passed to this method.
685- extra_headers : Headers | None = None ,
686- extra_query : Query | None = None ,
687- extra_body : Body | None = None ,
688- timeout : float | httpx .Timeout | None | NotGiven = NOT_GIVEN ,
689- ) -> Datasource :
690- """
691- 上传文件并创建数据源
692-
693- Args:
694- extra_headers: Send extra headers
695-
696- extra_query: Add additional query parameters to the request
697-
698- extra_body: Add additional JSON properties to the request
699-
700- timeout: Override the client-level default timeout for this request, in seconds
701- """
702- body = deepcopy_minimal ({"file" : file })
703- files = extract_files (cast (Mapping [str , object ], body ), paths = [["file" ]])
704- # It should be noted that the actual Content-Type header that will be
705- # sent to the server will contain a `boundary` parameter, e.g.
706- # multipart/form-data; boundary=---abc--
707- extra_headers = {"Content-Type" : "multipart/form-data" , ** (extra_headers or {})}
708- return await self ._post (
709- "/datasources/file" ,
710- body = await async_maybe_transform (body , datasource_create_from_file_params .DatasourceCreateFromFileParams ),
711- files = files ,
712- options = make_request_options (
713- extra_headers = extra_headers ,
714- extra_query = extra_query ,
715- extra_body = extra_body ,
716- timeout = timeout ,
717- query = await async_maybe_transform (
718- {
719- "async_process_meta" : async_process_meta ,
720- "name" : name ,
721- "value_index" : value_index ,
722- },
723- datasource_create_from_file_params .DatasourceCreateFromFileParams ,
724- ),
725- ),
726- cast_to = Datasource ,
727- )
728-
729631
730632class DatasourcesResourceWithRawResponse :
731633 def __init__ (self , datasources : DatasourcesResource ) -> None :
@@ -746,9 +648,6 @@ def __init__(self, datasources: DatasourcesResource) -> None:
746648 self .delete = to_raw_response_wrapper (
747649 datasources .delete ,
748650 )
749- self .create_from_file = to_raw_response_wrapper (
750- datasources .create_from_file ,
751- )
752651
753652 @cached_property
754653 def meta (self ) -> MetaResourceWithRawResponse :
@@ -782,9 +681,6 @@ def __init__(self, datasources: AsyncDatasourcesResource) -> None:
782681 self .delete = async_to_raw_response_wrapper (
783682 datasources .delete ,
784683 )
785- self .create_from_file = async_to_raw_response_wrapper (
786- datasources .create_from_file ,
787- )
788684
789685 @cached_property
790686 def meta (self ) -> AsyncMetaResourceWithRawResponse :
@@ -818,9 +714,6 @@ def __init__(self, datasources: DatasourcesResource) -> None:
818714 self .delete = to_streamed_response_wrapper (
819715 datasources .delete ,
820716 )
821- self .create_from_file = to_streamed_response_wrapper (
822- datasources .create_from_file ,
823- )
824717
825718 @cached_property
826719 def meta (self ) -> MetaResourceWithStreamingResponse :
@@ -854,9 +747,6 @@ def __init__(self, datasources: AsyncDatasourcesResource) -> None:
854747 self .delete = async_to_streamed_response_wrapper (
855748 datasources .delete ,
856749 )
857- self .create_from_file = async_to_streamed_response_wrapper (
858- datasources .create_from_file ,
859- )
860750
861751 @cached_property
862752 def meta (self ) -> AsyncMetaResourceWithStreamingResponse :
0 commit comments