Python flask_restx.Namespace() Examples
The following are 3
code examples of flask_restx.Namespace().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
flask_restx
, or try the search function
.
Example #1
Source File: ingestor.py From orca with Apache License 2.0 | 6 votes |
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
Example #2
Source File: graph.py From orca with Apache License 2.0 | 5 votes |
def initialize(graph): api = Namespace('graph', description='Graph API') api.add_resource(Graph, '/', resource_class_args=[graph]) return api
Example #3
Source File: generate.py From flaskerize with BSD 3-Clause "New" or "Revised" License | 4 votes |
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, )