def run(ctx, handler, event, config, secrets, pretty): """Run an nFlex module locally. The command will try to find a "main.py" file in the current working directory and execute the HANDLER, passing EVENT as a parameter and attaching the CONFIG to the context parameter of the HANDLER. EVENT and CONFIG must be valid JSON dictionaries HANDLER must be the handler name, i.e. "get_resources", "test_method", etc. Any output of the script will be printed on stderr and the return value of the HANDLER will be printed as JSON on stdout. """ if pretty: click.echo("warn: --pretty is deprecated", err=True) result = flexer.commands.run(handler, event, config, secrets, ctx.cmp) print_result(result)
def execute(ctx, module_id, handler, event, is_async, pretty): """Run an nFlex module remotely. Call the CMP API to trigger a module execution remotely. EVENT must be a valid JSON dictionary. HANDLER must be the handler name, i.e. "get_resources", "test_method", etc. The value of the module execution will be printed as JSON on stdout. """ if pretty: click.echo("warn: --pretty is deprecated", err=True) try: result = ctx.nflex.execute(module_id, handler, is_async, event) except requests.exceptions.RequestException as err: raise click.ClickException("Failed to execute nFlex module: %s" % err) print_result(result)
Call the CMP API to trigger a module execution remotely. EVENT must be a valid JSON dictionary. HANDLER must be the handler name, i.e. "get_resources", "test_method", etc. The value of the module execution will be printed as JSON on stdout. """ if pretty: click.echo("warn: --pretty is deprecated", err=True) try: result = ctx.nflex.execute(module_id, handler, async, event) except requests.exceptions.RequestException as err: raise click.ClickException("Failed to execute nFlex module: %s" % err) print_result(result) @cli.command() @click.option('-e', '--exclude', multiple=True, type=click.Path(resolve_path=False), help="Exclude directory from the build") @click.option('-z', '--zip', metavar="ZIP", default="/tmp/module.zip", type=click.Path(resolve_path=True), help="Output zip file name") @click.argument('directory',
def run(ctx, handler, event, pretty): """Run an nFlex module locally.""" result = flexer.commands.run(handler, event, ctx.cmp) print_result(result, pretty)