# Buggy code
def get_gke_clusters(container, project_id):
    """
    Returns a list of GKE clusters within some given project.

    :type container: The GCP Container resource object
    :param container: The Container resource object created by googleapiclient.discovery.build()

    :type project_id: str
    :param project_id: The Google Project Id that you are retrieving clusters from

    :rtype: Cluster Object
    :return: Cluster response object
    """
    try:
        req = (
            container.projects().zones().clusters().list(projectId=project_id, zone="-")
        )
        res = req.execute()
        return res
    except HttpError as e:
        reason = compute._get_error_reason(e)
        if reason == "invalid":
            logger.warning(
                (
                    "The project %s is invalid - returned a 400 invalid error."
                    "Full details: %s"
                ),
                project_id,
                e,
            )
            return {}
        elif reason == "forbidden":
            logger.warning(
                (
                    "You do not have container.projects.zones.clusters.list access to the project %s. "
                    "Full details: %s"
                ),
                project_id,
                e,
            )
            return {}
        else:
            raise


# 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 get_gke_clusters(container, project_id):
    """
    Returns a GCP response object containing a list of GKE clusters within the given project.

    :type container: The GCP Container resource object
    :param container: The Container resource object created by googleapiclient.discovery.build()

    :type project_id: str
    :param project_id: The Google Project Id that you are retrieving clusters from

    :rtype: Cluster Object
    :return: Cluster response object
    """
    try:
        req = (
            container.projects().zones().clusters().list(projectId=project_id, zone="-")
        )
        res = req.execute()
        return res
    except HttpError as e:
        err = json.loads(e.content.decode("utf-8"))["error"]
        if err["status"] == "PERMISSION_DENIED":
            logger.warning(
                (
                    "Could not retrieve GKE clusters on project %s due to permissions issue. Code: %s, Message: %s"
                ),
                project_id,
                err["code"],
                err["message"],
            )
            return {}
        else:
            raise