org.elasticsearch.client.ml.PreviewDatafeedResponse Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elasticsearch-rest-high-level-client Show documentation
Show all versions of elasticsearch-rest-high-level-client Show documentation
Elasticsearch subproject :client:rest-high-level
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
package org.elasticsearch.client.ml;
import org.elasticsearch.common.Strings;
import org.elasticsearch.common.bytes.BytesReference;
import org.elasticsearch.common.io.stream.StreamInput;
import org.elasticsearch.xcontent.DeprecationHandler;
import org.elasticsearch.xcontent.NamedXContentRegistry;
import org.elasticsearch.xcontent.ToXContentObject;
import org.elasticsearch.xcontent.XContentBuilder;
import org.elasticsearch.xcontent.XContentFactory;
import org.elasticsearch.xcontent.XContentParser;
import org.elasticsearch.xcontent.XContentType;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* Response containing a datafeed preview in JSON format
*/
public class PreviewDatafeedResponse implements ToXContentObject {
private BytesReference preview;
public static PreviewDatafeedResponse fromXContent(XContentParser parser) throws IOException {
try (XContentBuilder builder = XContentFactory.jsonBuilder()) {
parser.nextToken();
builder.copyCurrentStructure(parser);
return new PreviewDatafeedResponse(BytesReference.bytes(builder));
}
}
public PreviewDatafeedResponse(BytesReference preview) {
this.preview = preview;
}
public BytesReference getPreview() {
return preview;
}
/**
* Parses the preview to a list of {@link Map} objects
* @return List of previewed data
* @throws IOException If there is a parsing issue with the {@link BytesReference}
* @throws java.lang.ClassCastException If casting the raw {@link Object} entries to a {@link Map} fails
*/
@SuppressWarnings("unchecked")
public List
© 2015 - 2024 Weber Informatics LLC | Privacy Policy