def recursive_folder_model(iteration_number=10): folder_json_mapping = { 'path': fields.String(), 'name': Name(attribute='path'), 'browseUrl': BrowseUrl(attribute='path'), 'createdDate': CreatedDate(attribute='path'), 'parentBrowseUrl': ParentBrowseUrl(attribute='path'), 'assets': fields.List(fields.Nested(base_asset_model)) } if iteration_number: folder_json_mapping['children'] = fields.List(fields.Nested(recursive_folder_model(iteration_number-1), skip_none=True)) return api.model('Folder'+str(iteration_number), folder_json_mapping)
game_stats = api.model( 'game_stats', { 'home_team': fields.String( description='Team code of home team', required=True, max_length=3), 'home_points': fields.Integer(description='Number of points for the home team', required=True), 'away_team': fields.String( description='Team code of away team', required=True, max_length=3), 'away_points': fields.Integer(description='Number of points for the away team', required=True), 'number_of_completed_passes': fields.Integer( description='Number of passes with a result of complete (C).'), 'number_of_failed_passes': fields.Integer( description= 'Number of passes with a result other than complete (C).'), 'average_first_down_distance': fields.Float(description='The average distance to the first down'), 'number_of_fumbles': fields.Integer(description='Number of fumbles for the game'), 'number_of_penalties': fields.Integer(description='Number of penalties for the game'), 'number_of_kicks': fields.Integer(description='Number of kicks for the game'), 'average_kick_yardage': fields.Float(description='Average kicker yardage'), 'longest_kicker_name': fields.String(description='Name of kicker with longest kick', max_length=45) })
from flask_restplus import fields from restplus import api user_post = api.model( 'user post', { 'id': fields.Integer(readOnly=True, description='The unique identifier of a user post'), 'username': fields.String(required=True, description='username'), 'email': fields.String(required=True, description='email'), }) blog_post = api.model( 'blog post', { 'id': fields.Integer(readOnly=True, description='The unique identifier of a user'), 'blog_name': fields.String(required=True, description='blog_name'), 'blog_content': fields.String(required=True, description='blog_content'), 'create_time': fields.Date(required=True, description='create_time'), })
from flask_restplus import Resource, reqparse, fields from restplus import api as api from flask import request, make_response from database.models import Subunidade from rdf.models import Subunidade as SubunidadeRDF from simpot import graph from flask.json import jsonify from flask_jwt import jwt_required subunidade_model = api.model( 'Subunidade model', { 'codigo': fields.String(readOnly=True, description='The unique identifier of a "subunidade"'), 'nome': fields.String(required=True, description='Nome do docente'), }) ns = api.namespace('subunidade', description='Operations related to "subunidade"') # repetindo codigo, refatorar @api.representation('application/xml') def xml(data, code, headers): resp = make_response(data, code) resp.headers.extend(headers) return resp @ns.route('/<string:codigo>')
report = api.model( 'report', { "id": fields.Integer(readOnly=True, description='The unique identifier ' 'for a crime report'), "crime_id": fields.String(description='Crime ID'), "month": fields.Integer(description='Month'), "year": fields.Integer(description='Year'), "reported_by": fields.String(description='Reported By'), "falls_within": fields.String(description='Falls Within'), "longitude": fields.Float(description='Longitude'), "latitude": fields.Float(description='Latitude'), "location": fields.String(description='Location'), "lsoa_code": fields.String(description='LSOA Code'), "lsoa_name": fields.String(description='LSOA Name'), "crime_type": fields.String(description='Crime Type'), "last_outcome": fields.String(description='Last Outcome'), "context": fields.String(description='Context') })
from flask_restplus import fields from restplus import api # The team model to enforce inputs arguments from the API team = api.model('Team', {'team_code': fields.String(description='Team code of team', required=True, max_length=3), 'team_name': fields.String(description='Name of team', required=True, max_length=45), 'hometown': fields.String(description='Hometown of team,', required=True, max_length=45), 'mascot': fields.String(description="Mascot of team", required=True, max_length=45), 'university': fields.String(description='University of team', required=True, max_length=45) }) # Gets arguments from API's input data def get_team_args(data): return [data.get('team_code'), data.get('team_name'), data.get('hometown'), data.get('mascot'), data.get('university')]
from flask_restplus import fields, reqparse from restplus import api user_post = api.model( 'User post', { 'name': fields.String(required=True, description='Name of user'), }) movie_post = api.model( 'Movie post', { 'title': fields.String(required=True, description='Name of movie'), 'director': fields.String(required=True, description='Name of director'), 'ranking': fields.Float( required=True, description='Ranking of movie', min=1.0, max=10.0) }) bookings_post = api.model( 'Bookings post', { 'userId': fields.Integer(required=True, description='User id'), 'movieIds': fields.List(fields.String), 'pubDate': fields.DateTime, }) movie_parser = reqparse.RequestParser() movie_parser.add_argument('title', location='form') movie_parser.add_argument('director', location='form') movie_parser.add_argument('ranking', location='form')
from flask_restplus import fields from restplus import api merge_docx_post = api.model('Merge docx post', {'contents': fields.List(fields.String())}) welcome_output = api.model( 'Welcome message output', { 'message': fields.String(example="welcome to the jungle!"), 'version': fields.Float(example="1.0") })
from restplus import api from flask_restplus import fields category_serializer = api.model( 'Category', { 'id': fields.Integer(readonly=True), 'title': fields.String(required=True, description='The category title') })
split_url = urlparse.urlsplit(request.url) path = "/browse" query = "path=%s" % urllib.quote(value) return urlparse.urlunsplit((split_url.scheme, split_url.netloc, path, query, '')) class ParentPath(fields.Raw): def format(self, value): if value == '': return None value, _ = utils_fs.get_path_split(value) return value init_model = api.model('init_model', { 'inbox_folder_path': fields.String(), 'archive_folder_path': fields.String() }) base_folder_model = api.model('base_folder_model', { 'path': fields.String(), 'name': Name(attribute='path'), 'children': Children(attribute='path'), 'browseUrl': BrowseUrl(attribute='path'), 'createdDate': CreatedDate(attribute='path'), 'parentBrowseUrl': ParentBrowseUrl(attribute='path') }) base_asset_model = api.model('base_asset_model', { 'path': fields.String(), 'name': Name(attribute='path'),
from flask_restplus import Resource, fields from restplus import api as api from ufma_scrapper import unidade import json ns = api.namespace('unidade', description='Operations related to "unidade"') with open('endpoints/unidades.json') as json_file: unidades = json.load(json_file) unidades_field = api.model( 'Unidade', { 'nome': fields.String, 'diretor': fields.String, 'telefone': fields.String, 'end_alt': fields.String }) @ns.route('/') class Unidade(Resource): def get(self): return unidades @ns.route('/<string:codigo>') class Unidade(Resource): @api.marshal_with(unidades_field) def get(self, codigo): return unidade.get_unidade(codigo)
from flask_restplus import fields from restplus import api # The client model to enforce inputs from the API client = api.model( 'Client', { 'username': fields.String( description='Username of client', required=True, max_length=20), 'password': fields.String( description='Password of client', required=True, max_length=20) })
from restplus import api from flask_restplus import fields customer_serializer = api.model('Clientes', { 'cpf': fields.String(required=True, description='CPF'), 'phone_number': fields.String(required=True, description='Celular') }) tax_fields = { 'id': fields.String, 'valor': fields.Float, } tax_serializer = api.model('Taxas', { 'tipo': fields.String(description='Tipo'), 'taxas': fields.List(fields.Nested(tax_fields), description='Número de Parcelas') }) loan_serializer = api.model('Loan', { 'cpf': fields.String(description='CPF'), 'phone_number': fields.String(description='Celular'), 'loan_value': fields.String(description='Valor de empréstimo'), 'installments': fields.String(description='Número de Parcelas') }) simulation_serializer = api.model('Simulation', { 'tax': fields.String(description='Taxa de Juros'), 'loan_value': fields.String(description='Valor de empréstimo'), 'installments': fields.String(description='Número de Parcelas') })
from flask_jwt import jwt_required from flask_restplus import fields from restplus import api as api from database.models import Docente as docenteModelDB from rdf.models import Docente as docenteModelRDF from simpot import graph from rdflib import Graph from flask import request from flask.json import jsonify ns = api.namespace('docente', description='Operations related to "docente"') docente_model = api.model( 'Blog category', { 'siape': fields.Integer(readOnly=True, description='The unique identifier of a blog category'), 'nome': fields.String(required=True, description='Nome do docente'), }) @api.representation('application/xml') def xml(data, code, headers): resp = make_response(data, code) resp.headers.extend(headers) return resp @ns.route('/<int:siape>') @api.response(404, 'Docente not found.') class DocenteItem(Resource):
from flask_restplus import fields from restplus import api # The kick model to enforce inputs arguments from the API kick = api.model( 'kick', { 'kicker': fields.Integer(description='Player ID of the kicker on the play.', required=False), 'kick_yardage': fields.Integer(description='Yardage length of the kick', required=True), 'kick_result': fields.String( description= 'Kick Result. How a kickoff, punt or missed field goal ended. Options include ' 'returned (R), touchback including single points (T), out-of-bounds (O), blocked' ' (B), onside kick (ON), successful on-side kick (S), no yards (N), penalty ' 'before a return (P), whistle blown deadball (D) and missed (M) for a hit ' 'upright or crossbar deadball.', required=False, max_length=2), }) # The fumble model to enforce inputs arguments from the API fumble = api.model( 'fumble', { 'fum_player_id': fields.Integer( description='Player ID of player who fumbled the ball.'), 'rec_player_id':
from flask_restplus import fields, reqparse from models.util import max_length from restplus import api # The issue model to enforce inputs arguments from the API issue = api.model( 'Issue', { 'client_username': fields.String(description='username of client who reported the issue', required=True, max_length=20), 'description': fields.String(description='description of the issue', required=True, max_length=200), 'submission_date': fields.DateTime(description='submission date of the issue') }) # An issue parser to require a description argument from an issue form issue_parser = reqparse.RequestParser(bundle_errors=True) issue_parser.add_argument('description', required=True, type=max_length(200), location='form')
from flask_restplus import fields, reqparse from models.util import is_int from restplus import api # The admin model to enforce inputs from the API admin = api.model( 'Admin', { 'username': fields.String( description='Username of admin', required=True, max_length=20), 'password': fields.String( description='Password of admin', required=True, max_length=20), 'permission_level': fields.Integer(description='Permission level given to admin', required=True) }) # A parser for admin's permission level which is inputted from a form admin_permission_level_parser = reqparse.RequestParser(bundle_errors=True) admin_permission_level_parser.add_argument('new_permission_level', required=True, type=is_int(), location='form') # Gets arguments from API's input data def get_admin_args(data): return [ data.get('username'),