Exemplo n.º 1
0
from flask_restful import Resource
from core import api


class ChannelSubscribeResource(Resource):
    """
    Receive event the channle
    """
    def post(self):
        print("Hello Knative Eventing from ChannelSubscribeResource.")
        return "Hello Knative Eventing from ChannelSubscribeResource."


api.add_resource(ChannelSubscribeResource, '/event')
Exemplo n.º 2
0
# -*- coding: utf8 -*-

from core import app, api
from sun4all import TaskImagesAPI, TaskImageAPI, TaskImageAPI_byDescription
from cells import TaskCellsAPI
from mindpaths import TaskMindPathsAPI

api.add_resource(TaskImageAPI, "/api/image", endpoint = 'image')
api.add_resource(TaskImageAPI_byDescription, "/api/image/<path:description>", endpoint = 'image_description')
api.add_resource(TaskImagesAPI, "/api/images", endpoint = 'tasks')

api.add_resource(TaskCellsAPI, "/api/cellresults", endpoint ='cells')
api.add_resource(TaskMindPathsAPI, "/api/mindpathsresults", endpoint ='mindpaths')
Exemplo n.º 3
0
from flask import abort
from flask_jwt_extended import create_access_token
from flask_restful import (Resource, reqparse)

from core import api
from user.models import User

#################################################################
# Authentication Resource
#################################################################

parser = reqparse.RequestParser()
parser.add_argument('username', type=str)
parser.add_argument('password', type=str)


class AuthenticationResource(Resource):
    def post(self):
        data = parser.parse_args()
        user = User.query.get_by_email(data['username'])
        if user and user.check_password(data['password']):
            access_token = create_access_token(identity=user.id)
            return {'access_token': access_token}
        else:
            abort(401)


# Register API
api.add_resource(AuthenticationResource, '/auth')
Exemplo n.º 4
0
from flask_restful import Resource
from core import api


class DeliveryResource(Resource):
    """
    Delivery root API
    """
    def get(self):
        return "Delivery Service - Hello world."

    def post(self):
        return "Delivery Service - Hello Knative Eventing."


api.add_resource(DeliveryResource, '/')
Exemplo n.º 5
0
from .index import HomeApi
from .groups import GroupsApi
from .auth import SignupApi, LoginApi, AuthTokenApi, UserApi
from .categories import CategoryApi, CategoriesApi
from .messages import MessageTypesApi, MessageCategoriesApi, MessageApi, MessagesApi
from core import api

api.add_resource(HomeApi, '/')
api.add_resource(SignupApi, '/auth/signup')
api.add_resource(LoginApi, '/auth/login')
api.add_resource(AuthTokenApi, '/auth/token-api')
api.add_resource(UserApi, '/user')
api.add_resource(CategoryApi, '/category/<int:category_id>')
api.add_resource(CategoriesApi, '/categories')
api.add_resource(MessageTypesApi, '/message_types')
api.add_resource(MessageCategoriesApi, '/message_categories')
api.add_resource(MessageApi, '/message')
api.add_resource(MessagesApi, '/messages')
api.add_resource(GroupsApi, '/groups')
Exemplo n.º 6
0
from flask_restful import Resource
from core import api


class StoreResource(Resource):
    """
    Health check resource
    """
    def get(self):
        print("Hello Knative Eventing.")
        return "Hello Knative Eventing."

    def post(self):
        print("Hello Knative Eventing.")
        return "Hello Knative Eventing."


api.add_resource(StoreResource, '/')
# -*- coding: utf8 -*-

from core import app, api
from sun4all import TaskImagesAPI, TaskImageAPI, TaskImageAPI_byDescription
from cells import TaskCellsAPI
from mindpaths import TaskMindPathsAPI

api.add_resource(TaskImageAPI, "/api/image", endpoint='image')
api.add_resource(TaskImageAPI_byDescription,
                 "/api/image/<path:description>",
                 endpoint='image_description')
api.add_resource(TaskImagesAPI, "/api/images", endpoint='tasks')

api.add_resource(TaskCellsAPI, "/api/cellresults", endpoint='cells')
api.add_resource(TaskMindPathsAPI,
                 "/api/mindpathsresults",
                 endpoint='mindpaths')
Exemplo n.º 8
0
def init_services():
    # Generator
    api.add_resource(ListTemplate, "/gen/template/list")
    api.add_resource(ReadTemplate, "/gen/template/read")
    # api.add_resource(BxPackage, "/gen/bx-package")
    # api.add_resource(CreatePackageData, "/gen/package-data")
    # api.add_resource(LoadCommand, "/gen/load-command")
    # api.add_resource(Tcd, "/gen/tcd")
    # api.add_resource(TcdField, "/gen/tcd-field")

    # Substitute
    api.add_resource(Substitute, "/sub/text")
    api.add_resource(Case, "/sub/case")

    # Formatter
    api.add_resource(Table, "/fmt/table")
    api.add_resource(Pivot, "/fmt/pivot")

    # Templater
    api.add_resource(template.Create, "/template/create")
    api.add_resource(template.Apply, "/template/apply")

    # Builder
    api.add_resource(builder.Package, "/builder/package")
Exemplo n.º 9
0
        # Query user within radius from center point (lat, lng)
        users = User.query.filter_within_radius(lat, lng, radius).all()

        return users


#################################################################
# UserListResource
# lets you POST to create a new user
#################################################################

parser = reqparse.RequestParser()
parser.add_argument('email', type=str)
parser.add_argument('first_name', type=str)
parser.add_argument('last_name', type=str)
parser.add_argument('password', type=str)


class UserListResource(Resource):
    def post(self):
        data = parser.parse_args()
        user = User.create_new_user(data)
        user.access_token = create_access_token(identity=user.id)
        return marshal(user, resource_fields)


# Register API
api.add_resource(UserResource, '/user/<user_id>')
api.add_resource(UserListResource, '/users')
api.add_resource(UserLocationResource, '/user/location')
Exemplo n.º 10
0
            note['body'] = body
            mongo_db.save(note)

        return args, OK

    def delete(self, note_id):
        if not note_exists(note_id):
            abort(NOT_FOUND, message=f"Could not find note with id {note_id}")

        mongo_db.delete_one({'_id': ObjectId(note_id)})
        return '', NO_CONTENT


class Notes(Resource):
    def get(self):
        docs = []
        for note in mongo_db.find():
            note['_id'] = str(note['_id'])
            docs.append(note)
        return docs, OK


api.add_resource(Notes, '/api/notes', endpoint='all-notes')
api.add_resource(Note, '/api/note', endpoint='note')
api.add_resource(NoteModify,
                 '/api/note/<string:note_id>',
                 endpoint='note-modify')

if __name__ == "__main__":
    app.run()
Exemplo n.º 11
0
    def get(self):
        user_id = get_jwt_identity()
        todos = Todo.query \
            .by_owner(user_id) \
            .completed().all()
        return todos


#################################################################
# UnCompletedTodoListResource
# lets you GET a list of completed todos
#################################################################


class UnCompletedTodoListResource(Resource):
    @jwt_required
    @marshal_with(resource_fields)
    def get(self):
        user_id = get_jwt_identity()
        todos = Todo.query \
            .by_owner(user_id) \
            .uncompleted().all()
        return todos


# Register API
api.add_resource(TodoResource, '/todo/<id>')
api.add_resource(TodoListResource, '/todos')
api.add_resource(CompletedTodoListResource, '/todos/completed')
api.add_resource(UnCompletedTodoListResource, '/todos/uncompleted')
Exemplo n.º 12
0
from flask_restful import Resource
from core import api


class HealthResource(Resource):
    """
    Health check resource
    """
    def get(self):
        return "OK"


# Register the resource so the Load balancer can connect to this endpoint
# to check our service health.
api.add_resource(HealthResource, '/healthz')