当前位置: 首页>>代码示例>>Python>>正文


Python flask_restplus.Resource方法代码示例

本文整理汇总了Python中flask_restplus.Resource方法的典型用法代码示例。如果您正苦于以下问题:Python flask_restplus.Resource方法的具体用法?Python flask_restplus.Resource怎么用?Python flask_restplus.Resource使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask_restplus的用法示例。


在下文中一共展示了flask_restplus.Resource方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get

# 需要导入模块: import flask_restplus [as 别名]
# 或者: from flask_restplus import Resource [as 别名]
def get(self, term):
        """
        Returns list of matching concepts or entities using lexical search
        """
        args = simple_parser.parse_args()
        args['fq_string'] = copy.copy(args['fq'])
        args['fq'] = {}
        q = GolrSearchQuery(term, user_agent=USER_AGENT, **args)
        results = q.autocomplete()
        return results

#@ns.route('/entity/query/')
#class BooleanQuery(Resource):
#
#    @api.expect(adv_parser)
#    def get(self, search_term):
#        """
#        Returns list of matches based on 
#        """
#        args = parser.parse_args()
#
#        return [] 
开发者ID:biolink,项目名称:biolink-api,代码行数:24,代码来源:entitysearch.py

示例2: init

# 需要导入模块: import flask_restplus [as 别名]
# 或者: from flask_restplus import Resource [as 别名]
def init(api, _cors, impl):
    """Configures REST handlers for allocation resource."""

    namespace = webutils.namespace(
        api, __name__, 'Local nodeinfo redirect API.'
    )

    @namespace.route('/<hostname>/<path:path>')
    class _NodeRedirect(restplus.Resource):
        """Redirects to local nodeinfo endpoint."""

        def get(self, hostname, path):
            """Returns list of local instances."""
            hostport = impl.get(hostname)
            if not hostport:
                return 'Host not found.', http_client.NOT_FOUND

            url = utils.encode_uri_parts(path)
            return flask.redirect('http://%s/%s' % (hostport, url),
                                  code=http_client.FOUND) 
开发者ID:Morgan-Stanley,项目名称:treadmill,代码行数:22,代码来源:nodeinfo.py

示例3: init

# 需要导入模块: import flask_restplus [as 别名]
# 或者: from flask_restplus import Resource [as 别名]
def init(api, cors, impl):
    """Configures REST handlers for docker authz resource."""
    del cors
    namespace = api.namespace(
        _URL, description='Docker authz plugin activate call'
    )

    # only /Plugin.Activate allowd, /Plugin.Activate/ not allowed
    @namespace.route('')
    class _Activate(restplus.Resource):
        """Treadmill docker authz plugin activate resource"""

        def post(self):
            """Returns plugin name monitors."""
            status = http.client.OK
            return flask.Response(
                json.dumps(impl.activate()),
                status=status,
                mimetype='application/json'
            )

    # return URL explicitly because there is '.' in URL
    return _URL 
开发者ID:Morgan-Stanley,项目名称:treadmill,代码行数:25,代码来源:activate.py

示例4: setUp

# 需要导入模块: import flask_restplus [as 别名]
# 或者: from flask_restplus import Resource [as 别名]
def setUp(self):
        self.hello_world = HelloWorld(Resource)
        self.endpoints = Endpoints(Resource)
        self.model = Models(Resource)
        self.props = Props(Resource)
        self.model_menu = ModelMenu(Resource)
        self.run = RunModel(Resource)
        self.models = load_models(indra_dir) 
开发者ID:gcallah,项目名称:indras_net,代码行数:10,代码来源:test_api_endpoints.py

示例5: get

# 需要导入模块: import flask_restplus [as 别名]
# 或者: from flask_restplus import Resource [as 别名]
def get(self):
        dbm = access.DBMan(LOST_CONFIG)
        identity = get_jwt_identity()
        user = dbm.get_user_by_id(identity)
        if not user.has_role(roles.ANNOTATOR):
            dbm.close_session()
            return "You need to be {} in order to perform this request.".format(roles.ANNOTATOR), 401

        else:
            re = sia.finish(dbm, identity)
            dbm.close_session()
            return re

# @namespace.route('/junk/<int:img_id>')
# @namespace.param('img_id', 'The id of the image which should be junked.')
# class Junk(Resource):
#     @jwt_required 
#     def post(self,img_id):
#         dbm = access.DBMan(LOST_CONFIG)
#         identity = get_jwt_identity()
#         user = dbm.get_user_by_id(identity)
#         if not user.has_role(roles.ANNOTATOR):
#             dbm.close_session()
#             return "You need to be {} in order to perform this request.".format(roles.ANNOTATOR), 401

#         else:
#             re = sia.get_prev(dbm, identity,img_id)
#             dbm.close_session()
#             return re 
开发者ID:l3p-cv,项目名称:lost,代码行数:31,代码来源:endpoint.py

示例6: validate_resource

# 需要导入模块: import flask_restplus [as 别名]
# 或者: from flask_restplus import Resource [as 别名]
def validate_resource(resource):
    '''Resource is a table name with schema and column name combined as
    follow : schema.table.column
    '''
    if resource.count('.') != 2:
        api.abort(404, "resource must be in the form schema.table.column")

    table = resource[:resource.rfind('.')]
    column = resource.split('.')[-1]
    return table, column 
开发者ID:Oslandia,项目名称:lopocs,代码行数:12,代码来源:app.py

示例7: get

# 需要导入模块: import flask_restplus [as 别名]
# 或者: from flask_restplus import Resource [as 别名]
def get(self, id):
        """
        Returns graph of an ontology term
        """

        args = graph_params.parse_args()
        graph_type = args['graph_type'] + "_json" # GOLR field names

        data = run_solr_on(ESOLR.GOLR, ESOLRDoc.ONTOLOGY, id, graph_type)
        # step required as these graphs are stringified in the json
        data[graph_type] = json.loads(data[graph_type]) 
        
        return data

# @ns.route('/term/<id>/ancestor')
# class OntologyTermAncestor(Resource):

#     def get(self, id):
#         """
#         Returns ancestors of an ontology term
#         """
#         return None

# @ns.route('/term/<id>/descendant')
# class OntologyTermDescendant(Resource):

#     def get(self, id):
#         """
#         Returns descendants of an ontology term
#         """

#         ont = get_ontology("go")
#         print("ONT: ", ont)
#         print("GRAPH: ", ont.get_graph())

#         return None 
开发者ID:biolink,项目名称:biolink-api,代码行数:38,代码来源:ontology_endpoint.py

示例8: init

# 需要导入模块: import flask_restplus [as 别名]
# 或者: from flask_restplus import Resource [as 别名]
def init(api, cors, impl):
    """Configures REST handlers for state resource."""
    namespace = webutils.namespace(
        api, __name__, 'Trace REST operations'
    )

    model = {
        'name': fields.String(description='Application name'),
        'instances': fields.List(
            fields.String(description='Instance IDs')
        ),
    }
    trace_model = api.model(
        'Trace', model
    )

    @namespace.route('/<app_name>')
    @api.doc(params={'app_name': 'Application name'})
    class _TraceAppResource(restplus.Resource):
        """Treadmill application trace information resource.
        """

        @webutils.get_api(api, cors,
                          marshal=api.marshal_with,
                          resp_model=trace_model)
        def get(self, app_name):
            """Return trace information of a Treadmill application.
            """
            trace_info = impl.get(app_name)
            if trace_info is None:
                raise exc.NotFoundError(
                    'No trace information available for {}'.format(app_name)
                )
            return trace_info 
开发者ID:Morgan-Stanley,项目名称:treadmill,代码行数:36,代码来源:trace.py

示例9: init

# 需要导入模块: import flask_restplus [as 别名]
# 或者: from flask_restplus import Resource [as 别名]
def init(api, _cors, impl):
    """Configures REST handlers for keytab resource."""

    namespace = webutils.namespace(
        api, __name__, 'Keytab Locker REST operations'
    )

    @namespace.route('/')
    class _KeytabList(restplus.Resource):
        """Treadmill Keytab list resource"""

        def get(self):
            """Returns list of available keytabs."""
            return impl.list() 
开发者ID:Morgan-Stanley,项目名称:treadmill,代码行数:16,代码来源:keytab_locker.py

示例10: register_authz_resource

# 需要导入模块: import flask_restplus [as 别名]
# 或者: from flask_restplus import Resource [as 别名]
def register_authz_resource(resource, api, description):
    """Register a resource for authz namespace.

    :param resource: sub-class inherited from AuthzAPIBase.

    :param api: reserved parameter for `restplus.Resource`.
    :param description: reserved parameter for `restplus.Resource`.
    """
    namespace = webutils.namespace(api, '', description)
    namespace.add_resource(resource, _ROUTE) 
开发者ID:Morgan-Stanley,项目名称:treadmill,代码行数:12,代码来源:authz_base.py

示例11: __init__

# 需要导入模块: import flask_restplus [as 别名]
# 或者: from flask_restplus import Resource [as 别名]
def __init__(self, impl, api, *args, **kwargs):
        """
        :param impl: custom authorizer which should implement a function with
                     signature `authorize(user, action, resource, payload)`.

        :param api: reserved parameter for `restplus.Resource`.
        """
        super(AuthzAPIBase, self).__init__(api, *args, **kwargs)
        self.impl = impl 
开发者ID:Morgan-Stanley,项目名称:treadmill,代码行数:11,代码来源:authz_base.py

示例12: init

# 需要导入模块: import flask_restplus [as 别名]
# 或者: from flask_restplus import Resource [as 别名]
def init(api, cors, impl):
    """Configures REST handlers for docker authz resource."""
    del cors

    namespace = api.namespace(
        _URL, description='Docker authz plugin authz response call'
    )

    # authz plugin does not accept tailing '/'
    @namespace.route('')
    class _Authz(restplus.Resource):
        """Treadmill App monitor resource"""

        def post(self):
            """Returns list of configured app monitors."""
            status = http.client.OK
            payload = flask.request.get_json(force=True)

            (allow, msg) = impl.authzres(payload)

            return flask.Response(
                json.dumps({'allow': allow, 'msg': msg}),
                status=status,
                mimetype='application/json'
            )

    # return URL explicitly because there is '.' in URL
    return _URL 
开发者ID:Morgan-Stanley,项目名称:treadmill,代码行数:30,代码来源:authzres.py

示例13: init

# 需要导入模块: import flask_restplus [as 别名]
# 或者: from flask_restplus import Resource [as 别名]
def init(api, cors, impl):
    """Configures REST handlers for docker authz resource."""
    del cors
    namespace = api.namespace(
        _URL, description='Docker authz plugin authz request call'
    )

    # authz plugin does not accept tailing '/'
    @namespace.route('')
    class _Authz(restplus.Resource):
        """Treadmill App monitor resource"""

        def post(self):
            """Returns list of configured app monitors."""
            status = http.client.OK
            payload = flask.request.get_json(force=True)

            (allow, msg) = impl.authzreq(payload)

            return flask.Response(
                json.dumps({'Allow': allow, 'Msg': msg}),
                status=status,
                mimetype='application/json'
            )

    # return URL explicitly because there is '.' in URL
    return _URL 
开发者ID:Morgan-Stanley,项目名称:treadmill,代码行数:29,代码来源:authzreq.py

示例14: setUp

# 需要导入模块: import flask_restplus [as 别名]
# 或者: from flask_restplus import Resource [as 别名]
def setUp(self):
        """Initialize the app with the corresponding limit logic."""
        blueprint = flask.Blueprint('v1', __name__)
        self.api = restplus.Api(blueprint)

        self.app = flask.Flask(__name__)
        self.app.testing = True
        self.app.register_blueprint(blueprint)

        na = self.api.namespace(
            'na', description='Request Rate Control REST API Test',
        )

        @na.route('/foo')
        class _Foo(restplus.Resource):
            """Request rate control resource example"""

            def get(self):
                """Get resource implement"""
                return ''

        @na.route('/bar')
        class _Bar(restplus.Resource):
            """Request rate control resource example"""

            def get(self):
                """Get resource implement"""
                return ''

        nb = self.api.namespace(
            'nb', description='Request Rate Control REST API Test',
        )

        @nb.route('/baz')
        class _Baz(restplus.Resource):
            """Request rate control resource example"""

            def get(self):
                """Get resource implement"""
                return '' 
开发者ID:Morgan-Stanley,项目名称:treadmill,代码行数:42,代码来源:limit_test.py

示例15: get

# 需要导入模块: import flask_restplus [as 别名]
# 或者: from flask_restplus import Resource [as 别名]
def get(self):
        """
        Returns compact associations for a given input set
        """
        args = parser.parse_args()

        M=GolrFields()
        subjects = args.get('subject')
        del args['subject']
        results = search_associations(
            subjects=subjects,
            select_fields=[M.SUBJECT, M.RELATION, M.OBJECT],
            use_compact_associations=True,
            rows=MAX_ROWS,
            facet_fields=[],
            user_agent=USER_AGENT,
            **args
        )
        return results

#@ns.route('/DEPRECATEDhomologs/')
#class EntitySetHomologsDEPRECATED(Resource):
#
#    @api.expect(parser)
#    @api.marshal_list_with(association_results)
#    #@api.marshal_list_with(compact_association_set)
#    def get(self):
#        """
#        Returns homology associations for a given input set of genes
#        """
#        args = parser.parse_args()
#
#        M=GolrFields()
#        rel = 'RO:0002434'  # TODO; allow other types
#        results = search_associations(subjects=args.get('subject'),
#                                      select_fields=[M.SUBJECT, M.RELATION, M.OBJECT],
#                                      use_compact_associations=True,
#                                      relation=rel,
#                                      rows=MAX_ROWS,
#                                      facet_fields=[],
#                                      **args)
#        return results 
开发者ID:biolink,项目名称:biolink-api,代码行数:44,代码来源:summary.py


注:本文中的flask_restplus.Resource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。