Method: Azure::Table::TableService#merge_entity

Defined in:
lib/azure/table/table_service.rb

#merge_entity(table_name, entity_values, options = {}) ⇒ Object

Public: Updates an existing entity by updating the entity’s properties. This operation does not replace the existing entity, as the update_entity operation does.

Attributes

  • table_name - String. The table name

  • entity_values - Hash. A hash of the name/value pairs for the entity.

  • options - Hash. Optional parameters.

Options

Accepted key/value pairs in options parameter are:

  • :if_match - String. A matching condition which is required for update (optional, Default=“*”)

  • :create_if_not_exists - Boolean. If true, and partition_key and row_key do not reference and existing entity, that entity will be inserted. If false, the operation will fail. (optional, Default=false)

  • :timeout - Integer. A timeout in seconds.

See msdn.microsoft.com/en-us/library/azure/dd179392

Returns the ETag for the entity on success



336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
# File 'lib/azure/table/table_service.rb', line 336

def merge_entity(table_name, entity_values, options={})
  if_match = "*"
  if_match = options[:if_match] if options[:if_match]

  query = { }
  query["timeout"] = options[:timeout].to_s if options[:timeout]

  uri = entities_uri(table_name, entity_values["PartitionKey"], entity_values["RowKey"], query)

  headers = { "X-HTTP-Method"=> "MERGE" }
  headers["If-Match"] = if_match || "*" unless options[:create_if_not_exists]

  body = Azure::Table::Serialization.hash_to_entry_xml(entity_values).to_xml

  response = call(:post, uri, body, headers)
  response.headers["etag"]
end