@@ -348,9 +348,6 @@ def update_user(ctx: Context, userid: str, status: str = None, roles=None):
348348 return json .loads (rsp .read ())
349349
350350
351- #
352- # Transaction endpoint
353- #
354351class Transaction (object ):
355352 def __init__ (self , database : str , engine : str , abort = False ,
356353 mode : Mode = Mode .OPEN , nowait_durable = False , readonly = False ,
@@ -406,23 +403,15 @@ def run(self, ctx: Context, *args) -> dict:
406403 return json .loads (rsp .read ())
407404
408405
409- #
410- # /transactions endpoint
411- #
412406class TransactionAsync (object ):
413- def __init__ (self , database : str , engine : str , command : str , nowait_durable = False , readonly = False ,
414- inputs : dict = None ):
407+ def __init__ (self , database : str , engine : str , nowait_durable = False , readonly = False ):
415408 self .database = database
416409 self .engine = engine
417- self .command = command
418410 self .nowait_durable = nowait_durable
419411 self .readonly = readonly
420- self .inputs = inputs
421412
422413 @property
423414 def data (self ):
424- inputs = self .inputs or {}
425- inputs = [_query_action_input (k , v ) for k , v in inputs .items ()]
426415 result = {
427416 "dbname" : self .database ,
428417 "nowait_durable" : self .nowait_durable ,
@@ -431,16 +420,18 @@ def data(self):
431420 }
432421 if self .engine is not None :
433422 result ["engine_name" ] = self .engine
434- result ["query" ] = self .command
435- result ["inputs" ] = inputs
436423 return result
437424
438- def run (self , ctx : Context ) -> Union [dict , list ]:
425+ def run (self , ctx : Context , command : str , inputs : dict = None ) -> Union [dict , list ]:
439426 data = self .data
440- url = _mkurl (ctx , PATH_TRANSACTIONS )
441- rsp = rest .post (ctx , url , data )
427+ data ["query" ] = command
428+ if not inputs is None :
429+ inputs = [_query_action_input (k , v ) for k , v in inputs .items ()]
430+ data ["v1_inputs" ] = inputs
431+ rsp = rest .post (ctx , _mkurl (ctx , PATH_TRANSACTIONS ), data )
442432 content_type = rsp .headers .get ('content-type' , None )
443433 content = rsp .read ()
434+ # todo: response model should be based on status code (200 v. 201)
444435 # async mode
445436 if content_type .lower () == "application/json" :
446437 return json .loads (content )
@@ -668,8 +659,8 @@ def query(ctx: Context, database: str, engine: str, command: str,
668659
669660def query_async (ctx : Context , database : str , engine : str , command : str ,
670661 readonly : bool = True , inputs : dict = None ) -> Union [dict , list ]:
671- tx = TransactionAsync (database , engine , command , readonly = readonly , inputs = inputs )
672- return tx .run (ctx )
662+ tx = TransactionAsync (database , engine , readonly = readonly )
663+ return tx .run (ctx , command , inputs = inputs )
673664
674665
675666create_compute = create_engine # deprecated, use create_engine
0 commit comments