Skip to content

Commit

Permalink
0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
coleifer committed May 10, 2015
1 parent 7300e54 commit ef0e7eb
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
2 changes: 1 addition & 1 deletion scout.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"""
__author__ = 'Charles Leifer'
__kitty__ = 'Huey'
__version__ = '0.2.0'
__version__ = '0.2.1'

try:
from functools import reduce
Expand Down
25 changes: 19 additions & 6 deletions scout_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,20 @@ def delete_index(self, name):
def get_documents(self, **kwargs):
return self.get('/documents/', **kwargs)

def store_document(self, content, indexes, **metadata):
def store_document(self, content, indexes, identifier=None, **metadata):
if not isinstance(indexes, (list, tuple)):
indexes = [indexes]
return self.post('/documents/', {
'content': content,
'identifier': identifier,
'indexes': indexes,
'metadata': metadata})

def update_document(self, document_id, content=None, indexes=None,
metadata=None):
def update_document(self, document_id=None, content=None, indexes=None,
metadata=None, identifier=None):
if not document_id and not identifier:
raise ValueError('`document_id` or `identifier` must be provided.')

data = {}
if content is not None:
data['content'] = content
Expand All @@ -86,10 +90,19 @@ def update_document(self, document_id, content=None, indexes=None,
if not data:
raise ValueError('Nothing to update.')

return self.post('/documents/%s/' % document_id, data)
if document_id:
return self.post('/documents/%s/' % document_id, data)
else:
return self.post('/documents/identifier/%s/' % identifier, data)

def delete_document(self, document_id=None, identifier=None):
if not document_id and not identifier:
raise ValueError('`document_id` or `identifier` must be provided.')

def delete_document(self, document_id):
return self.delete('/documents/%s/' % document_id)
if document_id:
return self.delete('/documents/%s/' % document_id)
else:
return self.delete('/documents/identifier/%s/' % identifier)

def search(self, index, query, **kwargs):
kwargs['q'] = query
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import scout
VERSION = scout.__version__
except ImportError:
VERSION = '0.2.0'
VERSION = '0.2.1'

setup(
name='scout',
Expand Down

0 comments on commit ef0e7eb

Please sign in to comment.