import json


def create_incident_from_detection(detection: dict):
    """
    converts a detection object to an Incident object
    """
    labels = []
    for key, value in detection.items():
        labels.append({'type': key, 'value': json.dumps(value)})

        return {
            "name": f'Detection from Vectra with ID: {detection.get("id")}',
            "labels": labels,
            "rawJSON": json.dumps(detection)
        }