def insert_or_merge_entity(self, table_name, entity, timeout=None):
_validate_not_none('<STR_LIT>', table_name)<EOL>request = _insert_or_merge_entity(entity, self.require_encryption,<EOL>self.key_encryption_key)<EOL>request.host_locations = self._get_host_locations()<EOL>request.query['<STR_LIT>'] = _int_to_str(timeout)<EOL>request.path = _get_entity_path(table_name, entity['<STR_LIT>'], entity['<STR_LIT>'])<EOL>return self._perform_request(request, _extract_etag)<EOL>
Merges an existing entity or inserts a new entity if it does not exist
in the table. 

If insert_or_merge_entity is used to merge an entity, any properties from 
the previous entity will be retained if the request does not define or 
include them.

:param str table_name:
    The name of the table in which to insert or merge the entity.
:param entity:
    The entity to insert or merge. Could be a dict or an entity object. 
    Must contain a PartitionKey and a RowKey.
:type entity: dict or :class:`~azure.storage.table.models.Entity`
:param int timeout:
    The server timeout, expressed in seconds.
:return: The etag of the entity.
:rtype: str