/** * @return the data model object this one inherits from if it is a user defined data model object * in the same data model; otherwise returns null (for example if the data model object inherits from BaseEvent * or BaseTransaction). */ public DataModelObject getParent() { return this.getDataModel().getObject(this.parentName); }
PivotSpecification(DataModelObject dataModelObject) { this.dataModelObject = dataModelObject; if (dataModelObject.getDataModel().isAccelerated()) { this.accelerationNamespace = dataModelObject.getDataModel().getName(); } else { this.accelerationNamespace = null; } }
/** * @return a JSON serialization of this object. */ JsonObject toJson() { JsonObject root = new JsonObject(); root.addProperty("dataModel", this.dataModelObject.getDataModel().getName()); root.addProperty("baseClass", this.dataModelObject.getName()); JsonArray filterArray = new JsonArray(); for (PivotFilter p : filters) { filterArray.add(p.toJson()); } root.add("filters", filterArray); JsonArray rowsplitArray = new JsonArray(); for (PivotRowSplit p : rows) { rowsplitArray.add(p.toJson()); } root.add("rows", rowsplitArray); JsonArray cellvalueArray = new JsonArray(); for (PivotCellValue p : cells) { cellvalueArray.add(p.toJson()); } root.add("cells", cellvalueArray); JsonArray columnsplitArray = new JsonArray(); for (PivotColumnSplit p : columns) { columnsplitArray.add(p.toJson()); } root.add("columns", columnsplitArray); return root; }
public String getQuery() { return "| datamodel " + this.getDataModel().getName() + " " + this.getName() + " search"; }
/** * Start a job that applies querySuffix to all the events in this data model object. * * @param querySuffix a search query, starting with a '|' that will be appended to the command to fetch * the contents of this data model object (e.g., "| head 3"). * @param args arguments to control the job. * @return a Job object. */ public Job runQuery(String querySuffix, JobArgs args) { return getDataModel().getService().search(getQuery() + querySuffix, args); }
/** * Query Splunk for SPL queries corresponding to this pivot. * * @return a Pivot object encapsulating the returned queries. */ public Pivot pivot() { Service service = this.dataModelObject.getDataModel().getService(); Args args = new Args(); args.put("pivot_json", toJson()); if (this.accelerationNamespace != null) { args.put("namespace", this.accelerationNamespace); } ResponseMessage response = service.get( "datamodel/pivot/" + this.dataModelObject.getDataModel().getName(), args ); if (response.getStatus() != 200) { throw HttpException.create(response); } else { return Pivot.parseStream(service, response.getContent()); } } }