rockset 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/lib/rockset.rb +199 -0
- metadata +44 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 4964022460f62f6c4382f0109975dc0dbe6826cd
|
|
4
|
+
data.tar.gz: e8f3c63413429207d44ea4ff861c590d207c9acd
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 86852877c71e767bdc2187ac2565f4f43776c9878675bf374c8af08e8fd3393c0ab726782be85f82c2de7e6a9b69518b325a5dc7fac0b3c85371a1fae6c64b94
|
|
7
|
+
data.tar.gz: 52062e28ffc1b9b0d5acf52ae277a02dda807f8fe58622547ca59b09ee958dab63143675f2ae4983938d0f8ee988ac80f444de7c3b39ed99cb36325da4673c88
|
data/lib/rockset.rb
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
module Rockset
|
|
2
|
+
require "json"
|
|
3
|
+
require "uri"
|
|
4
|
+
require "net/http"
|
|
5
|
+
|
|
6
|
+
class InvalidQuery < StandardError
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def Rockset.auth(api_key, server)
|
|
10
|
+
$key = api_key
|
|
11
|
+
$server = "https://#{server}/v1/orgs/self"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def Rockset.query(query)
|
|
15
|
+
uri = URI("#{$server}/queries")
|
|
16
|
+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
|
17
|
+
req = Net::HTTP::Post.new(uri)
|
|
18
|
+
req["Content-Type"] = "application/json"
|
|
19
|
+
req["Authorization"] = "ApiKey #{$key}"
|
|
20
|
+
req.body = "{\"sql\": {\"query\": \"#{query}\"}}"
|
|
21
|
+
http.request(req)
|
|
22
|
+
end
|
|
23
|
+
return(JSON.parse(res.body))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def Rockset.validate_query(query)
|
|
27
|
+
uri = URI("#{$server}/queries/validations")
|
|
28
|
+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
|
29
|
+
req = Net::HTTP::Post.new(uri)
|
|
30
|
+
req["Content-Type"] = "application/json"
|
|
31
|
+
req["Authorization"] = "ApiKey #{$key}"
|
|
32
|
+
req.body = "{\"sql\": {\"query\": \"#{query}\"}}"
|
|
33
|
+
http.request(req)
|
|
34
|
+
end
|
|
35
|
+
if res.code == "200"
|
|
36
|
+
return("Valid")
|
|
37
|
+
else
|
|
38
|
+
raise(InvalidQuery.new(res.body))
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def Rockset.add_docs(docs, collection, workspace="commons")
|
|
43
|
+
uri = URI("#{$server}/ws/#{workspace}/collections/#{collection}/docs")
|
|
44
|
+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
|
45
|
+
req = Net::HTTP::Post.new(uri)
|
|
46
|
+
req["Content-Type"] = "application/json"
|
|
47
|
+
req["Authorization"] = "ApiKey #{$key}"
|
|
48
|
+
req.body = "{\"data\": #{docs.to_json}}"
|
|
49
|
+
http.request(req)
|
|
50
|
+
end
|
|
51
|
+
return(JSON.parse(res.body))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def Rockset.del_docs(docs, collection, workspace="commons")
|
|
55
|
+
uri = URI("#{$server}/ws/#{workspace}/collections/#{collection}/docs")
|
|
56
|
+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
|
57
|
+
req = Net::HTTP::Delete.new(uri)
|
|
58
|
+
req["Content-Type"] = "application/json"
|
|
59
|
+
req["Authorization"] = "ApiKey #{$key}"
|
|
60
|
+
req.body = "{\"data\": #{docs.to_json}}"
|
|
61
|
+
http.request(req)
|
|
62
|
+
end
|
|
63
|
+
return(JSON.parse(res.body))
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def Rockset.patch_docs(docs, collection, workspace="commons")
|
|
67
|
+
uri = URI("#{$server}/ws/#{workspace}/collections/#{collection}/docs")
|
|
68
|
+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
|
69
|
+
req = Net::HTTP::Patch.new(uri)
|
|
70
|
+
req["Content-Type"] = "application/json"
|
|
71
|
+
req["Authorization"] = "ApiKey #{$key}"
|
|
72
|
+
req.body = "{\"data\": #{docs.to_json}}"
|
|
73
|
+
http.request(req)
|
|
74
|
+
end
|
|
75
|
+
return(JSON.parse(res.body))
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def Rockset.create_collection(collection_metadata, workspace="commons")
|
|
79
|
+
uri = URI("#{$server}/ws/#{workspace}/collections")
|
|
80
|
+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
|
81
|
+
req = Net::HTTP::Post.new(uri)
|
|
82
|
+
req["Content-Type"] = "application/json"
|
|
83
|
+
req["Authorization"] = "ApiKey #{$key}"
|
|
84
|
+
req.body = "#{collection_metadata.to_json}"
|
|
85
|
+
http.request(req)
|
|
86
|
+
end
|
|
87
|
+
return(JSON.parse(res.body))
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def Rockset.del_collection(collection, workspace="commons")
|
|
91
|
+
uri = URI("#{$server}/ws/#{workspace}/collections/#{collection}")
|
|
92
|
+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
|
93
|
+
req = Net::HTTP::Delete.new(uri)
|
|
94
|
+
req["Content-Type"] = "application/json"
|
|
95
|
+
req["Authorization"] = "ApiKey #{$key}"
|
|
96
|
+
http.request(req)
|
|
97
|
+
end
|
|
98
|
+
return(JSON.parse(res.body))
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def Rockset.get_collection(collection, workspace="commons")
|
|
102
|
+
uri = URI("#{$server}/ws/#{workspace}/collections/#{collection}")
|
|
103
|
+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
|
104
|
+
req = Net::HTTP::Get.new(uri)
|
|
105
|
+
req["Content-Type"] = "application/json"
|
|
106
|
+
req["Authorization"] = "ApiKey #{$key}"
|
|
107
|
+
http.request(req)
|
|
108
|
+
end
|
|
109
|
+
return(JSON.parse(res.body))
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def Rockset.get_collection_qlambdas(collection, workspace="commons")
|
|
113
|
+
uri = URI("#{$server}/ws/#{workspace}/collections/#{collection}/lambdas")
|
|
114
|
+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
|
115
|
+
req = Net::HTTP::Get.new(uri)
|
|
116
|
+
req["Content-Type"] = "application/json"
|
|
117
|
+
req["Authorization"] = "ApiKey #{$key}"
|
|
118
|
+
http.request(req)
|
|
119
|
+
end
|
|
120
|
+
return(JSON.parse(res.body))
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def Rockset.get_collections
|
|
124
|
+
uri = URI("#{$server}/collections")
|
|
125
|
+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
|
126
|
+
req = Net::HTTP::Get.new(uri)
|
|
127
|
+
req["Content-Type"] = "application/json"
|
|
128
|
+
req["Authorization"] = "ApiKey #{$key}"
|
|
129
|
+
http.request(req)
|
|
130
|
+
end
|
|
131
|
+
return(JSON.parse(res.body))
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def Rockset.get_workspace_collections(workspace="commons")
|
|
135
|
+
uri = URI("#{server}/ws/#{workspace}/collections")
|
|
136
|
+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
|
137
|
+
req = Net::HTTP::Get.new(uri)
|
|
138
|
+
req["Content-Type"] = "application/json"
|
|
139
|
+
req["Authorization"] = "ApiKey #{$key}"
|
|
140
|
+
http.request(req)
|
|
141
|
+
end
|
|
142
|
+
return(JSON.parse(res.body))
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
def Rockset.get_org
|
|
146
|
+
uri = URI("#{$server}")
|
|
147
|
+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
|
148
|
+
req = Net::HTTP::Get.new(uri)
|
|
149
|
+
req["Content-Type"] = "application/json"
|
|
150
|
+
req["Authorization"] = "ApiKey #{$key}"
|
|
151
|
+
http.request(req)
|
|
152
|
+
end
|
|
153
|
+
return(JSON.parse(res.body))
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
def Rockset.add_qlambda(name, query, description="", default_params=[], workspace="commons")
|
|
157
|
+
uri = URI("#{$server}/ws/#{workspace}/lambdas")
|
|
158
|
+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
|
159
|
+
req = Net::HTTP::Post.new(uri)
|
|
160
|
+
req["Content-Type"] = "application/json"
|
|
161
|
+
req["Authorization"] = "ApiKey #{$key}"
|
|
162
|
+
req.body = "{
|
|
163
|
+
\"name\": \"#{name}\",
|
|
164
|
+
\"description\": \"#{description}\",
|
|
165
|
+
\"sql\": {
|
|
166
|
+
\"query\": \"#{query}\",
|
|
167
|
+
\"default_parameters\": #{default_params.to_json}
|
|
168
|
+
}
|
|
169
|
+
}"
|
|
170
|
+
http.request(req)
|
|
171
|
+
end
|
|
172
|
+
return(JSON.parse(res.body))
|
|
173
|
+
end
|
|
174
|
+
|
|
175
|
+
def Rockset.del_qlambda(qlambda, workspace="commons")
|
|
176
|
+
uri = URI("#{$server}/ws/#{workspace}/lambdas/#{qlambda}")
|
|
177
|
+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
|
178
|
+
req = Net::HTTP::Delete.new(uri)
|
|
179
|
+
req["Content-Type"] = "application/json"
|
|
180
|
+
req["Authorization"] = "ApiKey #{$key}"
|
|
181
|
+
http.request(req)
|
|
182
|
+
end
|
|
183
|
+
return(JSON.parse(res.body))
|
|
184
|
+
end
|
|
185
|
+
|
|
186
|
+
def Rockset.exec_qlambda(qlambda, version, parameters=[], workspace="commons")
|
|
187
|
+
uri = URI("#{$server}/ws/#{workspace}/lambdas/#{qlambda}/versions/#{version}")
|
|
188
|
+
res = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
|
|
189
|
+
req = Net::HTTP::Post.new(uri)
|
|
190
|
+
req["Content-Type"] = "application/json"
|
|
191
|
+
req["Authorization"] = "ApiKey #{$key}"
|
|
192
|
+
req.body = "{
|
|
193
|
+
\"parameters\": #{parameters.to_json}
|
|
194
|
+
}"
|
|
195
|
+
http.request(req)
|
|
196
|
+
end
|
|
197
|
+
return(JSON.parse(res.body))
|
|
198
|
+
end
|
|
199
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: rockset
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Aarav Borthakur
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2020-12-06 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description:
|
|
14
|
+
email:
|
|
15
|
+
executables: []
|
|
16
|
+
extensions: []
|
|
17
|
+
extra_rdoc_files: []
|
|
18
|
+
files:
|
|
19
|
+
- lib/rockset.rb
|
|
20
|
+
homepage:
|
|
21
|
+
licenses:
|
|
22
|
+
- MIT
|
|
23
|
+
metadata: {}
|
|
24
|
+
post_install_message:
|
|
25
|
+
rdoc_options: []
|
|
26
|
+
require_paths:
|
|
27
|
+
- lib
|
|
28
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
34
|
+
requirements:
|
|
35
|
+
- - ">="
|
|
36
|
+
- !ruby/object:Gem::Version
|
|
37
|
+
version: '0'
|
|
38
|
+
requirements: []
|
|
39
|
+
rubyforge_project:
|
|
40
|
+
rubygems_version: 2.5.2.3
|
|
41
|
+
signing_key:
|
|
42
|
+
specification_version: 4
|
|
43
|
+
summary: Rockset Ruby Client
|
|
44
|
+
test_files: []
|