from flask import Flask from flask.ext.restplus import Api, Resource, fields from werkzeug.contrib.fixers import ProxyFix from rested_users import DESCRIPTION, TITLE, VERSION from rested_users.group_dao import GroupDAO from rested_users.user_dao import UserDAO from rested_users.exceptions import GroupError, UserError app = Flask(__name__) app.wsgi_app = ProxyFix(app.wsgi_app) api = Api(app, version=VERSION, title=TITLE, description=DESCRIPTION, ) group_ns = api.namespace('groups', description='Group operations') user_ns = api.namespace('users', description='User operations') user = api.model('user', { 'first_name': fields.String(required=False, description='The firstname of the user.', default=""), 'last_name': fields.String(required=False, description='The lastname of the user.', default=""), 'userid': fields.String(required=True, description='The userid of the user.'), 'groups': fields.List(fields.String, required=False, description='A list of groups the user belongs to.', default=[""]) }) group = api.model('group', { 'name': fields.String(required=True, description='The name of the group.') }) group_update = api.model('group_update', {
from flask import Flask from flask.ext.restplus import Api app = Flask("dmon-agent") api = Api(app, version='0.0.4', title='DICE Monitoring Agent API', description="RESTful API for the DICE Monitoring Platform Agent (dmon-agent)", ) # changes the descriptor on the Swagger WUI and appends to api /dmon and then /v1 agent = api.namespace('agent', description='dmon agent operations')
from app import app from flask import Flask from flask.ext.restplus import Api, Resource, fields api = Api(app, version='1.0', title='TrueCar API', description='A simple TrueCar API borrowed from flask-restful example!', ) ns = api.namespace('vsnLookup', description='TrueCar API') #todo: not now probably continue later
from flask import Flask from flask.ext.restplus import Api app = Flask("dmon-logstash") app.config['RESTPLUS_VALIDATE'] = True api = Api(app, version='0.0.2', title='DICE Monitoring Logstash API', description="RESTful API for the DICE Monitoring Platform Logstash agent (dmon-logstash)", ) # changes the descriptor on the Swagger WUI and appends to api /dmon and then /v1 agent = api.namespace('agent', description='dmon logstash operations')
from mozart import app #Library backend imports import mozart.lib.job_utils import mozart.lib.queue_utils services = Blueprint('api_v0-2', __name__, url_prefix='/api/v0.2') api = Api(services, ui=False, version="0.2", title="Mozart API", description="API for HySDS job submission and query.") #Namespace declarations QUEUE_NS = "queue" queue_ns = api.namespace(QUEUE_NS, description="Mozart queue operations") JOBSPEC_NS = "job_spec" job_spec_ns = api.namespace(JOBSPEC_NS, description="Mozart job-specification operations") JOB_NS = "job" job_ns = api.namespace(JOB_NS, description="Mozart job operations") CONTAINER_NS = "container" container_ns = api.namespace(CONTAINER_NS, description="Mozart container operations") HYSDS_IO_NS = "hysds_io" hysds_io_ns = api.namespace(HYSDS_IO_NS, description="HySDS IO operations") EVENT_NS = "event" event_ns = api.namespace(EVENT_NS, description="HySDS event stream operations")
from flask import Flask, jsonify, request from flask.ext.restplus import Api, Resource, fields from flask import send_from_directory import shutil app = Flask("D-MON") api = Api( app, version='0.2.5', title='DICE MONitoring API', description='RESTful API for the DICE Monitoring Platform (D-MON)', ) backProc = None #changes the descriptor on the Swagger WUI and appends to api /dmon and then /v1 dmon = api.namespace('dmon', description='D-MON operations')
from flask import Flask, Blueprint, jsonify, render_template from flask.ext.restplus import Resource, fields, Api, apidoc from flask.ext.assets import Environment, Bundle from rcssmin import cssmin from kumo import geojson from kumo.query import (DEFAULT_LIMIT, station, stations, by_country, countries, is_station_id) app = Flask(__name__, static_folder='assets') app.config.SWAGGER_UI_DOC_EXPANSION = 'list' blueprint = Blueprint('api', __name__, url_prefix='/api') api = Api(blueprint, ui=False, title='Kumo', description='API to request air quality measuring stations') ns_station = api.namespace('stations', description='Get stations from ID') ns_country = api.namespace('countries', description='Get stations from countries') js_assets = ( 'bower/jquery/dist/jquery.js', 'bower/bootstrap/dist/js/bootstrap.js', 'bower/leaflet/dist/leaflet.js', 'bower/leaflet-filelayer/leaflet.filelayer.js', 'js/main.js', ) css_assets = ( 'bower/bootstrap/dist/css/bootstrap.min.css', 'bower/fontawesome/css/font-awesome.min.css', 'bower/leaflet/dist/leaflet.css',
from flask import Flask from flask.ext.restplus import Api app = Flask("dmon-adp") api = Api(app, version='0.0.1', title='DICE Anomaly Detection Platform API', description="RESTful API for the DICE Anomaly Detection Platform (dmon-adp)", ) # changes the descriptor on the Swagger WUI and appends to api /dmon and then /v1 adp = api.namespace('adp', description='dmon anomaly detection operations')
from flask import Flask from flask.ext.restplus import Api from flask.ext.restplus import fields from sklearn.externals import joblib app = Flask(__name__) api = Api(app, version='1.0', title='Prescription Prediction', description='Simple API Prototype') ns = api.namespace('PHC', description='Predicting drugs for') parser = api.parser() parser.add_argument( 'RevolvingUtilizationOfUnsecuredLines', type=float, required=True, help= 'Total balance on credit cards and personal lines of credit except real estate and no installment debt like car loans divided by the sum of credit limits', location='form') parser.add_argument('age', type=float, required=True, help='Age of borrower in years', location='form') parser.add_argument( 'NumberOfTime30-59DaysPastDueNotWorse', type=float, required=True,
from flask import Flask from flask.ext.restplus import Api app = Flask("dmon-agent") api = Api( app, version='0.0.6', title='DICE Monitoring Agent API', description= "RESTful API for the DICE Monitoring Platform Agent (dmon-agent)", ) # changes the descriptor on the Swagger WUI and appends to api /dmon and then /v1 agent = api.namespace('agent', description='dmon agent operations')
from flask import Flask from flask.ext.restplus import Api, Resource, fields app = Flask(__name__) api = Api(app, version='1.0', title='Resume Generator API', description='An API used to integrate resume information from various formats and transform them into different graphical representations.') ns = api.namespace('resumes', description='Resumes') resume_parser = api.parser() resume_parser.add_argument('username', type=str, required=True, help='Your username, used as an identifier for any request to the API', location='form') resume_parser.add_argument('fullname', type=str, required=True, help='Your full name', location='form') resume_parser.add_argument('age', type=int, required=True, help='Your age', location='form') resume = api.model('Resume', { 'username': fields.String(required=True), 'fullname': fields.String(required=True), 'age' : fields.Integer(required=True) }) SUPPORTED_INPUTS = ['json'] resume_content_parser = api.parser() resume_content_parser.add_argument('content', type=str, required=True, help='The resume content in the format described by content_type.', location='form') resume_content_parser.add_argument('content_type', type=str, required=True, help='The resume content type submitted. Currently supported: ' + ', '.join(SUPPORTED_INPUTS), location='form') resume_content = api.model('ResumeContent', { 'content' : fields.String(required=True), 'content_type' : fields.String(required=True, enum=SUPPORTED_INPUTS), })
####################### app.config['SESSION_TYPE'] = 'filesystem' session = Session(app) ############# # blueprint # ############# blueprint = Blueprint('api', __name__, url_prefix='/api') api = Api(blueprint, doc='/doc/') app.register_blueprint(blueprint) ############## # namespaces # ############## trans_ns = api.namespace('transmission', description='Operations on transmission API') auth_ns = api.namespace('authorization', description='Authorization and entitlements API') ########## # models # ########## # FIXME: Put models in a centralized map that can be referenced by resources listed_torrents = api.model('ListedTorrents', { 'ids': fields.List(fields.Integer, descriptions='An optional list of torrent IDs to retrieve.') }) auth_model = api.model('AuthModel', { 'username': fields.String(required=True), 'password': fields.String(required=True), 'application': fields.String(required=True), 'hostname': fields.String(required=False), 'port': fields.Integer(required=False)
from flask import Flask from flask.ext.restplus import Api app = Flask(__name__) app.config.SWAGGER_UI_DOC_EXPANSION = 'list' api = Api(app, version='1.0', title='AI API', description='A simple API for AI class project') tsp = api.namespace('tsp', description='TSP API')
import os, sys, json, requests, traceback from datetime import datetime from flask import Blueprint, request, redirect, url_for, Response, current_app from flask.ext.restplus import Api, apidoc, Resource, fields from flask.ext.login import login_user, logout_user, login_required from fv_prov_es import cache from fv_prov_es.lib.utils import get_prov_es_json, get_ttl from fv_prov_es.lib.import_utils import get_es_conn, import_prov NAMESPACE = "prov_es" services = Blueprint('api_v0-2', __name__, url_prefix='/api/v0.2') api = Api( services, ui=False, version="0.2", title="PROV-ES API", description="API for ingest, query, and visualization of PROV-ES documents" ) ns = api.namespace(NAMESPACE, description="PROV-ES operations") @services.route('/doc/', endpoint='doc') def swagger_ui(): return apidoc.ui_for(api)
from flask import Flask from flask.ext.sqlalchemy import SQLAlchemy from flask.ext.script import Manager from flask.ext.migrate import Migrate, MigrateCommand from flask.ext.restplus import Api app = Flask(__name__) app.config.from_object("config.config") api = Api(app, version=app.config["VERSION"], title="api title", description="Api description") namespace = api.namespace(app.config["URL_PREFIX"], description="version api") db = SQLAlchemy(app) migrate = Migrate(app, db) manager = Manager(app) manager.add_command("db", MigrateCommand) from app.users import userDb, users, login from app.transactions import send
from flask import Flask from flask.ext.restplus import Api, Resource, fields app = Flask(__name__) api = Api( app, version='1.0', title='Todo API', description= 'A simple TODO API extracted from the original flask-restful example', ) ns = api.namespace('todos', description='TODO operations') TODOS = { 'todo1': { 'task': 'build an API' }, 'todo2': { 'task': '?????' }, 'todo3': { 'task': 'profit!' }, } todo = api.model( 'Todo', {'task': fields.String(required=True, description='The task details')}) listed_todo = api.model(
result = {'error':'process_error', 'description':'Error while processing request.'} if GENERAL_DEBUG: result['description'] = result['description']+' '+text return result, 500 def controller_error(text): result = {'error':'controller_error', 'description':text} return result, 400 def not_started(): result = {'error':'not_started', 'description':'The process has not stated yet.'} return result, 400 # Install install_ns = api.namespace('install', description='Install operations.') @install_ns.route('/docker') class DockerInst(Resource): @api.doc(description='Install docker daemon') @api.response(500, 'Error processing the request', errorResponseModel) @api.response(200, 'OK', generalResponseModel) def get(self): try: return Installator.docker() except ControllerError as e: return controller_error(e.message) except Exception as e: return process_error(str(e)) @install_ns.route('/crane')
# Common errorResponseModel = api.model('Error', generalSchemas.basic_error_response) def not_implemented(): result = {'error':'not_implemented', 'description':'Feature not implemented yet'} return result, 500 def not_found(): result = {'error':'not_found', 'description':'Resource not found'} return result, 404 # Extra routes extra_ns = api.namespace('extra', description='Some extra functions.') @extra_ns.route('/purge') class Purge(Resource): @api.doc(description='Purge all data: contexts, compositions, files, etc.') def get(self): return managementOps.purge(datastore) @extra_ns.route('/tokens') class Tokens(Resource): @api.doc(description='Get all tokens in datastore.') def get(self): return managementOps.getAllTokens(datastore)
# -*- coding: utf-8 -*- from flask.ext.restplus import apidoc, Api from flask import Blueprint, render_template from flask_cors import cross_origin api_blueprint = Blueprint('api', __name__) api = Api(api_blueprint, doc=False, catch_all_404s=True, title='API version 2.0') ns_administrative = api.namespace('administrative', description="Administrative APIs", path='/') def init_app(app): from . import hail, taxi, ads, drivers, zupc, profile, vehicle, documents api.init_app(app, add_specs=False) app.register_blueprint(api_blueprint) app.register_blueprint(apidoc.apidoc) @app.route('/swagger.json', endpoint='api.specs') @cross_origin() def swagger(): return render_template('swagger.json', host=app.config['SERVER_NAME']), 200, {'Content-Type': 'application/json'}
def controller_error(text): result = {'error': 'controller_error', 'description': text} return result, 400 def not_started(): result = { 'error': 'not_started', 'description': 'The process has not stated yet.' } return result, 400 # Install install_ns = api.namespace('install', description='Install operations.') @install_ns.route('/docker') class DockerInst(Resource): @api.doc(description='Install docker daemon') @api.response(500, 'Error processing the request', errorResponseModel) @api.response(200, 'OK', generalResponseModel) def get(self): try: return Installator.docker() except ControllerError as e: return controller_error(e.message) except Exception as e: return process_error(str(e))
API_PATH = '/api' @app.route('/api/', endpoint='api') def swagger_ui(): return apidoc.ui_for(api) @app.route('/') @app.route('/app') def hello_world(): return render_template('criteria.html') api = Api(app, version='1', title='USSC test task', ui=False) criteria_ns = api.namespace(name='Criteria', description="Запросы, связанные с критериями", path=API_PATH) input_box_ip = api.model('BoxIPInput', {'data': fields.String}) @criteria_ns.route('/criteria/<criterion_id>', endpoint='criterion') class CriterionAPI(Resource): def __init__(self): super(CriterionAPI, self).__init__() def get(self, criterion_id): u""" Получить критерий """ return { "data": { "id": "0b1c7f57-0a89-41bc-966d-474301c25bc9",
from flask.ext.restplus import Api, Resource, fields, apidoc app = Flask(__name__) # PREFIX van de api -> http://SERVERNAME/<URL_PREFIX> blueprint = Blueprint('api', __name__, url_prefix='/apiv1') # CUSTOM CREATE van Api object ipv api = Api(blueprint, ui=False) api = Api() # manuele add van endpoint specs met path naar swagger.json, anders auto op /apiv1/swagger.json # AANPASSEN PATH->swagger.json naar /<NAMESPACE>/swagger.json api.add_resource(api.swagger_view(), '/sensoren/swagger.json', endpoint='specs', doc=False) # !!! Blueprint is een soort app. Aangezien de routes gekoppeld zijn ad blueprint, moet deze geregistreerd worden, dus niet api.init_app(app, add_specs=False, ui=False) # init Api api.init_app(blueprint, add_specs=False, ui=False) # NAMESPACE: AANPASSEN! Komt overeen met http://<SERVERNAME>/URL_PREFIX/<NAMESPACE> ns = api.namespace('sensoren', description='Temperatuursensoren Koelcel & Diepvriescel') # PATH NAAR SWAGGER (/<NAMESPACE>/swagger) @blueprint.route('/sensoren/swagger/', endpoint='swagger') def swagger_ui(): return apidoc.ui_for(api) # EFFECTIEVE API GEDEELTE # => http://<SERVERNAME>/URL_PREFIX/<NAMESPACE>/ @ns.route('/', endpoint='sensoren') @api.doc(description='test') class MyResource(Resource): def get(self): return "Hello!" model = api.model('Model', {
#!flask/bin/python from flask import Flask from flask.ext.restplus import Api, Resource from utils.utils import CKAN_Utils import json from utils.mas_alla_5_estrellas import Mas_alla_5_estrellas app = Flask(__name__) api = Api(app, version='1.0', title='ODQ API', description='Open Data Quality API' ) ns = api.namespace('api', description='Open Data Quality API') OPERATIONS = { 'avalible_operations' : [ '/api/', '/api_ckan/package_show/<string:ckan_portal>/<string:package_name>', '/api_ckan/resource_show/<string:ckan_portal>/<string:resource_id>', '/api_ckan/resource_status_show/<string:ckan_portal>/<string:resource_id>', '/ckan_data_quality/<string:ckan_portal>/<string:resource_id>', '/mas_alla_5_estrellas/disponibilidad/<string:ckan_portal>/<string:resource_id>', '/mas_alla_5_estrellas/reutilizacion/<string:ckan_portal>/<string:resource_id>', '/mas_alla_5_estrellas/granularidad/<string:ckan_portal>/<string:package_name>' ] } #Portals with CKAN Supported SUPPORTED_PORTALS = { 'uk' : { 'url': 'http://data.gov.uk' },
import sys from Project.app import app from flask.ext.restplus import Api, fields sys.setrecursionlimit(1000000) api = Api(app, version='4.0', title='smartlock', description='API for App Controlled Smartlock', default="smartlock") ns = api.namespace('smartlock', description='User operations') from api_hardware import * from api_locks import * from api_users import * from api_friends import * @api.doc(responses={200: 'Successfully pinged API'}) class HelloWorld(Resource): def get(self): """Testing: Primative GET""" return {'hello': 'world'} @api.doc(responses={200: 'Successfully logged in '}) class ProtectedResource(Resource): """ This endpoint is protected by basic auth and is only used for testing """ decorators = [requires_auth]
from flask import Flask, request from flask.ext.restplus import Api, apidoc, Resource, fields from werkzeug.datastructures import FileStorage app = Flask(__name__, static_url_path='') api = Api(app, version='0.1', title='Packaging-engine dummy API', description='Dummy API for the packaging-engine') namespace = api.namespace('v1', description='v1') newPackArgs = api.parser() newPackArgs.add_argument('requestToken', location='form') newPackArgs.add_argument('recipes', type=FileStorage, help='Tar archive that contains the recipes and related data following some rules.' , location='files') packprocessInfo = { 'status': fields.String, 'description': fields.String, 'percentage': fields.Integer } packprocessInfoModel = api.model('packprocessInfo', packprocessInfo) def __checkPackage__(file): if file.filename == 'validrecipes.tar': return True else: return False
from flask import Flask, jsonify, request from flask.ext.restplus import Api, Resource, fields from flask import send_from_directory import shutil app = Flask("D-MON") api = Api(app, version='0.2.5', title='DICE MONitoring API', description='RESTful API for the DICE Monitoring Platform (D-MON)', ) backProc = None #changes the descriptor on the Swagger WUI and appends to api /dmon and then /v1 dmon = api.namespace('dmon', description='D-MON operations')
#!/usr/bin/env python # coding=utf-8 from flask import Flask from flask.ext.restplus import Api, Resource, fields from uuid import uuid4 app = Flask(__name__) api = Api(app, version="1.0", title="API Transformer demonstration", description="API created to demonstrate the functionality offered by the API Transformer Convertron") demo_ns = api.namespace('demo', description='Demo operations') @demo_ns.route('') class Demo(Resource): @api.doc(description='A demo HTTP GET', responses={400: ("Bad request", api.model('Error', {"message": fields.String})), 500: "Unhandled exception (captured in server logs)"}) def get(self): return 'This is a demo!', 200 @api.expect(api.model('Demo Request', {"data": fields.String(required=True)})) @api.doc(description='A demo HTTP POST', responses={400: ("Bad request", api.model('Error', {"message": fields.String})), 500: "Unhandled exception (captured in server logs)"}) @api.marshal_with(api.model( 'Demo Response', {"id": fields.String(required=True), "data": fields.String(required=True)}), code=201) def post(self):
from flask import Flask from flask.ext.restplus import Api app = Flask("dmon-logstash") app.config['RESTPLUS_VALIDATE'] = True api = Api( app, version='0.0.2', title='DICE Monitoring Logstash API', description= "RESTful API for the DICE Monitoring Platform Logstash agent (dmon-logstash)", ) # changes the descriptor on the Swagger WUI and appends to api /dmon and then /v1 agent = api.namespace('agent', description='dmon logstash operations')
import os, sys, json, requests, types, re from flask import jsonify, Blueprint, request, Response, render_template, make_response from flask.ext.restplus import Api, apidoc, Resource, fields from flask.ext.login import login_required from grq2 import app from grq2.lib.dataset import update as updateDataset NAMESPACE = "grq" services = Blueprint('api_v0-2', __name__, url_prefix='/api/v0.2') api = Api(services, ui=False, version="0.2", title="Mozart API", description="API for GRQ Services.") ns = api.namespace(NAMESPACE, description="GRQ operations") @services.route('/doc/', endpoint='api_doc') def swagger_ui(): return apidoc.ui_for(api)
from flask import Blueprint, request, redirect, url_for, Response, current_app from flask.ext.restplus import Api, apidoc, Resource, fields from flask.ext.login import login_user, logout_user, login_required from fv_prov_es import cache from fv_prov_es.lib.utils import get_prov_es_json, get_ttl from fv_prov_es.lib.import_utils import get_es_conn, import_prov NAMESPACE = "prov_es" services = Blueprint('api_v0-1', __name__, url_prefix='/api/v0.1') api = Api(services, ui=False, version="0.1", title="PROV-ES API", description="API for ingest, query, and visualization of PROV-ES documents") ns = api.namespace(NAMESPACE, description="PROV-ES operations") @services.route('/doc/', endpoint='doc') def swagger_ui(): return apidoc.ui_for(api) @ns.route('/query', endpoint='query') @api.doc(responses={ 200: "Success", 400: "Invalid parameters", 500: "Query execution failed" }, description="Query PROV-ES ElasticSearch index and return results as a JSONP response.") class Query(Resource): """Query ElasticSearch index and return results as a JSONP response."""
from flask import Flask from flask.ext.restplus import Api from flask.ext.restplus import fields from sklearn.externals import joblib app = Flask(__name__) api = Api(app, version='1.0', title='Find your Dog', description='A simple Dog Prediction API') ns = api.namespace('predict_dog', description='Predict your Dog Breed Suited to your needs') parser = api.parser() parser.add_argument( 'Gender', type=float, required=True, help='Please input your gender. Put 1 for Female and 2 for Male.', location='form') parser.add_argument('Age', type=float, required=True, help='Please input your age.', location='form') parser.add_argument('Income', type=float, required=True, help='Please input your annual income.',
from flask import Flask, Blueprint from flask.ext.restplus import Api, Resource, fields api_v1 = Blueprint('api', __name__, url_prefix='/api/1') api = Api(api_v1, version='1.0', title='Todo API', description='A simple TODO API', ) ns = api.namespace('todos', description='TODO operations') TODOS = { 'todo1': {'task': 'build an API'}, 'todo2': {'task': '?????'}, 'todo3': {'task': 'profit!'}, } todo = api.model('Todo', { 'task': fields.String(required=True, description='The task details') }) listed_todo = api.model('ListedTodo', { 'id': fields.String(required=True, description='The todo ID'), 'todo': fields.Nested(todo, description='The Todo') }) def abort_if_todo_doesnt_exist(todo_id): if todo_id not in TODOS: api.abort(404, "Todo {} doesn't exist".format(todo_id))
from flask import Flask from flask.ext.restplus import Api app = Flask(__name__) api = Api( app, version='1.0', title='Risk Assessment for Loan', description= 'This module helps you understand how viable it is to grant loan to a certain individual ' ) ns = api.namespace('approve_loan', description='Approve Loan') from flask.ext.restplus import fields resource_fields = api.model('Resource', { 'result': fields.String, }) parser = api.parser() parser.add_argument( 'RevolvingUtilizationOfUnsecuredLines', type=float, required=True, help= 'Total balance on credit cards and personal lines of credit except real estate and no installment debt like car loans divided by the sum of credit limits', location='form') parser.add_argument('age', type=float,
def not_implemented(): result = { 'error': 'not_implemented', 'description': 'Feature not implemented yet' } return result, 500 def not_found(): result = {'error': 'not_found', 'description': 'Resource not found'} return result, 404 # Extra routes extra_ns = api.namespace('extra', description='Some extra functions.') @extra_ns.route('/purge') class Purge(Resource): @api.doc(description='Purge all data: contexts, compositions, files, etc.') def get(self): return managementOps.purge(datastore) @extra_ns.route('/tokens') class Tokens(Resource): @api.doc(description='Get all tokens in datastore.') def get(self): return managementOps.getAllTokens(datastore)
from flask import Flask from flask.ext.restplus import Api app = Flask("aspide-ede") api = Api( app, version='0.0.1', title='Aspide Event Detection Engine', description="RESTful API for the Aspide Event Detection Engine", ) adp = api.namespace('ede', description='ede operations')
from apscheduler.events import EVENT_JOB_EXECUTED, EVENT_JOB_ERROR from tasks import BaseTask, recorder, example import atexit app = Flask(__name__) app.config.SWAGGER_UI_DOC_EXPANSION = 'list' blueprint = Blueprint('api', __name__, url_prefix='/api') api = Api(blueprint, version='1.0', title="APScheduler API", description="A simple API to access APScheduler.") app.register_blueprint(blueprint) ns = api.namespace('jobs', description='Job operations') # Fields that are expected and need to be exposed from a Job fields = api.model( 'Job', { 'id': fields.String(), 'name': fields.String(), 'task_class': fields.String(attribute=lambda x: x.func_ref.replace(':', '.').replace( '.execute', '')), 'next_run_time': fields.DateTime(dt_format='iso8601'), 'misfire_grace_time': fields.String(),
# Download wizard if not os.path.exists(s.DIR_WIZARD): wizard.download() if not os.path.exists(s.DIR_WIZARD): raise Exception("Cannot get wizard.") # Write launch script for packages wizard.createLaunchScript() # Set Flask app = Flask(__name__, static_url_path="") api = Api(app, version="0.3", title="ComCloud-packager", description="API for the packaging-engine") namespace = api.namespace("v1", description="v1") downloads = api.namespace("downloads", description="downloads") newPackArgs = api.parser() newPackArgs.add_argument("requestToken", location="form") newPackArgs.add_argument( "recipes", type=FileStorage, help="Tar archive that contains the recipes and related data following some rules.", location="files", ) packprocessInfo = {"status": fields.String, "description": fields.String, "percentage": fields.Integer} packprocessInfoModel = api.model("packprocessInfo", packprocessInfo)
from app import app from flask import Flask from flask.ext.restplus import Api, Resource, fields api = Api( app, version="1.0", title="TrueCar API", description="A simple TrueCar API borrowed from flask-restful example!" ) ns = api.namespace("vsnLookup", description="TrueCar API") # todo: not now probably continue later
from flask.ext.restplus import Api, apidoc, Resource, fields from flask.ext.login import login_required from grq2 import app from grq2.lib.dataset import update as updateDataset import hysds_commons.hysds_io_utils NAMESPACE = "grq" services = Blueprint('api_v0-1', __name__, url_prefix='/api/v0.1') api = Api(services, ui=False, version="0.1", title="Mozart API", description="API for GRQ Services.") ns = api.namespace(NAMESPACE, description="GRQ operations") HYSDS_IO_NS = "hysds_io" hysds_io_ns = api.namespace(HYSDS_IO_NS, description="HySDS IO operations") @services.route('/doc/', endpoint='api_doc') def swagger_ui(): return apidoc.ui_for(api) @ns.route('/dataset/index', endpoint='dataset_index') @api.doc(responses={ 200: "Success", 500: "Execution failed" },
from flask import Flask from flask.ext.restplus import Api from flask.ext.restplus import fields from sklearn.externals import joblib app = Flask(__name__) api = Api( app, version='1.0', title='Credit API', description='A simple Prediction API') ns = api.namespace('approve_credit', description='Approve Credit Operations')
from flask import Flask from flask.ext.restplus import Api app = Flask("dmon-elasticsearch") api = Api(app, version='0.0.1', title='DICE Monitoring Elasticsearch API', description="RESTful API for the DICE Monitoring Platform Elasticsearch agent (dmon-elasticsearch)", ) # changes the descriptor on the Swagger WUI and appends to api /dmon and then /v1 agent = api.namespace('agent', description='dmon elasticsearch operations')
from flask import Flask from flask.ext.restplus import Api, Resource, fields app = Flask(__name__) api = Api( app, version="1.0", title="Todo API", description="A simple TODO API extracted from the original flask-restful example", ) ns = api.namespace("todos", description="TODO operations") TODOS = {"todo1": {"task": "build an API"}, "todo2": {"task": "?????"}, "todo3": {"task": "profit!"}} todo = api.model("Todo", {"task": fields.String(required=True, description="The task details")}) listed_todo = api.model( "ListedTodo", { "id": fields.String(required=True, description="The todo ID"), "todo": fields.Nested(todo, description="The Todo"), }, ) def abort_if_todo_doesnt_exist(todo_id): if todo_id not in TODOS: api.abort(404, "Todo {} doesn't exist".format(todo_id))
errorResponseModel = api.model("Error", generalSchemas.basic_error_response) def not_implemented(): result = {"error": "not_implemented", "description": "Feature not implemented yet"} return result, 500 def not_found(): result = {"error": "not_found", "description": "Resource not found"} return result, 404 # Extra routes extra_ns = api.namespace("extra", description="Some extra functions.") @extra_ns.route("/purge") class Purge(Resource): @api.doc(description="Purge all data: contexts, compositions, files, etc.") def get(self): return managementOps.purge(datastore) @extra_ns.route("/tokens") class Tokens(Resource): @api.doc(description="Get all tokens in datastore.") def get(self): return managementOps.getAllTokens(datastore)