def insert_or_replace_entity(self, table_name, entity, timeout=None):
_validate_not_none('<STR_LIT>', table_name)<EOL>request = _insert_or_replace_entity(entity)<EOL>request.host = self._get_host()<EOL>request.query += [('<STR_LIT>', _int_to_str(timeout))]<EOL>request.path = _get_entity_path(table_name, entity['<STR_LIT>'], entity['<STR_LIT>'])<EOL>response = self._perform_request(request)<EOL>return _extract_etag(response)<EOL>
Replaces an existing entity or inserts a new entity if it does not
exist in the table. Because this operation can insert or update an
entity, it is also known as an "upsert" operation.

If insert_or_replace_entity is used to replace an entity, any properties 
from the previous entity will be removed if the new entity does not define 
them.

:param str table_name:
    The name of the table in which to insert or replace the entity.
:param entity:
    The entity to insert or replace. Could be a dict or an entity object. 
    Must contain a PartitionKey and a RowKey.
:type entity: a 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