Class: Flydata::Api::DataEntry

Inherits:
Base
  • Object
show all
Defined in:
lib/flydata/api/data_entry.rb

Instance Method Summary collapse

Methods inherited from Base

#create, #list

Constructor Details

#initialize(api_client) ⇒ DataEntry

Returns a new instance of DataEntry.



7
8
9
10
11
# File 'lib/flydata/api/data_entry.rb', line 7

def initialize(api_client)
  @model_name = 'data_entry'
  @url_path = "/data_ports/:data_port_id/#{@model_name.pluralize}"
  super
end

Instance Method Details

#buffer_stat(data_entry_id, options = {}) ⇒ Object



13
14
15
16
# File 'lib/flydata/api/data_entry.rb', line 13

def buffer_stat(data_entry_id, options = {})
  tables = options[:tables] ? options[:tables].join(',') : ''
  @client.get("/#{@model_name.pluralize}/#{data_entry_id}/buffer_stat/#{options[:mode]}?tables=#{tables}")
end

#cleanup_sync(data_entry_id, tables, options = {}) ⇒ Object



23
24
25
26
# File 'lib/flydata/api/data_entry.rb', line 23

def cleanup_sync(data_entry_id, tables, options = {})
  params = options.merge({tables: tables.join(',')})
  @client.post("/#{@model_name.pluralize}/#{data_entry_id}/cleanup_sync", nil, params)
end

#complete_init_sync(data_entry_id, stats_hash) ⇒ Object

Tells the server that an initial sync has completed

stats_hash: {"init_sync_stats":{"Table1": 100, "Table2": 12345}}
  Sent 100 records for Table1, Sent 12345 records for Table2


39
40
41
# File 'lib/flydata/api/data_entry.rb', line 39

def complete_init_sync(data_entry_id, stats_hash)
  @client.post("/#{@model_name.pluralize}/#{data_entry_id}/complete_init_sync", {:headers => {:content_type => :json}}, stats_hash.to_json)
end

#table_status(data_entry_id, options = {}) ⇒ Object



18
19
20
21
# File 'lib/flydata/api/data_entry.rb', line 18

def table_status(data_entry_id, options = {})
  tables = options[:tables] ? options[:tables].join(',') : ''
  @client.post("/#{@model_name.pluralize}/#{data_entry_id}/table_status", nil, {tables: tables})
end

#update_table_validity(data_entry_id, table_validity_hash) ⇒ Object

Update validity of tables

table_validity_hash: {"updated_tables":{ "bad_table": "error reason", "good_table": nil }}
  table "bad_table" will be marked invalid with reason "error reason"
  table "good table" will be marked valid, that is, clear its error reason if it's set.


32
33
34
# File 'lib/flydata/api/data_entry.rb', line 32

def update_table_validity(data_entry_id, table_validity_hash)
  @client.post("/#{@model_name.pluralize}/#{data_entry_id}/update_table_validity", {:headers => {:content_type => :json}}, table_validity_hash.to_json)
end