Method: Azure::Table::TableService#insert_entity
- Defined in:
- lib/azure/table/table_service.rb
#insert_entity(table_name, entity_values, options = {}) ⇒ Object
Public: Inserts new entity to the table.
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:
-
:timeout- Integer. A timeout in seconds.
See msdn.microsoft.com/en-us/library/azure/dd179433
Returns a Azure::Entity::Table::Entity
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/azure/table/table_service.rb', line 204 def insert_entity(table_name, entity_values, ={}) body = Azure::Table::Serialization.hash_to_entry_xml(entity_values).to_xml query = { } query['timeout'] = [:timeout].to_s if [:timeout] response = call(:post, entities_uri(table_name, nil, nil, query), body) result = Azure::Table::Serialization.hash_from_entry_xml(response.body) Entity.new do |entity| entity.table = table_name entity.updated = result[:updated] entity.etag = response.headers['etag'] || result[:etag] entity.properties = result[:properties] end end |