Skip to content

Result API

api_delete_result(res_id)

Deletes a result by its identifier.

This function takes a result ID as input and calls the delete method from the Result class to remove the specified result from storage.

Parameters:

Name Type Description Default
res_id str

The unique identifier of the result to be deleted.

required

Returns:

Name Type Description
bool bool

True if the result was successfully deleted.

Raises:

Type Description
Exception

If the deletion process encounters an error.

Source code in moonshot/src/api/api_result.py
@validate_call
def api_delete_result(res_id: str) -> bool:
    """
    Deletes a result by its identifier.

    This function takes a result ID as input and calls the delete method from the Result class
    to remove the specified result from storage.

    Args:
        res_id (str): The unique identifier of the result to be deleted.

    Returns:
        bool: True if the result was successfully deleted.

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

api_get_all_result()

This function retrieves all available results and returns them as a list of dictionaries. Each dictionary represents a result and contains its information.

Returns:

Type Description
list[dict]

list[dict]: A list of dictionaries, each representing a result.

Source code in moonshot/src/api/api_result.py
def api_get_all_result() -> list[dict]:
    """
    This function retrieves all available results and returns them as a list of dictionaries. Each dictionary
    represents a result and contains its information.

    Returns:
        list[dict]: A list of dictionaries, each representing a result.
    """
    _, results = Result.get_available_items()
    return [result for result in results]

api_get_all_result_name()

This function retrieves all available result names and returns them as a list.

Returns:

Type Description
list[str]

list[str]: A list of result names.

Source code in moonshot/src/api/api_result.py
def api_get_all_result_name() -> list[str]:
    """
    This function retrieves all available result names and returns them as a list.

    Returns:
        list[str]: A list of result names.
    """
    results_name, _ = Result.get_available_items()
    return results_name

api_read_result(res_id)

Reads a result and returns its information.

This function takes a result ID as input, reads the corresponding database file from the storage manager, and returns a dictionary containing the result's information.

Parameters:

Name Type Description Default
res_id str

The ID of the result.

required

Returns:

Name Type Description
dict dict

A dictionary containing the result's information.

Source code in moonshot/src/api/api_result.py
@validate_call
def api_read_result(res_id: str) -> dict:
    """
    Reads a result and returns its information.

    This function takes a result ID as input, reads the corresponding database file from the storage manager,
    and returns a dictionary containing the result's information.

    Args:
        res_id (str): The ID of the result.

    Returns:
        dict: A dictionary containing the result's information.
    """
    return Result.read(res_id)

api_read_results(res_ids)

Reads multiple results and returns their information.

This function takes a list of result IDs as input, reads the corresponding database files from the storage manager, and returns a list of dictionaries, each containing a result's information.

Parameters:

Name Type Description Default
res_ids conlist(str, min_length=1

A list of result IDs.

required

Returns:

Type Description
list[dict]

list[dict]: A list of dictionaries, each containing a result's information.

Source code in moonshot/src/api/api_result.py
@validate_call
def api_read_results(res_ids: conlist(str, min_length=1)) -> list[dict]:
    """
    Reads multiple results and returns their information.

    This function takes a list of result IDs as input, reads the corresponding database files from the storage manager,
    and returns a list of dictionaries, each containing a result's information.

    Args:
        res_ids (conlist(str, min_length=1)): A list of result IDs.

    Returns:
        list[dict]: A list of dictionaries, each containing a result's information.
    """

    return [Result.read(res_id) for res_id in res_ids]