本文整理汇总了Python中flask_restplus.Namespace.inherit方法的典型用法代码示例。如果您正苦于以下问题:Python Namespace.inherit方法的具体用法?Python Namespace.inherit怎么用?Python Namespace.inherit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask_restplus.Namespace
的用法示例。
在下文中一共展示了Namespace.inherit方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_inherit
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import inherit [as 别名]
def test_inherit(self):
api = Namespace('test')
parent = api.model('Parent', {})
api.inherit('Child', parent, {})
self.assertIn('Parent', api.models)
self.assertIn('Child', api.models)
示例2: test_inherit
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import inherit [as 别名]
def test_inherit(self):
api = Namespace('test')
parent = api.model('Parent', {})
api.inherit('Child', parent, {})
assert 'Parent' in api.models
assert 'Child' in api.models
示例3: test_inherit_from_multiple_parents
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import inherit [as 别名]
def test_inherit_from_multiple_parents(self):
api = Namespace('test')
grand_parent = api.model('GrandParent', {})
parent = api.model('Parent', {})
api.inherit('Child', grand_parent, parent, {})
assert 'GrandParent' in api.models
assert 'Parent' in api.models
assert 'Child' in api.models
示例4: test_inherit
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import inherit [as 别名]
def test_inherit(self):
authorizations = {
'apikey': {
'type': 'apiKey',
'in': 'header',
'name': 'X-API-KEY'
}
}
api = Namespace('test', authorizations=authorizations)
parent = api.model('Parent', {})
api.inherit('Child', parent, {})
assert 'Parent' in api.models
assert 'Child' in api.models
assert api.authorizations == authorizations
示例5: Namespace
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import inherit [as 别名]
namespace = Namespace(WORKSPACES, description="Workspace Resources")
logger = logging.getLogger(__name__)
rep = namespace.model("Repository", {
'name': fields.String(required=True, description='The Repository Name'),
'url': fields.Url(required=True, description='The Repository URL')
})
ws = namespace.model("Workspace", {
'name': fields.String(required=True, description='The Workspace Name'),
"catalogues": fields.List(fields.Nested(rep)),
"platforms": fields.List(fields.Nested(rep))
})
ws_response = namespace.inherit("WorkspaceResponse", ws, {
"path": fields.String(description='The Physical Workspace location'),
"id": fields.Integer(description='The Workspace ID')
})
descriptor_content = namespace.model("Descriptor Content", {})
descriptor = namespace.model("Descriptor", {
"id": fields.Integer(description="The descriptor id"),
"descriptor": fields.Nested(descriptor_content)
})
@namespace.route('/')
class Workspaces(Resource):
"""Methods for the workspace resource directory"""
@namespace.response(200, "OK", [ws_response])
示例6:
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import inherit [as 别名]
'name': fields.String(required=True, description='The VNF Name'),
'vendor': fields.String(required=True, description='The VNF Vendor'),
'version': fields.String(required=True, description='The VNF Version')
})
serv = namespace.model("Service", {
'name': fields.String(required=True, description='The Service Name'),
'vendor': fields.String(required=True, description='The Service Vendor'),
'version': fields.String(required=True, description='The Service Version')
})
func_response = namespace.inherit("Response", 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'),
})
serv_response = namespace.inherit("Response", 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 project id'),
})
@namespace.route('/' + SERVICES + vendor_name_version_path)
@namespace.param('ws_id', 'The Workspace identifier')
@namespace.param('project_id', 'The Project identifier')
@namespace.param('vendor', 'The Network Service vendor')
@namespace.param('name', 'The Network Service name')
示例7: Namespace
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import inherit [as 别名]
from flask_restplus import fields
from son_editor.impl import projectsimpl
from son_editor.util.constants import WORKSPACES, PROJECTS
from son_editor.util.requestutil import prepare_response, get_json
namespace = Namespace(WORKSPACES + '/<int:ws_id>/' + PROJECTS, description="Project Resources")
logger = logging.getLogger(__name__)
pj = namespace.model("Project", {
'name': fields.String(required=True, description='The Project Name')
})
pj_response = namespace.inherit("ProjectResponse", pj, {
"rel_path": fields.String(description='The Projects location relative to its workpace'),
"id": fields.Integer(description='The Project ID'),
"workspace_id": fields.Integer(description='The parent workspace id')
})
@namespace.route('/')
class Projects(Resource):
@namespace.response(200, "OK", [pj_response])
def get(self, ws_id):
"""Lists projects
Lists projects in the given workspace"""
projects = projectsimpl.get_projects(ws_id)
return prepare_response(projects)
@namespace.expect(pj)
示例8:
# 需要导入模块: from flask_restplus import Namespace [as 别名]
# 或者: from flask_restplus.Namespace import inherit [as 别名]
'compression_enabled': fields.Boolean(),
'inline_compression': fields.Boolean(),
'caching_policy': fields.String(),
})
volume_create_model = api.inherit('VolumeCreate', volume_write_model, {
'name': fields.String(
min_length=1,
description="The internal name of the volume",
example="volume_name",
),
'size_total': fields.Integer(
description=("The total size of the volume, "
" in bytes. If creating, the size"
" of the volume.")
),
'aggregate_name': fields.String(
min_length=1, required=False,
description=("If applicable, the"
" aggregate to place the volume in"
" (NetApp only). If not provided, will"
" use the one with the most free"
" space.")
),
'junction_path': fields.String(min_length=1),
})
volume_read_model = api.inherit('VolumeRead', volume_create_model, {
'size_used': fields.Integer(),
'uuid': fields.String(min_length=1),
'state': fields.String(min_length=1),