def params()

in eventdata/parameter_sources/elasticlogs_bulk_source.py [0:0]


    def params(self):
        # Build bulk array
        bulk_array = []
        self._randomevent.start_bulk(self._bulk_size)
        for x in range(0, self._bulk_size):
            try:
                evt, idx, typ = self._randomevent.generate_event()
            except StopIteration:
                if len(bulk_array) > 0:
                    # return any remaining items if there are any (otherwise we'd lose the last bulk request)
                    break
                else:
                    # otherwise stop immediately
                    raise

            if self._id_type == "auto":
                bulk_array.append('{"index": {"_index": "%s"}}' % idx)
            else:
                docid = "%s-%d" % (self.__get_seq_id(), self._params["client_id"])
                bulk_array.append('{"index": {"_index": "%s", "_id": "%s"}}' % (idx, docid))

            bulk_array.append(evt)

        response = {
            "body": "\n".join(bulk_array),
            "action-metadata-present": True,
            # the bulk array contains the action-and-metadata line and the actual document
            "bulk-size": len(bulk_array) // 2,
            "unit": "docs"
        }

        if "pipeline" in self._params.keys():
            response["pipeline"] = self._params["pipeline"]

        return response