Developer Documentation

Development for the toolbelt is aimed to be accessible for everyone! This set of articles contains documentation on how to develop new commands for the toolbelt using argus-cli and argus-api.

Getting started

Use the following links to get more extensive help on developing for the toolbelt!

Example command

The following is a simple command for printing case-numbers when searching a case :

from argus_cli.plugin import register_command, run  # Function for registering a command to the cli
from argus_cli.utils import formatting  # Common helper for creating nice outputs
from argus_api.api.cases.v2.case import advanced_case_search  # The case search endpoint

from argus_plugins import argus_cli_module
from argus_plugins.cases.utils import get_customer_id


# Register the command
@register_command(module=argus_cli_module)
# The command with arguments for title and customer (which automatically translates a customer name to it's ID)
def search(title: str, customer: get_customer_id):
    """Search for a case

    :param title: Title to search for
    :param customer: Customer to base the search on
    """
    # Get cases based on a customer and keyword
    cases = advanced_case_search(
        customerID=[customer],
        keywords = [title]
    )["data"]  # We only care about the data the endpoint returned. Not the metadata about the response.

    # Prints the ID and subject in CSV format
    print(formatting.csv(cases, headers=["id", "subject"]))

# Allow for running by simply executing the file
if __name__ == "__main__":
    run(search)
Usage
./my_command.py Email mnemonic
Result
id,subject
23,Suspect Email
42,Weird Email
Usage
./my_command.py --help
Result
 usage: my_command.py [-h] [--apikey APIKEY] [--debug]
                           [--environment ENVIRONMENT]
                           title customer

 positional arguments:
   title                 Title to search for
   customer              Customer to base the search on

 optional arguments:
   -h, --help            show this help message and exit
   --apikey APIKEY
   --debug
   --environment ENVIRONMENT