示例#1
0
"""
import configparser
import ast

from flask import current_app as app
from flask import request
from flask_restplus import Resource

from globomap_api.api.v2 import api
from globomap_api.api.v2.auth import permissions
from globomap_api.api.v2.auth.decorators import permission_classes
from globomap_api.api_plugins.abstract_plugin import PluginError
from globomap_api.api_plugins.abstract_plugin import PluginNotFoundException
from globomap_api.api_plugins.plugin_loader import ApiPluginLoader

ns = api.namespace('plugins', description='Plugins')


@ns.route('/')
@api.header(
    'Authorization',
    'Token Authorization',
    required=True,
    default='Token token='
)
class Plugins(Resource):

    @api.doc(responses={
        200: 'Success',
        401: 'Unauthorized',
        403: 'Forbidden'
示例#2
0
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
"""
from flask import current_app as app
from flask import request
from flask_restplus import Resource
from globomap_auth_manager import exceptions

from globomap_api.api.v2 import api
from globomap_api.api.v2.auth import facade
from globomap_api.api.v2.auth.exceptions import AuthException
from globomap_api.config import SPECS
from globomap_api.util import get_dict

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


@ns.route('/')
class CreateAuth(Resource):

    @api.doc(responses={
        200: 'Success',
        401: 'Unauthorized',
    })
    @api.expect(api.schema_model('Auth', get_dict(SPECS.get('auth'))))
    def post(self):
        """Create token"""

        try:
            data = request.get_json()
示例#3
0
from flask import current_app as app
from flask import request
from flask_restplus import Resource
from jsonspec.validators.exceptions import ValidationError

from globomap_api import exceptions as gmap_exc
from globomap_api.api.v2 import api
from globomap_api.api.v2 import facade
from globomap_api.api.v2.auth import permissions
from globomap_api.api.v2.auth.decorators import permission_classes
from globomap_api.api.v2.parsers import collections as coll_parsers
from globomap_api.api.v2.parsers.base import search_parser
from globomap_api.api.v2.util import get_dict
from globomap_api.api.v2.util import validate

ns = api.namespace(
    'collections', description='Operations related to collections')

specs = app.config['SPECS']


@ns.route('/')
@api.header(
    'Authorization',
    'Token Authorization',
    required=True,
    default='Token token='
)
class Collections(Resource):

    @api.doc(responses={
        200: 'Success',
示例#4
0
from flask import current_app as app
from flask import request
from flask_restplus import Resource
from jsonspec.validators.exceptions import ValidationError

from globomap_api import exceptions as gmap_exc
from globomap_api.api.v2 import api
from globomap_api.api.v2 import facade
from globomap_api.api.v2.auth import permissions
from globomap_api.api.v2.auth.decorators import permission_classes
from globomap_api.api.v2.parsers import queries as query_parsers
from globomap_api.api.v2.util import get_dict
from globomap_api.api.v2.util import validate

ns = api.namespace('queries', description='Operations related to queries')

specs = app.config['SPECS']


@ns.route('/')
@api.header('Authorization',
            'Token Authorization',
            required=True,
            default='Token token=')
class Query(Resource):
    @api.doc(responses={
        200: 'Success',
        401: 'Unauthorized',
        403: 'Forbidden',
    })
示例#5
0
from flask import current_app as app
from flask import request
from flask_restplus import Resource
from jsonspec.validators.exceptions import ValidationError

from globomap_api import exceptions as gmap_exc
from globomap_api.api.v2 import api
from globomap_api.api.v2 import facade
from globomap_api.api.v2.auth import permissions
from globomap_api.api.v2.auth.decorators import permission_classes
from globomap_api.api.v2.parsers import graphs as graphs_parsers
from globomap_api.api.v2.util import get_dict
from globomap_api.api.v2.util import validate
from globomap_api.config import SPECS

ns = api.namespace('graphs', description='Operations related to graphs')


@ns.route('/')
@api.header('Authorization',
            'Token Authorization',
            required=True,
            default='Token token=')
class Graph(Resource):
    @api.doc(responses={200: 'Success', 401: 'Unauthorized', 403: 'Forbidden'})
    @permission_classes((permissions.Read, permissions.Graph))
    def get(self):
        """List all graphs from DB."""

        graphs = facade.list_graphs()
        return graphs, 200
示例#6
0
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
"""
import flask
import six
from flask import current_app as app
from flask_restplus import Resource

from globomap_api.api.v2 import api
from globomap_api.api.v2 import facade
from globomap_api.api.v2.auth.facade import Auth
from globomap_api.models.db import DB

ns = api.namespace('healthcheck', description='Healthcheck')


def text(data, code, headers=None):
    return flask.make_response(six.text_type(data))


@ns.route('/')
class Healthcheck(Resource):
    representations = {
        'text/plain': text,
    }

    @api.doc(responses={
        200: 'Success',
        503: 'Service Unavailable',
示例#7
0
from flask import request
from flask_restplus import Resource
from jsonspec.validators.exceptions import ValidationError

from globomap_api import exceptions as gmap_exc
from globomap_api.api.v2 import api
from globomap_api.api.v2 import facade
from globomap_api.api.v2.auth import permissions
from globomap_api.api.v2.auth.decorators import permission_classes
from globomap_api.api.v2.parsers import edges as edges_parsers
from globomap_api.api.v2.parsers.base import search_parser
from globomap_api.api.v2.util import get_dict
from globomap_api.api.v2.util import validate
from globomap_api.config import SPECS

ns = api.namespace('edges', description='Operations related to edges')


@ns.route('/')
@api.header('Authorization',
            'Token Authorization',
            required=True,
            default='Token token=')
class Edges(Resource):
    @api.doc(responses={
        200: 'Success',
        401: 'Unauthorized',
        403: 'Forbidden',
    })
    @api.expect(search_parser)
    @permission_classes((permissions.Read, permissions.Edge))