def METHOD_NAME(payload):
    params = request.get_json(force=True)
    domains = []
    if params.get("kind") == "desktop":
        categories = (
            json.loads(params.get("categories")) if params.get("categories") else None
        )
        if payload["role_id"] == "manager":
            categories = [payload["category_id"]]
        domains = admins.ListDesktops(
            categories,
        )
    else:
        domains = admins.ListTemplates(payload["user_id"])
        if payload["role_id"] == "manager":
            domains = [d for d in domains if d["category"] == payload["category_id"]]
    return (
        json.dumps(domains),
        200,
        {"Content-Type": "application/json"},
    )