@@ -9,28 +9,34 @@ def __init__(self, api):
99 self .api = api
1010
1111 def to_received (self , work_id : str , message : str ):
12- self .api .app_logger .info ("Reporting work update_received" , {"work_id" : work_id })
13- query = """
14- mutation workToReceived($id: ID!, $message: String) {
15- workEdit(id: $id) {
16- toReceived (message: $message)
12+ if self .api .bundle_send_to_queue :
13+ self .api .app_logger .info (
14+ "Reporting work update_received" , {"work_id" : work_id }
15+ )
16+ query = """
17+ mutation workToReceived($id: ID!, $message: String) {
18+ workEdit(id: $id) {
19+ toReceived (message: $message)
20+ }
1721 }
18- }
19- """
20- self .api .query (query , {"id" : work_id , "message" : message })
22+ """
23+ self .api .query (query , {"id" : work_id , "message" : message })
2124
2225 def to_processed (self , work_id : str , message : str , in_error : bool = False ):
23- self .api .app_logger .info (
24- "Reporting work update_processed" , {"work_id" : work_id }
25- )
26- query = """
27- mutation workToProcessed($id: ID!, $message: String, $inError: Boolean) {
28- workEdit(id: $id) {
29- toProcessed (message: $message, inError: $inError)
26+ if self .api .bundle_send_to_queue :
27+ self .api .app_logger .info (
28+ "Reporting work update_processed" , {"work_id" : work_id }
29+ )
30+ query = """
31+ mutation workToProcessed($id: ID!, $message: String, $inError: Boolean) {
32+ workEdit(id: $id) {
33+ toProcessed (message: $message, inError: $inError)
34+ }
3035 }
31- }
32- """
33- self .api .query (query , {"id" : work_id , "message" : message , "inError" : in_error })
36+ """
37+ self .api .query (
38+ query , {"id" : work_id , "message" : message , "inError" : in_error }
39+ )
3440
3541 def ping (self , work_id : str ):
3642 self .api .app_logger .info ("Ping work" , {"work_id" : work_id })
@@ -44,49 +50,52 @@ def ping(self, work_id: str):
4450 self .api .query (query , {"id" : work_id })
4551
4652 def report_expectation (self , work_id : str , error ):
47- self .api .app_logger .info ("Report expectation" , {"work_id" : work_id })
48- query = """
49- mutation reportExpectation($id: ID!, $error: WorkErrorInput) {
50- workEdit(id: $id) {
51- reportExpectation(error: $error)
53+ if self .api .bundle_send_to_queue :
54+ self .api .app_logger .info ("Report expectation" , {"work_id" : work_id })
55+ query = """
56+ mutation reportExpectation($id: ID!, $error: WorkErrorInput) {
57+ workEdit(id: $id) {
58+ reportExpectation(error: $error)
59+ }
5260 }
53- }
54- """
55- try :
56- self .api .query (query , {"id" : work_id , "error" : error })
57- except :
58- self .api .app_logger .error ("Cannot report expectation" )
61+ """
62+ try :
63+ self .api .query (query , {"id" : work_id , "error" : error })
64+ except :
65+ self .api .app_logger .error ("Cannot report expectation" )
5966
6067 def add_expectations (self , work_id : str , expectations : int ):
61- self .api .app_logger .info (
62- "Update action expectations" ,
63- {"work_id" : work_id , "expectations" : expectations },
64- )
65- query = """
66- mutation addExpectations($id: ID!, $expectations: Int) {
67- workEdit(id: $id) {
68- addExpectations(expectations: $expectations)
68+ if self .api .bundle_send_to_queue :
69+ self .api .app_logger .info (
70+ "Update action expectations" ,
71+ {"work_id" : work_id , "expectations" : expectations },
72+ )
73+ query = """
74+ mutation addExpectations($id: ID!, $expectations: Int) {
75+ workEdit(id: $id) {
76+ addExpectations(expectations: $expectations)
77+ }
6978 }
70- }
71- """
72- try :
73- self .api .query (query , {"id" : work_id , "expectations" : expectations })
74- except :
75- self .api .app_logger .error ("Cannot report expectation" )
79+ """
80+ try :
81+ self .api .query (query , {"id" : work_id , "expectations" : expectations })
82+ except :
83+ self .api .app_logger .error ("Cannot report expectation" )
7684
7785 def initiate_work (self , connector_id : str , friendly_name : str ) -> str :
78- self .api .app_logger .info ("Initiate work" , {"connector_id" : connector_id })
79- query = """
80- mutation workAdd($connectorId: String!, $friendlyName: String) {
81- workAdd(connectorId: $connectorId, friendlyName: $friendlyName) {
82- id
86+ if self .api .bundle_send_to_queue :
87+ self .api .app_logger .info ("Initiate work" , {"connector_id" : connector_id })
88+ query = """
89+ mutation workAdd($connectorId: String!, $friendlyName: String) {
90+ workAdd(connectorId: $connectorId, friendlyName: $friendlyName) {
91+ id
92+ }
8393 }
84- }
85- """
86- work = self .api .query (
87- query , {"connectorId" : connector_id , "friendlyName" : friendly_name }
88- )
89- return work ["data" ]["workAdd" ]["id" ]
94+ """
95+ work = self .api .query (
96+ query , {"connectorId" : connector_id , "friendlyName" : friendly_name }
97+ )
98+ return work ["data" ]["workAdd" ]["id" ]
9099
91100 def delete_work (self , work_id : str ):
92101 query = """
0 commit comments