Skip to content

Red Teaming API

api_delete_attack_module(am_id)

Deletes an attack module by its identifier.

This function takes an attack module ID as input and calls the delete method from the AttackModule class to remove the specified attack module from storage.

Parameters:

Name Type Description Default
am_id str

The unique identifier of the attack module to be deleted.

required

Returns:

Name Type Description
bool bool

True if the attack module was successfully deleted.

Raises:

Type Description
Exception

If the deletion process encounters an error.

Source code in moonshot/src/api/api_red_teaming.py
@validate_call
def api_delete_attack_module(am_id: str) -> bool:
    """
    Deletes an attack module by its identifier.

    This function takes an attack module ID as input and calls the delete method from the AttackModule class
    to remove the specified attack module from storage.

    Args:
        am_id (str): The unique identifier of the attack module to be deleted.

    Returns:
        bool: True if the attack module was successfully deleted.

    Raises:
        Exception: If the deletion process encounters an error.
    """
    return AttackModule.delete(am_id)

api_get_all_attack_module_metadata()

Retrieves metadata for all available attack modules.

This function calls the get_available_items method from the AttackModule class to retrieve all available attack modules metadata.

It then extracts the metadata for each attack module and returns a list of dictionaries, each containing the metadata of an attack module.

Returns:

Type Description
list[dict]

list[dict]: A list of dictionaries, each representing the metadata of an attack module.

Source code in moonshot/src/api/api_red_teaming.py
def api_get_all_attack_module_metadata() -> list[dict]:
    """
    Retrieves metadata for all available attack modules.

    This function calls the `get_available_items` method from the `AttackModule` class to retrieve all available
    attack modules metadata.

    It then extracts the metadata for each attack module and returns a list of dictionaries, each containing the
    metadata of an attack module.

    Returns:
        list[dict]: A list of dictionaries, each representing the metadata of an attack module.
    """
    _, attack_modules_metadata = AttackModule.get_available_items()
    return attack_modules_metadata

api_get_all_attack_modules()

Retrieves all available attack module IDs.

This function calls the get_available_items method from the AttackModule class to retrieve all available attack modules.

It then extracts the IDs of each attack module and returns a list of these IDs.

Returns:

Type Description
list[str]

list[str]: A list of strings, each representing an attack module ID.

Source code in moonshot/src/api/api_red_teaming.py
def api_get_all_attack_modules() -> list[str]:
    """
    Retrieves all available attack module IDs.

    This function calls the `get_available_items` method from the `AttackModule` class to retrieve all available
    attack modules.

    It then extracts the IDs of each attack module and returns a list of these IDs.

    Returns:
        list[str]: A list of strings, each representing an attack module ID.
    """
    attack_modules_ids, _ = AttackModule.get_available_items()
    return attack_modules_ids