def METHOD_NAME(**data):
    if "alt_names" not in data:
        return
    if len(data["alt_names"]) == 0:
        return
    l = []
    for i, d in enumerate(data["alt_names"]):
        try:
            ip = ip_address(d)
        except ValueError:
            ip = None
        if d.startswith("IP:") or d.startswith("DNS:"):
            l.append(d)
        elif ip:
            l.append("IP:%s" % d)
        else:
            l.append("DNS:%s" % d)
    return "subjectAltName = %s" % ",".join(l)