def METHOD_NAME(
    name: str, room: Room, switch_room: Room, processor: User
) -> PatchPort:
    # This check can be removed as soon as the unique constraint exists
    if PatchPort.q.filter_by(name=name, switch_room=switch_room).first():
        raise PatchPortAlreadyExistsException()
    patch_port = PatchPort(name=name, room=room, switch_room=switch_room)
    session.add(patch_port)
    message = (
        deferred_gettext("Created patch-port {} to {}.")
        .format(patch_port.name, room.short_name)
        .to_json()
    )
    log_room_event(message, processor, switch_room)
    return patch_port