def _create_chunks_and_post_to_sentinel(
        self, data, table_name, fields, entity_state=None, entities_endpoint=False
    ):
        """Create chunks and post to chunk to sentinel."""
        __method_name = inspect.currentframe().f_code.co_name
        chunk = []
        if self._get_size_of_chunk_in_mb(data) < 30:
            self.post_data_to_sentinel(data, table_name, fields)
            return
        for event in data:
            chunk.append(event)
            if self._get_size_of_chunk_in_mb(chunk) >= 30:
                if chunk[:-1]:
                    self.post_data_to_sentinel(chunk[:-1], table_name, fields)
                    if entities_endpoint:
                        next_checkpoint = chunk[-2].get("last_modified_timestamp")

                    else:
                        next_checkpoint = chunk[-2].get("id")
                    self.save_checkpoint(
                        data=next_checkpoint, entity_state=entity_state, entities_endpoint=entities_endpoint
                    )
                    chunk = [event]
                    continue
                else:
                    id = chunk[0].get("id")
                    self.applogger.error(
                        "{}(method={}) : {} : event with id {} is too large to post into the sentinel hence skipping it.".format(
                            consts.LOGS_STARTS_WITH,
                            __method_name,
                            self.function_name,
                            id,
                        )
                    )
                    chunk = []
                    continue
        if chunk:
            self.post_data_to_sentinel(chunk, table_name, fields)
Create chunks and post to chunk to sentinel.
Solutions/Vectra XDR/Data Connectors/VectraDataConnector/SharedCode/collector.py