@@ -37,14 +37,14 @@ into the system, the answer should be a list whose only element is
3737require ' rbslicer'
3838
3939# Configure the client
40- client = SlicingDice .new (master_key: " API_KEY" , uses_test_endpoint: true )
40+ client = SlicingDice .new (master_key: " API_KEY" )
4141
4242# Inserting data
4343insert_data = {
4444 " user50@slicingdice.com" => {
4545 " age" => 22
4646 },
47- " auto-create" => [" table " , " column" ]
47+ " auto-create" => [" dimension " , " column" ]
4848}
4949client.insert(insert_data)
5050
@@ -75,14 +75,13 @@ puts client.count_entity(query_data)
7575
7676### Constructor
7777
78- ` initialize(master_key: nil, custom_key: nil, read_key: nil, write_key: nil, timeout: 60, use_ssl: true, uses_test_endpoint: false ) `
78+ ` initialize(master_key: nil, custom_key: nil, read_key: nil, write_key: nil, timeout: 60, use_ssl: true) `
7979* ` master_key (String) ` - [ API key] ( https://docs.slicingdice.com/docs/api-keys ) to authenticate requests with the SlicingDice API.
8080* ` custom_key (String) ` - [ API key] ( https://docs.slicingdice.com/docs/api-keys ) to authenticate requests with the SlicingDice API.
8181* ` read_key (String) ` - [ API key] ( https://docs.slicingdice.com/docs/api-keys ) to authenticate requests with the SlicingDice API.
8282* ` write_key (String) ` - [ API key] ( https://docs.slicingdice.com/docs/api-keys ) to authenticate requests with the SlicingDice API.
8383* ` use_ssl (Bool) ` - Define if the requests verify SSL for HTTPS requests.
8484* ` timeout (Fixnum) ` - Amount of time, in seconds, to wait for results for each request.
85- * ` uses_test_endpoint (Bool) ` - If false the client will send requests to production end-point, otherwise to tests end-point.
8685
8786### ` get_database() `
8887Get information about current database. This method corresponds to a ` GET ` request at ` /database ` .
@@ -91,7 +90,7 @@ Get information about current database. This method corresponds to a `GET` reque
9190
9291``` ruby
9392require ' rbslicer'
94- client = SlicingDice .new (master_key: " API_KEY" , uses_test_endpoint: false )
93+ client = SlicingDice .new (master_key: " API_KEY" )
9594
9695puts client.get_database()
9796```
@@ -102,7 +101,7 @@ puts client.get_database()
102101{
103102 "name" : " Database 1" ,
104103 "description" : " My first database" ,
105- "tables " : [
104+ "dimensions " : [
106105 " default" ,
107106 " users"
108107 ],
@@ -118,7 +117,7 @@ Get all created columns, both active and inactive ones. This method corresponds
118117
119118``` ruby
120119require ' rbslicer'
121- client = SlicingDice .new (master_key: " API_KEY" , uses_test_endpoint: false )
120+ client = SlicingDice .new (master_key: " API_KEY" )
122121puts client.get_columns()
123122```
124123
@@ -157,7 +156,7 @@ Create a new column. This method corresponds to a [POST request at /column](http
157156
158157``` ruby
159158require ' rbslicer'
160- client = SlicingDice .new (master_key: " API_KEY" , uses_test_endpoint: false )
159+ client = SlicingDice .new (master_key: " API_KEY" )
161160column = {
162161 " name" => " Year" ,
163162 " api-name" => " year" ,
@@ -184,7 +183,7 @@ Insert data to existing entities or create new entities, if necessary. This meth
184183
185184``` ruby
186185require ' rbslicer'
187- client = SlicingDice .new (master_key: " API_KEY" , uses_test_endpoint: false )
186+ client = SlicingDice .new (master_key: " API_KEY" )
188187insert_data = {
189188 " user1@slicingdice.com" => {
190189 " car-model" => " Ford Ka" ,
@@ -218,7 +217,7 @@ insert_data = {
218217 " date" => " 2016-08-17T13:23:47+00:00"
219218 }
220219 },
221- " auto-create" => [" table " , " column" ]
220+ " auto-create" => [" dimension " , " column" ]
222221}
223222puts client.insert(insert_data)
224223```
@@ -234,14 +233,14 @@ puts client.insert(insert_data)
234233}
235234```
236235
237- ### ` exists_entity(ids, table ) `
238- Verify which entities exist in a table (uses ` default ` table if not provided) given a list of entity IDs. This method corresponds to a [ POST request at /query/exists/entity] ( https://docs.slicingdice.com/docs/exists ) .
236+ ### ` exists_entity(ids, dimension ) `
237+ Verify which entities exist in a dimension (uses ` default ` dimension if not provided) given a list of entity IDs. This method corresponds to a [ POST request at /query/exists/entity] ( https://docs.slicingdice.com/docs/exists ) .
239238
240239#### Request example
241240
242241``` ruby
243242require ' rbslicer'
244- client = SlicingDice .new (master_key: " API_KEY" , uses_test_endpoint: false )
243+ client = SlicingDice .new (master_key: " API_KEY" )
245244ids = [
246245 " user1@slicingdice.com" ,
247246 " user2@slicingdice.com" ,
@@ -273,7 +272,7 @@ Count the number of inserted entities in the whole database. This method corresp
273272
274273``` ruby
275274require ' rbslicer'
276- client = SlicingDice .new (master_key: " API_KEY" , uses_test_endpoint: false )
275+ client = SlicingDice .new (master_key: " API_KEY" )
277276
278277puts client.count_entity_total()
279278```
@@ -290,18 +289,18 @@ puts client.count_entity_total()
290289}
291290```
292291
293- ### ` count_entity_total(tables ) `
294- Count the total number of inserted entities in the given tables . This method corresponds to a [ POST request at /query/count/entity/total] ( https://docs.slicingdice.com/docs/total#section-counting-specific-tables ) .
292+ ### ` count_entity_total(dimensions ) `
293+ Count the total number of inserted entities in the given dimensions . This method corresponds to a [ POST request at /query/count/entity/total] ( https://docs.slicingdice.com/docs/total#section-counting-specific-tables ) .
295294
296295#### Request example
297296
298297``` ruby
299298require ' rbslicer'
300- client = SlicingDice .new (master_key: " API_KEY" , uses_test_endpoint: false )
299+ client = SlicingDice .new (master_key: " API_KEY" )
301300
302- tables = [" default" ]
301+ dimensions = [" default" ]
303302
304- puts client.count_entity_total(tables )
303+ puts client.count_entity_total(dimensions )
305304```
306305
307306#### Output example
@@ -323,7 +322,7 @@ Count the number of entities matching the given query. This method corresponds t
323322
324323``` ruby
325324require ' rbslicer'
326- client = SlicingDice .new (master_key: " API_KEY" , uses_test_endpoint: false )
325+ client = SlicingDice .new (master_key: " API_KEY" )
327326query = [
328327 {
329328 ' query-name' => ' corolla-or-fit' ,
@@ -377,7 +376,7 @@ Count the number of occurrences for time-series events matching the given query.
377376
378377``` ruby
379378require ' rbslicer'
380- client = SlicingDice .new (master_key: " API_KEY" , uses_test_endpoint: false )
379+ client = SlicingDice .new (master_key: " API_KEY" )
381380query = [
382381 {
383382 ' query-name' => ' test-drives-in-ny' ,
@@ -433,7 +432,7 @@ Return the top values for entities matching the given query. This method corresp
433432
434433``` ruby
435434require ' rbslicer'
436- client = SlicingDice .new (master_key: " API_KEY" , uses_test_endpoint: false )
435+ client = SlicingDice .new (master_key: " API_KEY" )
437436query = {
438437 " car-year" => {
439438 " year" => 2
@@ -491,7 +490,7 @@ Return the aggregation of all columns in the given query. This method correspond
491490
492491``` ruby
493492require ' rbslicer'
494- client = SlicingDice .new (master_key: " API_KEY" , uses_test_endpoint: false )
493+ client = SlicingDice .new (master_key: " API_KEY" )
495494query = {
496495 " query" => [
497496 {
@@ -543,7 +542,7 @@ Get all saved queries. This method corresponds to a [GET request at /query/saved
543542
544543``` ruby
545544require ' rbslicer'
546- client = SlicingDice .new (master_key: " API_KEY" , uses_test_endpoint: false )
545+ client = SlicingDice .new (master_key: " API_KEY" )
547546puts client.get_saved_queries()
548547```
549548
@@ -594,7 +593,7 @@ Create a saved query at SlicingDice. This method corresponds to a [POST request
594593
595594``` ruby
596595require ' rbslicer'
597- client = SlicingDice .new (master_key: " API_KEY" , uses_test_endpoint: false )
596+ client = SlicingDice .new (master_key: " API_KEY" )
598597query = {
599598 " name" => " my-saved-query" ,
600599 " type" => " count/entity" ,
@@ -648,7 +647,7 @@ Update an existing saved query at SlicingDice. This method corresponds to a [PUT
648647
649648``` ruby
650649require ' rbslicer'
651- client = SlicingDice .new (master_key: " API_KEY" , uses_test_endpoint: false )
650+ client = SlicingDice .new (master_key: " API_KEY" )
652651new_query = {
653652 " type" => " count/entity" ,
654653 " query" => [
@@ -700,7 +699,7 @@ Executed a saved query at SlicingDice. This method corresponds to a [GET request
700699
701700``` ruby
702701require ' rbslicer'
703- client = SlicingDice .new (master_key: " API_KEY" , uses_test_endpoint: false )
702+ client = SlicingDice .new (master_key: " API_KEY" )
704703puts client.get_saved_query(" my-saved-query" )
705704```
706705
@@ -737,7 +736,7 @@ Delete a saved query at SlicingDice. This method corresponds to a [DELETE reques
737736
738737``` ruby
739738require ' rbslicer'
740- client = SlicingDice .new (master_key: " API_KEY" , uses_test_endpoint: false )
739+ client = SlicingDice .new (master_key: " API_KEY" )
741740puts client.delete_saved_query(" my-saved-query" )
742741```
743742
@@ -774,7 +773,7 @@ Retrieve inserted values for entities matching the given query. This method corr
774773
775774``` ruby
776775require ' rbslicer'
777- client = SlicingDice .new (master_key: " API_KEY" , uses_test_endpoint: false )
776+ client = SlicingDice .new (master_key: " API_KEY" )
778777query = {
779778 " query" => [
780779 {
@@ -823,7 +822,7 @@ Retrieve inserted values as well as their relevance for entities matching the gi
823822
824823``` ruby
825824require ' rbslicer'
826- client = SlicingDice .new (master_key: " API_KEY" , uses_test_endpoint: false )
825+ client = SlicingDice .new (master_key: " API_KEY" )
827826query = {
828827 " query" => [
829828 {
@@ -868,6 +867,32 @@ puts client.score(query)
868867}
869868```
870869
870+ ### ` sql(query) `
871+ Retrieve inserted values using a SQL syntax. This method corresponds to a POST request at /query/sql.
872+
873+ #### Request example
874+
875+ ``` go
876+ require ' rbslicer'
877+ client = SlicingDice .new (master_key: " API_KEY" )
878+ query = " SELECT COUNT(*) FROM default WHERE age BETWEEN 0 AND 49"
879+
880+ puts client.sql (query)
881+ ```
882+
883+ #### Output example
884+
885+ ``` json
886+ {
887+ "took" :0.063 ,
888+ "result" :[
889+ {"COUNT" : 3 }
890+ ],
891+ "count" :1 ,
892+ "status" :" success"
893+ }
894+ ```
895+
871896## License
872897
873898[ MIT] ( https://opensource.org/licenses/MIT )
0 commit comments