update api docs

This commit is contained in:
rolux 2014-11-18 16:19:50 +00:00
parent e4842e023e
commit e5d5ccd7b9

View file

@ -99,6 +99,44 @@ def parse_query(data, user):
def find(request, data): def find(request, data):
''' '''
Finds items
takes {
clipsQuery: ...,
keys: [string], // list of keys to return (optional)
positions: [string], // list of item ids (optional)
query: { // query object
conditions: [{ // list of condition objects
key: string,
operator: string, // comparison operator, see below
value: string
}, { // or query objects (nested subconditions)
query: {
conditions: [{}],
operator: string
}
}],
operator: string // logical operator, '&' or '|'
},
sort: [{ // list of sort objects
key: string, // item key
operator: string // sort order, '+' or '-'
}],
range: [int, int] // from, to
}
returns {
items: [{
id: string, // item id
...
}]
} or { // if `keys` is missing
items: int // total number of items
} or { // if `positions` is set
...
}
Comparison operators are '=' (contains) '==' (is), '^' (starts with),
'$' (ends with), '<', '<=', '>', or '>=', each optionally prefixed with '!'
(not).
Example: Example:
find({ find({
query:{ query:{
@ -110,13 +148,6 @@ def find(request, data):
sort: [{key: 'title', operator: '+'}] sort: [{key: 'title', operator: '+'}]
}) })
takes {
'query': query,
'sort': array,
'range': array
clipsQuery: ...
}
query: query object, more on query syntax at query: query object, more on query syntax at
https://wiki.0x2620.org/wiki/pandora/QuerySyntax https://wiki.0x2620.org/wiki/pandora/QuerySyntax
sort: array of key, operator dics sort: array of key, operator dics
@ -306,16 +337,16 @@ actions.register(find)
def autocomplete(request, data): def autocomplete(request, data):
''' '''
takes { takes {
key: string, key: string,
value: string, value: string,
operator: string // '=', '==', '^', '$' operator: string // '=', '==', '^', '$'
query: object // item query to limit results query: object // item query to limit results
range: [int, int] range: [int, int]
} }
returns { returns {
items: [string, ...] //array of matching values items: [string, ...] // array of matching values
} }
''' '''
if not 'range' in data: if not 'range' in data:
data['range'] = [0, 10] data['range'] = [0, 10]
@ -369,12 +400,12 @@ actions.register(autocomplete)
def findId(request, data): def findId(request, data):
''' '''
takes { takes {
'id': string 'id': string
'title': string 'title': string
'director': [string] 'director': [string]
'year': int 'year': int
} }
''' '''
response = json_response({}) response = json_response({})
response['data']['items'] = [] response['data']['items'] = []
@ -397,16 +428,16 @@ actions.register(findId)
def getMetadata(request, data): def getMetadata(request, data):
''' '''
takes { Gets metadata from an external service
id: string, takes {
keys: [string] id: string,
} keys: [string]
}
returns {
key: value
..
}
returns {
key: value
..
}
''' '''
response = json_response({}) response = json_response({})
if settings.DATA_SERVICE: if settings.DATA_SERVICE: