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


Python Namespace.add_model方法代码示例

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


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

示例1: Model

# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import add_model [as 别名]
uid = Model("VNF_UID", {
    'id': fields.String(required=True, description='The VNF UID')
})

funct_response = funct.inherit("FunctionResponse", funct, {
    "descriptor": fields.Nested(model=funct, description="The Complete VNF Descriptor"),
    "id": fields.Integer(description='The Project ID'),
    "project_id": fields.Integer(description='The parent project id'),
})

message_response = proj_namespace.model("Message", {
    'message': fields.String(required=True, description="The result message")
})

proj_namespace.add_model(funct.name, funct)
proj_namespace.add_model(funct_response.name, funct_response)


@proj_namespace.route('/')
@cata_namespace.route('/')
@plat_namespace.route('/')
@proj_namespace.param('ws_id', 'The Workspace identifier')
@cata_namespace.param('ws_id', 'The Workspace identifier')
@plat_namespace.param('ws_id', 'The Workspace identifier')
@proj_namespace.param('parent_id', 'The Project identifier')
@cata_namespace.param('parent_id', 'The Catalogue identifier')
@plat_namespace.param('parent_id', 'The Platform identifier')
class Functions(Resource):
    """Resource methods for all function descriptors of this directory"""
开发者ID:Jmanuel4SandMan,项目名称:upb-son-editor-backend,代码行数:31,代码来源:functionsapi.py

示例2: Model

# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import add_model [as 别名]
uid = Model("VNF_UID", {
    'id': fields.String(required=True, description='The VNF UID')
})

funct_response = funct.inherit("FunctionResponse", funct, {
    "descriptor": fields.Nested(model=funct, description="The Complete VNF Descriptor"),
    "id": fields.Integer(description='The Project ID'),
    "project_id": fields.Integer(description='The parent project id'),
})

message_response = namespace.model("Message", {
    'message': fields.String(required=True, description="The result message")
})

namespace.add_model(funct.name, funct)
namespace.add_model(funct_response.name, funct_response)


@namespace.route('/')
@namespace.param('ws_id', 'The Workspace identifier')
@namespace.param('project_id', 'The Project identifier')
class Functions(Resource):
    """Resource methods for all function descriptors of this directory"""

    @namespace.response(200, "OK", [funct_response])
    def get(self, ws_id, project_id):
        """List all functions

        Lists all available functions in the given project or catalogue."""
        functions = functionsimpl.get_functions(ws_id, project_id)
开发者ID:CN-UPB,项目名称:upb-son-editor-backend,代码行数:32,代码来源:project_functionsapi.py

示例3: Model

# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import add_model [as 别名]
serv_id = Model("Service ID", {
    'id': fields.Integer(required=True, description='The son-editor id of the service being published')
})

serv_response = serv.inherit("ServiceResponse", serv, {
    "descriptor": fields.Nested(model=serv, description="The Complete Service Descriptor"),
    "id": fields.Integer(description='The Project ID'),
    "project_id": fields.Integer(description='The parent workspace id'),
})

message_response = proj_namespace.model("Message", {
    'message': fields.String(required=True, description="The result message")
})

proj_namespace.add_model(serv_update.name, serv_update)
proj_namespace.add_model(serv.name, serv)
proj_namespace.add_model(serv_response.name, serv_response)


@proj_namespace.route('/')
@cata_namespace.route('/')
@plat_namespace.route('/')
@proj_namespace.param('ws_id', 'The Workspace identifier')
@cata_namespace.param('ws_id', 'The Workspace identifier')
@plat_namespace.param('ws_id', 'The Workspace identifier')
@proj_namespace.param('parent_id', 'The Project identifier')
@cata_namespace.param('parent_id', 'The Catalogue identifier')
@plat_namespace.param('parent_id', 'The Platform identifier')
@proj_namespace.response(200, "OK")
class Services(Resource):
开发者ID:Jmanuel4SandMan,项目名称:upb-son-editor-backend,代码行数:32,代码来源:servicesapi.py

示例4: Namespace

# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import add_model [as 别名]
@author: Jonas
"""
from flask_restplus import Resource, Namespace, Model, fields
from flask.globals import request
from son_editor.util.requestutil import get_json
from son_editor.impl import platformsimpl, platform_connector
from son_editor.util.constants import WORKSPACES, PLATFORMS, SERVICES
from son_editor.util.requestutil import prepare_response

namespace = Namespace(WORKSPACES + '/<int:ws_id>/' + PLATFORMS, description="Platform Resources")

serv_id = Model("Service ID", {
    'id': fields.Integer(required=True, description='The son-editor id of the service being published')
})

namespace.add_model(serv_id.name, serv_id)


@namespace.route("/")
@namespace.response(200, "OK")
class Platforms(Resource):
    """Platforms"""

    def get(self, ws_id):
        """List platforms

        Lists all service platforms in the given workspace"""
        return prepare_response(platformsimpl.get_platforms(ws_id))

    @namespace.doc("")
    def post(self, ws_id):
开发者ID:CN-UPB,项目名称:upb-son-editor-backend,代码行数:33,代码来源:platformsapi.py


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