from flask_restx import Namespace, Resource
from Rest.Answer import message_response_model
from Rest.ServerVarREST import ServerVarREST

from Blueprints.APIModels import a_main_channel_id, a_options, a_all_options, a_regex, a_theme, a_themes, a_tag, \
    a_card_vars
from Blueprints.BaseRequestParser import base_parser, handle_request

api = Namespace('ServerVar', path='/server_var/', description='static server variables')

a_main_channel_id_response = message_response_model(a_main_channel_id, True)

a_options_response = message_response_model(a_options, True)

a_all_options_response = message_response_model(a_all_options, True)

a_regex_response = message_response_model(a_regex, True)

a_theme_response = message_response_model(a_theme, True)

a_themes_response = message_response_model(a_themes, True)

a_tags_response = message_response_model(a_tag)

a_card_vars_response = message_response_model(a_card_vars, True)


@api.route('/regex')
class Regex(Resource):
    @api.doc(parser=base_parser)
    def get(self):
        return handle_request(rest_function=ServerVarREST.get_regex,
                              model=a_regex_response)


@api.route('/main_channel_id')
class DeviceActivity(Resource):
    @api.doc(parser=base_parser)
    def get(self):
        return handle_request(rest_function=ServerVarREST.get_main_cannel_ID,
                              model=a_main_channel_id_response)


@api.route('/interest_options')
class Interests(Resource):
    @api.doc(parser=base_parser)
    def get(self):
        return handle_request(rest_function=ServerVarREST.get_interests_options,
                              model=a_options_response)


@api.route('/project_type_options')
class CoursesOfStudy(Resource):
    @api.doc(parser=base_parser)
    def get(self):
        return handle_request(rest_function=ServerVarREST.get_project_type_options,
                              model=a_options_response)


@api.route('/course_of_study_options')
class CoursesOfStudy(Resource):
    @api.doc(parser=base_parser)
    def get(self):
        return handle_request(rest_function=ServerVarREST.get_course_of_study_options,
                              model=a_options_response)


@api.route('/themes')
class Themes(Resource):
    @api.doc(parser=base_parser)
    def get(self):
        return handle_request(rest_function=ServerVarREST.get_themes,
                              model=a_themes_response)


@api.route('/theme/<name>')
@api.doc(params={'name': 'name of a theme to get'})
class Theme(Resource):
    @api.doc(parser=base_parser)
    def get(self, name):
        return handle_request(path_args=[name],
                              rest_function=ServerVarREST.get_theme,
                              model=a_theme_response)


@api.route('/tags')
class Tags(Resource):
    @api.doc(parser=base_parser)
    def get(self):
        return handle_request(rest_function=ServerVarREST.get_tags,
                              model=a_tags_response)


@api.route('/')
class All(Resource):
    @api.doc(parser=base_parser)
    def get(self):
        return handle_request(rest_function=ServerVarREST.get_all,
                              model=a_all_options_response)


@api.route('/card_vars')
class CardVars(Resource):
    @api.doc(parser=base_parser)
    def get(self):
        return handle_request(rest_function=ServerVarREST.get_card_vars,
                              model=a_card_vars_response)
