@@ -32,21 +32,21 @@ class SlicingDice(SlicingDiceAPI):
3232
3333 To create an object of the SliceDicer:
3434
35- >>> from pyslicer.api import SlicingDice
36- >>> sd = SlicingDice('my-token')
35+ from pyslicer.api import SlicingDice
36+ sd = SlicingDice('my-token')
3737
3838 To create a field:
3939
40- >>> field_json = {
40+ field_json = {
4141 'name': 'Pyslicer String Field',
4242 'description': 'Pyslicer example description',
4343 'type': 'string',
4444 'cardinality': 'low'}
45- >>> print sd.create_field(field_json)
45+ print sd.create_field(field_json)
4646
4747 To make a query:
4848
49- >>> query_json = {
49+ query_json = {
5050 'type': 'count',
5151 'select': [
5252 {
@@ -64,11 +64,11 @@ class SlicingDice(SlicingDiceAPI):
6464 },
6565 ]
6666 }
67- >>> print sd.query(query_json)
67+ print sd.query(query_json)
6868
6969 To make a index:
7070
71- >>> indexing_json = {
71+ indexing_json = {
7272 'foo@bar.com': {
7373 'pyslicer-string-field': 'test_value_1',
7474 'pyslicer-integer-field': 42,
@@ -78,7 +78,7 @@ class SlicingDice(SlicingDiceAPI):
7878 'pyslicer-integer-field': 42,
7979 },
8080 }
81- >>> print sd.index(indexing_json)
81+ print sd.index(indexing_json)
8282 """
8383 def __init__ (
8484 self , write_key = None , read_key = None , master_key = None ,
@@ -87,10 +87,10 @@ def __init__(
8787
8888 Keyword arguments:
8989 key(string or SlicerKey obj) -- Key to access API
90- timeout(int) -- Define timeout to request,
91- defaults 30 secs(default 30).
9290 use_ssl(bool) -- Define if the request uses verification SSL for
9391 HTTPS requests. Defaults False.(Optional)
92+ timeout(int) -- Define timeout to request,
93+ defaults 30 secs(default 30).
9494 """
9595 super (SlicingDice , self ).__init__ (
9696 write_key , read_key , master_key , custom_key , use_ssl , timeout )
@@ -141,20 +141,17 @@ def _saved_query_wrapper(self, url, query, update=False):
141141 update(bool) -- Indicates with operation is update a
142142 saved query or not.(default false)
143143 """
144+ req_type = "post"
144145 if update :
145- return self ._make_request (
146- url = url ,
147- json_data = ujson .dumps (query ),
148- req_type = "put" ,
149- key_level = 2 )
146+ req_type = "put"
150147 return self ._make_request (
151148 url = url ,
152149 json_data = ujson .dumps (query ),
153- req_type = "post" ,
150+ req_type = req_type ,
154151 key_level = 2 )
155152
156153 def get_projects (self ):
157- """Get a list of projects"""
154+ """Get a list of projects (all) """
158155 url = SlicingDice .BASE_URL + URLResources .PROJECT
159156 return self ._make_request (
160157 url = url ,
@@ -168,6 +165,7 @@ def create_field(self, data, test=False):
168165 Keyword arguments:
169166 data -- A dictionary in the Slicing Dice field
170167 format.
168+ test(bool) -- if true will use tests end-point (default False)
171169 """
172170 base_url = self ._wrapper_test (test )
173171 sd_data = validators .FieldValidator (data )
@@ -180,7 +178,11 @@ def create_field(self, data, test=False):
180178 key_level = 1 )
181179
182180 def get_fields (self , test = False ):
183- """Get a list of fields"""
181+ """Get a list of fields
182+
183+ Keyword arguments:
184+ test(bool) -- if true will use tests end-point (default False)
185+ """
184186 base_url = self ._wrapper_test (test )
185187 url = base_url + URLResources .FIELD
186188 return self ._make_request (
@@ -189,11 +191,14 @@ def get_fields(self, test=False):
189191 key_level = 2 )
190192
191193 def index (self , data , auto_create_fields = False , test = False ):
192- """Make a index in Slicing Dice
194+ """Make a index in Slicing Dice API
193195
194196 Keyword arguments:
195197 data -- A dictionary in the Slicing Dice index
196198 format.
199+ auto_create_fields(bool) -- if true SlicingDice API will automatically
200+ create nonexistent fields (default False)
201+ test(bool) -- if true will use tests end-point (default False)
197202 """
198203 if auto_create_fields :
199204 data ["auto-create-fields" ] = True
@@ -212,13 +217,17 @@ def count_entity(self, query, test=False):
212217
213218 Keyword arguments:
214219 query -- A dictionary in the Slicing Dice query
220+ test(bool) -- if true will use tests end-point (default False)
215221 """
216222 base_url = self ._wrapper_test (test )
217223 url = base_url + URLResources .QUERY_COUNT_ENTITY
218224 return self ._count_query_wrapper (url , query )
219225
220226 def count_entity_total (self , test = False ):
221- """Make a count entity total query"""
227+ """Make a count entity total query
228+
229+ test(bool) -- if true will use tests end-point (default False)
230+ """
222231 base_url = self ._wrapper_test (test )
223232 url = base_url + URLResources .QUERY_COUNT_ENTITY_TOTAL
224233 return self ._make_request (
@@ -231,6 +240,7 @@ def count_event(self, query, test=False):
231240
232241 Keyword arguments:
233242 data -- A dictionary query
243+ test(bool) -- if true will use tests end-point (default False)
234244 """
235245 base_url = self ._wrapper_test (test )
236246 url = base_url + URLResources .QUERY_COUNT_EVENT
@@ -240,7 +250,8 @@ def aggregation(self, query, test=False):
240250 """Make a aggregation query
241251
242252 Keyword arguments:
243- data -- A dictionary query
253+ query -- An aggregation query
254+ test(bool) -- if true will use tests end-point (default False)
244255 """
245256 base_url = self ._wrapper_test (test )
246257 url = base_url + URLResources .QUERY_AGGREGATION
@@ -262,6 +273,7 @@ def top_values(self, query, test=False):
262273
263274 Keyword arguments:
264275 query -- A dictionary query
276+ test(bool) -- if true will use tests end-point (default False)
265277 """
266278 base_url = self ._wrapper_test (test )
267279 url = base_url + URLResources .QUERY_TOP_VALUES
@@ -278,6 +290,7 @@ def exists_entity(self, ids, test=False):
278290
279291 Keyword arguments:
280292 ids -- A list with entity to check if exists
293+ test(bool) -- if true will use tests end-point (default False)
281294 """
282295 base_url = self ._wrapper_test (test )
283296 url = base_url + URLResources .QUERY_EXISTS_ENTITY
@@ -297,7 +310,8 @@ def get_saved_query(self, query_name, test=False):
297310 """Get a saved query
298311
299312 Keyword arguments:
300- query_name(string) -- A string with query name
313+ query_name(string) -- The name of the saved query
314+ test(bool) -- if true will use tests end-point (default False)
301315 """
302316 base_url = self ._wrapper_test (test )
303317 url = base_url + URLResources .QUERY_SAVED + query_name
@@ -310,7 +324,8 @@ def get_saved_queries(self, test=False):
310324 """Get all saved queries
311325
312326 Keyword arguments:
313- query_name(string) -- A string with query name
327+ query_name(string) -- The name of the saved query
328+ test(bool) -- if true will use tests end-point (default False)
314329 """
315330 base_url = self ._wrapper_test (test )
316331 url = base_url + URLResources .QUERY_SAVED
@@ -323,7 +338,8 @@ def delete_saved_query(self, query_name, test=False):
323338 """Delete a saved query
324339
325340 Keyword arguments:
326- query_name(string) -- A string with query name
341+ query_name(string) -- The name of the saved query
342+ test(bool) -- if true will use tests end-point (default False)
327343 """
328344 base_url = self ._wrapper_test (test )
329345 url = base_url + URLResources .QUERY_SAVED + query_name
@@ -338,6 +354,7 @@ def create_saved_query(self, query, test=False):
338354
339355 Keyword arguments:
340356 query -- A dictionary query
357+ test(bool) -- if true will use tests end-point (default False)
341358 """
342359 base_url = self ._wrapper_test (test )
343360 url = base_url + URLResources .QUERY_SAVED
@@ -347,8 +364,9 @@ def update_saved_query(self, name, query, test=False):
347364 """Get a list of queries saved
348365
349366 Keyword arguments:
350- name -- A dictionary query
367+ name -- The name of the saved query to update
351368 query -- A dictionary query
369+ test(bool) -- if true will use tests end-point (default False)
352370 """
353371 base_url = self ._wrapper_test (test )
354372 url = base_url + URLResources .QUERY_SAVED + name
@@ -359,16 +377,18 @@ def result(self, query, test=False):
359377
360378 Keyword arguments:
361379 query -- A dictionary query
380+ test(bool) -- if true will use tests end-point (default False)
362381 """
363382 base_url = self ._wrapper_test (test )
364383 url = base_url + URLResources .QUERY_DATA_EXTRACTION_RESULT
365384 return self ._data_extraction_wrapper (url , query )
366385
367386 def score (self , query , test = False ):
368- """Get a data extraction result
387+ """Get a data extraction score
369388
370389 Keyword arguments:
371390 query -- A dictionary query
391+ test(bool) -- if true will use tests end-point (default False)
372392 """
373393 base_url = self ._wrapper_test (test )
374394 url = base_url + URLResources .QUERY_DATA_EXTRACTION_SCORE
0 commit comments