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)
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)
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)
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)
def protocols(ctx: Context): """List all the installed protocols.""" result = list_agent_items(ctx, "protocol") click.echo(format_items(sort_items(result)))
def connections(ctx: Context): """List all the installed connections.""" result = list_agent_items(ctx, "connection") click.echo(format_items(sort_items(result)))
def contracts(ctx: Context): """List all the installed protocols.""" result = list_agent_items(ctx, CONTRACT) click.echo(format_items(sort_items(result)))
def protocols(ctx: Context) -> None: """List all the installed protocols.""" result = list_agent_items(ctx, PROTOCOL) click.echo(format_items(sort_items(result)))
def connections(ctx: Context) -> None: """List all the installed connections.""" result = list_agent_items(ctx, CONNECTION) click.echo(format_items(sort_items(result)))