Beispiel #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)
Beispiel #2
0
def _output_search_results(item_type: str, results: List[Dict]) -> None:
    """
    Output search results.

    :param results: list of found items

    """
    item_type_plural = item_type + "s"
    if len(results) == 0:
        click.echo("No {} found.".format(item_type_plural))  # pragma: no cover
    else:
        click.echo("{} found:\n".format(item_type_plural.title()))
        click.echo(format_items(results))
Beispiel #3
0
def agents(ctx: Context, query):
    """Search for Agents."""
    click.echo('Searching for "{}"...'.format(query))
    if ctx.config.get("is_local"):
        results = _search_items(ctx, "agents")
    else:
        results = request_api("GET", "/agents", params={"search": query})

    if not len(results):
        click.echo("No agents found.")  # pragma: no cover
    else:
        click.echo("Agents found:\n")
        click.echo(format_items(results))
Beispiel #4
0
 def testformat_items_positive(self):
     """Test format_items positive result."""
     items = [{
         "public_id": "author/name:version",
         "name": "obj-name",
         "description": "Some description",
         "author": "author",
         "version": "1.0",
     }]
     result = format_items(items)
     expected_result = ("------------------------------\n"
                        "Public ID: author/name:version\n"
                        "Name: obj-name\n"
                        "Description: Some description\n"
                        "Author: author\n"
                        "Version: 1.0\n"
                        "------------------------------\n")
     self.assertEqual(result, expected_result)
Beispiel #5
0
def _output_search_results(item_type: str, results: List[Dict], count: int,
                           page: int) -> None:
    """
    Output search results.

    :param item_type: str item type.
    :param results: list of found items.
    :param count: items total count.

    """
    item_type_plural = item_type + "s"
    len_results = len(results)
    if len_results == 0:
        click.echo("No {} found.".format(item_type_plural))  # pragma: no cover
    else:
        click.echo("{} found:\n".format(item_type_plural.title()))
        click.echo(format_items(results))
        if count > len_results:
            click.echo("{} {} out of {}.\nPage {}".format(
                len_results, item_type_plural, count,
                page))  # pragma: no cover
Beispiel #6
0
def protocols(ctx: Context):
    """List all the installed protocols."""
    result = _get_item_details(ctx, "protocol")
    print(format_items(sorted(result, key=lambda k: k["name"])))
Beispiel #7
0
def connections(ctx: Context):
    """List all the installed connections."""
    result = _get_item_details(ctx, "connection")
    print(format_items(sorted(result, key=lambda k: k["name"])))
Beispiel #8
0
def skills(ctx: Context):
    """List all the installed skills."""
    result = list_agent_items(ctx, "skill")
    click.echo(format_items(sorted(result, key=lambda k: k["name"])))
Beispiel #9
0
def protocols(ctx: Context):
    """List all the installed protocols."""
    result = list_agent_items(ctx, "protocol")
    click.echo(format_items(sort_items(result)))
Beispiel #10
0
def connections(ctx: Context):
    """List all the installed connections."""
    result = list_agent_items(ctx, "connection")
    click.echo(format_items(sort_items(result)))
Beispiel #11
0
def contracts(ctx: Context):
    """List all the installed protocols."""
    result = list_agent_items(ctx, CONTRACT)
    click.echo(format_items(sort_items(result)))
Beispiel #12
0
def protocols(ctx: Context) -> None:
    """List all the installed protocols."""
    result = list_agent_items(ctx, PROTOCOL)
    click.echo(format_items(sort_items(result)))
Beispiel #13
0
def connections(ctx: Context) -> None:
    """List all the installed connections."""
    result = list_agent_items(ctx, CONNECTION)
    click.echo(format_items(sort_items(result)))