Esempio n. 1
0
def all_command(ctx: Context):
    """List all the installed packages."""
    for item_type in ITEM_TYPES:
        details = list_agent_items(ctx, item_type)
        if not details:
            continue
        output = "{}:\n{}".format(item_type.title() + "s",
                                  format_items(sort_items(details)))
        click.echo(output)
Esempio n. 2
0
def get_registered_items(item_type: str):
    """Create a new AEA project."""
    # need to place ourselves one directory down so the cher can find the packages
    ctx = Context(cwd=app_context.agents_dir)
    try:
        cli_setup_search_ctx(ctx, local=app_context.local)
        result, _ = cli_search_items(ctx, item_type, query="", page=1)
    except ClickException:
        return {"detail": "Failed to search items."}, 400  # 400 Bad request
    else:
        sorted_items = sort_items(result)
        return sorted_items, 200  # 200 (Success)
Esempio n. 3
0
def get_local_items(agent_id: str, item_type: str):
    """Return a list of protocols, skills or connections supported by a local agent."""
    if agent_id == "NONE":
        return [], 200  # 200 (Success)

    # need to place ourselves one directory down so the searcher can find the packages
    ctx = Context(cwd=os.path.join(app_context.agents_dir, agent_id))
    try:
        try_to_load_agent_config(ctx)
        result = cli_list_agent_items(ctx, item_type)
    except ClickException:
        return {
            "detail": "Failed to list agent items."
        }, 400  # 400 Bad request
    else:
        sorted_items = sort_items(result)
        return sorted_items, 200  # 200 (Success)
Esempio n. 4
0
def search_registered_items(item_type: str, search_term: str):
    """Create a new AEA project."""
    # need to place ourselves one directory down so the searcher can find the packages
    ctx = Context(cwd=app_context.agents_dir)
    try:
        cli_setup_search_ctx(ctx, local=app_context.local)
        result = cli_search_items(ctx, item_type, query=search_term)
    except ClickException:
        return {"detail": "Failed to search items."}, 400  # 400 Bad request
    else:
        sorted_items = sort_items(result)
        response = {
            "search_result": sorted_items,
            "item_type": item_type,
            "search_term": search_term,
        }
        return response, 200  # 200 (Success)
Esempio n. 5
0
def protocols(ctx: Context):
    """List all the installed protocols."""
    result = list_agent_items(ctx, "protocol")
    click.echo(format_items(sort_items(result)))
Esempio n. 6
0
def connections(ctx: Context):
    """List all the installed connections."""
    result = list_agent_items(ctx, "connection")
    click.echo(format_items(sort_items(result)))
Esempio n. 7
0
def contracts(ctx: Context):
    """List all the installed protocols."""
    result = list_agent_items(ctx, CONTRACT)
    click.echo(format_items(sort_items(result)))
Esempio n. 8
0
def protocols(ctx: Context) -> None:
    """List all the installed protocols."""
    result = list_agent_items(ctx, PROTOCOL)
    click.echo(format_items(sort_items(result)))
Esempio n. 9
0
def connections(ctx: Context) -> None:
    """List all the installed connections."""
    result = list_agent_items(ctx, CONNECTION)
    click.echo(format_items(sort_items(result)))