Skip to content

Commit 2ce24b6

Browse files
authored
Merge pull request #30 from SlicingDice/feature/change-table-to-dimension
Change table to dimension on code
2 parents 19cc18d + c14f13c commit 2ce24b6

File tree

5 files changed

+34
-35
lines changed

5 files changed

+34
-35
lines changed

README.md

+14-15
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SlicingDice Official Python Client (v2.0.0)
1+
# SlicingDice Official Python Client (v2.0.1)
22
### Build Status: [![CircleCI](https://circleci.com/gh/SlicingDice/slicingdice-python.svg?style=svg)](https://circleci.com/gh/SlicingDice/slicingdice-python)
33

44
Official Python client for [SlicingDice](http://www.slicingdice.com/), Data Warehouse and Analytics Database as a Service.
@@ -43,7 +43,7 @@ insert_data = {
4343
4444
"age": 22
4545
},
46-
"auto-create": ["table", "column"]
46+
"auto-create": ["dimension", "column"]
4747
}
4848
client.insert(insert_data)
4949

@@ -74,17 +74,16 @@ print(client.count_entity(query_data))
7474

7575
### Constructor
7676

77-
`__init__(self, write_key=None, read_key=None, master_key=None, custom_key=None, use_ssl=True, timeout=60, uses_test_endpoint=False)`
77+
`__init__(self, write_key=None, read_key=None, master_key=None, custom_key=None, use_ssl=True, timeout=60)`
7878
* `write_key (str)` - [API key](https://docs.slicingdice.com/docs/api-keys) to authenticate requests with the SlicingDice API Write Key.
7979
* `read_key (str)` - [API key](https://docs.slicingdice.com/docs/api-keys) to authenticate requests with the SlicingDice API Read Key.
8080
* `master_key (str)` - [API key](https://docs.slicingdice.com/docs/api-keys) to authenticate requests with the SlicingDice API Master Key.
8181
* `custom_key (str)` - [API key](https://docs.slicingdice.com/docs/api-keys) to authenticate requests with the SlicingDice API Custom Key.
8282
* `use_ssl (bool)` - Define if the requests verify SSL for HTTPS requests.
8383
* `timeout (int)` - Amount of time, in seconds, to wait for results for each request.
84-
* `uses_test_endpoint (bool)` - If false the client will send requests to production end-point, otherwise to tests end-point.
8584

8685
### `get_database()`
87-
Get information about current database(related to api keys informed on construction). This method corresponds to a `GET` request at `/database`.
86+
Get information about current database(related to api keys informed on construction). This method corresponds to a [`GET` request at `/database`](https://docs.slicingdice.com/docs/how-to-list-edit-or-delete-databases).
8887

8988
#### Request example
9089

@@ -100,7 +99,7 @@ print(client.get_database())
10099
{
101100
"name": "Database 1",
102101
"description": "My first database",
103-
"tables": [
102+
"dimensions": [
104103
"default",
105104
"users"
106105
],
@@ -109,7 +108,7 @@ print(client.get_database())
109108
}
110109
```
111110

112-
### `get_columns(test=False)`
111+
### `get_columns()`
113112
Get all created columns, both active and inactive ones. This method corresponds to a [GET request at /column](https://docs.slicingdice.com/docs/how-to-list-edit-or-delete-columns).
114113

115114
#### Request example
@@ -148,7 +147,7 @@ print(client.get_columns())
148147
}
149148
```
150149

151-
### `create_column(json_data, test=False)`
150+
### `create_column(json_data)`
152151
Create a new column. This method corresponds to a [POST request at /column](https://docs.slicingdice.com/docs/how-to-create-columns#section-creating-columns-using-column-endpoint).
153152

154153
#### Request example
@@ -216,7 +215,7 @@ insert_data = {
216215
"date": "2016-08-17T13:23:47+00:00"
217216
}
218217
},
219-
"auto-create": ["table", "column"]
218+
"auto-create": ["dimension", "column"]
220219
}
221220
print(client.insert(insert_data))
222221
```
@@ -232,8 +231,8 @@ print(client.insert(insert_data))
232231
}
233232
```
234233

235-
### `exists_entity(ids, table=None)`
236-
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).
234+
### `exists_entity(ids, dimension=None)`
235+
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).
237236

238237
#### Request example
239238

@@ -288,18 +287,18 @@ print(client.count_entity_total())
288287
}
289288
```
290289

291-
### `count_entity_total(tables)`
292-
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).
290+
### `count_entity_total(dimensions)`
291+
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).
293292

294293
#### Request example
295294

296295
```python
297296
from pyslicer import SlicingDice
298297
client = SlicingDice('MASTER_OR_READ_API_KEY')
299298

300-
tables = ['default']
299+
dimensions = ['default']
301300

302-
print(client.count_entity_total(tables))
301+
print(client.count_entity_total(dimensions))
303302
```
304303

305304
#### Output example

pyslicer/client.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -202,16 +202,16 @@ def count_entity(self, query):
202202
url = SlicingDice.BASE_URL + URLResources.QUERY_COUNT_ENTITY
203203
return self._count_query_wrapper(url, query)
204204

205-
def count_entity_total(self, tables=None):
205+
def count_entity_total(self, dimensions=None):
206206
"""Make a count entity total query
207207
208208
Keyword arguments:
209-
tables -- A dictionary containing the tables in which
209+
dimensions -- A dictionary containing the dimensions in which
210210
the total query will be performed
211211
"""
212212
query = {}
213-
if tables is not None:
214-
query['tables'] = tables
213+
if dimensions is not None:
214+
query['dimensions'] = dimensions
215215
url = SlicingDice.BASE_URL + URLResources.QUERY_COUNT_ENTITY_TOTAL
216216
return self._make_request(
217217
url=url,
@@ -263,12 +263,12 @@ def top_values(self, query):
263263
req_type="post",
264264
key_level=0)
265265

266-
def exists_entity(self, ids, table=None):
266+
def exists_entity(self, ids, dimension=None):
267267
"""Make a exists entity query
268268
269269
Keyword arguments:
270270
ids -- A list with entities to check if exists
271-
table -- In which table entities check be checked
271+
dimension -- In which dimension entities check be checked
272272
"""
273273
url = SlicingDice.BASE_URL + URLResources.QUERY_EXISTS_ENTITY
274274
if len(ids) > 100:
@@ -277,8 +277,8 @@ def exists_entity(self, ids, table=None):
277277
query = {
278278
'ids': ids
279279
}
280-
if table:
281-
query['table'] = table
280+
if dimension:
281+
query['dimension'] = dimension
282282
return self._make_request(
283283
url=url,
284284
json_data=ujson.dumps(query),

pyslicer/utils/validators.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def _has_empty_column(self):
229229
# Value is a dictionary when it is an entity being inserted:
230230
# "my-entity": {"year": 2016}
231231
# It can also be a parameter, such as "auto-create":
232-
# "auto-create": ["table", "column"]
232+
# "auto-create": ["dimension", "column"]
233233
if not isinstance(
234234
value, (dict, list)) or value is None or len(
235235
str(value)) == 0:

tests_and_examples/examples/count_entity.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -23283,7 +23283,7 @@
2328323283
"name": "Test for a \"COUNT ENTITY\" query using automatically created columns, operator \"AND\" and parameter \"EQUALS\".",
2328423284
"columns": [],
2328523285
"insert": {
23286-
"auto-create": ["table", "column"],
23286+
"auto-create": ["dimension", "column"],
2328723287
"24": {
2328823288
"string-test-column": "value:matched_value",
2328923289
"numeric-test-column": 1000001
@@ -23713,7 +23713,7 @@
2371323713
"name": "Test for a \"COUNT ENTITY\" query using automatically created columns, operators \"AND\" and \"OR\" and parameter \"EQUALS\".",
2371423714
"columns": [],
2371523715
"insert": {
23716-
"auto-create": ["table", "column"],
23716+
"auto-create": ["dimension", "column"],
2371723717
"24": {
2371823718
"string-test-column": "value:matched_value",
2371923719
"boolean-test-column": "true",
@@ -24251,7 +24251,7 @@
2425124251
"name": "Test for a \"COUNT ENTITY\" query using automatically created columns, operators \"AND\" and \"OR\" and parameters \"EQUALS\", \"BETWEEN\" and \"MINFREQ\".",
2425224252
"columns": [],
2425324253
"insert": {
24254-
"auto-create": ["table", "column"],
24254+
"auto-create": ["dimension", "column"],
2425524255
"24": {
2425624256
"string-test-column": "value:matched_value",
2425724257
"boolean-test-column": "true",

tests_and_examples/examples/sql_insert.json

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"city": "New York",
77
"country": "USA",
88
"age": 19,
9-
"table": "users",
9+
"dimension": "users",
1010
"name": "joao",
1111
"browser": "firefox",
1212
"os": "Linux",
@@ -41,7 +41,7 @@
4141
"city": "Natal",
4242
"country": "Brazil",
4343
"age": 21,
44-
"table": "users",
44+
"dimension": "users",
4545
"name": "eduardo",
4646
"browser": "chrome",
4747
"os": "Windows",
@@ -76,7 +76,7 @@
7676
"city": "Salvador",
7777
"country": "Brazil",
7878
"age": 17,
79-
"table": "users",
79+
"dimension": "users",
8080
"name": "gabriela",
8181
"browser": "safari",
8282
"os": "mac",
@@ -106,7 +106,7 @@
106106
]
107107
},
108108
"auto-create": [
109-
"table",
109+
"dimension",
110110
"column"
111111
]
112112
},
@@ -116,10 +116,10 @@
116116
"salary": 2350.50,
117117
"age": 19,
118118
"admission": "2017-07-17",
119-
"table": "jobs"
119+
"dimension": "jobs"
120120
},
121121
"auto-create": [
122-
"table",
122+
"dimension",
123123
"column"
124124
]
125125
},
@@ -140,10 +140,10 @@
140140
"value": 15,
141141
"date": "2017-08-18T00:00:00Z"
142142
},
143-
"table": "inserttest"
143+
"dimension": "inserttest"
144144
},
145145
"auto-create": [
146-
"table",
146+
"dimension",
147147
"column"
148148
]
149149
}

0 commit comments

Comments
 (0)