def get(self, author_id): author, index = abort_if_author_doesnt_exist(author_id) #return author, 200 return ld_response(author, 200, context=contextPath, apiDoc=apiDocumentation)
def get(self, book_id): book, index = abort_if_book_doesnt_exist(book_id) #return book, 200 return ld_response(book, 200, context=contextPath, apiDoc=apiDocumentation)
def get(self): contextPath = "/contexts/authorList.jsonld" return ld_response(authors, 200, context=contextPath, apiDoc=apiDocumentation, contentType="application/json")
def delete(self, book_id): book, index = abort_if_book_doesnt_exist(book_id) #del books[book_id] books.pop(index) #return '', 204 return ld_response('', 204, context=contextPath, apiDoc=apiDocumentation)
def get(self, contextName): #TODO check context extension and load accordingly filePath = os.path.join(app.config['CONTEXTS_FOLDER'], contextName) with app.open_resource(filePath) as f: #TODO: Check if file exists before reading. data = json.load(f) return ld_response(data, 200, context="/contexts/" + contextName)
def delete(self, author_id): author, index = abort_if_author_doesnt_exist(author_id) #del authors[author_id] authors.pop(index) #return '', 204 return ld_response('', 204, context=contextPath, apiDoc=apiDocumentation)
def put(self, book_id): args = parser.parse_args() #PUT is idempotent and it should take id in the request itself. #book, index = book_find(book_id) book, index = abort_if_book_doesnt_exist(book_id) book = {'id': int(args['id']), 'name': args['name']} books.append(book) #return book, 201 return ld_response(book, 200, context=contextPath, apiDoc=apiDocumentation)
def put(self, author_id): args = parser.parse_args() #PUT is idempotent and it should take id in the request itself. #author, index = author_find(author_id) author, index = abort_if_author_doesnt_exist(author_id) author = {'id': int(args['id']), 'name': args['name']} authors.append(author) #return author, 201 return ld_response(author, 200, context=contextPath, apiDoc=apiDocumentation)
def post(self): args = parser.parse_args() author_id = len(authors) + 1 author = { '@context': contextPath, '@type': 'schema:author', 'id': str(author_id), 'name': args['name'] } authors.append(author) #return author, 201 return ld_response(author, 201, context=contextPath, apiDoc=apiDocumentation)
def post(self): args = parser.parse_args() book_id = len(books) + 1 book = { '@context': contextPath, '@type': 'schema:Book', 'id': str(book_id), 'title': args['title'], 'author': args['author'] } books.append(book) #return book, 201 return ld_response(book, 201, context=contextPath, apiDoc=apiDocumentation)
def post(self, book_id): args = parser.parse_args() #book, index = book_find(book_id) book, index = abort_if_book_doesnt_exist(book_id) #book = {'id': book_id, 'name': args['name']} print("Request:: ", file=sys.stderr) print(request.__dict__, file=sys.stderr) for key, value in args.items(): print(key, file=sys.stderr) if key in args and value is not None: if isinstance(value, list) and len(value) <= 1: value = value[0] book[key] = value books[index] = book #return books[book_id], 200 return ld_response(book, 200, context=contextPath, apiDoc=apiDocumentation)
def post(self, author_id): args = parser.parse_args() #author, index = author_find(author_id) author, index = abort_if_author_doesnt_exist(author_id) #author = {'id': author_id, 'name': args['name']} print("ARGS:: ", file=sys.stderr) print(args, file=sys.stderr) print("AUTHOR:: ", file=sys.stderr) print(author, file=sys.stderr) for key, value in args.items(): if key in args and value is not None: if isinstance(value, list) and len(value) <= 1: value = value[0] author[key] = value authors[index] = author #return authors[author_id], 200 return ld_response(author, 200, context=contextPath, apiDoc=apiDocumentation)
def get(self): return ld_response(books, 200, context=contextPath, apiDoc=apiDocumentation)
def get(self): return ld_response(entryPoint, 200, context=contextPath, apiDoc=apiDocumentation)