def _TransformNumInstances(resource):
  """Sums up number of instances in a patch job."""
  if 'instanceDetailsSummary' not in resource:
    return None

  instance_details_summary = resource['instanceDetailsSummary']
  num_instances = 0
  for status in instance_details_summary:
    num_instances += int(instance_details_summary.get(status, 0))
  return num_instances