def PUT(self, db): LOG.debug('adding database %s' % db) if self.client.db_init(db): return ok() return error()
def DELETE(self, db): LOG.debug('deleting database %s' % db) if self.client.db_delete(db): return ok() return error()
def DELETE(self, db, doc): LOG.debug('with database %s deleting document %s' % (db, doc)) if self.client.doc_delete(db, doc): return ok() return error()
def PUT(self, db, doc, content=None): LOG.debug('with database %s adding document %s' % (db, doc)) if self.client.doc_save(db, doc, json.loads(content)): return ok() return error()
def GET(self, db): LOG.debug('fetching database %s', db) documents = self.client.db_fetch(db) if documents: return ok(json.dumps({ 'documents': self.client.db_fetch(db) })) return not_found()
def GET(self, db, doc): LOG.debug('with database %s fetching document %s' % (db, doc)) document = self.client.doc_fetch(db, doc) if document: return ok(json.dumps({ 'document': document })) return not_found()
def GET(self): LOG.debug('fetching server status') return ok()