from flask import request from flask_restplus import Resource from skf.api.security import security_headers, validate_privilege, select_userid_jwt from skf.api.questions_post.business import get_post_items from skf.api.questions_post.serializers import post_items, message from skf.api.questions_post.parsers import authorization from skf.api.restplus import api ns = api.namespace('questions_post', description='Operations related to question post items') @ns.route('/<int:id>') @api.doc(params={'id': 'The sprint id'}) @api.response(404, 'Validation error', message) class QuestionPostCollection(Resource): @api.expect(authorization) @api.marshal_with(post_items) @api.response(400, 'No results found', message) def get(self, id): """ Returns list of question post items. * Privileges required: **none** """ result = get_post_items(id) return result, 200, security_headers()
from flask import request from flask_restplus import Resource from skf.api.security import security_headers from skf.api.user.business import activate_user from skf.api.user.serializers import activate, message from skf.api.restplus import api ns = api.namespace('user', description='Operations related to users') @ns.route('/activate/<int:id>') @api.doc(params={'id': 'The user id'}) @api.response(404, 'Validation error', 'hello') class userActivation(Resource): @api.expect(activate) @api.marshal_with(message, 'Success') @api.response(400, 'No results found', message) def put(self, id): """ Activate an user. * Privileges required: **none** """ data = request.json result = activate_user(id, data) return result, 200, security_headers()
from flask import request from flask_restplus import Resource from skf.api.security import security_headers, validate_privilege from skf.api.checklist.business import create_checklist_type from skf.api.checklist.serializers import checklist_type, message from skf.api.kb.parsers import authorization from skf.api.restplus import api from skf.api.security import log, val_num, val_float, val_alpha_num, val_alpha_num_special ns = api.namespace('checklist_types', description='Operations related to checklist types') @ns.route('/create/<int:category_id>') @api.response(404, 'Validation error', message) class ChecklistCreate(Resource): @api.expect(authorization, checklist_type) @api.response(400, 'No results found', message) def put(self, category_id): """ Create a new checklist type. * Privileges required: **edit** """ validate_privilege(self, 'edit') data = request.json val_num(category_id) val_alpha_num_special(data.get('name')) val_alpha_num_special(data.get('description')) val_alpha_num_special(data.get('visibility')) result = create_checklist_type(data, category_id) return result, 200, security_headers()
from flask import request from flask_restplus import Resource from skf.api.security import security_headers, validate_privilege from skf.api.checklist_category.business import update_checklist_category from skf.api.checklist_category.serializers import checklist_type_update, message from skf.api.kb.parsers import authorization from skf.api.restplus import api from skf.api.security import log, val_num, val_alpha, val_alpha_num, val_alpha_num_special ns = api.namespace('checklist_category', description='Operations related to checklist items') @ns.route('/update/<int:id>') @api.doc(params={'id': 'The checklist category id'}) @api.response(404, 'Validation error', message) class ChecklistCategoryUpdate(Resource): @api.expect(authorization, checklist_type_update) @api.response(400, 'No results found', message) def put(self, id): """ Update a checklist type. * Privileges required: **edit** """ data = request.json val_num(id) val_alpha_num_special(data.get('name')) val_alpha_num_special(data.get('description')) validate_privilege(self, 'edit') result = update_checklist_category(id, data) return result, 200, security_headers()
from flask import request from flask_restplus import Resource from skf.api.chatbot.scripts import intent_classifier from skf.api.security import security_headers, validate_privilege from skf.api.chatbot.business import des_sol,code from skf.api.chatbot.serializers import question_response, question_chatbot, message from skf.api.restplus import api ns = api.namespace('chatbot', description='Operations related to the chatbot interactions') @ns.route('/question') @api.response(404, 'Validation error', message) class ChatbotQuestion(Resource): @api.expect(question_chatbot) @api.marshal_with(question_response) @api.response(400, 'No results found', message) def post(self): """ Returns a answer on a question. * Privileges required: **none** """ data = request.json data_q=data.get('question') intent=intent_classifier.predict(data_q) if intent=='Code': lang=None code_ans,lang=code(data_q,intent,lang) if type(lang)!=str:
from flask import request from flask_restplus import Resource from skf.api.security import security_headers, validate_privilege, select_userid_jwt from skf.api.sprints.business import get_sprint_item from skf.api.sprints.serializers import sprint, message from skf.api.sprints.parsers import authorization from skf.api.restplus import api from skf.api.security import log, val_num, val_alpha_num, val_alpha_num_special ns = api.namespace('sprint', description='Operations related to sprint items') @ns.route('/<int:id>') @api.doc(params={'id': 'The sprint id'}) @api.response(404, 'Validation error', message) class ProjectSprintItem(Resource): @api.expect(authorization) @api.marshal_with(sprint) @api.response(400, 'No results found', message) def get(self, id): """ Returns a sprint item. * Privileges required: **read** """ val_num(id) validate_privilege(self, 'read') result = get_sprint_item(id) return result, 200, security_headers()
from flask_restplus import Resource from skf.api.security import security_headers from skf.api.checklist.business import get_checklist_items_lvl from skf.api.checklist.serializers import checklist_items, message from skf.api.restplus import api ns = api.namespace('checklist', description='Operations related to checklist items') @ns.route('/level/<int:level>') @api.doc(params={'level': 'The checklist level'}) @api.response(404, 'Validation error', message) class ChecklistItem(Resource): @api.marshal_list_with(checklist_items) @api.response(400, 'No results found', message) def get(self, level): """ Returns list of checklist items based on level. * Privileges required: **none** """ lvl = level result = get_checklist_items_lvl(lvl) return result, 200, security_headers()
from flask import request from flask_restplus import Resource from skf.api.security import security_headers, validate_privilege, select_userid_jwt from skf.api.projects.business import update_project from skf.api.projects.serializers import project_update, message from skf.api.projects.parsers import authorization from skf.api.restplus import api ns = api.namespace('project', description='Operations related to project items') @ns.route('/update/<int:id>') @api.doc(params={'id': 'The project id'}) @api.response(404, 'Validation error', message) class ProjectItemUpdate(Resource): @api.expect(authorization, project_update) @api.marshal_with(message, 'Success') @api.response(400, 'No results found', message) def put(self, id): """ Update a project item. * Privileges required: **edit** """ validate_privilege(self, 'edit') user_id = select_userid_jwt(self) data = request.json result = update_project(id, user_id, data) return result, 200, security_headers()
from flask import request from flask_restplus import Resource from skf.api.security import security_headers, validate_privilege from skf.api.search.business import search_lab from skf.api.search.serializers import message, lab from skf.api.restplus import api from skf.api.search.parsers import authorization import json ns = api.namespace( 'search', description='Operations related to the search functionality') @ns.route('/lab/<string:search_string>') @api.response(404, 'Validation error', message) class SearchLab(Resource): @api.expect(authorization) @api.marshal_with(lab) @api.response(400, 'No results found', message) def get(self, search_string): """ Returns list of search lab hits. * Privileges required: **read** """ validate_privilege(self, 'read') result = search_lab(search_string) return result, 200, security_headers()
from flask import request from flask_restplus import Resource from skf.api.security import security_headers from skf.api.code.business import get_code_items_lang from skf.api.code.serializers import code_items, message from skf.api.restplus import api ns = api.namespace('code', description='Operations related to code example items') @ns.route('/lang/<string:code_lang>') @api.doc(params={'code_lang': 'The code lang type'}) @api.response(404, 'Validation error', message) class CodeLangItem(Resource): @api.marshal_with(code_items) @api.response(400, 'No results found', message) def get(self, code_lang): """ Returns a code example item. * Privileges required: **none** """ result = get_code_items_lang(code_lang) return result, 200, security_headers()
from flask import request from flask_restplus import Resource from skf.api.chatbot.scripts import intent_classifier from skf.api.security import security_headers, validate_privilege from skf.api.chatbot.business import des_sol, code from skf.api.chatbot.serializers import question_response, question_chatbot, message from skf.api.restplus import api ns = api.namespace( 'chatbot', description='Operations related to the chatbot interactions') @ns.route('/question') @api.response(404, 'Validation error', message) class ChatbotQuestion(Resource): @api.expect(question_chatbot) @api.marshal_with(question_response) @api.response(400, 'No results found', message) def post(self): """ Returns a answer on a question. * Privileges required: **none** """ data = request.json data_q = data.get('question') intent = intent_classifier.predict(data_q) if intent == 'Code': lang = None code_ans, lang = code(data_q, intent, lang) if type(lang) != str:
from flask import request from flask_restplus import Resource from skf.api.security import security_headers from skf.api.user.business import activate_user from skf.api.user.serializers import activate, message from skf.api.restplus import api ns = api.namespace('user', description='Operations related to users') @ns.route('/activate/<int:id>') @api.doc(params={'id': 'The user id'}) @api.response(404, 'Validation error', message) class userActivation(Resource): @api.expect(activate) @api.marshal_with(message, 'Success') @api.response(400, 'No results found', message) def put(self, id): """ Activate an user. * Privileges required: **none** """ data = request.json result = activate_user(id, data) return result, 200, security_headers()
from flask import request from flask_restplus import Resource from skf.api.security import security_headers, validate_privilege, select_userid_jwt from skf.api.comment.business import new_comment_item from skf.api.comment.serializers import comment, comment_new, message from skf.api.comment.parsers import authorization from skf.api.restplus import api ns = api.namespace('comment', description='Operations related to comment items') @ns.route('/new') @api.response(404, 'Validation error', message) class CommentItemNew(Resource): @api.expect(authorization, comment_new) @api.marshal_with(message, 'Success') @api.response(400, 'No results found', message) def put(self): """ Create a comment item. * Privileges required: **edit** """ validate_privilege(self, 'edit') user_id = select_userid_jwt(self) data = request.json result = new_comment_item(user_id, data) return result, 200, security_headers()
from flask import request from flask_restplus import Resource from skf.api.security import security_headers, validate_privilege from skf.api.comment.business import get_comment_items from skf.api.comment.serializers import comment_items, comment_get, message from skf.api.comment.parsers import authorization from skf.api.restplus import api ns = api.namespace('comment', description='Operations related to comment items') @ns.route('/items') @api.response(404, 'Validation error', message) class CommentItem(Resource): @api.expect(authorization, comment_get) @api.marshal_with(comment_items) @api.response(400, 'No results found', message) def post(self): """ Returns a comment item. * Privileges required: **read** """ validate_privilege(self, 'read') data = request.json result = get_comment_items(data) return result, 200, security_headers()
from flask import request from flask_restplus import Resource from skf.api.security import security_headers from skf.api.labs.business import get_labs from skf.api.labs.serializers import lab_items, message from skf.api.restplus import api ns = api.namespace('interactive_labs', description='Operations related to the labs') @ns.route('/items') @api.response(404, 'Validation error', message) class LabCollection(Resource): @api.marshal_with(lab_items) @api.response(400, 'No results found', message) def get(self): """ Returns list of labs. * Privileges required: **none** """ result = get_labs() return result, 200, security_headers()
from flask import request from flask_restplus import Resource from skf.api.security import security_headers, validate_privilege, select_userid_jwt from skf.api.questions.business import new_question from skf.api.questions.serializers import question_item_update, message from skf.api.questions.parsers import authorization from skf.api.restplus import api ns = api.namespace('questions', description='Operations related to question sprint items') @ns.route('/item/new') @api.response(404, 'Validation error', message) class QuestionSprintCollection(Resource): @api.expect(authorization, question_item_update) @api.response(400, 'No results found', message) def put(self): """ Create new questions . * Privileges required: **manage** """ validate_privilege(self, 'manage') data = request.json result = new_question(data) return result, 200, security_headers()
from flask import request from flask_restplus import Resource from skf.api.security import security_headers, validate_privilege, select_userid_jwt from skf.api.sprints.business import get_sprint_item from skf.api.sprints.serializers import sprint, message from skf.api.sprints.parsers import authorization from skf.api.restplus import api ns = api.namespace('sprint', description='Operations related to sprint items') @ns.route('/<int:id>') @api.doc(params={'id': 'The sprint id'}) @api.response(404, 'Validation error', message) class ProjectSprintItem(Resource): @api.expect(authorization) @api.marshal_with(sprint) @api.response(400, 'No results found', message) def get(self, id): """ Returns a sprint item. * Privileges required: **read** """ validate_privilege(self, 'read') user_id = select_userid_jwt(self) result = get_sprint_item(id, user_id) return result, 200, security_headers()
from flask import request from flask_restplus import Resource from skf.api.security import security_headers, validate_privilege, select_userid_jwt from skf.api.code.business import delete_code_item from skf.api.code.serializers import message from skf.api.code.parsers import authorization from skf.api.restplus import api ns = api.namespace('code', description='Operations related to knowledge base') @ns.route('/delete/<int:id>') @api.doc(params={'id': 'The code id'}) @api.response(404, 'Validation error', message) class KnowledgebaseItemDelete(Resource): @api.expect(authorization) @api.marshal_with(message, 'Success') @api.response(400, 'No results found', message) def delete(self, id): """ Deletes code item. * Privileges required: **delete** """ validate_privilege(self, 'delete') user_id = select_userid_jwt(self) result = delete_code_item(id, user_id) return result, 200, security_headers()
from flask import request from flask_restplus import Resource from skf.api.security import security_headers, validate_privilege, select_userid_jwt from skf.api.projects.business import stats_project from skf.api.projects.serializers import message, project_stats from skf.api.projects.parsers import authorization from skf.api.restplus import api ns = api.namespace('project', description='Operations related to project items') @ns.route('/stats/<int:id>') @api.doc(params={'id': 'The project id'}) @api.response(404, 'Validation error', message) class ProjectStats(Resource): @api.expect(authorization) @api.marshal_with(project_stats) @api.response(400, 'No results found', message) def get(self, id): """ Returns project stats. * Privileges required: **read** """ validate_privilege(self, 'read') user_id = select_userid_jwt(self) result = stats_project(id) return result, 200, security_headers()
from flask import request from flask_restplus import Resource from skf.api.security import security_headers from skf.api.kb.business import get_kb_item from skf.api.kb.serializers import kb, message from skf.api.restplus import api ns = api.namespace('kb', description='Operations related to kb items') @ns.route('/<int:id>') @api.doc(params={'id': 'The kb item id'}) @api.response(404, 'Validation error', message) class KBItem(Resource): @api.marshal_with(kb) @api.response(400, 'No results found', message) def get(self, id): """ Returns a kb item. * Privileges required: **none** """ result = get_kb_item(id) return result, 200, security_headers()
from flask import request from flask_restplus import Resource from skf.api.security import security_headers from skf.api.kb.business import get_kb_items from skf.api.kb.serializers import kb_items, message from skf.api.restplus import api ns = api.namespace('kb', description='Operations related to kb items') @ns.route('/items') @api.response(404, 'Validation error', message) class KBCollection(Resource): @api.marshal_with(kb_items) @api.response(400, 'No results found', message) def get(self): """ Returns list of kb items. * Privileges required: **none** """ result = get_kb_items() return result, 200, security_headers()
from flask import request from flask_restplus import Resource from skf.api.security import security_headers, validate_privilege from skf.api.code.business import delete_code_item_checklist_kb from skf.api.code.serializers import code_items_checklist_kb_all, message from skf.api.restplus import api from skf.api.code.parsers import authorization from skf.api.security import log, val_num, val_alpha, val_alpha_num, val_alpha_num_special ns = api.namespace('code', description='Operations related to code example items') @ns.route('/items/requirements/<int:checklist_kb_id>/<int:code_id>') @api.response(404, 'Validation error', message) class CodeCollection(Resource): @api.expect(authorization) #@api.marshal_with(code_items_checklist_kb_all) @api.response(400, 'No results found', message) def delete(self, checklist_kb_id, code_id): """ Delete code example item from requirements * Privileges required: **delete** """ val_num(checklist_kb_id) val_num(code_id) validate_privilege(self, 'delete') result = delete_code_item_checklist_kb(checklist_kb_id, code_id) return result, 200, security_headers()
from flask import request from flask_restplus import Resource from skf.api.security import security_headers from skf.api.questions_sprint.business import get_sprint_items from skf.api.questions_sprint.serializers import question_items, message from skf.api.restplus import api ns = api.namespace('questions_sprint', description='Operations related to question items') @ns.route('/items') @api.response(404, 'Validation error', message) class QuestionSprintCollection(Resource): @api.marshal_with(question_items) @api.response(400, 'No results found', message) def get(self): """ Returns list of question items. * Privileges required: **none** """ result = get_sprint_items() return result, 200, security_headers()