@@ -181,11 +181,29 @@ def delete(self, keys):
181181 self ._origin .delete (keys )
182182
183183 def count (self , * args , ** kwargs ):
184+ """Count collection items with a given filters.
185+
186+ :return: amount of elements in collection.
187+ :rtype: :class:`int`
188+ """
189+ # TODO describe allowable params
184190 return self ._origin ._collections .count (
185191 self ._origin .coltype , self ._origin .colname , * args , ** kwargs )
186192
187193 def iter (self , key = None , prefix = None , prefixcount = None , startts = None ,
188194 endts = None , requests_params = None , ** params ):
195+ """A method to iterate through collection items.
196+
197+ :param key: a string key or a list of keys to filter with.
198+ :param prefix: a string prefix to filter items.
199+ :param prefixcount: maximum number of values to return per prefix.
200+ :param startts: UNIX timestamp at which to begin results.
201+ :param endts: UNIX timestamp at which to end results.
202+ :param requests_params: (optional) a dict with optional requests params.
203+ :param \*\*params: (optional) additional query params for the request.
204+ :return: an iterator over items list.
205+ :rtype: :class:`collections.Iterable[dict]`
206+ """
189207 update_kwargs (params , key = key , prefix = prefix , prefixcount = prefixcount ,
190208 startts = startts , endts = endts ,
191209 requests_params = requests_params )
@@ -195,6 +213,19 @@ def iter(self, key=None, prefix=None, prefixcount=None, startts=None,
195213
196214 def iter_raw_json (self , key = None , prefix = None , prefixcount = None ,
197215 startts = None , endts = None , requests_params = None , ** params ):
216+ """A method to iterate through json pack-ed items.
217+ Can be convenient if data is needed in the json format.
218+
219+ :param key: a string key or a list of keys to filter with.
220+ :param prefix: a string prefix to filter items.
221+ :param prefixcount: maximum number of values to return per prefix.
222+ :param startts: UNIX timestamp at which to begin results.
223+ :param endts: UNIX timestamp at which to end results.
224+ :param requests_params: (optional) a dict with optional requests params.
225+ :param \*\*params: (optional) additional query params for the request.
226+ :return: an iterator over items list packed with json.
227+ :rtype: :class:`collections.Iterable[str]`
228+ """
198229 update_kwargs (params , key = key , prefix = prefix , prefixcount = prefixcount ,
199230 startts = startts , endts = endts ,
200231 requests_params = requests_params )
@@ -248,6 +279,18 @@ def list(self, key=None, prefix=None, prefixcount=None, startts=None,
248279 startts = startts , endts = endts )
249280 return list (self .iter (requests_params = requests_params , ** params ))
250281
251- def create_writer (self , ** kwargs ):
282+ def create_writer (self , start = 0 , auth = None , size = 1000 , interval = 15 ,
283+ qsize = None , content_encoding = 'identity' ,
284+ maxitemsize = 1024 ** 2 , callback = None ):
285+ """Create a new writer for a collection.
286+
287+ :return: a new writer object.
288+ :rtype: :class:`~scrapinghub.hubstorage.batchuploader._BatchWriter`
289+ """
290+ # TODO describe allowable params
291+ kwargs = {}
292+ update_kwargs (start = start , auth = auth , size = size , interval = interval ,
293+ qsize = qsize , content_encoding = content_encoding ,
294+ maxitemsize = maxitemsize , callback = callback )
252295 return self ._origin ._collections .create_writer (
253296 self ._origin .coltype , self ._origin .colname , ** kwargs )
0 commit comments