# Buggy code
def _services_enabled_on_project(serviceusage, project_id):
    """
    Return a list of all Google API services that are enabled on the given project ID.
    See https://cloud.google.com/service-usage/docs/reference/rest/v1/services/list for data shape.
    :param serviceusage: the serviceusage resource provider. See https://cloud.google.com/service-usage/docs/overview.
    :param project_id: The project ID number to sync.  See  the `projectId` field in
    https://cloud.google.com/resource-manager/reference/rest/v1/projects
    :return: A set of services that are enabled on the project
    """
    try:
        req = serviceusage.services().list(
            parent=f"projects/{project_id}", filter="state:ENABLED"
        )
        res = req.execute()
        if "services" in res:
            return {svc["config"]["name"] for svc in res["services"]}
        else:
            return {}
    except googleapiclient.discovery.HttpError as http_error:
        http_error = json.loads(http_error.content.decode("utf-8"))
        logger.warning(
            f"HttpError when trying to get enabled services on project {project_id}. "
            f"Code: {http_error['error']['code']}, Message: {http_error['error']['message']}. "
            f"Skipping.",
        )
        return {}


# Traceback (googleapiclient.errors.HttpError)
Traceback (most recent call last):
File "{path}/site-packages/cartography/sync.py", line 71, in run
stage_func(neo4j_session, config)
File "{path}/site-packages/cartography/util.py", line 58, in timed
result = method(*args, **kwargs)
File "{path}/site-packages/cartography/intel/gcp/__init__.py", line 218, in start_gcp_ingestion
_sync_multiple_projects(neo4j_session, resources, projects, config.update_tag, common_job_parameters)
File "{path}/site-packages/cartography/intel/gcp/__init__.py", line 177, in _sync_multiple_projects
_sync_single_project(neo4j_session, resources, project_id, gcp_update_tag, common_job_parameters)
File "{path}/site-packages/cartography/intel/gcp/__init__.py", line 155, in _sync_single_project
gke.sync_gke_clusters(neo4j_session, resources.container, project_id, gcp_update_tag, common_job_parameters)
File "{path}/site-packages/cartography/util.py", line 58, in timed
result = method(*args, **kwargs)
File "{path}/site-packages/cartography/intel/gcp/gke.py", line 197, in sync_gke_clusters
gke_res = get_gke_clusters(container, project_id)
File "{path}/site-packages/cartography/util.py", line 58, in timed
result = method(*args, **kwargs)
File "{path}/site-packages/cartography/intel/gcp/gke.py", line 28, in get_gke_clusters
res = req.execute()
File "{path}/site-packages/googleapiclient/_helpers.py", line 134, in positional_wrapper
return wrapped(*args, **kwargs)
File "{path}/site-packages/googleapiclient/http.py", line 907, in execute
raise HttpError(resp, content, uri=self.uri)
googleapiclient.errors.HttpError: <HttpError 403 when requesting https://container.googleapis.com/v1/projects/{ProjectName}}/zones/-/clusters?alt=json returned "Required "container.clusters.list" permission(s) for "projects/{ProjectName}".">

# Fixed code
def _services_enabled_on_project(serviceusage, project_id):
    """
    Return a list of all Google API services that are enabled on the given project ID.
    See https://cloud.google.com/service-usage/docs/reference/rest/v1/services/list for data shape.
    :param serviceusage: the serviceusage resource provider. See https://cloud.google.com/service-usage/docs/overview.
    :param project_id: The project ID number to sync.  See  the `projectId` field in
    https://cloud.google.com/resource-manager/reference/rest/v1/projects
    :return: A set of services that are enabled on the project
    """
    try:
        req = serviceusage.services().list(
            parent=f"projects/{project_id}", filter="state:ENABLED"
        )
        res = req.execute()
        if "services" in res:
            return {svc["config"]["name"] for svc in res["services"]}
        else:
            return {}
    except googleapiclient.discovery.HttpError as http_error:
        http_error = json.loads(http_error.content.decode("utf-8"))
        # This is set to log-level `info` because Google creates many projects under the hood that cartography cannot
        # audit (e.g. adding a script to a Google spreadsheet causes a project to get created) and we don't need to emit
        # a warning for these projects.
        logger.info(
            f"HttpError when trying to get enabled services on project {project_id}. "
            f"Code: {http_error['error']['code']}, Message: {http_error['error']['message']}. "
            f"Skipping.",
        )
        return {}