in cartography/intel/gcp/compute.py [0:0]
def transform_gcp_instances(response_objects):
"""
Process the GCP instance response objects and return a flattened list of GCP instances with all the necessary fields
we need to load it into Neo4j
:param response_objects: The return data from get_gcp_instance_responses()
:return: A list of GCP instances
"""
instance_list = []
for res in response_objects:
prefix = res['id']
prefix_fields = _parse_instance_uri_prefix(prefix)
for instance in res.get('items', []):
instance['partial_uri'] = f"{prefix}/{instance['name']}"
instance['project_id'] = prefix_fields.project_id
instance['zone_name'] = prefix_fields.zone_name
for nic in instance.get('networkInterfaces', []):
nic['subnet_partial_uri'] = _parse_compute_full_uri_to_partial_uri(nic['subnetwork'])
nic['vpc_partial_uri'] = _parse_compute_full_uri_to_partial_uri(nic['network'])
instance_list.append(instance)
return instance_list