def METHOD_NAME(
    self,
    start_time: Optional[datetime] = None,
    end_time: Optional[datetime] = None,
    filter_pattern: Optional[str] = None,
):
    kwargs = {"logGroupName": self.cw_log_group, "interleaved": True}
    if start_time:
        kwargs["startTime"] = to_timestamp(start_time)
    if end_time:
        kwargs["endTime"] = to_timestamp(end_time)
    if filter_pattern:
        kwargs["filterPattern"] = filter_pattern
    while True:
        LOG.debug("Fetching logs from CloudWatch with parameters %s", kwargs)
        try:
            result = self.logs_client.filter_log_events(**kwargs)
            self._invalid_log_group = False
        except self.logs_client.exceptions.ResourceNotFoundException:
            if not self._invalid_log_group:
                LOG.debug(
                    "The specified log group %s does not exist. "
                    "This may be due to your resource have not been invoked yet.",
                    self.cw_log_group,
                )
                self._invalid_log_group = True
            break
        # Several events will be returned. Consume one at a time
        for event in result.get("events", []):
            self.had_data = True
            cw_event = CWLogEvent(self.cw_log_group, dict(event), self.resource_name)
            if cw_event.timestamp > self.latest_event_time:
                self.latest_event_time = cw_event.timestamp
            self.consumer.consume(cw_event)
        # Keep iterating until there are no more logs left to query.
        next_token = result.get("nextToken", None)
        kwargs["nextToken"] = next_token
        if not next_token:
            break