# Path: virtool/types.py



from typing import Any, Dict
from virtool.types import Document
import virtool.users.utils
import virtool.utils

    """
    return await db.users.find_one(user_id, PROJECTION)


async def get_alternate_id(db, name: str) -> str:
    """
    Get an alternate id for an API key whose provided `name` is not unique. Appends an
    integer suffix to the end of the `name`.

    :param db: the application database object
    :param name: the API key name
    :return: an alternate unique id for the key

    """
    existing_alt_ids = await db.keys.distinct("id")

    suffix = 0

    while True:
        candidate = f"{name.lower()}_{suffix}"

        if candidate not in existing_alt_ids:
            return candidate

        suffix += 1


async def create_api_key(
    db, name: str, permissions: Dict[str, bool], user_id: str

# Path: virtool/types.py



# Path: virtool/account/db.py
from typing import Any, Dict
from virtool.types import Document
import virtool.users.utils
import virtool.utils


    """
    return await db.users.find_one(user_id, PROJECTION)


async def get_alternate_id(db, name: str) -> str:
    """
    Get an alternate id for an API key whose provided `name` is not unique. Appends an
    integer suffix to the end of the `name`.

    :param db: the application database object
    :param name: the API key name
    :return: an alternate unique id for the key

    """
    existing_alt_ids = await db.keys.distinct("id")

    suffix = 0

    while True:
        candidate = f"{name.lower()}_{suffix}"

        if candidate not in existing_alt_ids:
            return candidate

        suffix += 1


async def create_api_key(
    db, name: str, permissions: Dict[str, bool], user_id: str

) -> Document: