worqhat 3.9.0__py3-none-any.whl → 4.1.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.
Files changed (80) hide show
  1. worqhat/__init__.py +8 -89
  2. worqhat/client.py +62 -0
  3. worqhat/exceptions.py +43 -0
  4. worqhat/http_client.py +171 -0
  5. worqhat/py.typed +1 -0
  6. worqhat/resources/__init__.py +5 -59
  7. worqhat/resources/database.py +293 -0
  8. worqhat/resources/flows.py +61 -409
  9. worqhat/resources/storage.py +41 -431
  10. worqhat-4.1.0.dist-info/METADATA +538 -0
  11. worqhat-4.1.0.dist-info/RECORD +13 -0
  12. {worqhat-3.9.0.dist-info → worqhat-4.1.0.dist-info}/WHEEL +2 -1
  13. worqhat-4.1.0.dist-info/top_level.txt +1 -0
  14. worqhat/_base_client.py +0 -1995
  15. worqhat/_client.py +0 -484
  16. worqhat/_compat.py +0 -219
  17. worqhat/_constants.py +0 -14
  18. worqhat/_exceptions.py +0 -108
  19. worqhat/_files.py +0 -123
  20. worqhat/_models.py +0 -835
  21. worqhat/_qs.py +0 -150
  22. worqhat/_resource.py +0 -43
  23. worqhat/_response.py +0 -830
  24. worqhat/_streaming.py +0 -333
  25. worqhat/_types.py +0 -260
  26. worqhat/_utils/__init__.py +0 -64
  27. worqhat/_utils/_compat.py +0 -45
  28. worqhat/_utils/_datetime_parse.py +0 -136
  29. worqhat/_utils/_logs.py +0 -25
  30. worqhat/_utils/_proxy.py +0 -65
  31. worqhat/_utils/_reflection.py +0 -42
  32. worqhat/_utils/_resources_proxy.py +0 -24
  33. worqhat/_utils/_streams.py +0 -12
  34. worqhat/_utils/_sync.py +0 -86
  35. worqhat/_utils/_transform.py +0 -457
  36. worqhat/_utils/_typing.py +0 -156
  37. worqhat/_utils/_utils.py +0 -421
  38. worqhat/_version.py +0 -4
  39. worqhat/lib/.keep +0 -4
  40. worqhat/resources/db/__init__.py +0 -33
  41. worqhat/resources/db/db.py +0 -800
  42. worqhat/resources/db/tables.py +0 -389
  43. worqhat/resources/health.py +0 -143
  44. worqhat/types/__init__.py +0 -32
  45. worqhat/types/db/__init__.py +0 -10
  46. worqhat/types/db/table_get_row_count_params.py +0 -12
  47. worqhat/types/db/table_get_row_count_response.py +0 -15
  48. worqhat/types/db/table_list_params.py +0 -15
  49. worqhat/types/db/table_list_response.py +0 -26
  50. worqhat/types/db/table_retrieve_schema_params.py +0 -12
  51. worqhat/types/db/table_retrieve_schema_response.py +0 -29
  52. worqhat/types/db_delete_records_params.py +0 -19
  53. worqhat/types/db_delete_records_response.py +0 -18
  54. worqhat/types/db_execute_batch_params.py +0 -36
  55. worqhat/types/db_execute_batch_response.py +0 -27
  56. worqhat/types/db_execute_query_params.py +0 -24
  57. worqhat/types/db_execute_query_response.py +0 -21
  58. worqhat/types/db_insert_record_params.py +0 -19
  59. worqhat/types/db_insert_record_response.py +0 -15
  60. worqhat/types/db_process_nl_query_params.py +0 -19
  61. worqhat/types/db_process_nl_query_response.py +0 -18
  62. worqhat/types/db_update_records_params.py +0 -22
  63. worqhat/types/db_update_records_response.py +0 -18
  64. worqhat/types/flow_get_metrics_params.py +0 -25
  65. worqhat/types/flow_get_metrics_response.py +0 -55
  66. worqhat/types/flow_trigger_with_file_params.py +0 -17
  67. worqhat/types/flow_trigger_with_file_response.py +0 -18
  68. worqhat/types/flow_trigger_with_payload_params.py +0 -13
  69. worqhat/types/flow_trigger_with_payload_response.py +0 -20
  70. worqhat/types/get_server_info_response.py +0 -15
  71. worqhat/types/health_check_response.py +0 -33
  72. worqhat/types/storage_delete_file_by_id_response.py +0 -18
  73. worqhat/types/storage_retrieve_file_by_id_response.py +0 -33
  74. worqhat/types/storage_retrieve_file_by_path_params.py +0 -12
  75. worqhat/types/storage_retrieve_file_by_path_response.py +0 -33
  76. worqhat/types/storage_upload_file_params.py +0 -17
  77. worqhat/types/storage_upload_file_response.py +0 -33
  78. worqhat-3.9.0.dist-info/METADATA +0 -432
  79. worqhat-3.9.0.dist-info/RECORD +0 -73
  80. worqhat-3.9.0.dist-info/licenses/LICENSE +0 -201
@@ -1,800 +0,0 @@
1
- # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
-
3
- from __future__ import annotations
4
-
5
- from typing import Dict, Union, Iterable
6
- from typing_extensions import Literal
7
-
8
- import httpx
9
-
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,
20
- db_execute_query_params,
21
- db_insert_record_params,
22
- db_delete_records_params,
23
- db_update_records_params,
24
- db_process_nl_query_params,
25
- )
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 (
31
- to_raw_response_wrapper,
32
- to_streamed_response_wrapper,
33
- async_to_raw_response_wrapper,
34
- async_to_streamed_response_wrapper,
35
- )
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
43
-
44
- __all__ = ["DBResource", "AsyncDBResource"]
45
-
46
-
47
- class DBResource(SyncAPIResource):
48
- @cached_property
49
- def tables(self) -> TablesResource:
50
- return TablesResource(self._client)
51
-
52
- @cached_property
53
- def with_raw_response(self) -> DBResourceWithRawResponse:
54
- """
55
- This property can be used as a prefix for any HTTP method call to return
56
- the raw response object instead of the parsed content.
57
-
58
- For more information, see https://www.github.com/WorqHat/worqhat-python-sdk#accessing-raw-response-data-eg-headers
59
- """
60
- return DBResourceWithRawResponse(self)
61
-
62
- @cached_property
63
- def with_streaming_response(self) -> DBResourceWithStreamingResponse:
64
- """
65
- An alternative to `.with_raw_response` that doesn't eagerly read the response body.
66
-
67
- For more information, see https://www.github.com/WorqHat/worqhat-python-sdk#with_streaming_response
68
- """
69
- return DBResourceWithStreamingResponse(self)
70
-
71
- def delete_records(
72
- self,
73
- *,
74
- table: str,
75
- where: Dict[str, object],
76
- environment: Literal["development", "staging", "production"] | Omit = omit,
77
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
78
- # The extra values given here take precedence over values defined on the client or passed to this method.
79
- extra_headers: Headers | None = None,
80
- extra_query: Query | None = None,
81
- extra_body: Body | None = None,
82
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
83
- ) -> DBDeleteRecordsResponse:
84
- """
85
- Deletes records from the specified table that match the where conditions.
86
- Organization ID filtering is automatically applied for multi-tenant security.
87
-
88
- Args:
89
- table: Table name to delete from
90
-
91
- where: Where conditions
92
-
93
- environment: Environment to delete from (development, staging, production)
94
-
95
- extra_headers: Send extra headers
96
-
97
- extra_query: Add additional query parameters to the request
98
-
99
- extra_body: Add additional JSON properties to the request
100
-
101
- timeout: Override the client-level default timeout for this request, in seconds
102
- """
103
- return self._delete(
104
- "/db/delete",
105
- body=maybe_transform(
106
- {
107
- "table": table,
108
- "where": where,
109
- "environment": environment,
110
- },
111
- db_delete_records_params.DBDeleteRecordsParams,
112
- ),
113
- options=make_request_options(
114
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
115
- ),
116
- cast_to=DBDeleteRecordsResponse,
117
- )
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
-
168
- def execute_query(
169
- self,
170
- *,
171
- query: str,
172
- environment: Literal["development", "staging", "production"] | Omit = omit,
173
- params: Union[Dict[str, object], SequenceNotStr[Union[str, float, bool]]] | Omit = omit,
174
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
175
- # The extra values given here take precedence over values defined on the client or passed to this method.
176
- extra_headers: Headers | None = None,
177
- extra_query: Query | None = None,
178
- extra_body: Body | None = None,
179
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
180
- ) -> DBExecuteQueryResponse:
181
- """Executes a raw SQL query directly against the database.
182
-
183
- Supports both named
184
- parameters ({param}) and positional parameters ($1, $2). Provides security
185
- guardrails to prevent destructive operations.
186
-
187
- Args:
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
194
-
195
- extra_headers: Send extra headers
196
-
197
- extra_query: Add additional query parameters to the request
198
-
199
- extra_body: Add additional JSON properties to the request
200
-
201
- timeout: Override the client-level default timeout for this request, in seconds
202
- """
203
- return self._post(
204
- "/db/query",
205
- body=maybe_transform(
206
- {
207
- "query": query,
208
- "environment": environment,
209
- "params": params,
210
- },
211
- db_execute_query_params.DBExecuteQueryParams,
212
- ),
213
- options=make_request_options(
214
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
215
- ),
216
- cast_to=DBExecuteQueryResponse,
217
- )
218
-
219
- def insert_record(
220
- self,
221
- *,
222
- data: Dict[str, object],
223
- table: str,
224
- environment: Literal["development", "staging", "production"] | Omit = omit,
225
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
226
- # The extra values given here take precedence over values defined on the client or passed to this method.
227
- extra_headers: Headers | None = None,
228
- extra_query: Query | None = None,
229
- extra_body: Body | None = None,
230
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
231
- ) -> DBInsertRecordResponse:
232
- """Inserts a new record into the specified table.
233
-
234
- Organization ID is automatically
235
- added for multi-tenant security.
236
-
237
- Args:
238
- data: Data to insert
239
-
240
- table: Table name to insert into
241
-
242
- environment: Environment to insert into (development, staging, production)
243
-
244
- extra_headers: Send extra headers
245
-
246
- extra_query: Add additional query parameters to the request
247
-
248
- extra_body: Add additional JSON properties to the request
249
-
250
- timeout: Override the client-level default timeout for this request, in seconds
251
- """
252
- return self._post(
253
- "/db/insert",
254
- body=maybe_transform(
255
- {
256
- "data": data,
257
- "table": table,
258
- "environment": environment,
259
- },
260
- db_insert_record_params.DBInsertRecordParams,
261
- ),
262
- options=make_request_options(
263
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
264
- ),
265
- cast_to=DBInsertRecordResponse,
266
- )
267
-
268
- def process_nl_query(
269
- self,
270
- *,
271
- question: str,
272
- context: Dict[str, object] | Omit = omit,
273
- environment: Literal["development", "staging", "production"] | Omit = omit,
274
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
275
- # The extra values given here take precedence over values defined on the client or passed to this method.
276
- extra_headers: Headers | None = None,
277
- extra_query: Query | None = None,
278
- extra_body: Body | None = None,
279
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
280
- ) -> DBProcessNlQueryResponse:
281
- """
282
- Converts a natural language question into a SQL query and executes it.
283
- Organization ID filtering is automatically applied for multi-tenant security.
284
-
285
- Args:
286
- question: Natural language question
287
-
288
- context: Optional context for the query
289
-
290
- environment: Environment to query (development, staging, production)
291
-
292
- extra_headers: Send extra headers
293
-
294
- extra_query: Add additional query parameters to the request
295
-
296
- extra_body: Add additional JSON properties to the request
297
-
298
- timeout: Override the client-level default timeout for this request, in seconds
299
- """
300
- return self._post(
301
- "/db/nl-query",
302
- body=maybe_transform(
303
- {
304
- "question": question,
305
- "context": context,
306
- "environment": environment,
307
- },
308
- db_process_nl_query_params.DBProcessNlQueryParams,
309
- ),
310
- options=make_request_options(
311
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
312
- ),
313
- cast_to=DBProcessNlQueryResponse,
314
- )
315
-
316
- def update_records(
317
- self,
318
- *,
319
- data: Dict[str, object],
320
- table: str,
321
- where: Dict[str, object],
322
- environment: Literal["development", "staging", "production"] | Omit = omit,
323
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
324
- # The extra values given here take precedence over values defined on the client or passed to this method.
325
- extra_headers: Headers | None = None,
326
- extra_query: Query | None = None,
327
- extra_body: Body | None = None,
328
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
329
- ) -> DBUpdateRecordsResponse:
330
- """
331
- Updates records in the specified table that match the where conditions.
332
- Organization ID filtering is automatically applied for multi-tenant security.
333
-
334
- Args:
335
- data: Data to update
336
-
337
- table: Table name to update
338
-
339
- where: Where conditions
340
-
341
- environment: Environment to update in (development, staging, production)
342
-
343
- extra_headers: Send extra headers
344
-
345
- extra_query: Add additional query parameters to the request
346
-
347
- extra_body: Add additional JSON properties to the request
348
-
349
- timeout: Override the client-level default timeout for this request, in seconds
350
- """
351
- return self._put(
352
- "/db/update",
353
- body=maybe_transform(
354
- {
355
- "data": data,
356
- "table": table,
357
- "where": where,
358
- "environment": environment,
359
- },
360
- db_update_records_params.DBUpdateRecordsParams,
361
- ),
362
- options=make_request_options(
363
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
364
- ),
365
- cast_to=DBUpdateRecordsResponse,
366
- )
367
-
368
-
369
- class AsyncDBResource(AsyncAPIResource):
370
- @cached_property
371
- def tables(self) -> AsyncTablesResource:
372
- return AsyncTablesResource(self._client)
373
-
374
- @cached_property
375
- def with_raw_response(self) -> AsyncDBResourceWithRawResponse:
376
- """
377
- This property can be used as a prefix for any HTTP method call to return
378
- the raw response object instead of the parsed content.
379
-
380
- For more information, see https://www.github.com/WorqHat/worqhat-python-sdk#accessing-raw-response-data-eg-headers
381
- """
382
- return AsyncDBResourceWithRawResponse(self)
383
-
384
- @cached_property
385
- def with_streaming_response(self) -> AsyncDBResourceWithStreamingResponse:
386
- """
387
- An alternative to `.with_raw_response` that doesn't eagerly read the response body.
388
-
389
- For more information, see https://www.github.com/WorqHat/worqhat-python-sdk#with_streaming_response
390
- """
391
- return AsyncDBResourceWithStreamingResponse(self)
392
-
393
- async def delete_records(
394
- self,
395
- *,
396
- table: str,
397
- where: Dict[str, object],
398
- environment: Literal["development", "staging", "production"] | Omit = omit,
399
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
400
- # The extra values given here take precedence over values defined on the client or passed to this method.
401
- extra_headers: Headers | None = None,
402
- extra_query: Query | None = None,
403
- extra_body: Body | None = None,
404
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
405
- ) -> DBDeleteRecordsResponse:
406
- """
407
- Deletes records from the specified table that match the where conditions.
408
- Organization ID filtering is automatically applied for multi-tenant security.
409
-
410
- Args:
411
- table: Table name to delete from
412
-
413
- where: Where conditions
414
-
415
- environment: Environment to delete from (development, staging, production)
416
-
417
- extra_headers: Send extra headers
418
-
419
- extra_query: Add additional query parameters to the request
420
-
421
- extra_body: Add additional JSON properties to the request
422
-
423
- timeout: Override the client-level default timeout for this request, in seconds
424
- """
425
- return await self._delete(
426
- "/db/delete",
427
- body=await async_maybe_transform(
428
- {
429
- "table": table,
430
- "where": where,
431
- "environment": environment,
432
- },
433
- db_delete_records_params.DBDeleteRecordsParams,
434
- ),
435
- options=make_request_options(
436
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
437
- ),
438
- cast_to=DBDeleteRecordsResponse,
439
- )
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
-
490
- async def execute_query(
491
- self,
492
- *,
493
- query: str,
494
- environment: Literal["development", "staging", "production"] | Omit = omit,
495
- params: Union[Dict[str, object], SequenceNotStr[Union[str, float, bool]]] | Omit = omit,
496
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
497
- # The extra values given here take precedence over values defined on the client or passed to this method.
498
- extra_headers: Headers | None = None,
499
- extra_query: Query | None = None,
500
- extra_body: Body | None = None,
501
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
502
- ) -> DBExecuteQueryResponse:
503
- """Executes a raw SQL query directly against the database.
504
-
505
- Supports both named
506
- parameters ({param}) and positional parameters ($1, $2). Provides security
507
- guardrails to prevent destructive operations.
508
-
509
- Args:
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
516
-
517
- extra_headers: Send extra headers
518
-
519
- extra_query: Add additional query parameters to the request
520
-
521
- extra_body: Add additional JSON properties to the request
522
-
523
- timeout: Override the client-level default timeout for this request, in seconds
524
- """
525
- return await self._post(
526
- "/db/query",
527
- body=await async_maybe_transform(
528
- {
529
- "query": query,
530
- "environment": environment,
531
- "params": params,
532
- },
533
- db_execute_query_params.DBExecuteQueryParams,
534
- ),
535
- options=make_request_options(
536
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
537
- ),
538
- cast_to=DBExecuteQueryResponse,
539
- )
540
-
541
- async def insert_record(
542
- self,
543
- *,
544
- data: Dict[str, object],
545
- table: str,
546
- environment: Literal["development", "staging", "production"] | Omit = omit,
547
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
548
- # The extra values given here take precedence over values defined on the client or passed to this method.
549
- extra_headers: Headers | None = None,
550
- extra_query: Query | None = None,
551
- extra_body: Body | None = None,
552
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
553
- ) -> DBInsertRecordResponse:
554
- """Inserts a new record into the specified table.
555
-
556
- Organization ID is automatically
557
- added for multi-tenant security.
558
-
559
- Args:
560
- data: Data to insert
561
-
562
- table: Table name to insert into
563
-
564
- environment: Environment to insert into (development, staging, production)
565
-
566
- extra_headers: Send extra headers
567
-
568
- extra_query: Add additional query parameters to the request
569
-
570
- extra_body: Add additional JSON properties to the request
571
-
572
- timeout: Override the client-level default timeout for this request, in seconds
573
- """
574
- return await self._post(
575
- "/db/insert",
576
- body=await async_maybe_transform(
577
- {
578
- "data": data,
579
- "table": table,
580
- "environment": environment,
581
- },
582
- db_insert_record_params.DBInsertRecordParams,
583
- ),
584
- options=make_request_options(
585
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
586
- ),
587
- cast_to=DBInsertRecordResponse,
588
- )
589
-
590
- async def process_nl_query(
591
- self,
592
- *,
593
- question: str,
594
- context: Dict[str, object] | Omit = omit,
595
- environment: Literal["development", "staging", "production"] | Omit = omit,
596
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
597
- # The extra values given here take precedence over values defined on the client or passed to this method.
598
- extra_headers: Headers | None = None,
599
- extra_query: Query | None = None,
600
- extra_body: Body | None = None,
601
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
602
- ) -> DBProcessNlQueryResponse:
603
- """
604
- Converts a natural language question into a SQL query and executes it.
605
- Organization ID filtering is automatically applied for multi-tenant security.
606
-
607
- Args:
608
- question: Natural language question
609
-
610
- context: Optional context for the query
611
-
612
- environment: Environment to query (development, staging, production)
613
-
614
- extra_headers: Send extra headers
615
-
616
- extra_query: Add additional query parameters to the request
617
-
618
- extra_body: Add additional JSON properties to the request
619
-
620
- timeout: Override the client-level default timeout for this request, in seconds
621
- """
622
- return await self._post(
623
- "/db/nl-query",
624
- body=await async_maybe_transform(
625
- {
626
- "question": question,
627
- "context": context,
628
- "environment": environment,
629
- },
630
- db_process_nl_query_params.DBProcessNlQueryParams,
631
- ),
632
- options=make_request_options(
633
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
634
- ),
635
- cast_to=DBProcessNlQueryResponse,
636
- )
637
-
638
- async def update_records(
639
- self,
640
- *,
641
- data: Dict[str, object],
642
- table: str,
643
- where: Dict[str, object],
644
- environment: Literal["development", "staging", "production"] | Omit = omit,
645
- # Use the following arguments if you need to pass additional parameters to the API that aren't available via kwargs.
646
- # The extra values given here take precedence over values defined on the client or passed to this method.
647
- extra_headers: Headers | None = None,
648
- extra_query: Query | None = None,
649
- extra_body: Body | None = None,
650
- timeout: float | httpx.Timeout | None | NotGiven = not_given,
651
- ) -> DBUpdateRecordsResponse:
652
- """
653
- Updates records in the specified table that match the where conditions.
654
- Organization ID filtering is automatically applied for multi-tenant security.
655
-
656
- Args:
657
- data: Data to update
658
-
659
- table: Table name to update
660
-
661
- where: Where conditions
662
-
663
- environment: Environment to update in (development, staging, production)
664
-
665
- extra_headers: Send extra headers
666
-
667
- extra_query: Add additional query parameters to the request
668
-
669
- extra_body: Add additional JSON properties to the request
670
-
671
- timeout: Override the client-level default timeout for this request, in seconds
672
- """
673
- return await self._put(
674
- "/db/update",
675
- body=await async_maybe_transform(
676
- {
677
- "data": data,
678
- "table": table,
679
- "where": where,
680
- "environment": environment,
681
- },
682
- db_update_records_params.DBUpdateRecordsParams,
683
- ),
684
- options=make_request_options(
685
- extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout
686
- ),
687
- cast_to=DBUpdateRecordsResponse,
688
- )
689
-
690
-
691
- class DBResourceWithRawResponse:
692
- def __init__(self, db: DBResource) -> None:
693
- self._db = db
694
-
695
- self.delete_records = to_raw_response_wrapper(
696
- db.delete_records,
697
- )
698
- self.execute_batch = to_raw_response_wrapper(
699
- db.execute_batch,
700
- )
701
- self.execute_query = to_raw_response_wrapper(
702
- db.execute_query,
703
- )
704
- self.insert_record = to_raw_response_wrapper(
705
- db.insert_record,
706
- )
707
- self.process_nl_query = to_raw_response_wrapper(
708
- db.process_nl_query,
709
- )
710
- self.update_records = to_raw_response_wrapper(
711
- db.update_records,
712
- )
713
-
714
- @cached_property
715
- def tables(self) -> TablesResourceWithRawResponse:
716
- return TablesResourceWithRawResponse(self._db.tables)
717
-
718
-
719
- class AsyncDBResourceWithRawResponse:
720
- def __init__(self, db: AsyncDBResource) -> None:
721
- self._db = db
722
-
723
- self.delete_records = async_to_raw_response_wrapper(
724
- db.delete_records,
725
- )
726
- self.execute_batch = async_to_raw_response_wrapper(
727
- db.execute_batch,
728
- )
729
- self.execute_query = async_to_raw_response_wrapper(
730
- db.execute_query,
731
- )
732
- self.insert_record = async_to_raw_response_wrapper(
733
- db.insert_record,
734
- )
735
- self.process_nl_query = async_to_raw_response_wrapper(
736
- db.process_nl_query,
737
- )
738
- self.update_records = async_to_raw_response_wrapper(
739
- db.update_records,
740
- )
741
-
742
- @cached_property
743
- def tables(self) -> AsyncTablesResourceWithRawResponse:
744
- return AsyncTablesResourceWithRawResponse(self._db.tables)
745
-
746
-
747
- class DBResourceWithStreamingResponse:
748
- def __init__(self, db: DBResource) -> None:
749
- self._db = db
750
-
751
- self.delete_records = to_streamed_response_wrapper(
752
- db.delete_records,
753
- )
754
- self.execute_batch = to_streamed_response_wrapper(
755
- db.execute_batch,
756
- )
757
- self.execute_query = to_streamed_response_wrapper(
758
- db.execute_query,
759
- )
760
- self.insert_record = to_streamed_response_wrapper(
761
- db.insert_record,
762
- )
763
- self.process_nl_query = to_streamed_response_wrapper(
764
- db.process_nl_query,
765
- )
766
- self.update_records = to_streamed_response_wrapper(
767
- db.update_records,
768
- )
769
-
770
- @cached_property
771
- def tables(self) -> TablesResourceWithStreamingResponse:
772
- return TablesResourceWithStreamingResponse(self._db.tables)
773
-
774
-
775
- class AsyncDBResourceWithStreamingResponse:
776
- def __init__(self, db: AsyncDBResource) -> None:
777
- self._db = db
778
-
779
- self.delete_records = async_to_streamed_response_wrapper(
780
- db.delete_records,
781
- )
782
- self.execute_batch = async_to_streamed_response_wrapper(
783
- db.execute_batch,
784
- )
785
- self.execute_query = async_to_streamed_response_wrapper(
786
- db.execute_query,
787
- )
788
- self.insert_record = async_to_streamed_response_wrapper(
789
- db.insert_record,
790
- )
791
- self.process_nl_query = async_to_streamed_response_wrapper(
792
- db.process_nl_query,
793
- )
794
- self.update_records = async_to_streamed_response_wrapper(
795
- db.update_records,
796
- )
797
-
798
- @cached_property
799
- def tables(self) -> AsyncTablesResourceWithStreamingResponse:
800
- return AsyncTablesResourceWithStreamingResponse(self._db.tables)