def merge_entity(self, table_name, partition_key, row_key, entity, content_type='application/atom+xml', if_match='*'): ''' Updates an existing entity by updating the entity's properties. This operation does not replace the existing entity as the Update Entity operation does. entity: Required. The entity object to insert. Can be a dict format or entity object. partition_key: PartitionKey of the entity. row_key: RowKey of the entity. Content-Type: this is required and has to be set to application/atom+xml ''' _validate_not_none('table_name', table_name) _validate_not_none('partition_key', partition_key) _validate_not_none('row_key', row_key) _validate_not_none('entity', entity) _validate_not_none('content_type', content_type) request = HTTPRequest() request.method = 'MERGE' request.host = _get_table_host(self.account_name, self.use_local_storage) request.path = '/' + str(table_name) + '(PartitionKey=\'' + str(partition_key) + '\',RowKey=\'' + str(row_key) + '\')' request.headers = [ ('Content-Type', _str_or_none(content_type)), ('If-Match', _str_or_none(if_match)) ] request.body = _get_request_body(convert_entity_to_xml(entity)) request.path, request.query = _update_request_uri_query_local_storage(request, self.use_local_storage) request.headers = _update_storage_table_header(request) response = self._perform_request(request) return _parse_response_for_dict_filter(response, filter=['etag'])
def insert_or_merge_entity(self, table_name, partition_key, row_key, entity, content_type='application/atom+xml'): ''' Merges 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. entity: Required. The entity object to insert. Could be a dict format or entity object. partition_key: PartitionKey of the entity. row_key: RowKey of the entity. Content-Type: this is required and has to be set to application/atom+xml ''' _validate_not_none('table_name', table_name) _validate_not_none('partition_key', partition_key) _validate_not_none('row_key', row_key) _validate_not_none('entity', entity) _validate_not_none('content_type', content_type) request = HTTPRequest() request.method = 'MERGE' request.host = _get_table_host(self.account_name, self.use_local_storage) request.path = '/' + str(table_name) + '(PartitionKey=\'' + str(partition_key) + '\',RowKey=\'' + str(row_key) + '\')' request.headers = [('Content-Type', _str_or_none(content_type))] request.body = _get_request_body(convert_entity_to_xml(entity)) request.path, request.query = _update_request_uri_query_local_storage(request, self.use_local_storage) request.headers = _update_storage_table_header(request) response = self._perform_request(request) return _parse_response_for_dict_filter(response, filter=['etag'])
def insert_or_merge_entity(self, table_name, partition_key, row_key, entity, content_type='application/atom+xml'): ''' Merges 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. entity: Required. The entity object to insert. Could be a dict format or entity object. partition_key: PartitionKey of the entity. row_key: RowKey of the entity. Content-Type: this is required and has to be set to application/atom+xml ''' _validate_not_none('table_name', table_name) _validate_not_none('partition_key', partition_key) _validate_not_none('row_key', row_key) _validate_not_none('entity', entity) _validate_not_none('content_type', content_type) request = HTTPRequest() request.method = 'MERGE' request.host = self._get_host() request.path = '/' + str(table_name) + '(PartitionKey=\'' + str(partition_key) + '\',RowKey=\'' + str(row_key) + '\')' request.headers = [('Content-Type', _str_or_none(content_type))] request.body = _get_request_body(convert_entity_to_xml(entity)) request.path, request.query = _update_request_uri_query_local_storage(request, self.use_local_storage) request.headers = _update_storage_table_header(request) response = self._perform_request(request) return _parse_response_for_dict_filter(response, filter=['etag'])
def merge_entity(self, table_name, partition_key, row_key, entity, content_type='application/atom+xml', if_match='*'): ''' Updates an existing entity by updating the entity's properties. This operation does not replace the existing entity as the Update Entity operation does. entity: Required. The entity object to insert. Can be a dict format or entity object. partition_key: PartitionKey of the entity. row_key: RowKey of the entity. Content-Type: this is required and has to be set to application/atom+xml ''' _validate_not_none('table_name', table_name) _validate_not_none('partition_key', partition_key) _validate_not_none('row_key', row_key) _validate_not_none('entity', entity) _validate_not_none('content_type', content_type) request = HTTPRequest() request.method = 'MERGE' request.host = self._get_host() request.path = '/' + str(table_name) + '(PartitionKey=\'' + str(partition_key) + '\',RowKey=\'' + str(row_key) + '\')' request.headers = [ ('Content-Type', _str_or_none(content_type)), ('If-Match', _str_or_none(if_match)) ] request.body = _get_request_body(convert_entity_to_xml(entity)) request.path, request.query = _update_request_uri_query_local_storage(request, self.use_local_storage) request.headers = _update_storage_table_header(request) response = self._perform_request(request) return _parse_response_for_dict_filter(response, filter=['etag'])
def insert_entity(self, table_name, entity, content_type='application/atom+xml'): ''' Inserts a new entity into a table. entity: Required. The entity object to insert. Could be a dict format or entity object. Content-Type: this is required and has to be set to application/atom+xml ''' _validate_not_none('table_name', table_name) _validate_not_none('entity', entity) _validate_not_none('content_type', content_type) request = HTTPRequest() request.method = 'POST' request.host = self._get_host() request.path = '/' + _str(table_name) + '' request.headers = [('Content-Type', _str_or_none(content_type))] request.body = _get_request_body(convert_entity_to_xml(entity)) request.path, request.query = _update_request_uri_query_local_storage( request, self.use_local_storage) request.headers = _update_storage_table_header(request) response = self._perform_request(request) return _convert_response_to_entity(response)
def update_entity(self, table_name, partition_key, row_key, entity, content_type='application/atom+xml', if_match='*'): ''' Updates an existing entity in a table. The Update Entity operation replaces the entire entity and can be used to remove properties. entity: Required. The entity object to insert. Could be a dict format or entity object. partition_key: PartitionKey of the entity. row_key: RowKey of the entity. Content-Type: this is required and has to be set to application/atom+xml ''' _validate_not_none('table_name', table_name) _validate_not_none('partition_key', partition_key) _validate_not_none('row_key', row_key) _validate_not_none('entity', entity) _validate_not_none('content_type', content_type) request = HTTPRequest() request.method = 'PUT' request.host = _get_table_host(self.account_name, self.use_local_storage) request.path = '/' + str(table_name) + '(PartitionKey=\'' + str( partition_key) + '\',RowKey=\'' + str(row_key) + '\')' request.headers = [('Content-Type', _str_or_none(content_type)), ('If-Match', _str_or_none(if_match))] request.body = _get_request_body(convert_entity_to_xml(entity)) request.path, request.query = _update_request_uri_query_local_storage( request, self.use_local_storage) request.headers = _update_storage_table_header(request) response = self._perform_request(request)
def insert_entity(self, table_name, entity, content_type='application/atom+xml'): ''' Inserts a new entity into a table. entity: Required. The entity object to insert. Could be a dict format or entity object. Content-Type: this is required and has to be set to application/atom+xml ''' _validate_not_none('table_name', table_name) _validate_not_none('entity', entity) _validate_not_none('content_type', content_type) request = HTTPRequest() request.method = 'POST' request.host = _get_table_host(self.account_name, self.use_local_storage) request.path = '/' + str(table_name) + '' request.headers = [('Content-Type', _str_or_none(content_type))] request.body = _get_request_body(convert_entity_to_xml(entity)) request.path, request.query = _update_request_uri_query_local_storage(request, self.use_local_storage) request.headers = _update_storage_table_header(request) response = self._perform_request(request)