Class: Zillabyte::API::Data

Inherits:
Base
  • Object
show all
Defined in:
lib/zillabyte/api/data.rb

Instance Method Summary collapse

Methods inherited from Base

#initialize, #request

Methods included from Helpers

#app, #ask, #command, #create_git_remote, #display, #error, #extract_app_from_git_config, #extract_app_in_dir, #format_with_bang, #friendly_dir, #get_flow_ui_link, #get_info, #get_rich_info, #git, #handle_downloading_manifest, #has_git?, #longest, #read_multiline, #truncate_message, #version_okay?, #with_tty

Constructor Details

This class inherits a constructor from Zillabyte::API::Base

Instance Method Details

#append(id, options = {}) ⇒ Object

POST /datasets/1/append



84
85
86
87
88
89
90
91
92
93
94
95
96
# File 'lib/zillabyte/api/data.rb', line 84

def append(id, options = {})
  
  res = @api.request(
    :expects  => 200,
    :method   => :post,
    :path     => "/relations/#{CGI.escape(id)}/append",
    # :headers  => {"Content-Type" => "application/octet-stream"},
    :body     => options.to_json
  )
  hash = res.body
  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, options = {})
  
  options = {
    :name => name,
    # rows
    # schema
    # relations
  }.merge(options)

  res = @api.request(
    :expects  => 200,
    :method   => :post,
    :path     => "/relations",
    :body     => options.to_json
  )

  res.body
  
end

#delete(id, options = {}) ⇒ Object



70
71
72
73
74
75
76
77
78
79
80
# File 'lib/zillabyte/api/data.rb', line 70

def delete(id, options={})
  
  res = @api.request(
    :expects => 200,
    :method  => :delete,
    :path    => "/relations/#{CGI.escape(id)}",
    :body    => options.to_json
  )

  res.body
end

#get(id, options = {}) ⇒ Object

GET /datasets/1



7
8
9
10
11
12
13
14
15
# File 'lib/zillabyte/api/data.rb', line 7

def get(id, options = {})
  res = @api.request(
    :expects  => 200,
    :method   => :get,
    :path     => "/relations/#{CGI.escape(id)}",
    :body     => options.to_json 
  )
  res.body
end

#pull(id, options = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
# File 'lib/zillabyte/api/data.rb', line 28

def pull(id, options = {})
  res = @api.request(
    :expects  => 200,
    :method   => :post,
    :path     => "/relations/#{CGI.escape(id)}/pull",
    :body     => options.to_json 
  )
  res.body
end

#pull_to_s3(id, options) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/zillabyte/api/data.rb', line 38

def pull_to_s3(id, options)
  res = @api.request(
    :expects => 200,
    :method  => :post,
    :path    => "/relations/#{CGI.escape(id)}/pull_to_s3",
    :body    => options.to_json
  )
  res.body
end

#show(id, method, options = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/zillabyte/api/data.rb', line 17

def show(id, method, options = {})
  res = @api.request(
    :expects  => 200,
    :method   => method,
    :path     => "/relations/#{CGI.escape(id)}/samples",
    :body     => options.to_json
  )

  res.body
end