Skip to content

Commit dced8d4

Browse files
fix(api)!: better support union schemas with common properties (#116)
1 parent fbf67b0 commit dced8d4

File tree

4 files changed

+44
-466
lines changed

4 files changed

+44
-466
lines changed

src/asktable/resources/datasources/meta.py

Lines changed: 4 additions & 206 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@
33
from __future__ import annotations
44

55
from typing import Dict
6-
from typing_extensions import overload
76

87
import httpx
98

109
from ..._types import NOT_GIVEN, Body, Query, Headers, NotGiven
1110
from ..._utils import (
12-
required_args,
1311
maybe_transform,
1412
async_maybe_transform,
1513
)
@@ -48,15 +46,14 @@ def with_streaming_response(self) -> MetaResourceWithStreamingResponse:
4846
"""
4947
return MetaResourceWithStreamingResponse(self)
5048

51-
@overload
5249
def create(
5350
self,
5451
datasource_id: str,
5552
*,
5653
name: str,
5754
async_process_meta: bool | NotGiven = NOT_GIVEN,
5855
value_index: bool | NotGiven = NOT_GIVEN,
59-
schemas: Dict[str, meta_create_params.MetaCreateSchemas] | NotGiven = NOT_GIVEN,
56+
schemas: Dict[str, meta_create_params.Schemas] | NotGiven = NOT_GIVEN,
6057
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
6158
# The extra values given here take precedence over values defined on the client or passed to this method.
6259
extra_headers: Headers | None = None,
@@ -82,58 +79,6 @@ def create(
8279
8380
timeout: Override the client-level default timeout for this request, in seconds
8481
"""
85-
...
86-
87-
@overload
88-
def create(
89-
self,
90-
datasource_id: str,
91-
*,
92-
body: None,
93-
async_process_meta: bool | NotGiven = NOT_GIVEN,
94-
value_index: bool | NotGiven = NOT_GIVEN,
95-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
96-
# The extra values given here take precedence over values defined on the client or passed to this method.
97-
extra_headers: Headers | None = None,
98-
extra_query: Query | None = None,
99-
extra_body: Body | None = None,
100-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
101-
) -> object:
102-
"""
103-
创建数据源的 meta,如果已经存在,则删除旧的
104-
105-
如果上传了 meta,则使用用户上传的数据创建。
106-
107-
否则从数据源中自动获取。
108-
109-
Args:
110-
extra_headers: Send extra headers
111-
112-
extra_query: Add additional query parameters to the request
113-
114-
extra_body: Add additional JSON properties to the request
115-
116-
timeout: Override the client-level default timeout for this request, in seconds
117-
"""
118-
...
119-
120-
@required_args(["name"], ["body"])
121-
def create(
122-
self,
123-
datasource_id: str,
124-
*,
125-
name: str | NotGiven = NOT_GIVEN,
126-
async_process_meta: bool | NotGiven = NOT_GIVEN,
127-
value_index: bool | NotGiven = NOT_GIVEN,
128-
schemas: Dict[str, meta_create_params.MetaCreateSchemas] | NotGiven = NOT_GIVEN,
129-
body: None | NotGiven = NOT_GIVEN,
130-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
131-
# The extra values given here take precedence over values defined on the client or passed to this method.
132-
extra_headers: Headers | None = None,
133-
extra_query: Query | None = None,
134-
extra_body: Body | None = None,
135-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
136-
) -> object:
13782
if not datasource_id:
13883
raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}")
13984
return self._post(
@@ -142,7 +87,6 @@ def create(
14287
{
14388
"name": name,
14489
"schemas": schemas,
145-
"body": body,
14690
},
14791
meta_create_params.MetaCreateParams,
14892
),
@@ -195,13 +139,12 @@ def retrieve(
195139
cast_to=Meta,
196140
)
197141

198-
@overload
199142
def update(
200143
self,
201144
datasource_id: str,
202145
*,
203146
name: str,
204-
schemas: Dict[str, meta_update_params.MetaCreateSchemas] | NotGiven = NOT_GIVEN,
147+
schemas: Dict[str, meta_update_params.Schemas] | NotGiven = NOT_GIVEN,
205148
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
206149
# The extra values given here take precedence over values defined on the client or passed to this method.
207150
extra_headers: Headers | None = None,
@@ -223,50 +166,6 @@ def update(
223166
224167
timeout: Override the client-level default timeout for this request, in seconds
225168
"""
226-
...
227-
228-
@overload
229-
def update(
230-
self,
231-
datasource_id: str,
232-
*,
233-
body: None,
234-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
235-
# The extra values given here take precedence over values defined on the client or passed to this method.
236-
extra_headers: Headers | None = None,
237-
extra_query: Query | None = None,
238-
extra_body: Body | None = None,
239-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
240-
) -> object:
241-
"""
242-
用于更新 DB 类型的数据源的 Meta(增加新表或者删除老表)
243-
244-
Args:
245-
extra_headers: Send extra headers
246-
247-
extra_query: Add additional query parameters to the request
248-
249-
extra_body: Add additional JSON properties to the request
250-
251-
timeout: Override the client-level default timeout for this request, in seconds
252-
"""
253-
...
254-
255-
@required_args(["name"], ["body"])
256-
def update(
257-
self,
258-
datasource_id: str,
259-
*,
260-
name: str | NotGiven = NOT_GIVEN,
261-
schemas: Dict[str, meta_update_params.MetaCreateSchemas] | NotGiven = NOT_GIVEN,
262-
body: None | NotGiven = NOT_GIVEN,
263-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
264-
# The extra values given here take precedence over values defined on the client or passed to this method.
265-
extra_headers: Headers | None = None,
266-
extra_query: Query | None = None,
267-
extra_body: Body | None = None,
268-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
269-
) -> object:
270169
if not datasource_id:
271170
raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}")
272171
return self._put(
@@ -275,7 +174,6 @@ def update(
275174
{
276175
"name": name,
277176
"schemas": schemas,
278-
"body": body,
279177
},
280178
meta_update_params.MetaUpdateParams,
281179
),
@@ -341,15 +239,14 @@ def with_streaming_response(self) -> AsyncMetaResourceWithStreamingResponse:
341239
"""
342240
return AsyncMetaResourceWithStreamingResponse(self)
343241

344-
@overload
345242
async def create(
346243
self,
347244
datasource_id: str,
348245
*,
349246
name: str,
350247
async_process_meta: bool | NotGiven = NOT_GIVEN,
351248
value_index: bool | NotGiven = NOT_GIVEN,
352-
schemas: Dict[str, meta_create_params.MetaCreateSchemas] | NotGiven = NOT_GIVEN,
249+
schemas: Dict[str, meta_create_params.Schemas] | NotGiven = NOT_GIVEN,
353250
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
354251
# The extra values given here take precedence over values defined on the client or passed to this method.
355252
extra_headers: Headers | None = None,
@@ -375,58 +272,6 @@ async def create(
375272
376273
timeout: Override the client-level default timeout for this request, in seconds
377274
"""
378-
...
379-
380-
@overload
381-
async def create(
382-
self,
383-
datasource_id: str,
384-
*,
385-
body: None,
386-
async_process_meta: bool | NotGiven = NOT_GIVEN,
387-
value_index: bool | NotGiven = NOT_GIVEN,
388-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
389-
# The extra values given here take precedence over values defined on the client or passed to this method.
390-
extra_headers: Headers | None = None,
391-
extra_query: Query | None = None,
392-
extra_body: Body | None = None,
393-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
394-
) -> object:
395-
"""
396-
创建数据源的 meta,如果已经存在,则删除旧的
397-
398-
如果上传了 meta,则使用用户上传的数据创建。
399-
400-
否则从数据源中自动获取。
401-
402-
Args:
403-
extra_headers: Send extra headers
404-
405-
extra_query: Add additional query parameters to the request
406-
407-
extra_body: Add additional JSON properties to the request
408-
409-
timeout: Override the client-level default timeout for this request, in seconds
410-
"""
411-
...
412-
413-
@required_args(["name"], ["body"])
414-
async def create(
415-
self,
416-
datasource_id: str,
417-
*,
418-
name: str | NotGiven = NOT_GIVEN,
419-
async_process_meta: bool | NotGiven = NOT_GIVEN,
420-
value_index: bool | NotGiven = NOT_GIVEN,
421-
schemas: Dict[str, meta_create_params.MetaCreateSchemas] | NotGiven = NOT_GIVEN,
422-
body: None | NotGiven = NOT_GIVEN,
423-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
424-
# The extra values given here take precedence over values defined on the client or passed to this method.
425-
extra_headers: Headers | None = None,
426-
extra_query: Query | None = None,
427-
extra_body: Body | None = None,
428-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
429-
) -> object:
430275
if not datasource_id:
431276
raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}")
432277
return await self._post(
@@ -435,7 +280,6 @@ async def create(
435280
{
436281
"name": name,
437282
"schemas": schemas,
438-
"body": body,
439283
},
440284
meta_create_params.MetaCreateParams,
441285
),
@@ -488,13 +332,12 @@ async def retrieve(
488332
cast_to=Meta,
489333
)
490334

491-
@overload
492335
async def update(
493336
self,
494337
datasource_id: str,
495338
*,
496339
name: str,
497-
schemas: Dict[str, meta_update_params.MetaCreateSchemas] | NotGiven = NOT_GIVEN,
340+
schemas: Dict[str, meta_update_params.Schemas] | NotGiven = NOT_GIVEN,
498341
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
499342
# The extra values given here take precedence over values defined on the client or passed to this method.
500343
extra_headers: Headers | None = None,
@@ -516,50 +359,6 @@ async def update(
516359
517360
timeout: Override the client-level default timeout for this request, in seconds
518361
"""
519-
...
520-
521-
@overload
522-
async def update(
523-
self,
524-
datasource_id: str,
525-
*,
526-
body: None,
527-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
528-
# The extra values given here take precedence over values defined on the client or passed to this method.
529-
extra_headers: Headers | None = None,
530-
extra_query: Query | None = None,
531-
extra_body: Body | None = None,
532-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
533-
) -> object:
534-
"""
535-
用于更新 DB 类型的数据源的 Meta(增加新表或者删除老表)
536-
537-
Args:
538-
extra_headers: Send extra headers
539-
540-
extra_query: Add additional query parameters to the request
541-
542-
extra_body: Add additional JSON properties to the request
543-
544-
timeout: Override the client-level default timeout for this request, in seconds
545-
"""
546-
...
547-
548-
@required_args(["name"], ["body"])
549-
async def update(
550-
self,
551-
datasource_id: str,
552-
*,
553-
name: str | NotGiven = NOT_GIVEN,
554-
schemas: Dict[str, meta_update_params.MetaCreateSchemas] | NotGiven = NOT_GIVEN,
555-
body: None | NotGiven = NOT_GIVEN,
556-
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
557-
# The extra values given here take precedence over values defined on the client or passed to this method.
558-
extra_headers: Headers | None = None,
559-
extra_query: Query | None = None,
560-
extra_body: Body | None = None,
561-
timeout: float | httpx.Timeout | None | NotGiven = NOT_GIVEN,
562-
) -> object:
563362
if not datasource_id:
564363
raise ValueError(f"Expected a non-empty value for `datasource_id` but received {datasource_id!r}")
565364
return await self._put(
@@ -568,7 +367,6 @@ async def update(
568367
{
569368
"name": name,
570369
"schemas": schemas,
571-
"body": body,
572370
},
573371
meta_update_params.MetaUpdateParams,
574372
),

0 commit comments

Comments
 (0)