def METHOD_NAME(
    channel: str, role: str, delegation: db_models.RoleDelegation
) -> Callable:
    def root_builder(json_dict: Dict[str, Any]):
        return libmamba_api.RootImpl(json.dumps(json_dict))
    def key_mgr_builder(json_dict: Dict[str, Any]):
        keys = [k.public_key for k in delegation.keys]
        threshold = delegation.threshold
        spec = libmamba_api.SpecImpl()
        full_keys = libmamba_api.RoleFullKeys(
            keys={k: libmamba_api.Key.from_ed25519(k) for k in keys},
            threshold=threshold,
        )
        return libmamba_api.KeyMgr(json.dumps(json_dict), full_keys, spec)
    def pkg_mgr_builder(json_dict: Dict[str, Any]):
        keys = [k.public_key for k in delegation.keys]
        threshold = delegation.threshold
        spec = libmamba_api.SpecImpl()
        full_keys = libmamba_api.RoleFullKeys(
            keys={k: libmamba_api.Key.from_ed25519(k) for k in keys},
            threshold=threshold,
        )
        return libmamba_api.PkgMgr(json.dumps(json_dict), full_keys, spec)
    def wrong_role(_: Dict[str, Any]):
        raise RuntimeError()
    builder = dict(root=root_builder, key_mgr=key_mgr_builder, pkg_mgr=pkg_mgr_builder)
    return builder.get(role, wrong_role)