@@ -173,6 +173,8 @@ def __init__(self,
173173 "actions-queued" : 0 }
174174 self .server_status = {"status" : "Never contacted" ,
175175 "endpoint" : self .endpoint }
176+ self .sync_started = False
177+ self .sync_ended = False
176178 if auth :
177179 self .auth = auth
178180 elif auth_dict :
@@ -369,7 +371,7 @@ def execute_multiple(self, actions, immediate=True):
369371 Execute multiple Actions (each containing commands on a single object).
370372 Normally, the actions are sent for execution immediately (possibly preceded
371373 by earlier queued commands), but if you are going for maximum efficiency
372- you can set immeediate =False which will cause the connection to wait
374+ you can set immediate =False which will cause the connection to wait
373375 and batch as many actions as allowed in each server call.
374376
375377 Since any command can fill the current batch, one or more of your commands may be submitted
@@ -431,6 +433,16 @@ def execute_multiple(self, actions, immediate=True):
431433 raise BatchError (exceptions , queued , sent , completed )
432434 return queued , sent , completed
433435
436+ def start_sync (self ):
437+ """Signal the beginning of a sync operation
438+ Sends a header with the first batch of UMAPI actions"""
439+ self .sync_started = True
440+
441+ def end_sync (self ):
442+ """Signal the end of a sync operation
443+ Sends a header with the next batch of UMAPI actions"""
444+ self .sync_ended = True
445+
434446 def _execute_batch (self , actions ):
435447 """
436448 Execute a single batch of Actions.
@@ -467,10 +479,20 @@ def make_call(self, path, body=None, delete=False):
467479 :return: the requests.result object (on 200 response), raise error otherwise
468480 """
469481 if body :
482+ extra_headers = {}
483+ # if the sync_started or sync_ended flags are set, send a header on this POST
484+ if self .sync_started :
485+ self .logger .info ("Sending start_sync signal" )
486+ extra_headers ['Pragma' ] = 'umapi-sync-start'
487+ self .sync_started = False
488+ elif self .sync_ended :
489+ self .logger .info ("Sending end_sync signal" )
490+ extra_headers ['Pragma' ] = 'umapi-sync-end'
491+ self .sync_ended = False
470492 request_body = json .dumps (body )
471493 def call ():
472494 return self .session .post (self .endpoint + path , auth = self .auth , data = request_body , timeout = self .timeout ,
473- verify = self .ssl_verify )
495+ verify = self .ssl_verify , headers = extra_headers )
474496 else :
475497 if not delete :
476498 def call ():
0 commit comments