worqhat 3.5.0__py3-none-any.whl → 3.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.
- worqhat/__init__.py +3 -1
- worqhat/_base_client.py +12 -12
- worqhat/_client.py +20 -11
- worqhat/_compat.py +48 -48
- worqhat/_models.py +51 -45
- worqhat/_qs.py +7 -7
- worqhat/_types.py +53 -12
- worqhat/_utils/__init__.py +9 -2
- worqhat/_utils/_compat.py +45 -0
- worqhat/_utils/_datetime_parse.py +136 -0
- worqhat/_utils/_transform.py +13 -3
- worqhat/_utils/_typing.py +6 -1
- worqhat/_utils/_utils.py +4 -5
- worqhat/_version.py +1 -1
- worqhat/resources/__init__.py +14 -0
- worqhat/resources/db/__init__.py +33 -0
- worqhat/resources/{db.py → db/db.py} +255 -48
- worqhat/resources/db/tables.py +389 -0
- worqhat/resources/flows.py +29 -23
- worqhat/resources/health.py +3 -3
- worqhat/resources/storage.py +462 -0
- worqhat/types/__init__.py +10 -0
- worqhat/types/db/__init__.py +10 -0
- worqhat/types/db/table_get_row_count_params.py +12 -0
- worqhat/types/db/table_get_row_count_response.py +15 -0
- worqhat/types/db/table_list_params.py +15 -0
- worqhat/types/db/table_list_response.py +26 -0
- worqhat/types/db/table_retrieve_schema_params.py +12 -0
- worqhat/types/db/table_retrieve_schema_response.py +29 -0
- worqhat/types/db_delete_records_params.py +6 -2
- worqhat/types/db_delete_records_response.py +2 -2
- worqhat/types/db_execute_batch_params.py +36 -0
- worqhat/types/db_execute_batch_response.py +27 -0
- worqhat/types/db_execute_query_params.py +14 -2
- worqhat/types/db_execute_query_response.py +2 -2
- worqhat/types/db_insert_record_params.py +6 -2
- worqhat/types/db_insert_record_response.py +2 -2
- worqhat/types/db_process_nl_query_params.py +7 -3
- worqhat/types/db_process_nl_query_response.py +2 -2
- worqhat/types/db_update_records_params.py +7 -3
- worqhat/types/db_update_records_response.py +2 -2
- worqhat/types/flow_trigger_with_payload_params.py +3 -2
- worqhat/types/storage_delete_file_by_id_response.py +18 -0
- worqhat/types/storage_retrieve_file_by_id_response.py +33 -0
- worqhat/types/storage_retrieve_file_by_path_params.py +12 -0
- worqhat/types/storage_retrieve_file_by_path_response.py +33 -0
- worqhat/types/storage_upload_file_params.py +17 -0
- worqhat/types/storage_upload_file_response.py +33 -0
- {worqhat-3.5.0.dist-info → worqhat-3.9.0.dist-info}/METADATA +2 -2
- worqhat-3.9.0.dist-info/RECORD +73 -0
- worqhat-3.5.0.dist-info/RECORD +0 -53
- {worqhat-3.5.0.dist-info → worqhat-3.9.0.dist-info}/WHEEL +0 -0
- {worqhat-3.5.0.dist-info → worqhat-3.9.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -2,36 +2,53 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
+
from typing import Dict, Union, Iterable
|
|
6
|
+
from typing_extensions import Literal
|
|
7
|
+
|
|
5
8
|
import httpx
|
|
6
9
|
|
|
7
|
-
from
|
|
10
|
+
from .tables import (
|
|
11
|
+
TablesResource,
|
|
12
|
+
AsyncTablesResource,
|
|
13
|
+
TablesResourceWithRawResponse,
|
|
14
|
+
AsyncTablesResourceWithRawResponse,
|
|
15
|
+
TablesResourceWithStreamingResponse,
|
|
16
|
+
AsyncTablesResourceWithStreamingResponse,
|
|
17
|
+
)
|
|
18
|
+
from ...types import (
|
|
19
|
+
db_execute_batch_params,
|
|
8
20
|
db_execute_query_params,
|
|
9
21
|
db_insert_record_params,
|
|
10
22
|
db_delete_records_params,
|
|
11
23
|
db_update_records_params,
|
|
12
24
|
db_process_nl_query_params,
|
|
13
25
|
)
|
|
14
|
-
from
|
|
15
|
-
from
|
|
16
|
-
from
|
|
17
|
-
from
|
|
18
|
-
from
|
|
26
|
+
from ..._types import Body, Omit, Query, Headers, NotGiven, SequenceNotStr, omit, not_given
|
|
27
|
+
from ..._utils import maybe_transform, async_maybe_transform
|
|
28
|
+
from ..._compat import cached_property
|
|
29
|
+
from ..._resource import SyncAPIResource, AsyncAPIResource
|
|
30
|
+
from ..._response import (
|
|
19
31
|
to_raw_response_wrapper,
|
|
20
32
|
to_streamed_response_wrapper,
|
|
21
33
|
async_to_raw_response_wrapper,
|
|
22
34
|
async_to_streamed_response_wrapper,
|
|
23
35
|
)
|
|
24
|
-
from
|
|
25
|
-
from
|
|
26
|
-
from
|
|
27
|
-
from
|
|
28
|
-
from
|
|
29
|
-
from
|
|
36
|
+
from ..._base_client import make_request_options
|
|
37
|
+
from ...types.db_execute_batch_response import DBExecuteBatchResponse
|
|
38
|
+
from ...types.db_execute_query_response import DBExecuteQueryResponse
|
|
39
|
+
from ...types.db_insert_record_response import DBInsertRecordResponse
|
|
40
|
+
from ...types.db_delete_records_response import DBDeleteRecordsResponse
|
|
41
|
+
from ...types.db_update_records_response import DBUpdateRecordsResponse
|
|
42
|
+
from ...types.db_process_nl_query_response import DBProcessNlQueryResponse
|
|
30
43
|
|
|
31
44
|
__all__ = ["DBResource", "AsyncDBResource"]
|
|
32
45
|
|
|
33
46
|
|
|
34
47
|
class DBResource(SyncAPIResource):
|
|
48
|
+
@cached_property
|
|
49
|
+
def tables(self) -> TablesResource:
|
|
50
|
+
return TablesResource(self._client)
|
|
51
|
+
|
|
35
52
|
@cached_property
|
|
36
53
|
def with_raw_response(self) -> DBResourceWithRawResponse:
|
|
37
54
|
"""
|
|
@@ -55,13 +72,14 @@ class DBResource(SyncAPIResource):
|
|
|
55
72
|
self,
|
|
56
73
|
*,
|
|
57
74
|
table: str,
|
|
58
|
-
where: object,
|
|
75
|
+
where: Dict[str, object],
|
|
76
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
59
77
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
60
78
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
61
79
|
extra_headers: Headers | None = None,
|
|
62
80
|
extra_query: Query | None = None,
|
|
63
81
|
extra_body: Body | None = None,
|
|
64
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
82
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
65
83
|
) -> DBDeleteRecordsResponse:
|
|
66
84
|
"""
|
|
67
85
|
Deletes records from the specified table that match the where conditions.
|
|
@@ -72,6 +90,8 @@ class DBResource(SyncAPIResource):
|
|
|
72
90
|
|
|
73
91
|
where: Where conditions
|
|
74
92
|
|
|
93
|
+
environment: Environment to delete from (development, staging, production)
|
|
94
|
+
|
|
75
95
|
extra_headers: Send extra headers
|
|
76
96
|
|
|
77
97
|
extra_query: Add additional query parameters to the request
|
|
@@ -86,6 +106,7 @@ class DBResource(SyncAPIResource):
|
|
|
86
106
|
{
|
|
87
107
|
"table": table,
|
|
88
108
|
"where": where,
|
|
109
|
+
"environment": environment,
|
|
89
110
|
},
|
|
90
111
|
db_delete_records_params.DBDeleteRecordsParams,
|
|
91
112
|
),
|
|
@@ -95,25 +116,81 @@ class DBResource(SyncAPIResource):
|
|
|
95
116
|
cast_to=DBDeleteRecordsResponse,
|
|
96
117
|
)
|
|
97
118
|
|
|
119
|
+
def execute_batch(
|
|
120
|
+
self,
|
|
121
|
+
*,
|
|
122
|
+
operations: Iterable[db_execute_batch_params.Operation],
|
|
123
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
124
|
+
transactional: bool | Omit = omit,
|
|
125
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
126
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
127
|
+
extra_headers: Headers | None = None,
|
|
128
|
+
extra_query: Query | None = None,
|
|
129
|
+
extra_body: Body | None = None,
|
|
130
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
131
|
+
) -> DBExecuteBatchResponse:
|
|
132
|
+
"""
|
|
133
|
+
Executes multiple database operations (queries, inserts, updates, deletes) in a
|
|
134
|
+
single transaction. If transactional is true, all operations will be rolled back
|
|
135
|
+
if any operation fails.
|
|
136
|
+
|
|
137
|
+
Args:
|
|
138
|
+
operations: Array of database operations to execute
|
|
139
|
+
|
|
140
|
+
environment: Environment to execute operations in
|
|
141
|
+
|
|
142
|
+
transactional: Whether to execute all operations in a single transaction
|
|
143
|
+
|
|
144
|
+
extra_headers: Send extra headers
|
|
145
|
+
|
|
146
|
+
extra_query: Add additional query parameters to the request
|
|
147
|
+
|
|
148
|
+
extra_body: Add additional JSON properties to the request
|
|
149
|
+
|
|
150
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
151
|
+
"""
|
|
152
|
+
return self._post(
|
|
153
|
+
"/db/batch",
|
|
154
|
+
body=maybe_transform(
|
|
155
|
+
{
|
|
156
|
+
"operations": operations,
|
|
157
|
+
"environment": environment,
|
|
158
|
+
"transactional": transactional,
|
|
159
|
+
},
|
|
160
|
+
db_execute_batch_params.DBExecuteBatchParams,
|
|
161
|
+
),
|
|
162
|
+
options=make_request_options(
|
|
163
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
164
|
+
),
|
|
165
|
+
cast_to=DBExecuteBatchResponse,
|
|
166
|
+
)
|
|
167
|
+
|
|
98
168
|
def execute_query(
|
|
99
169
|
self,
|
|
100
170
|
*,
|
|
101
171
|
query: str,
|
|
172
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
173
|
+
params: Union[Dict[str, object], SequenceNotStr[Union[str, float, bool]]] | Omit = omit,
|
|
102
174
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
103
175
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
104
176
|
extra_headers: Headers | None = None,
|
|
105
177
|
extra_query: Query | None = None,
|
|
106
178
|
extra_body: Body | None = None,
|
|
107
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
179
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
108
180
|
) -> DBExecuteQueryResponse:
|
|
109
|
-
"""Executes a raw SQL query directly against
|
|
181
|
+
"""Executes a raw SQL query directly against the database.
|
|
110
182
|
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
operations.
|
|
183
|
+
Supports both named
|
|
184
|
+
parameters ({param}) and positional parameters ($1, $2). Provides security
|
|
185
|
+
guardrails to prevent destructive operations.
|
|
114
186
|
|
|
115
187
|
Args:
|
|
116
|
-
query: SQL query to execute
|
|
188
|
+
query: SQL query to execute. Supports both named parameters ({param}) and positional
|
|
189
|
+
parameters ($1, $2)
|
|
190
|
+
|
|
191
|
+
environment: Environment to query (development, staging, production)
|
|
192
|
+
|
|
193
|
+
params: Named parameters for queries with {param} syntax
|
|
117
194
|
|
|
118
195
|
extra_headers: Send extra headers
|
|
119
196
|
|
|
@@ -125,7 +202,14 @@ class DBResource(SyncAPIResource):
|
|
|
125
202
|
"""
|
|
126
203
|
return self._post(
|
|
127
204
|
"/db/query",
|
|
128
|
-
body=maybe_transform(
|
|
205
|
+
body=maybe_transform(
|
|
206
|
+
{
|
|
207
|
+
"query": query,
|
|
208
|
+
"environment": environment,
|
|
209
|
+
"params": params,
|
|
210
|
+
},
|
|
211
|
+
db_execute_query_params.DBExecuteQueryParams,
|
|
212
|
+
),
|
|
129
213
|
options=make_request_options(
|
|
130
214
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
131
215
|
),
|
|
@@ -135,14 +219,15 @@ class DBResource(SyncAPIResource):
|
|
|
135
219
|
def insert_record(
|
|
136
220
|
self,
|
|
137
221
|
*,
|
|
138
|
-
data: object,
|
|
222
|
+
data: Dict[str, object],
|
|
139
223
|
table: str,
|
|
224
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
140
225
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
141
226
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
142
227
|
extra_headers: Headers | None = None,
|
|
143
228
|
extra_query: Query | None = None,
|
|
144
229
|
extra_body: Body | None = None,
|
|
145
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
230
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
146
231
|
) -> DBInsertRecordResponse:
|
|
147
232
|
"""Inserts a new record into the specified table.
|
|
148
233
|
|
|
@@ -154,6 +239,8 @@ class DBResource(SyncAPIResource):
|
|
|
154
239
|
|
|
155
240
|
table: Table name to insert into
|
|
156
241
|
|
|
242
|
+
environment: Environment to insert into (development, staging, production)
|
|
243
|
+
|
|
157
244
|
extra_headers: Send extra headers
|
|
158
245
|
|
|
159
246
|
extra_query: Add additional query parameters to the request
|
|
@@ -168,6 +255,7 @@ class DBResource(SyncAPIResource):
|
|
|
168
255
|
{
|
|
169
256
|
"data": data,
|
|
170
257
|
"table": table,
|
|
258
|
+
"environment": environment,
|
|
171
259
|
},
|
|
172
260
|
db_insert_record_params.DBInsertRecordParams,
|
|
173
261
|
),
|
|
@@ -181,13 +269,14 @@ class DBResource(SyncAPIResource):
|
|
|
181
269
|
self,
|
|
182
270
|
*,
|
|
183
271
|
question: str,
|
|
184
|
-
|
|
272
|
+
context: Dict[str, object] | Omit = omit,
|
|
273
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
185
274
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
186
275
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
187
276
|
extra_headers: Headers | None = None,
|
|
188
277
|
extra_query: Query | None = None,
|
|
189
278
|
extra_body: Body | None = None,
|
|
190
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
279
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
191
280
|
) -> DBProcessNlQueryResponse:
|
|
192
281
|
"""
|
|
193
282
|
Converts a natural language question into a SQL query and executes it.
|
|
@@ -196,7 +285,9 @@ class DBResource(SyncAPIResource):
|
|
|
196
285
|
Args:
|
|
197
286
|
question: Natural language question
|
|
198
287
|
|
|
199
|
-
|
|
288
|
+
context: Optional context for the query
|
|
289
|
+
|
|
290
|
+
environment: Environment to query (development, staging, production)
|
|
200
291
|
|
|
201
292
|
extra_headers: Send extra headers
|
|
202
293
|
|
|
@@ -211,7 +302,8 @@ class DBResource(SyncAPIResource):
|
|
|
211
302
|
body=maybe_transform(
|
|
212
303
|
{
|
|
213
304
|
"question": question,
|
|
214
|
-
"
|
|
305
|
+
"context": context,
|
|
306
|
+
"environment": environment,
|
|
215
307
|
},
|
|
216
308
|
db_process_nl_query_params.DBProcessNlQueryParams,
|
|
217
309
|
),
|
|
@@ -224,15 +316,16 @@ class DBResource(SyncAPIResource):
|
|
|
224
316
|
def update_records(
|
|
225
317
|
self,
|
|
226
318
|
*,
|
|
227
|
-
data: object,
|
|
319
|
+
data: Dict[str, object],
|
|
228
320
|
table: str,
|
|
229
|
-
where: object,
|
|
321
|
+
where: Dict[str, object],
|
|
322
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
230
323
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
231
324
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
232
325
|
extra_headers: Headers | None = None,
|
|
233
326
|
extra_query: Query | None = None,
|
|
234
327
|
extra_body: Body | None = None,
|
|
235
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
328
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
236
329
|
) -> DBUpdateRecordsResponse:
|
|
237
330
|
"""
|
|
238
331
|
Updates records in the specified table that match the where conditions.
|
|
@@ -245,6 +338,8 @@ class DBResource(SyncAPIResource):
|
|
|
245
338
|
|
|
246
339
|
where: Where conditions
|
|
247
340
|
|
|
341
|
+
environment: Environment to update in (development, staging, production)
|
|
342
|
+
|
|
248
343
|
extra_headers: Send extra headers
|
|
249
344
|
|
|
250
345
|
extra_query: Add additional query parameters to the request
|
|
@@ -260,6 +355,7 @@ class DBResource(SyncAPIResource):
|
|
|
260
355
|
"data": data,
|
|
261
356
|
"table": table,
|
|
262
357
|
"where": where,
|
|
358
|
+
"environment": environment,
|
|
263
359
|
},
|
|
264
360
|
db_update_records_params.DBUpdateRecordsParams,
|
|
265
361
|
),
|
|
@@ -271,6 +367,10 @@ class DBResource(SyncAPIResource):
|
|
|
271
367
|
|
|
272
368
|
|
|
273
369
|
class AsyncDBResource(AsyncAPIResource):
|
|
370
|
+
@cached_property
|
|
371
|
+
def tables(self) -> AsyncTablesResource:
|
|
372
|
+
return AsyncTablesResource(self._client)
|
|
373
|
+
|
|
274
374
|
@cached_property
|
|
275
375
|
def with_raw_response(self) -> AsyncDBResourceWithRawResponse:
|
|
276
376
|
"""
|
|
@@ -294,13 +394,14 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
294
394
|
self,
|
|
295
395
|
*,
|
|
296
396
|
table: str,
|
|
297
|
-
where: object,
|
|
397
|
+
where: Dict[str, object],
|
|
398
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
298
399
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
299
400
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
300
401
|
extra_headers: Headers | None = None,
|
|
301
402
|
extra_query: Query | None = None,
|
|
302
403
|
extra_body: Body | None = None,
|
|
303
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
404
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
304
405
|
) -> DBDeleteRecordsResponse:
|
|
305
406
|
"""
|
|
306
407
|
Deletes records from the specified table that match the where conditions.
|
|
@@ -311,6 +412,8 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
311
412
|
|
|
312
413
|
where: Where conditions
|
|
313
414
|
|
|
415
|
+
environment: Environment to delete from (development, staging, production)
|
|
416
|
+
|
|
314
417
|
extra_headers: Send extra headers
|
|
315
418
|
|
|
316
419
|
extra_query: Add additional query parameters to the request
|
|
@@ -325,6 +428,7 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
325
428
|
{
|
|
326
429
|
"table": table,
|
|
327
430
|
"where": where,
|
|
431
|
+
"environment": environment,
|
|
328
432
|
},
|
|
329
433
|
db_delete_records_params.DBDeleteRecordsParams,
|
|
330
434
|
),
|
|
@@ -334,25 +438,81 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
334
438
|
cast_to=DBDeleteRecordsResponse,
|
|
335
439
|
)
|
|
336
440
|
|
|
441
|
+
async def execute_batch(
|
|
442
|
+
self,
|
|
443
|
+
*,
|
|
444
|
+
operations: Iterable[db_execute_batch_params.Operation],
|
|
445
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
446
|
+
transactional: bool | Omit = omit,
|
|
447
|
+
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
448
|
+
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
449
|
+
extra_headers: Headers | None = None,
|
|
450
|
+
extra_query: Query | None = None,
|
|
451
|
+
extra_body: Body | None = None,
|
|
452
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
453
|
+
) -> DBExecuteBatchResponse:
|
|
454
|
+
"""
|
|
455
|
+
Executes multiple database operations (queries, inserts, updates, deletes) in a
|
|
456
|
+
single transaction. If transactional is true, all operations will be rolled back
|
|
457
|
+
if any operation fails.
|
|
458
|
+
|
|
459
|
+
Args:
|
|
460
|
+
operations: Array of database operations to execute
|
|
461
|
+
|
|
462
|
+
environment: Environment to execute operations in
|
|
463
|
+
|
|
464
|
+
transactional: Whether to execute all operations in a single transaction
|
|
465
|
+
|
|
466
|
+
extra_headers: Send extra headers
|
|
467
|
+
|
|
468
|
+
extra_query: Add additional query parameters to the request
|
|
469
|
+
|
|
470
|
+
extra_body: Add additional JSON properties to the request
|
|
471
|
+
|
|
472
|
+
timeout: Override the client-level default timeout for this request, in seconds
|
|
473
|
+
"""
|
|
474
|
+
return await self._post(
|
|
475
|
+
"/db/batch",
|
|
476
|
+
body=await async_maybe_transform(
|
|
477
|
+
{
|
|
478
|
+
"operations": operations,
|
|
479
|
+
"environment": environment,
|
|
480
|
+
"transactional": transactional,
|
|
481
|
+
},
|
|
482
|
+
db_execute_batch_params.DBExecuteBatchParams,
|
|
483
|
+
),
|
|
484
|
+
options=make_request_options(
|
|
485
|
+
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
486
|
+
),
|
|
487
|
+
cast_to=DBExecuteBatchResponse,
|
|
488
|
+
)
|
|
489
|
+
|
|
337
490
|
async def execute_query(
|
|
338
491
|
self,
|
|
339
492
|
*,
|
|
340
493
|
query: str,
|
|
494
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
495
|
+
params: Union[Dict[str, object], SequenceNotStr[Union[str, float, bool]]] | Omit = omit,
|
|
341
496
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
342
497
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
343
498
|
extra_headers: Headers | None = None,
|
|
344
499
|
extra_query: Query | None = None,
|
|
345
500
|
extra_body: Body | None = None,
|
|
346
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
501
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
347
502
|
) -> DBExecuteQueryResponse:
|
|
348
|
-
"""Executes a raw SQL query directly against
|
|
503
|
+
"""Executes a raw SQL query directly against the database.
|
|
349
504
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
operations.
|
|
505
|
+
Supports both named
|
|
506
|
+
parameters ({param}) and positional parameters ($1, $2). Provides security
|
|
507
|
+
guardrails to prevent destructive operations.
|
|
353
508
|
|
|
354
509
|
Args:
|
|
355
|
-
query: SQL query to execute
|
|
510
|
+
query: SQL query to execute. Supports both named parameters ({param}) and positional
|
|
511
|
+
parameters ($1, $2)
|
|
512
|
+
|
|
513
|
+
environment: Environment to query (development, staging, production)
|
|
514
|
+
|
|
515
|
+
params: Named parameters for queries with {param} syntax
|
|
356
516
|
|
|
357
517
|
extra_headers: Send extra headers
|
|
358
518
|
|
|
@@ -364,7 +524,14 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
364
524
|
"""
|
|
365
525
|
return await self._post(
|
|
366
526
|
"/db/query",
|
|
367
|
-
body=await async_maybe_transform(
|
|
527
|
+
body=await async_maybe_transform(
|
|
528
|
+
{
|
|
529
|
+
"query": query,
|
|
530
|
+
"environment": environment,
|
|
531
|
+
"params": params,
|
|
532
|
+
},
|
|
533
|
+
db_execute_query_params.DBExecuteQueryParams,
|
|
534
|
+
),
|
|
368
535
|
options=make_request_options(
|
|
369
536
|
extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
|
|
370
537
|
),
|
|
@@ -374,14 +541,15 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
374
541
|
async def insert_record(
|
|
375
542
|
self,
|
|
376
543
|
*,
|
|
377
|
-
data: object,
|
|
544
|
+
data: Dict[str, object],
|
|
378
545
|
table: str,
|
|
546
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
379
547
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
380
548
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
381
549
|
extra_headers: Headers | None = None,
|
|
382
550
|
extra_query: Query | None = None,
|
|
383
551
|
extra_body: Body | None = None,
|
|
384
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
552
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
385
553
|
) -> DBInsertRecordResponse:
|
|
386
554
|
"""Inserts a new record into the specified table.
|
|
387
555
|
|
|
@@ -393,6 +561,8 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
393
561
|
|
|
394
562
|
table: Table name to insert into
|
|
395
563
|
|
|
564
|
+
environment: Environment to insert into (development, staging, production)
|
|
565
|
+
|
|
396
566
|
extra_headers: Send extra headers
|
|
397
567
|
|
|
398
568
|
extra_query: Add additional query parameters to the request
|
|
@@ -407,6 +577,7 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
407
577
|
{
|
|
408
578
|
"data": data,
|
|
409
579
|
"table": table,
|
|
580
|
+
"environment": environment,
|
|
410
581
|
},
|
|
411
582
|
db_insert_record_params.DBInsertRecordParams,
|
|
412
583
|
),
|
|
@@ -420,13 +591,14 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
420
591
|
self,
|
|
421
592
|
*,
|
|
422
593
|
question: str,
|
|
423
|
-
|
|
594
|
+
context: Dict[str, object] | Omit = omit,
|
|
595
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
424
596
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
425
597
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
426
598
|
extra_headers: Headers | None = None,
|
|
427
599
|
extra_query: Query | None = None,
|
|
428
600
|
extra_body: Body | None = None,
|
|
429
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
601
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
430
602
|
) -> DBProcessNlQueryResponse:
|
|
431
603
|
"""
|
|
432
604
|
Converts a natural language question into a SQL query and executes it.
|
|
@@ -435,7 +607,9 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
435
607
|
Args:
|
|
436
608
|
question: Natural language question
|
|
437
609
|
|
|
438
|
-
|
|
610
|
+
context: Optional context for the query
|
|
611
|
+
|
|
612
|
+
environment: Environment to query (development, staging, production)
|
|
439
613
|
|
|
440
614
|
extra_headers: Send extra headers
|
|
441
615
|
|
|
@@ -450,7 +624,8 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
450
624
|
body=await async_maybe_transform(
|
|
451
625
|
{
|
|
452
626
|
"question": question,
|
|
453
|
-
"
|
|
627
|
+
"context": context,
|
|
628
|
+
"environment": environment,
|
|
454
629
|
},
|
|
455
630
|
db_process_nl_query_params.DBProcessNlQueryParams,
|
|
456
631
|
),
|
|
@@ -463,15 +638,16 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
463
638
|
async def update_records(
|
|
464
639
|
self,
|
|
465
640
|
*,
|
|
466
|
-
data: object,
|
|
641
|
+
data: Dict[str, object],
|
|
467
642
|
table: str,
|
|
468
|
-
where: object,
|
|
643
|
+
where: Dict[str, object],
|
|
644
|
+
environment: Literal["development", "staging", "production"] | Omit = omit,
|
|
469
645
|
# Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
|
|
470
646
|
# The extra values given here take precedence over values defined on the client or passed to this method.
|
|
471
647
|
extra_headers: Headers | None = None,
|
|
472
648
|
extra_query: Query | None = None,
|
|
473
649
|
extra_body: Body | None = None,
|
|
474
|
-
timeout: float | httpx.Timeout | None | NotGiven =
|
|
650
|
+
timeout: float | httpx.Timeout | None | NotGiven = not_given,
|
|
475
651
|
) -> DBUpdateRecordsResponse:
|
|
476
652
|
"""
|
|
477
653
|
Updates records in the specified table that match the where conditions.
|
|
@@ -484,6 +660,8 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
484
660
|
|
|
485
661
|
where: Where conditions
|
|
486
662
|
|
|
663
|
+
environment: Environment to update in (development, staging, production)
|
|
664
|
+
|
|
487
665
|
extra_headers: Send extra headers
|
|
488
666
|
|
|
489
667
|
extra_query: Add additional query parameters to the request
|
|
@@ -499,6 +677,7 @@ class AsyncDBResource(AsyncAPIResource):
|
|
|
499
677
|
"data": data,
|
|
500
678
|
"table": table,
|
|
501
679
|
"where": where,
|
|
680
|
+
"environment": environment,
|
|
502
681
|
},
|
|
503
682
|
db_update_records_params.DBUpdateRecordsParams,
|
|
504
683
|
),
|
|
@@ -516,6 +695,9 @@ class DBResourceWithRawResponse:
|
|
|
516
695
|
self.delete_records = to_raw_response_wrapper(
|
|
517
696
|
db.delete_records,
|
|
518
697
|
)
|
|
698
|
+
self.execute_batch = to_raw_response_wrapper(
|
|
699
|
+
db.execute_batch,
|
|
700
|
+
)
|
|
519
701
|
self.execute_query = to_raw_response_wrapper(
|
|
520
702
|
db.execute_query,
|
|
521
703
|
)
|
|
@@ -529,6 +711,10 @@ class DBResourceWithRawResponse:
|
|
|
529
711
|
db.update_records,
|
|
530
712
|
)
|
|
531
713
|
|
|
714
|
+
@cached_property
|
|
715
|
+
def tables(self) -> TablesResourceWithRawResponse:
|
|
716
|
+
return TablesResourceWithRawResponse(self._db.tables)
|
|
717
|
+
|
|
532
718
|
|
|
533
719
|
class AsyncDBResourceWithRawResponse:
|
|
534
720
|
def __init__(self, db: AsyncDBResource) -> None:
|
|
@@ -537,6 +723,9 @@ class AsyncDBResourceWithRawResponse:
|
|
|
537
723
|
self.delete_records = async_to_raw_response_wrapper(
|
|
538
724
|
db.delete_records,
|
|
539
725
|
)
|
|
726
|
+
self.execute_batch = async_to_raw_response_wrapper(
|
|
727
|
+
db.execute_batch,
|
|
728
|
+
)
|
|
540
729
|
self.execute_query = async_to_raw_response_wrapper(
|
|
541
730
|
db.execute_query,
|
|
542
731
|
)
|
|
@@ -550,6 +739,10 @@ class AsyncDBResourceWithRawResponse:
|
|
|
550
739
|
db.update_records,
|
|
551
740
|
)
|
|
552
741
|
|
|
742
|
+
@cached_property
|
|
743
|
+
def tables(self) -> AsyncTablesResourceWithRawResponse:
|
|
744
|
+
return AsyncTablesResourceWithRawResponse(self._db.tables)
|
|
745
|
+
|
|
553
746
|
|
|
554
747
|
class DBResourceWithStreamingResponse:
|
|
555
748
|
def __init__(self, db: DBResource) -> None:
|
|
@@ -558,6 +751,9 @@ class DBResourceWithStreamingResponse:
|
|
|
558
751
|
self.delete_records = to_streamed_response_wrapper(
|
|
559
752
|
db.delete_records,
|
|
560
753
|
)
|
|
754
|
+
self.execute_batch = to_streamed_response_wrapper(
|
|
755
|
+
db.execute_batch,
|
|
756
|
+
)
|
|
561
757
|
self.execute_query = to_streamed_response_wrapper(
|
|
562
758
|
db.execute_query,
|
|
563
759
|
)
|
|
@@ -571,6 +767,10 @@ class DBResourceWithStreamingResponse:
|
|
|
571
767
|
db.update_records,
|
|
572
768
|
)
|
|
573
769
|
|
|
770
|
+
@cached_property
|
|
771
|
+
def tables(self) -> TablesResourceWithStreamingResponse:
|
|
772
|
+
return TablesResourceWithStreamingResponse(self._db.tables)
|
|
773
|
+
|
|
574
774
|
|
|
575
775
|
class AsyncDBResourceWithStreamingResponse:
|
|
576
776
|
def __init__(self, db: AsyncDBResource) -> None:
|
|
@@ -579,6 +779,9 @@ class AsyncDBResourceWithStreamingResponse:
|
|
|
579
779
|
self.delete_records = async_to_streamed_response_wrapper(
|
|
580
780
|
db.delete_records,
|
|
581
781
|
)
|
|
782
|
+
self.execute_batch = async_to_streamed_response_wrapper(
|
|
783
|
+
db.execute_batch,
|
|
784
|
+
)
|
|
582
785
|
self.execute_query = async_to_streamed_response_wrapper(
|
|
583
786
|
db.execute_query,
|
|
584
787
|
)
|
|
@@ -591,3 +794,7 @@ class AsyncDBResourceWithStreamingResponse:
|
|
|
591
794
|
self.update_records = async_to_streamed_response_wrapper(
|
|
592
795
|
db.update_records,
|
|
593
796
|
)
|
|
797
|
+
|
|
798
|
+
@cached_property
|
|
799
|
+
def tables(self) -> AsyncTablesResourceWithStreamingResponse:
|
|
800
|
+
return AsyncTablesResourceWithStreamingResponse(self._db.tables)
|