"""Subaccount logic module.""" import uuid from permissions.models import identity as identity_model, neo4j_subaccount from permissions.types import Subaccount def get_directly_accessible_subaccounts_by_profile( identity_id: uuid.UUID, profile_id: int, profile_type: str, ) -> list[Subaccount]: """ Get accessible subaccounts for the identity and profile. Args: identity_id (uuid.UUID): The user's identity id. profile_id (str): The profile id. profile_type (str): The profile type. Returns: list[Subaccount]: A list of Subaccount objects. """ # check if the profile exists. profile = identity_model.get_profile_by_identity_id_and_profile_id_and_type( identity_id=identity_id, profile_id=profile_id, profile_type=profile_type ) if not profile: return [] return neo4j_subaccount.get_directly_accessible_subaccounts_by_profile( identity_id=identity_id, profile_id=profile_id, profile_type=profile_type, )