Sha256: 9c872cc4a7459e00192ec519e590cd659c5039667077d6e65c17c75d83786e58

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

require 'json'
require 'flydata/api/base'

module Flydata
  module Api
    class DataEntry < Base
      def initialize(api_client)
        @model_name = 'data_entry'
        @url_path = "/data_ports/:data_port_id/#{@model_name.pluralize}"
        super
      end

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

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

      # Update validity of tables
      #  table_validity_hash: { "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.
      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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
flydata-0.4.3 lib/flydata/api/data_entry.rb
flydata-0.4.2 lib/flydata/api/data_entry.rb
flydata-0.4.1 lib/flydata/api/data_entry.rb