Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "umapi-client"
version = "2.17.1"
version = "2.18"
description = "Client for the User Management API (UMAPI) from Adobe - see https://adobe.ly/2h1pHgV"
readme = "README.md"
authors = ["Andrew Dorton <[email protected]>", "Dan Brotsky", "Danimae Vossen", "Kevin Bhunut"]
Expand Down
26 changes: 24 additions & 2 deletions umapi_client/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ def __init__(self,
"actions-queued": 0}
self.server_status = {"status": "Never contacted",
"endpoint": self.endpoint}
self.sync_started = False
self.sync_ended = False
if auth:
self.auth = auth
elif auth_dict:
Expand Down Expand Up @@ -369,7 +371,7 @@ def execute_multiple(self, actions, immediate=True):
Execute multiple Actions (each containing commands on a single object).
Normally, the actions are sent for execution immediately (possibly preceded
by earlier queued commands), but if you are going for maximum efficiency
you can set immeediate=False which will cause the connection to wait
you can set immediate=False which will cause the connection to wait
and batch as many actions as allowed in each server call.

Since any command can fill the current batch, one or more of your commands may be submitted
Expand Down Expand Up @@ -431,6 +433,16 @@ def execute_multiple(self, actions, immediate=True):
raise BatchError(exceptions, queued, sent, completed)
return queued, sent, completed

def start_sync(self):
"""Signal the beginning of a sync operation
Sends a header with the first batch of UMAPI actions"""
self.sync_started = True

def end_sync(self):
"""Signal the end of a sync operation
Sends a header with the next batch of UMAPI actions"""
self.sync_ended = True

def _execute_batch(self, actions):
"""
Execute a single batch of Actions.
Expand Down Expand Up @@ -467,10 +479,20 @@ def make_call(self, path, body=None, delete=False):
:return: the requests.result object (on 200 response), raise error otherwise
"""
if body:
extra_headers = {}
# if the sync_started or sync_ended flags are set, send a header on this POST
if self.sync_started:
self.logger.info("Sending start_sync signal")
extra_headers['Pragma'] = 'umapi-sync-start'
self.sync_started = False
elif self.sync_ended:
self.logger.info("Sending end_sync signal")
extra_headers['Pragma'] = 'umapi-sync-end'
self.sync_ended = False
request_body = json.dumps(body)
def call():
return self.session.post(self.endpoint + path, auth=self.auth, data=request_body, timeout=self.timeout,
verify=self.ssl_verify)
verify=self.ssl_verify, headers=extra_headers)
else:
if not delete:
def call():
Expand Down
6 changes: 6 additions & 0 deletions umapi_client/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,12 @@ def __init__(self, id_type=IdentityTypes.adobeID, email=None, username=None, dom
else:
Action.__init__(self, user=email, **kwargs)

def __str__(self):
return "UserAction "+str(self.__dict__)

def __repr__(self):
return "UserAction "+str(self.__dict__)

def create(self, first_name=None, last_name=None, country=None, email=None,
on_conflict=IfAlreadyExistsOptions.ignoreIfAlreadyExists):
"""
Expand Down
2 changes: 1 addition & 1 deletion umapi_client/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

__version__ = "2.17.1"
__version__ = "2.18"