Class: Zillabyte::API::Data
Instance Method Summary collapse
-
#append(id, options = {}) ⇒ Object
POST /datasets/1/append.
-
#create(name, options = {}) ⇒ Object
POST /datasets.
-
#get(id, options = {}) ⇒ Object
GET /datasets/1.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Zillabyte::API::Base
Instance Method Details
#append(id, options = {}) ⇒ Object
POST /datasets/1/append
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/zillabyte/api/data.rb', line 75 def append(id, = {}) opts = {:name => id} file = [:file] if [:file] if(file) opts[:size] = File.size(file) .delete(:file) end = opts.merge() res = @api.request( :expects => 200, :method => :post, :path => "/relations/#{id}/append", :body => .to_json ) hash = res.body if(hash['uri']) uri = URI(hash['uri']) response = nil try_again = 1 while(try_again) Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http| request = Net::HTTP::Put.new(uri.request_uri) request.body_stream = Zillabyte::Common::Tar.tar(file, []) request['Content-Length'] = request.body_stream.size request['Content-Type'] = '' response = http.request(request) if response.code.to_i >= 300 try_again = 1 break end try_again = nil end end hash[:appended] = opts[:size] hash.delete('uri') res = @api.request( :expects => 200, :method => :post, :path => "/relations/#{id}/store", :body => .to_json ) end hash end |
#create(name, options = {}) ⇒ Object
POST /datasets
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/zillabyte/api/data.rb', line 49 def create(name, = {}) = { :name => name, # rows # schema # relations }.merge() res = @api.request( :expects => 200, :method => :post, :path => "/relations", :body => .to_json ) res.body end |
#get(id, options = {}) ⇒ Object
GET /datasets/1
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/zillabyte/api/data.rb', line 27 def get(id, = {}) = { :name => id # rows # schema # relations }.merge() res = @api.request( :expects => 200, :method => :get, :path => "/relations/#{id}", :body => .to_json ) res.body end |