本文整理汇总了Python中flask_restx.Namespace方法的典型用法代码示例。如果您正苦于以下问题:Python flask_restx.Namespace方法的具体用法?Python flask_restx.Namespace怎么用?Python flask_restx.Namespace使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flask_restx
的用法示例。
在下文中一共展示了flask_restx.Namespace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: initialize
# 需要导入模块: import flask_restx [as 别名]
# 或者: from flask_restx import Namespace [as 别名]
def initialize(graph):
api = Namespace('ingestor', description='Ingestor API')
event_dispatcher = linker.EventDispatcher()
graph.add_listener(event_dispatcher)
ingestor_registry = IngestorRegistry(api, graph, event_dispatcher)
ingestor_modules = []
if CONFIG.ingestors.prometheus.enabled:
ingestor_modules.append(alerts.prometheus)
if CONFIG.ingestors.falco.enabled:
ingestor_modules.append(alerts.falco)
if CONFIG.ingestors.elastalert.enabled:
ingestor_modules.append(alerts.elastalert)
for ingestor_module in ingestor_modules:
for ingestor_bundle in ingestor_module.get_ingestors():
ingestor_registry.register(ingestor_bundle)
return api
示例2: initialize
# 需要导入模块: import flask_restx [as 别名]
# 或者: from flask_restx import Namespace [as 别名]
def initialize(graph):
api = Namespace('graph', description='Graph API')
api.add_resource(Graph, '/', resource_class_args=[graph])
return api
示例3: namespace_test
# 需要导入模块: import flask_restx [as 别名]
# 或者: from flask_restx import Namespace [as 别名]
def namespace_test(args):
"""
Generate a new Flask-RESTplus API Namespace
"""
CONTENTS = f"""import pytest
from app.test.fixtures import app, client
from .{args.output_name} import {args.output_name.title()}, {args.output_name.title()}Schema
@pytest.fixture
def schema():
return {args.output_name.title()}Schema()
def test_schema_valid(schema): # noqa
assert schema
def test_post(app, client, schema): # noqa
with client:
obj = {args.output_name.title()}(id=42)
resp = client.post('{args.output_name}/', json=schema.dump(obj).data)
rv = schema.load(resp.json).data
assert obj.id == rv.id
def test_get(app, client, schema): # noqa
with client:
resp = client.get('{args.output_name}/?id=42')
rv = schema.load(resp.json).data
assert rv
assert rv.id == 42
"""
print(args)
_generate(
CONTENTS,
output_name=args.output_name
and args.output_name.replace(".py", "") + "_test.py",
filename=args.output_file and args.output_file.replace(".py", "") + "_test.py",
dry_run=args.dry_run,
)