@@ -165,12 +165,25 @@ def __repr__(self):
165
165
return "<QueryFilter [{} {} {}]>" .format (self .column_name , self .filter_type , self .value )
166
166
167
167
168
+ class AuditBehavior :
169
+ """
170
+ Enum of different auditing levels
171
+ """
172
+
173
+ DETAILED = "DETAILED"
174
+ NONE = "NONE"
175
+ SUMMARY = "SUMMARY"
176
+
177
+
168
178
def delete_rows (
169
179
server_context : ServerContext ,
170
180
schema_name : str ,
171
181
query_name : str ,
172
182
rows : any ,
173
183
container_path : str = None ,
184
+ transacted : bool = True ,
185
+ audit_behavior : AuditBehavior = None ,
186
+ audit_user_comment : str = None ,
174
187
timeout : int = _default_timeout ,
175
188
):
176
189
"""
@@ -180,12 +193,25 @@ def delete_rows(
180
193
:param query_name: table name to delete from
181
194
:param rows: Set of rows to delete
182
195
:param container_path: labkey container path if not already set in context
196
+ :param transacted: whether all of the updates should be done in a single transaction
197
+ :param audit_behavior: used to override the audit behavior for the update. See class query.AuditBehavior
198
+ :param audit_user_comment: used to provide a comment that will be attached to certain detailed audit log records
183
199
:param timeout: timeout of request in seconds (defaults to 30s)
184
200
:return:
185
201
"""
186
202
url = server_context .build_url ("query" , "deleteRows.api" , container_path = container_path )
203
+
187
204
payload = {"schemaName" : schema_name , "queryName" : query_name , "rows" : rows }
188
205
206
+ if transacted is False :
207
+ payload ["transacted" ] = transacted
208
+
209
+ if audit_behavior is not None :
210
+ payload ["auditBehavior" ] = audit_behavior
211
+
212
+ if audit_user_comment is not None :
213
+ payload ["auditUserComment" ] = audit_user_comment
214
+
189
215
return server_context .make_request (
190
216
url ,
191
217
json = payload ,
@@ -288,6 +314,10 @@ def insert_rows(
288
314
query_name : str ,
289
315
rows : List [any ],
290
316
container_path : str = None ,
317
+ skip_reselect_rows : bool = False ,
318
+ transacted : bool = True ,
319
+ audit_behavior : AuditBehavior = None ,
320
+ audit_user_comment : str = None ,
291
321
timeout : int = _default_timeout ,
292
322
):
293
323
"""
@@ -297,13 +327,29 @@ def insert_rows(
297
327
:param query_name: table name to insert into
298
328
:param rows: set of rows to insert
299
329
:param container_path: labkey container path if not already set in context
330
+ :param skip_reselect_rows: whether the full detailed response for the insert can be skipped
331
+ :param transacted: whether all of the updates should be done in a single transaction
332
+ :param audit_behavior: used to override the audit behavior for the update. See class query.AuditBehavior
333
+ :param audit_user_comment: used to provide a comment that will be attached to certain detailed audit log records
300
334
:param timeout: timeout of request in seconds (defaults to 30s)
301
335
:return:
302
336
"""
303
337
url = server_context .build_url ("query" , "insertRows.api" , container_path = container_path )
304
338
305
339
payload = {"schemaName" : schema_name , "queryName" : query_name , "rows" : rows }
306
340
341
+ if skip_reselect_rows is True :
342
+ payload ["skipReselectRows" ] = skip_reselect_rows
343
+
344
+ if transacted is False :
345
+ payload ["transacted" ] = transacted
346
+
347
+ if audit_behavior is not None :
348
+ payload ["auditBehavior" ] = audit_behavior
349
+
350
+ if audit_user_comment is not None :
351
+ payload ["auditUserComment" ] = audit_user_comment
352
+
307
353
return server_context .make_request (
308
354
url ,
309
355
json = payload ,
@@ -422,6 +468,9 @@ def update_rows(
422
468
query_name : str ,
423
469
rows : List [any ],
424
470
container_path : str = None ,
471
+ transacted : bool = True ,
472
+ audit_behavior : AuditBehavior = None ,
473
+ audit_user_comment : str = None ,
425
474
timeout : int = _default_timeout ,
426
475
):
427
476
"""
@@ -432,13 +481,25 @@ def update_rows(
432
481
:param query_name: table name to update
433
482
:param rows: Set of rows to update
434
483
:param container_path: labkey container path if not already set in context
484
+ :param transacted: whether all of the updates should be done in a single transaction
485
+ :param audit_behavior: used to override the audit behavior for the update. See class query.AuditBehavior
486
+ :param audit_user_comment: used to provide a comment that will be attached to certain detailed audit log records
435
487
:param timeout: timeout of request in seconds (defaults to 30s)
436
488
:return:
437
489
"""
438
490
url = server_context .build_url ("query" , "updateRows.api" , container_path = container_path )
439
491
440
492
payload = {"schemaName" : schema_name , "queryName" : query_name , "rows" : rows }
441
493
494
+ if transacted is False :
495
+ payload ["transacted" ] = transacted
496
+
497
+ if audit_behavior is not None :
498
+ payload ["auditBehavior" ] = audit_behavior
499
+
500
+ if audit_user_comment is not None :
501
+ payload ["auditUserComment" ] = audit_user_comment
502
+
442
503
return server_context .make_request (
443
504
url ,
444
505
json = payload ,
@@ -461,10 +522,21 @@ def delete_rows(
461
522
query_name : str ,
462
523
rows : any ,
463
524
container_path : str = None ,
525
+ transacted : bool = True ,
526
+ audit_behavior : AuditBehavior = None ,
527
+ audit_user_comment : str = None ,
464
528
timeout : int = _default_timeout ,
465
529
):
466
530
return delete_rows (
467
- self .server_context , schema_name , query_name , rows , container_path , timeout
531
+ self .server_context ,
532
+ schema_name ,
533
+ query_name ,
534
+ rows ,
535
+ container_path ,
536
+ transacted ,
537
+ audit_behavior ,
538
+ audit_user_comment ,
539
+ timeout
468
540
)
469
541
470
542
@functools .wraps (truncate_table )
@@ -512,10 +584,23 @@ def insert_rows(
512
584
query_name : str ,
513
585
rows : List [any ],
514
586
container_path : str = None ,
587
+ skip_reselect_rows : bool = False ,
588
+ transacted : bool = True ,
589
+ audit_behavior : AuditBehavior = None ,
590
+ audit_user_comment : str = None ,
515
591
timeout : int = _default_timeout ,
516
592
):
517
593
return insert_rows (
518
- self .server_context , schema_name , query_name , rows , container_path , timeout
594
+ self .server_context ,
595
+ schema_name ,
596
+ query_name ,
597
+ rows ,
598
+ container_path ,
599
+ skip_reselect_rows ,
600
+ transacted ,
601
+ audit_behavior ,
602
+ audit_user_comment ,
603
+ timeout
519
604
)
520
605
521
606
@functools .wraps (select_rows )
@@ -571,8 +656,19 @@ def update_rows(
571
656
query_name : str ,
572
657
rows : List [any ],
573
658
container_path : str = None ,
659
+ transacted : bool = True ,
660
+ audit_behavior : AuditBehavior = None ,
661
+ audit_user_comment : str = None ,
574
662
timeout : int = _default_timeout ,
575
663
):
576
664
return update_rows (
577
- self .server_context , schema_name , query_name , rows , container_path , timeout
665
+ self .server_context ,
666
+ schema_name ,
667
+ query_name ,
668
+ rows ,
669
+ container_path ,
670
+ transacted ,
671
+ audit_behavior ,
672
+ audit_user_comment ,
673
+ timeout
578
674
)
0 commit comments