def resource_events_enricher(event: KubernetesResourceEvent, params: ExtendedEventEnricherParams):
    """
    Given a Kubernetes resource, fetch related events in the near past
    """

    resource = event.get_resource()
    if resource.kind not in events_supported_types:
        raise ActionException(
            ErrorCodes.RESOURCE_NOT_SUPPORTED, f"Resource events enricher is not supported for resource {resource.kind}"
        )

    kind: str = resource.kind

    events = get_resource_events(
        kind,
        resource.metadata.name,
        resource.metadata.namespace,
        included_types=params.included_types,
    )

    # append related pod data as well
    if params.dependent_pod_mode and kind not in ["Pod", "Node"]:
        pods = []
        if kind == "Job":
            pods = get_job_all_pods(resource) or []
        else:
            selector = resource.spec.get("selector", {}) if isinstance(resource.spec, dict) else resource.spec.selector
            pods = list_pods_using_selector(resource.metadata.namespace, selector, "")

        selected_pods = pods[: min(len(pods), params.max_pods)]
        for pod in selected_pods:
            if len(events) >= params.max_events:
                break

            events.extend(
                get_resource_events(
                    "Pod",
                    pod.metadata.name,
                    pod.metadata.namespace,
                    included_types=params.included_types,
                )
            )

    events = events[: params.max_events]
    events = sorted(events, key=get_event_timestamp, reverse=True)

    if len(events) > 0:
        rows = [
            [
                e.reason,
                e.type,
                parse_kubernetes_datetime_to_ms(get_event_timestamp(e)) if get_event_timestamp(e) else 0,
                e.regarding.kind,
                e.regarding.name,
                e.note,
            ]
            for e in events
        ]

        events_row = [
            EventRow(
                reason=event.reason,
                type=event.type,
                time=render_value(
                    RendererType.DATETIME,
                    parse_kubernetes_datetime_to_ms(get_event_timestamp(event)) if get_event_timestamp(event) else 0,
                ),
                message=event.note,
                kind=kind.lower(),
                name=event.regarding.name,
                namespace=event.regarding.namespace,
            )
            for event in events
        ]

        event.add_enrichment(
            [
                EventsBlock(
                    events=events_row,
                    table_name=f"{kind} Events",
                    column_renderers={"time": RendererType.DATETIME},
                    headers=["reason", "type", "time", "kind", "name", "message"],
                    rows=rows,
                    column_width=[1, 1, 1, 1, 1, 2],
                )
            ],
            {SlackAnnotations.ATTACHMENT: True},
            enrichment_type=EnrichmentType.k8s_events,
            title="Resource Events",
        )

    Given a Kubernetes resource, fetch related events in the near past
    
playbooks/robusta_playbooks/event_enrichments.py