Exemplo n.º 1
0
def add_table_model(table_cls):
    global _mapping
    global _model_write_one, _model_write_multi
    global _model_read_one, _model_read_multi
    table_name = table_cls.__tablename__
    columns = table_cls.__table__.columns

    read_fields = {
        key: _mapping[type(columns[key].type)](required=True)
        for key in columns.keys() if type(columns[key].type) in _mapping
    }
    write_fields = read_fields.copy()
    for col_name, column in columns.items():
        if type(column.autoincrement) == bool and column.autoincrement is True:
            # print('removing autoincrement field ' + table_name + '.' + column.name)
            write_fields.pop(col_name)

    write_one = api.model(table_name + '_w', write_fields)
    _model_write_one[table_name] = write_one
    _model_write_multi = api.inherit(
        table_name + '_list_w', pagination,
        {'items': fields.List(fields.Nested(write_one), required=True)})

    _model_read_one[table_name] = api.model(table_name, read_fields)
    _model_read_multi[table_name] = api.inherit(
        table_name + '_list', pagination, {
            'items':
            fields.List(fields.Nested(_model_read_one[table_name]),
                        required=True)
        })
Exemplo n.º 2
0
class Refresh(Resource):
    @api.expect(api.model('RefreshToken',
                          {'refresh_token': fields.String(required=True)}),
                validate=True)
    @api.response(200, 'Success', return_token_model)
    def post(self):
        _refresh_token = request.json['refresh_token']

        try:
            payload = jwt.decode(_refresh_token, settings.PASSWORD_JWT)

            refresh_token = RefreshToken.query.filter_by(
                user_id=payload['uid'], refresh_token=_refresh_token).first()

            if not refresh_token:
                raise jwt.InvalidIssuerError

            # Generate new pair

            _access_token = jwt.encode(
                {
                    'uid':
                    refresh_token.user_id,
                    'exp':
                    datetime.datetime.utcnow() +
                    datetime.timedelta(minutes=15),
                    'iat':
                    datetime.datetime.utcnow()
                }, settings.PASSWORD_JWT).decode('utf-8')
            _refresh_token = jwt.encode(
                {
                    'uid': refresh_token.user_id,
                    'exp':
                    datetime.datetime.utcnow() + datetime.timedelta(days=30),
                    'iat': datetime.datetime.utcnow()
                }, settings.PASSWORD_JWT).decode('utf-8')

            refresh_token.refresh_token = _refresh_token
            db.session.add(refresh_token)
            db.session.commit()

            return {
                'access_token': _access_token,
                'refresh_token': _refresh_token
            }, 200

        except jwt.ExpiredSignatureError as e:
            raise e
        except (jwt.DecodeError, jwt.InvalidTokenError) as e:
            raise e
        except Exception as e:
            api.abort(401, 'Unknown token error' + str(e))
Exemplo n.º 3
0
from flask_restplus import fields
from api.restplus import api

text_message = api.model('text message', {
    'text': fields.String(readOnly=True, description='the message text')
})

Exemplo n.º 4
0
from flask_restplus import fields
from api.restplus import api

# '''test get arguments'''
# test_get_arg = api.model('管理员参数', {
# 		'user_name':fields.String(required=True, description='管理员姓名'),
# 		'user_phone':fields.String(required=True, description='管理员电话')
# 	})

'''test post arg'''
test_post_arg = api.model('post args', {
		'user_addr':fields.String(required=True, default="shenzhen", description='user address'),
		'user_sex':fields.String(required=True, default="male", description='user sex')
	})


Exemplo n.º 5
0
from flask_restplus import fields
from api.restplus import api

bucketitems = api.model('Bucketlists', {
    'id': fields.Integer,
    'name': fields.String(required=True, description='The name of a bucketlist item'),
    'bucketlist_id': fields.Integer,
    'date_created': fields.DateTime,
    'date_modified': fields.DateTime,
    'done': fields.Boolean
})

create_bucket = api.model('Bucketlists', {
    'name': fields.String(required=True, description='The name of a bucketlist')
})

buckets = api.model('Items', {
    'id': fields.Integer,
    'name': fields.String(required=True, description='The name of a bucketlist'),
    'items': fields.List(fields.Nested(bucketitems)),
    'date_created': fields.DateTime,
    'date_modified': fields.DateTime,
    'created_by': fields.Integer
})

email_and_password = api.model('Email_and_password', {
    'email': fields.String(required=True),
    'password': fields.String(required=True)
})
Exemplo n.º 6
0
from flask_restplus import fields
from api.restplus import api

filing = api.model('Filing', {
    '_id': fields.String(readOnly=True, description='The unique identifier of a blog category'),
    'cik': fields.String(required=True, description='CIK'),
    'companyName': fields.String(required=True, description='Company Name'),
    'File/Film Number': fields.String(required=True, description='Filing Number'),
    'Filings': fields.String(required=True, description='Filing Type'),
    'Filing Date': fields.String(required=True, description='Filing Date'),
    'DocumentsLink': fields.String(required=True, description='Link to filing on the SEC website'),
    'InteractiveDataUrl': fields.String(required=True, description='Link to the interactive data')
})

search_results = api.model('search_results', {
    '_id': fields.String(readOnly=True, description='The unique identifier of a blog category'),
    'cik': fields.String(required=True, description='CIK'),
    'companyName': fields.String(required=True, description='Company Name'),
    'File/Film Number': fields.String(required=True, description='Filing Number'),
    'Filings': fields.String(required=True, description='Filing Type'),
    'Filing Date': fields.String(required=True, description='Filing Date'),
    'DocumentsLink': fields.String(required=True, description='Link to filing on the SEC website'),
    'InteractiveDataUrl': fields.String(required=True, description='Link to the interactive data'),
    'raw_matches': fields.String(required=False, description='Matches found in the raw text of the filing'),
    'table_matches': fields.String(required=False, description='Matches found in the interactive tables')
})
Exemplo n.º 7
0
from flask_restplus import fields
from api.restplus import api

authors = api.model('authors', {
    'literal': fields.String(readOnly=True, description='Literal name'),
    'given': fields.String(readOnly=True, description='Given name'),
    'family': fields.String(readOnly=True, description='Family anme'),
})

works = api.model('works', {
    'title': fields.String(readOnly=True, description='Article title'),
    'authors': fields.List(fields.Nested(authors)),
    'description': fields.String(readOnly=True, description='Description of the article'),
    'year': fields.String(readOnly=True, description='Publication date of article'),
    'doi': fields.String(readOnly=True, description='Doi reference'),
    'access_constraints': fields.String(readOnly=True, description='Access constraints'),
})

works_list = api.inherit('works list', works, {
    'items': fields.List(fields.Nested(works))
})
Exemplo n.º 8
0
from flask_restplus import fields

from api.restplus import api

movie_fields = api.model(
    'Movie list', {
        'title': fields.String,
        'opening_crawl': fields.String,
        'release_date': fields.String
    })

planet_fields = api.model('Planet list', {
    'name': fields.String,
    'diameter': fields.String,
    'population': fields.String
})
Exemplo n.º 9
0
from flask_restplus import reqparse, fields
from api.restplus import api

getTokenParams = api.model('获取认证',{
  'access_token':fields.String(required=True, description='认证token'),
  'group_id':fields.String(required=True, description='用户组')
  })

# 1--获取机器人access_token
pagination_arguments_token = reqparse.RequestParser()
pagination_arguments_token.add_argument('appId', type=str, required=True, default=1, help='固定的企业/个人ID')
pagination_arguments_token.add_argument('createTime', type=int, required=False, default=1, help='自1970年1月1日0时起至今的毫秒数(可随意填写,小于至今的秒数即可)')
pagination_arguments_token.add_argument('sign', type=str, required=True,
                                  help='签名(appId,appKey,createTime以字符串方式拼接后经过 MD5 加密)')
pagination_arguments_token.add_argument('expire', type=int, required=False, choices=[4,8,12,16,20,24], default=24,
                                           help='token 过期时间,单位小时(可传入大于 0,小于 25 的整数)')
# 2--机器人单轮对话
pagination_arguments_dialog = reqparse.RequestParser()
pagination_arguments_dialog.add_argument('access_token', type=str, required=True, default=1, help='调用接口凭证')
pagination_arguments_dialog.add_argument('sysNum', type=str, required=True, default=1, help='企业或账号标识')
pagination_arguments_dialog.add_argument('question', type=str, required=True, default='Hello', help='用户问题')
pagination_arguments_dialog.add_argument('robotFlag', type=int, required=True, choices=[1,2,3],
                                  default=1, help='机器人编号')


# 3--添加知识库对话
pagination_arguments_addDialog = reqparse.RequestParser()
pagination_arguments_addDialog.add_argument('access_token', type=str, required=True, default=1, help='调用接口凭证')
pagination_arguments_addDialog.add_argument('robotFlag', type=int, required=True, choices=[1,2,3],
                                  default=1, help='机器人编号')
pagination_arguments_addDialog.add_argument('questionTitle', type=str, required=True, default='Hi', help='标准问题')
Exemplo n.º 10
0
from flask_restx import fields

from api.restplus import api

location = api.model('Resource Location', {
    'location': fields.String(required=True)
})

message = api.model('Message', {
    'message': fields.String(required=True)
})

bad_request = api.inherit('Bad request', message, {

    'erorrs': fields.Wildcard(fields.String)
})

category_output = api.model('Category Output', {
    'id': fields.Integer(required=True),
    'name': fields.String(required=True, description='Category name')
})

category_input = api.model('Category Input', {
    'name': fields.String(required=True, description='Category name')
})

generic_file_output = api.model('Generic File Output', {
    'id': fields.Integer(required=True),
    'file_name': fields.String(required=True),
    'link': fields.String(required=True),
    'created_at': fields.String(required=True)
from flask_restplus import fields
from api.restplus import api

translation_model = api.model('Translation payload', {
    'source': fields.String(required=True,defaut='en', description='Source language, Default is en'),
    'destination': fields.String(required=True, description='Destination language, Default is en'),
    'text': fields.String(required=True, description='Text to be convert')
})


goslate_translation_model = api.model('Goslate Translation payload', {
    'destination': fields.String(required=True, description='Destination language, Default is en'),
    'text': fields.String(required=True, description='Text to be convert')
})
Exemplo n.º 12
0
from flask_restplus import fields
from api.restplus import api


model_score = api.model('Model Score', {
    'algorithm': fields.String(required=True, description='Model name'),
    'source_url': fields.String(required=True, description='Source URL'),
    'field_names': fields.String(required=True, description='Field Names'),
})
Exemplo n.º 13
0
from flask_restplus import fields
from api.restplus import api

ctx = api.model(
    'Context', {
        'id':
        fields.Integer(readOnly=True,
                       description='The unique identifier of a model template')
    })

model = api.model(
    'Model', {
        'id':
        fields.Integer(
            readOnly=True,
            description='The unique identifier of a model template'),
        'name':
        fields.String(required=True, description='Model template name'),
        'cookiecutter_context':
        fields.Nested(description='Context for model generating job',
                      model=ctx),
        'job_id':
        fields.String(description='Model template name'),
        'build_id':
        fields.String(description='Model template name'),
        'title':
        fields.String(description='Model template name')
    })
Exemplo n.º 14
0
from flask_restplus import fields
from api.restplus import api

course = api.model(
    'Course', {
        'id': fields.Integer(required=True, description='Course id'),
        'name': fields.String(required=True, description='Course name'),
    })

course_creation = api.model(
    'CourseCreation',
    {'name': fields.String(required=True, description='Course period')})
Exemplo n.º 15
0
from flask_restplus import fields
from api.restplus import api
"""
Serializers are used to define the structure of the response of endpoints.
The returned object is walked through and serialized using the decorator @api.marshal_with()
More info about response marshaling: https://flask-restplus.readthedocs.io/en/stable/marshalling.html
"""

user_json = api.model(
    'User', {
        'id':
        fields.Integer(readOnly=True,
                       description='The unique identifier of a user'),
        'username':
        fields.String(description='Username'),
        'password':
        fields.String(description='Password'),
    })

photo_json = api.model(
    'Photo', {
        'id':
        fields.Integer(readOnly=True,
                       description='The unique identifier of a photo'),
        'user_id':
        fields.Integer(description='User ID'),
        'user':
        fields.Nested(user_json,
                      description='User object',
                      skip_none=True,
                      allow_null=True),
Exemplo n.º 16
0
from flask_restplus import fields
from api.restplus import api

speech = api.model(
    'Speech input', {
        'text': fields.String(required=True, description='Input text'),
    })
humidity = api.model(
    'Humidity', {
        'id':
        fields.Integer(readOnly=True,
                       description='The unique identifier of the record'),
        'value':
        fields.Float(
            required=True, readOnly=True, description='The reading'
            's value'),
        'value_units':
        fields.String(required=True,
                      readOnly=True,
                      max=16,
                      description='The unit for the value (e.g. percent)'),
        'value_error_range':
        fields.Float(required=True,
                     readOnly=True,
                     description='The error range for the reading'
                     's value'),
        'latitude':
        fields.Float(required=True,
                     readOnly=True,
                     description='The latitude of the reading'),
        'latitude_public':
        fields.Float(required=True,
                     readOnly=True,
                     description='The public latitude of the reading'),
        'longitude':
        fields.Float(required=True,
                     readOnly=True,
                     description='The longitude of the reading'),
        'longitude_public':
        fields.Float(required=True,
                     readOnly=True,
                     description='The public longitude of the reading'),
        'city':
        fields.String(
            required=True, readOnly=True, description='The record'
            's city.'),
        'province':
        fields.String(required=True,
                      readOnly=True,
                      description='The record'
                      's province.'),
        'country':
        fields.String(required=True,
                      readOnly=True,
                      description='The record'
                      's country.'),
        'elevation':
        fields.Float(required=True,
                     readOnly=True,
                     description='The record'
                     's elevation.'),
        'elevation_units':
        fields.String(
            required=True,
            readOnly=True,
            max=16,
            description='The unit for the elevation (e.g. meters, feet)'),
        'timestamp':
        fields.DateTime(
            required=True,
            readOnly=True,
            description='The date and time the reading was recorded'),
    })
Exemplo n.º 18
0
from api.restplus import api


country = api.model(
    'Country',
    {
        'alpha_2': fields.String(
            required=True,
            readOnly=True,
            max=2,
            description='The unique two character identifier of the record'),
        'alpha_3': fields.String(
            required=True,
            readOnly=True,
            max=3,
            description='The unique three character identifier of the record'),
        'name': fields.String(
            required=True,
            readOnly=True,
            description='The country''s name'),
        'numeric': fields.String(
            required=True,
            readOnly=True,
            description='The country''s unique numeric code'),
        'official_name': fields.String(
            required=False,
            readOnly=True,
            description='The country''s official name'),
    })

subdivision = api.model(
    'Subdivision',
Exemplo n.º 19
0
from flask_restplus import fields
from api.restplus import api
from api.problems.serializers import problem
from api.submissions.serializers import simple_submission

assignment = api.model(
    'Assignment', {
        'id':
        fields.Integer(required=True, description='Assignment id'),
        'title':
        fields.String(required=True, description='Assignment title'),
        'start_date':
        fields.DateTime(required=True, description='Assignment start date'),
        'due_date':
        fields.DateTime(required=True, description='Assignment due date'),
        'group_id':
        fields.Integer(
            required=True,
            description='Id of the group where the assignment is due'),
        'problem':
        fields.Nested(problem)
    })

assignment_creation = api.model(
    'AssignmentCreation', {
        'title':
        fields.String(required=True, description='Assignment title'),
        'start_date':
        fields.DateTime(required=True, description='Assignment start date'),
        'due_date':
        fields.DateTime(required=True, description='Assignment due date'),
Exemplo n.º 20
0
from flask_restplus import fields
from api.restplus import api
from api.users.serializers import user
from api.topics.serializers import topic
from api.groups.serializers import group
from api.teams.serializer import team

contest_creation = api.model(
    'Contest-creation', {
        'name':
        fields.String(required=True, description='Contest name'),
        'start_date':
        fields.DateTime(required=True, description='Contest start date'),
        'end_date':
        fields.DateTime(required=True, description='Contest end date'),
        'group_id':
        fields.Integer(required=True, description="Grouu ID"),
        'problems':
        fields.List(fields.Integer(required=True, description='Problem id'))
    })

test_case = api.model(
    'Case', {
        'id':
        fields.Integer(required=True, description='Test case id'),
        'feedback':
        fields.String(required=True, description='Test case feedback'),
        'input':
        fields.String(required=True, description='Test case input'),
        'output':
        fields.String(required=True, description='Test case output'),
Exemplo n.º 21
0
from api.restplus import api

lb_subject_data = api.model(
    'LBSubjectStatus', {
        'id':
        fields.String(description='Auto increment id for subject record'),
        'subject_id':
        fields.String(description='Unique subject id of the patient'),
        'dob':
        fields.String(description='Date of birth of the patient'),
        'enrollment_id':
        fields.String(description='enrollment id of the patient'),
        'enrollment_status':
        fields.String(description='enrollment staus of the patient'),
        'process_name':
        fields.String(description='Process name'),
        'site_name':
        fields.String(description='Hostpital name'),
        'inclusion':
        fields.String(description='Binary stautus 1 or 0 '),
        'biobank':
        fields.String(description='Binary stautus 1 or 0 '),
        'sequencing':
        fields.String(description='Binary stautus 1 or 0 '),
        'curation':
        fields.String(description='Binary stautus 1 or 0 '),
        'randomization':
        fields.String(description='Binary stautus 1 or 0')
    })

header = api.model(
Exemplo n.º 22
0
from flask_restplus import fields
from api.restplus import api


user = api.model('User', {
    'id': fields.Integer(readOnly=True, description='The unique identifier of an user'),
    'name': fields.String,
    'mail': fields.String,
    'photo': fields.String,
    'birth_date': fields.DateTime,
    'bio': fields.String,
    'telephone': fields.String,
    'instagram': fields.String,

})

create_user = api.model('Create User', {
    'name': fields.String,
    'mail': fields.String,
    'photo': fields.String,
    'birth_date': fields.DateTime,
    'password': fields.String,
    'bio': fields.String,
    'telephone': fields.String,
    'instagram': fields.String,
})

edit_user = api.model('Update User', {
    'name': fields.String,
    'mail': fields.String,
    'photo': fields.String,
Exemplo n.º 23
0
from flask_restplus import fields
from api.restplus import api
from api.users.serializers import user
from api.topics.serializers import topic

test_case = api.model(
    'Case', {
        'id':
        fields.Integer(required=True, description='Test case id'),
        'feedback':
        fields.String(required=True, description='Test case feedback'),
        'input':
        fields.String(required=True, description='Test case input'),
        'output':
        fields.String(required=True, description='Test case output'),
        'is_sample':
        fields.Boolean(required=True, description='Is test case sample?')
    })

enable_test_case = api.model(
    'Case', {
        'id':
        fields.Integer(required=True, description='Test case id'),
        'is_sample':
        fields.Boolean(required=True, description='Is test case sample?')
    })

problem = api.model(
    'Problem', {
        'id':
        fields.Integer(required=True, description='Problem id'),
Exemplo n.º 24
0
# -*- coding: UTF-8 -*-
from flask_restplus import fields
from api.restplus import api

####################################################
# Restful API data model for Compiler Warning info #
####################################################

api_job = api.model('APIJob', {
    'id': fields.Integer(readOnly=True, description='Jenkins job id'),
    'name': fields.String(readOnly=True, description='Jenkins job name'),
    'job_type': fields.String(readOnly=True, required=False, default="ci", description='Jenkins job type: ci,deploy,smoke_test,santity_test,function_test,dynamic_test'),
    'display': fields.Boolean(readOnly=True, required=False, default=True, description='Whether to display job')
})

api_jobs = api.model('APIJobs', {
    'total_count': fields.Integer(readOnly=True, default=0, description='Total job counts'),
    'page': fields.Integer(readOnly=True, default=-1, description='The current page number of jobs'),
    'per_page': fields.Integer(readOnly=True, default=-1, description='Job count of one page'),
    'api_job_items': fields.List(fields.Nested(api_job), readOnly=True, description='Job records')
})
Exemplo n.º 25
0
from flask_restplus import fields
from api.restplus import api

user_auth = api.model('UserAuth', {
    'email': fields.String(required=True, description='User email'),
    'password': fields.String(required=True, description='User password')
})

user_token = api.model('UserToken', {
    'token': fields.String(required=True, description='User auth token')
})

user = api.model('User', {
    'id': fields.Integer(required=True, description='User id'),
    'email': fields.String(required=True, description='User email'),
    'first_name': fields.String(required=True, description='User name'),
    'last_name': fields.String(required=True, description='User last name'),
    'role': fields.String(required=True, description='User role'),
    'enrollment': fields.String(required=True, description='User enrollment number')
})

user_creation = api.model('UserCreation', {
    'email': fields.String(required=True, description='User email'),
    'password': fields.String(required=True, description='User password'),
    'first_name': fields.String(required=True, description='User name'),
    'last_name': fields.String(required=True, description='User last name'),
    'enrollment': fields.String(required=True, description='User enrollment number'),
    'role': fields.String(required=True, description='User role')
})

user_edit = api.model('UserEdit', {
Exemplo n.º 26
0
from flask_restplus import fields
from api.restplus import api

user = api.model(
    'User', {
        'id':
        fields.Integer(readOnly=True,
                       description='The unique identifier of a user'),
        'username':
        fields.String(required=True, description='Unique user name'),
    })
Exemplo n.º 27
0
from flask_restplus import fields
from api.restplus import api
from api.courses.serializers import course
from api.users.serializers import user
from api.assignments.serializers import assignment

team = api.model(
    'Team', {
        'id':
        fields.Integer(required=True, description='Team id'),
        'name':
        fields.String(required=True, description='Team name'),
        'professor_id':
        fields.Integer(required=True, description='Team professor id'),
        'group_id':
        fields.Integer(required=True, description='Team group id'),
        'students':
        fields.List(fields.Nested(user))
    })

team_with_students = api.model(
    'TeamWithStudents', {
        'id':
        fields.Integer(required=True, description='Team id'),
        'name':
        fields.String(required=True, description='Team name'),
        'professor_id':
        fields.Integer(required=True, description='Team professor id'),
        'group_id':
        fields.Integer(required=True, description='Team group id'),
        'students':
Exemplo n.º 28
0
from flask_restplus import fields
from api.restplus import api

setting = api.model(
    'setting', {
        'key': fields.String(required=True, description='key'),
        'value': fields.String(required=True, description='value'),
    })

user = api.model(
    'user', {
        'username': fields.String(readOnly=True, description='Logged in user'),
    })

system = api.model(
    'system', {
        'cpu_load':
        fields.Integer(readOnly=True, description='CPU load (in percent)'),
        'cpu_num':
        fields.Integer(readOnly=True, description='Amount of cores'),
        'cpu_freq':
        fields.Integer(readOnly=True, description='CPU frequency (in MHz)'),
        'ram_max':
        fields.Integer(readOnly=True,
                       description='Installed amount of RAM (in MB)'),
        'ram_used':
        fields.Integer(readOnly=True, description='RAM used (in MB)'),
        'ram_pct':
        fields.Integer(readOnly=True, description='RAM used (in percent)'),
        'root_disk_pct':
        fields.Integer(readOnly=True,
Exemplo n.º 29
0
from flask_restplus import fields
from api.restplus import api
from api.problems.serializers import problem
from api.users.serializers import user

submission_feedback = api.model(
    'SubmissionFeedback', {
        'status': fields.String(required=True, description='Feedback status'),
        'feedback': fields.String(required=True, description='Feedback')
    })

submission = api.model(
    'Submission', {
        'id':
        fields.Integer(required=True, description='Submission id'),
        'language':
        fields.String(required=True, description='Submission lang'),
        'code':
        fields.String(required=True, description='Submission code'),
        'grade':
        fields.String(required=True, description='Submission grade'),
        'feedback_list':
        fields.List(fields.Nested(submission_feedback)),
        'problem':
        fields.Nested(problem),
        'created':
        fields.DateTime(required=True, description='Date of last submission'),
        'user':
        fields.Nested(user),
        'no_of_attempt':
        fields.Integer(required=True, description='Number of attempt')
Exemplo n.º 30
0
from flask_restplus import fields
from api.restplus import api

data = api.model(
    'Dataset Model', {
        'id_personne':
        fields.String(readOnly=True,
                      description='The unique identifier of row'),
        'nom_personne':
        fields.String(required=True, description='Name '),
        'prenom_personne':
        fields.String(required=True, description='First name'),
        'date_naissance':
        fields.String(required=True, description='Date birth'),
    })

dataset_head = api.model(
    'Model output if succes request', {
        'id_dataset':
        fields.String(readOnly=True,
                      description='The unique identifier of dataset'),
        'nom_dataset':
        fields.String(readOnly=True, description='Dataset name'),
        'insertion_date':
        fields.String(required=True, description='Date insert dataset'),
    })

dataset_kpis = api.model(
    'Dataset stats', {
        'number_lines':
        fields.Integer(readOnly=True,
Exemplo n.º 31
0
from database.models import User
from api.restplus import api
from flask import request
from database import db
from database.models import RefreshToken
import settings
import jwt
import datetime
import hashlib

ns = api.namespace('users/auth',
                   description='Operations related to authentication')

return_token_model = api.model(
    'ReturnToken', {
        'access_token': fields.String(required=True),
        'refresh_token': fields.String(required=True)
    })

login_model = api.model('LoginModel', {
    'mail': fields.String(required=True),
    'password': fields.String(required=True)
})


@ns.route('/')
@api.response(401, 'User or password incorrect')
class Login(Resource):
    @api.response(200, 'Login ok')
    @api.expect(login_model)
    def post(self):