def METHOD_NAME(
    events: Events,
    schedule: dict,
    webstream: dict,
    show: dict,
):
    """
    Generate events for a scheduled webstream.
    """
    schedule_start_event_key = datetime_to_event_key(schedule["starts_at"])
    schedule_end_event_key = datetime_to_event_key(schedule["ends_at"])
    stream_buffer_start_event = WebStreamEvent(
        type=EventKind.WEB_STREAM_BUFFER_START,
        row_id=schedule["id"],
        start=schedule["starts_at"] - timedelta(seconds=5),
        end=schedule["starts_at"] - timedelta(seconds=5),
        uri=webstream["url"],
        id=webstream["id"],
        # Show data
        show_name=show["name"],
    )
    insert_event(events, schedule_start_event_key, stream_buffer_start_event)
    stream_output_start_event = WebStreamEvent(
        type=EventKind.WEB_STREAM_OUTPUT_START,
        row_id=schedule["id"],
        start=schedule["starts_at"],
        end=schedule["ends_at"],
        uri=webstream["url"],
        id=webstream["id"],
        # Show data
        show_name=show["name"],
    )
    insert_event(events, schedule_start_event_key, stream_output_start_event)
    # NOTE: stream_*_end were previously triggered 1 second before
    # the schedule end.
    stream_buffer_end_event = WebStreamEvent(
        type=EventKind.WEB_STREAM_BUFFER_END,
        row_id=schedule["id"],
        start=schedule["ends_at"],
        end=schedule["ends_at"],
        uri=webstream["url"],
        id=webstream["id"],
        # Show data
        show_name=show["name"],
    )
    insert_event(events, schedule_end_event_key, stream_buffer_end_event)
    stream_output_end_event = WebStreamEvent(
        type=EventKind.WEB_STREAM_OUTPUT_END,
        row_id=schedule["id"],
        start=schedule["ends_at"],
        end=schedule["ends_at"],
        uri=webstream["url"],
        id=webstream["id"],
        # Show data
        show_name=show["name"],
    )
    insert_event(events, schedule_end_event_key, stream_output_end_event)