Method: Azure::Table::TableService#update_entity

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

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

Public: Updates an existing entity in a table. The Update Entity operation replaces the entire entity and can be used to remove properties.

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/dd179427

Returns the ETag for the entity on success



298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
# File 'lib/azure/table/table_service.rb', line 298

def update_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 = {}
  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(:put, uri, body, headers)
  response.headers["etag"]
end