Migrate ToXContent impls to ToXContentObject
Original commit: elastic/x-pack-elasticsearch@b09f537ef4
This commit is contained in:
parent
0b93bc98bf
commit
8d31827f28
|
@ -12,6 +12,7 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentFactory;
|
import org.elasticsearch.common.xcontent.XContentFactory;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
@ -29,7 +30,7 @@ import java.util.Locale;
|
||||||
* Data structure for license. Use {@link Builder} to build a license.
|
* Data structure for license. Use {@link Builder} to build a license.
|
||||||
* Provides serialization/deserialization & validation methods for license object
|
* Provides serialization/deserialization & validation methods for license object
|
||||||
*/
|
*/
|
||||||
public class License implements ToXContent {
|
public class License implements ToXContentObject {
|
||||||
public static final int VERSION_START = 1;
|
public static final int VERSION_START = 1;
|
||||||
public static final int VERSION_NO_FEATURE_TYPE = 2;
|
public static final int VERSION_NO_FEATURE_TYPE = 2;
|
||||||
public static final int VERSION_START_DATE = 3;
|
public static final int VERSION_START_DATE = 3;
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.Writeable;
|
import org.elasticsearch.common.io.stream.Writeable;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.xpack.XPackBuild;
|
import org.elasticsearch.xpack.XPackBuild;
|
||||||
|
|
||||||
|
@ -140,7 +141,7 @@ public class XPackInfoResponse extends ActionResponse {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class BuildInfo implements ToXContent, Writeable {
|
public static class BuildInfo implements ToXContentObject, Writeable {
|
||||||
|
|
||||||
private final String hash;
|
private final String hash;
|
||||||
private final String timestamp;
|
private final String timestamp;
|
||||||
|
@ -180,7 +181,7 @@ public class XPackInfoResponse extends ActionResponse {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class FeatureSetsInfo implements ToXContent, Writeable {
|
public static class FeatureSetsInfo implements ToXContentObject, Writeable {
|
||||||
|
|
||||||
private final Map<String, FeatureSet> featureSets;
|
private final Map<String, FeatureSet> featureSets;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ package org.elasticsearch.xpack;
|
||||||
import org.elasticsearch.common.io.stream.NamedWriteable;
|
import org.elasticsearch.common.io.stream.NamedWriteable;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -25,7 +25,7 @@ public interface XPackFeatureSet {
|
||||||
|
|
||||||
Usage usage();
|
Usage usage();
|
||||||
|
|
||||||
abstract class Usage implements ToXContent, NamedWriteable {
|
abstract class Usage implements ToXContentObject, NamedWriteable {
|
||||||
|
|
||||||
private static final String AVAILABLE_XFIELD = "available";
|
private static final String AVAILABLE_XFIELD = "available";
|
||||||
private static final String ENABLED_XFIELD = "enabled";
|
private static final String ENABLED_XFIELD = "enabled";
|
||||||
|
|
|
@ -8,10 +8,10 @@ package org.elasticsearch.xpack.common.http;
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.ParseFieldMatcher;
|
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentHelper;
|
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
@ -35,7 +35,7 @@ import java.util.Objects;
|
||||||
import static java.util.Collections.emptyMap;
|
import static java.util.Collections.emptyMap;
|
||||||
import static java.util.Collections.unmodifiableMap;
|
import static java.util.Collections.unmodifiableMap;
|
||||||
|
|
||||||
public class HttpRequest implements ToXContent {
|
public class HttpRequest implements ToXContentObject {
|
||||||
|
|
||||||
final String host;
|
final String host;
|
||||||
final int port;
|
final int port;
|
||||||
|
|
|
@ -8,11 +8,11 @@ package org.elasticsearch.xpack.common.http;
|
||||||
import io.netty.handler.codec.http.HttpHeaders;
|
import io.netty.handler.codec.http.HttpHeaders;
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.ParseFieldMatcher;
|
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.collect.MapBuilder;
|
import org.elasticsearch.common.collect.MapBuilder;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.rest.RestUtils;
|
import org.elasticsearch.rest.RestUtils;
|
||||||
|
@ -33,7 +33,7 @@ import static java.util.Collections.emptyMap;
|
||||||
import static java.util.Collections.singletonMap;
|
import static java.util.Collections.singletonMap;
|
||||||
import static java.util.Collections.unmodifiableMap;
|
import static java.util.Collections.unmodifiableMap;
|
||||||
|
|
||||||
public class HttpRequestTemplate implements ToXContent {
|
public class HttpRequestTemplate implements ToXContentObject {
|
||||||
|
|
||||||
private final Scheme scheme;
|
private final Scheme scheme;
|
||||||
private final String host;
|
private final String host;
|
||||||
|
|
|
@ -9,11 +9,10 @@ import io.netty.handler.codec.http.HttpHeaders;
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.ParseFieldMatcher;
|
|
||||||
import org.elasticsearch.common.bytes.BytesArray;
|
import org.elasticsearch.common.bytes.BytesArray;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.collect.MapBuilder;
|
import org.elasticsearch.common.collect.MapBuilder;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
|
@ -29,7 +28,7 @@ import java.util.Map;
|
||||||
import static java.util.Collections.emptyMap;
|
import static java.util.Collections.emptyMap;
|
||||||
import static java.util.Collections.unmodifiableMap;
|
import static java.util.Collections.unmodifiableMap;
|
||||||
|
|
||||||
public class HttpResponse implements ToXContent {
|
public class HttpResponse implements ToXContentObject {
|
||||||
|
|
||||||
private final int status;
|
private final int status;
|
||||||
private final Map<String, String[]> headers;
|
private final Map<String, String[]> headers;
|
||||||
|
|
|
@ -7,13 +7,13 @@ package org.elasticsearch.xpack.common.http.auth;
|
||||||
|
|
||||||
import org.apache.http.auth.AuthScope;
|
import org.apache.http.auth.AuthScope;
|
||||||
import org.apache.http.client.CredentialsProvider;
|
import org.apache.http.client.CredentialsProvider;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
|
|
||||||
public abstract class ApplicableHttpAuth<Auth extends HttpAuth> implements ToXContent {
|
public abstract class ApplicableHttpAuth<Auth extends HttpAuth> implements ToXContentObject {
|
||||||
|
|
||||||
protected final Auth auth;
|
protected final Auth auth;
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.common.http.auth;
|
package org.elasticsearch.xpack.common.http.auth;
|
||||||
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
|
|
||||||
public interface HttpAuth extends ToXContent {
|
public interface HttpAuth extends ToXContentObject {
|
||||||
|
|
||||||
String type();
|
String type();
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ public abstract class Attachment extends BodyPartSource {
|
||||||
* intentionally not emitting path as it may come as an information leak
|
* intentionally not emitting path as it may come as an information leak
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public final XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
return builder.startObject()
|
return builder.startObject()
|
||||||
.field("type", type())
|
.field("type", type())
|
||||||
.field("id", id)
|
.field("id", id)
|
||||||
|
|
|
@ -8,6 +8,7 @@ package org.elasticsearch.xpack.notification.email;
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
|
@ -19,7 +20,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import static org.elasticsearch.xpack.watcher.support.Exceptions.illegalArgument;
|
import static org.elasticsearch.xpack.watcher.support.Exceptions.illegalArgument;
|
||||||
|
|
||||||
public enum DataAttachment implements ToXContent {
|
public enum DataAttachment implements ToXContentObject {
|
||||||
|
|
||||||
YAML() {
|
YAML() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
@ -31,7 +32,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import static java.util.Collections.unmodifiableMap;
|
import static java.util.Collections.unmodifiableMap;
|
||||||
|
|
||||||
public class Email implements ToXContent {
|
public class Email implements ToXContentObject {
|
||||||
|
|
||||||
final String id;
|
final String id;
|
||||||
final Address from;
|
final Address from;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
package org.elasticsearch.xpack.notification.email;
|
package org.elasticsearch.xpack.notification.email;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||||
|
@ -20,7 +20,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class EmailTemplate implements ToXContent {
|
public class EmailTemplate implements ToXContentObject {
|
||||||
|
|
||||||
final TextTemplate from;
|
final TextTemplate from;
|
||||||
final TextTemplate[] replyTo;
|
final TextTemplate[] replyTo;
|
||||||
|
|
|
@ -6,16 +6,15 @@
|
||||||
package org.elasticsearch.xpack.notification.email.support;
|
package org.elasticsearch.xpack.notification.email.support;
|
||||||
|
|
||||||
import org.elasticsearch.SpecialPermission;
|
import org.elasticsearch.SpecialPermission;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
|
|
||||||
import javax.activation.CommandMap;
|
|
||||||
import javax.activation.FileTypeMap;
|
import javax.activation.FileTypeMap;
|
||||||
import javax.mail.MessagingException;
|
import javax.mail.MessagingException;
|
||||||
import javax.mail.internet.MimeBodyPart;
|
import javax.mail.internet.MimeBodyPart;
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
|
|
||||||
public abstract class BodyPartSource implements ToXContent {
|
public abstract class BodyPartSource implements ToXContentObject {
|
||||||
|
|
||||||
protected static FileTypeMap fileTypeMap;
|
protected static FileTypeMap fileTypeMap;
|
||||||
static {
|
static {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||||
|
@ -23,7 +24,7 @@ import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class HipChatMessage implements ToXContent {
|
public class HipChatMessage implements ToXContentObject {
|
||||||
|
|
||||||
final String body;
|
final String body;
|
||||||
@Nullable final String[] rooms;
|
@Nullable final String[] rooms;
|
||||||
|
|
|
@ -7,6 +7,7 @@ package org.elasticsearch.xpack.notification.hipchat;
|
||||||
|
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||||
import org.elasticsearch.xpack.common.http.HttpResponse;
|
import org.elasticsearch.xpack.common.http.HttpResponse;
|
||||||
|
@ -17,7 +18,7 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class SentMessages implements ToXContent, Iterable<SentMessages.SentMessage> {
|
public class SentMessages implements ToXContentObject, Iterable<SentMessages.SentMessage> {
|
||||||
|
|
||||||
private String accountName;
|
private String accountName;
|
||||||
private List<SentMessage> messages;
|
private List<SentMessage> messages;
|
||||||
|
|
|
@ -10,7 +10,7 @@ import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||||
|
@ -24,7 +24,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class JiraIssue implements ToXContent {
|
public class JiraIssue implements ToXContentObject {
|
||||||
|
|
||||||
@Nullable final String account;
|
@Nullable final String account;
|
||||||
private final Map<String, Object> fields;
|
private final Map<String, Object> fields;
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.xpack.common.http.HttpMethod;
|
import org.elasticsearch.xpack.common.http.HttpMethod;
|
||||||
|
@ -35,7 +36,7 @@ import java.util.Objects;
|
||||||
* https://developer.pagerduty.com/documentation/integration/events/acknowledge
|
* https://developer.pagerduty.com/documentation/integration/events/acknowledge
|
||||||
* https://developer.pagerduty.com/documentation/integration/events/resolve
|
* https://developer.pagerduty.com/documentation/integration/events/resolve
|
||||||
*/
|
*/
|
||||||
public class IncidentEvent implements ToXContent {
|
public class IncidentEvent implements ToXContentObject {
|
||||||
|
|
||||||
static final String HOST = "events.pagerduty.com";
|
static final String HOST = "events.pagerduty.com";
|
||||||
static final String PATH = "/generic/2010-04-15/create_event.json";
|
static final String PATH = "/generic/2010-04-15/create_event.json";
|
||||||
|
|
|
@ -9,20 +9,20 @@ import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
import org.elasticsearch.common.xcontent.json.JsonXContent;
|
||||||
import org.elasticsearch.xpack.watcher.actions.pagerduty.PagerDutyAction;
|
|
||||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||||
import org.elasticsearch.xpack.common.http.HttpResponse;
|
import org.elasticsearch.xpack.common.http.HttpResponse;
|
||||||
|
import org.elasticsearch.xpack.watcher.actions.pagerduty.PagerDutyAction;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class SentEvent implements ToXContent {
|
public class SentEvent implements ToXContentObject {
|
||||||
|
|
||||||
final IncidentEvent event;
|
final IncidentEvent event;
|
||||||
@Nullable final HttpRequest request;
|
@Nullable final HttpRequest request;
|
||||||
|
|
|
@ -7,6 +7,7 @@ package org.elasticsearch.xpack.notification.slack;
|
||||||
|
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||||
import org.elasticsearch.xpack.common.http.HttpResponse;
|
import org.elasticsearch.xpack.common.http.HttpResponse;
|
||||||
|
@ -17,7 +18,7 @@ import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class SentMessages implements ToXContent, Iterable<SentMessages.SentMessage> {
|
public class SentMessages implements ToXContentObject, Iterable<SentMessages.SentMessage> {
|
||||||
|
|
||||||
private String accountName;
|
private String accountName;
|
||||||
private List<SentMessage> messages;
|
private List<SentMessage> messages;
|
||||||
|
|
|
@ -7,7 +7,7 @@ package org.elasticsearch.xpack.notification.slack.message;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.xpack.common.text.TextTemplate;
|
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||||
|
@ -142,7 +142,7 @@ public class Attachment implements MessageElement {
|
||||||
return builder.endObject();
|
return builder.endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
static class Template implements ToXContent {
|
static class Template implements ToXContentObject {
|
||||||
|
|
||||||
final TextTemplate fallback;
|
final TextTemplate fallback;
|
||||||
final TextTemplate color;
|
final TextTemplate color;
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
package org.elasticsearch.xpack.notification.slack.message;
|
package org.elasticsearch.xpack.notification.slack.message;
|
||||||
|
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
|
|
||||||
public interface MessageElement extends ToXContent {
|
public interface MessageElement extends ToXContentObject {
|
||||||
|
|
||||||
interface XField {
|
interface XField {
|
||||||
ParseField TITLE = new ParseField("title");
|
ParseField TITLE = new ParseField("title");
|
||||||
|
|
|
@ -8,7 +8,7 @@ package org.elasticsearch.xpack.security.action.role;
|
||||||
import org.elasticsearch.action.ActionResponse;
|
import org.elasticsearch.action.ActionResponse;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -16,7 +16,7 @@ import java.io.IOException;
|
||||||
/**
|
/**
|
||||||
* Response for a role being deleted from the security index
|
* Response for a role being deleted from the security index
|
||||||
*/
|
*/
|
||||||
public class DeleteRoleResponse extends ActionResponse implements ToXContent {
|
public class DeleteRoleResponse extends ActionResponse implements ToXContentObject {
|
||||||
|
|
||||||
private boolean found = false;
|
private boolean found = false;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ package org.elasticsearch.xpack.security.action.user;
|
||||||
import org.elasticsearch.action.ActionResponse;
|
import org.elasticsearch.action.ActionResponse;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -17,7 +17,7 @@ import java.io.IOException;
|
||||||
* Response when adding a user to the security index. Returns a
|
* Response when adding a user to the security index. Returns a
|
||||||
* single boolean field for whether the user was created or updated.
|
* single boolean field for whether the user was created or updated.
|
||||||
*/
|
*/
|
||||||
public class PutUserResponse extends ActionResponse implements ToXContent {
|
public class PutUserResponse extends ActionResponse implements ToXContentObject {
|
||||||
|
|
||||||
private boolean created;
|
private boolean created;
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,7 @@ import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.Streamable;
|
import org.elasticsearch.common.io.stream.Streamable;
|
||||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentHelper;
|
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
@ -37,7 +38,7 @@ import java.util.Map;
|
||||||
* A holder for a Role that contains user-readable information about the Role
|
* A holder for a Role that contains user-readable information about the Role
|
||||||
* without containing the actual Role object.
|
* without containing the actual Role object.
|
||||||
*/
|
*/
|
||||||
public class RoleDescriptor implements ToXContent {
|
public class RoleDescriptor implements ToXContentObject {
|
||||||
|
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String[] clusterPrivileges;
|
private final String[] clusterPrivileges;
|
||||||
|
|
|
@ -11,11 +11,10 @@ import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.inject.internal.Nullable;
|
import org.elasticsearch.common.inject.internal.Nullable;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.xpack.security.support.MetadataUtils;
|
import org.elasticsearch.xpack.security.support.MetadataUtils;
|
||||||
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -24,7 +23,7 @@ import java.util.Map;
|
||||||
/**
|
/**
|
||||||
* An authenticated user
|
* An authenticated user
|
||||||
*/
|
*/
|
||||||
public class User implements ToXContent {
|
public class User implements ToXContentObject {
|
||||||
|
|
||||||
private final String username;
|
private final String username;
|
||||||
private final String[] roles;
|
private final String[] roles;
|
||||||
|
@ -170,7 +169,7 @@ public class User implements ToXContent {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public final XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
builder.field(Fields.USERNAME.getPreferredName(), principal());
|
builder.field(Fields.USERNAME.getPreferredName(), principal());
|
||||||
builder.array(Fields.ROLES.getPreferredName(), roles());
|
builder.array(Fields.ROLES.getPreferredName(), roles());
|
||||||
|
|
|
@ -8,12 +8,13 @@ package org.elasticsearch.xpack.watcher.actions;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.logging.LoggerMessageFormat;
|
import org.elasticsearch.common.logging.LoggerMessageFormat;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public interface Action extends ToXContent {
|
public interface Action extends ToXContentObject {
|
||||||
|
|
||||||
String type();
|
String type();
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,7 @@ import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
@ -23,7 +24,7 @@ import java.util.Objects;
|
||||||
import static org.elasticsearch.xpack.watcher.support.Exceptions.illegalArgument;
|
import static org.elasticsearch.xpack.watcher.support.Exceptions.illegalArgument;
|
||||||
import static org.elasticsearch.xpack.watcher.support.WatcherDateTimeUtils.dateTimeFormatter;
|
import static org.elasticsearch.xpack.watcher.support.WatcherDateTimeUtils.dateTimeFormatter;
|
||||||
|
|
||||||
public class ActionStatus implements ToXContent {
|
public class ActionStatus implements ToXContentObject {
|
||||||
|
|
||||||
private AckStatus ackStatus;
|
private AckStatus ackStatus;
|
||||||
@Nullable private Execution lastExecution;
|
@Nullable private Execution lastExecution;
|
||||||
|
|
|
@ -13,6 +13,7 @@ import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.license.XPackLicenseState;
|
import org.elasticsearch.license.XPackLicenseState;
|
||||||
|
@ -31,7 +32,7 @@ import java.time.Clock;
|
||||||
|
|
||||||
import static org.elasticsearch.common.unit.TimeValue.timeValueMillis;
|
import static org.elasticsearch.common.unit.TimeValue.timeValueMillis;
|
||||||
|
|
||||||
public class ActionWrapper implements ToXContent {
|
public class ActionWrapper implements ToXContentObject {
|
||||||
|
|
||||||
private String id;
|
private String id;
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
|
@ -6,14 +6,14 @@
|
||||||
package org.elasticsearch.xpack.watcher.actions;
|
package org.elasticsearch.xpack.watcher.actions;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||||
import org.elasticsearch.xpack.watcher.watch.Payload;
|
import org.elasticsearch.xpack.watcher.watch.Payload;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public abstract class ExecutableAction<A extends Action> implements ToXContent {
|
public abstract class ExecutableAction<A extends Action> implements ToXContentObject {
|
||||||
|
|
||||||
protected final A action;
|
protected final A action;
|
||||||
protected final Logger logger;
|
protected final Logger logger;
|
||||||
|
@ -59,7 +59,7 @@ public abstract class ExecutableAction<A extends Action> implements ToXContent {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public final XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
return action.toXContent(builder, params);
|
return action.toXContent(builder, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.elasticsearch.action.support.ToXContentToBytes;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.xpack.watcher.actions.Action;
|
import org.elasticsearch.xpack.watcher.actions.Action;
|
||||||
import org.elasticsearch.xpack.watcher.actions.throttler.Throttler;
|
import org.elasticsearch.xpack.watcher.actions.throttler.Throttler;
|
||||||
|
@ -162,7 +163,7 @@ public class WatchSourceBuilder extends ToXContentToBytes implements ToXContent
|
||||||
return builder.endObject();
|
return builder.endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
static class TransformedAction implements ToXContent {
|
static class TransformedAction implements ToXContentObject {
|
||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
private final Action action;
|
private final Action action;
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
package org.elasticsearch.xpack.watcher.condition;
|
package org.elasticsearch.xpack.watcher.condition;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||||
|
|
||||||
|
@ -40,11 +39,6 @@ public final class AlwaysCondition extends Condition {
|
||||||
return RESULT_INSTANCE;
|
return RESULT_INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
|
||||||
return builder.startObject().endObject();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
return obj instanceof AlwaysCondition;
|
return obj instanceof AlwaysCondition;
|
||||||
|
|
|
@ -7,6 +7,7 @@ package org.elasticsearch.xpack.watcher.condition;
|
||||||
|
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||||
|
|
||||||
|
@ -14,7 +15,7 @@ import java.io.IOException;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class Condition implements ToXContent {
|
public abstract class Condition implements ToXContentObject {
|
||||||
|
|
||||||
protected final String type;
|
protected final String type;
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ package org.elasticsearch.xpack.watcher.execution;
|
||||||
|
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.xpack.watcher.actions.ActionWrapper;
|
import org.elasticsearch.xpack.watcher.actions.ActionWrapper;
|
||||||
import org.elasticsearch.xpack.watcher.condition.Condition;
|
import org.elasticsearch.xpack.watcher.condition.Condition;
|
||||||
|
@ -19,7 +19,7 @@ import org.joda.time.DateTime;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class WatchExecutionResult implements ToXContent {
|
public class WatchExecutionResult implements ToXContentObject {
|
||||||
|
|
||||||
private final DateTime executionTime;
|
private final DateTime executionTime;
|
||||||
private final long executionDurationMs;
|
private final long executionDurationMs;
|
||||||
|
|
|
@ -8,7 +8,7 @@ package org.elasticsearch.xpack.watcher.execution;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.Streamable;
|
import org.elasticsearch.common.io.stream.Streamable;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.xpack.watcher.actions.ActionWrapper;
|
import org.elasticsearch.xpack.watcher.actions.ActionWrapper;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
@ -17,7 +17,7 @@ import org.joda.time.DateTimeZone;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class WatchExecutionSnapshot implements Streamable, ToXContent {
|
public class WatchExecutionSnapshot implements Streamable, ToXContentObject {
|
||||||
|
|
||||||
private String watchId;
|
private String watchId;
|
||||||
private String watchRecordId;
|
private String watchRecordId;
|
||||||
|
|
|
@ -10,7 +10,7 @@ import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.collect.MapBuilder;
|
import org.elasticsearch.common.collect.MapBuilder;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.xpack.watcher.actions.Action;
|
import org.elasticsearch.xpack.watcher.actions.Action;
|
||||||
import org.elasticsearch.xpack.watcher.actions.ActionWrapper;
|
import org.elasticsearch.xpack.watcher.actions.ActionWrapper;
|
||||||
|
@ -30,7 +30,7 @@ import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public abstract class WatchRecord implements ToXContent {
|
public abstract class WatchRecord implements ToXContentObject {
|
||||||
|
|
||||||
protected final Wid id;
|
protected final Wid id;
|
||||||
protected final TriggerEvent triggerEvent;
|
protected final TriggerEvent triggerEvent;
|
||||||
|
@ -117,7 +117,7 @@ public abstract class WatchRecord implements ToXContent {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public final XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
builder.field(Field.WATCH_ID.getPreferredName(), id.watchId());
|
builder.field(Field.WATCH_ID.getPreferredName(), id.watchId());
|
||||||
builder.field(Field.STATE.getPreferredName(), state.id());
|
builder.field(Field.STATE.getPreferredName(), state.id());
|
||||||
|
|
|
@ -7,14 +7,14 @@ package org.elasticsearch.xpack.watcher.input;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||||
import org.elasticsearch.xpack.watcher.watch.Payload;
|
import org.elasticsearch.xpack.watcher.watch.Payload;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public abstract class ExecutableInput<I extends Input, R extends Input.Result> implements ToXContent {
|
public abstract class ExecutableInput<I extends Input, R extends Input.Result> implements ToXContentObject {
|
||||||
|
|
||||||
protected final I input;
|
protected final I input;
|
||||||
protected final Logger logger;
|
protected final Logger logger;
|
||||||
|
|
|
@ -7,18 +7,18 @@ package org.elasticsearch.xpack.watcher.input;
|
||||||
|
|
||||||
import org.elasticsearch.ExceptionsHelper;
|
import org.elasticsearch.ExceptionsHelper;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.xpack.watcher.watch.Payload;
|
import org.elasticsearch.xpack.watcher.watch.Payload;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public interface Input extends ToXContent {
|
public interface Input extends ToXContentObject {
|
||||||
|
|
||||||
String type();
|
String type();
|
||||||
|
|
||||||
abstract class Result implements ToXContent {
|
abstract class Result implements ToXContentObject {
|
||||||
|
|
||||||
public enum Status {
|
public enum Status {
|
||||||
SUCCESS, FAILURE
|
SUCCESS, FAILURE
|
||||||
|
@ -85,9 +85,7 @@ public interface Input extends ToXContent {
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Builder<I extends Input> {
|
interface Builder<I extends Input> {
|
||||||
|
|
||||||
I build();
|
I build();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
interface Field {
|
interface Field {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
import org.elasticsearch.common.bytes.BytesReference;
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.script.Script;
|
import org.elasticsearch.script.Script;
|
||||||
|
@ -30,7 +30,7 @@ import java.util.Objects;
|
||||||
* A {@link WatcherSearchTemplateRequest} contains the search request and the eventual template that will
|
* A {@link WatcherSearchTemplateRequest} contains the search request and the eventual template that will
|
||||||
* be rendered as a script by {@link WatcherSearchTemplateService} before being executed.
|
* be rendered as a script by {@link WatcherSearchTemplateService} before being executed.
|
||||||
*/
|
*/
|
||||||
public class WatcherSearchTemplateRequest implements ToXContent {
|
public class WatcherSearchTemplateRequest implements ToXContentObject {
|
||||||
|
|
||||||
private final String[] indices;
|
private final String[] indices;
|
||||||
private final String[] types;
|
private final String[] types;
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.elasticsearch.ExceptionsHelper;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.xpack.watcher.watch.Payload;
|
import org.elasticsearch.xpack.watcher.watch.Payload;
|
||||||
|
|
||||||
|
@ -19,7 +20,7 @@ public interface Transform extends ToXContent {
|
||||||
|
|
||||||
String type();
|
String type();
|
||||||
|
|
||||||
abstract class Result implements ToXContent {
|
abstract class Result implements ToXContentObject {
|
||||||
|
|
||||||
public enum Status {
|
public enum Status {
|
||||||
SUCCESS, FAILURE
|
SUCCESS, FAILURE
|
||||||
|
@ -67,7 +68,7 @@ public interface Transform extends ToXContent {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public final XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
builder.field(Field.TYPE.getPreferredName(), type);
|
builder.field(Field.TYPE.getPreferredName(), type);
|
||||||
builder.field(Field.STATUS.getPreferredName(), status.name().toLowerCase(Locale.ROOT));
|
builder.field(Field.STATUS.getPreferredName(), status.name().toLowerCase(Locale.ROOT));
|
||||||
|
|
|
@ -9,7 +9,7 @@ import org.elasticsearch.action.ActionResponse;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.io.stream.StreamInput;
|
import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.xpack.watcher.WatcherMetaData;
|
import org.elasticsearch.xpack.watcher.WatcherMetaData;
|
||||||
import org.elasticsearch.xpack.watcher.WatcherState;
|
import org.elasticsearch.xpack.watcher.WatcherState;
|
||||||
|
@ -21,7 +21,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public class WatcherStatsResponse extends ActionResponse implements ToXContent {
|
public class WatcherStatsResponse extends ActionResponse implements ToXContentObject {
|
||||||
|
|
||||||
private long watchesCount;
|
private long watchesCount;
|
||||||
private WatcherState watcherState;
|
private WatcherState watcherState;
|
||||||
|
|
|
@ -5,12 +5,12 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.watcher.trigger;
|
package org.elasticsearch.xpack.watcher.trigger;
|
||||||
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public interface Trigger extends ToXContent {
|
public interface Trigger extends ToXContentObject {
|
||||||
|
|
||||||
String type();
|
String type();
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
package org.elasticsearch.xpack.watcher.trigger;
|
package org.elasticsearch.xpack.watcher.trigger;
|
||||||
|
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.xpack.watcher.support.WatcherDateTimeUtils;
|
import org.elasticsearch.xpack.watcher.support.WatcherDateTimeUtils;
|
||||||
import org.joda.time.DateTime;
|
import org.joda.time.DateTime;
|
||||||
|
@ -15,7 +15,7 @@ import java.io.IOException;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public abstract class TriggerEvent implements ToXContent {
|
public abstract class TriggerEvent implements ToXContentObject {
|
||||||
|
|
||||||
private final String jobName;
|
private final String jobName;
|
||||||
protected final DateTime triggeredTime;
|
protected final DateTime triggeredTime;
|
||||||
|
|
|
@ -20,7 +20,7 @@ import static org.elasticsearch.xpack.watcher.support.WatcherUtils.responseToDat
|
||||||
|
|
||||||
public interface Payload extends ToXContent {
|
public interface Payload extends ToXContent {
|
||||||
|
|
||||||
Simple EMPTY = new Simple(Collections.<String, Object>emptyMap());
|
Simple EMPTY = new Simple(Collections.emptyMap());
|
||||||
|
|
||||||
Map<String, Object> data();
|
Map<String, Object> data();
|
||||||
|
|
||||||
|
@ -29,7 +29,7 @@ public interface Payload extends ToXContent {
|
||||||
private final Map<String, Object> data;
|
private final Map<String, Object> data;
|
||||||
|
|
||||||
public Simple() {
|
public Simple() {
|
||||||
this(new HashMap<String, Object>());
|
this(new HashMap<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Simple(String key, Object value) {
|
public Simple(String key, Object value) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ import org.elasticsearch.common.lucene.uid.Versions;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.unit.TimeValue;
|
import org.elasticsearch.common.unit.TimeValue;
|
||||||
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
import org.elasticsearch.common.xcontent.NamedXContentRegistry;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.xpack.common.secret.Secret;
|
import org.elasticsearch.xpack.common.secret.Secret;
|
||||||
|
@ -31,7 +31,6 @@ import org.elasticsearch.xpack.watcher.input.ExecutableInput;
|
||||||
import org.elasticsearch.xpack.watcher.input.InputRegistry;
|
import org.elasticsearch.xpack.watcher.input.InputRegistry;
|
||||||
import org.elasticsearch.xpack.watcher.input.none.ExecutableNoneInput;
|
import org.elasticsearch.xpack.watcher.input.none.ExecutableNoneInput;
|
||||||
import org.elasticsearch.xpack.watcher.support.WatcherDateTimeUtils;
|
import org.elasticsearch.xpack.watcher.support.WatcherDateTimeUtils;
|
||||||
import org.elasticsearch.xpack.watcher.support.xcontent.WatcherParams;
|
|
||||||
import org.elasticsearch.xpack.watcher.support.xcontent.WatcherXContentParser;
|
import org.elasticsearch.xpack.watcher.support.xcontent.WatcherXContentParser;
|
||||||
import org.elasticsearch.xpack.watcher.transform.ExecutableTransform;
|
import org.elasticsearch.xpack.watcher.transform.ExecutableTransform;
|
||||||
import org.elasticsearch.xpack.watcher.trigger.Trigger;
|
import org.elasticsearch.xpack.watcher.trigger.Trigger;
|
||||||
|
@ -45,17 +44,15 @@ import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import static java.util.Collections.unmodifiableMap;
|
import static java.util.Collections.unmodifiableMap;
|
||||||
import static org.elasticsearch.common.unit.TimeValue.timeValueMillis;
|
import static org.elasticsearch.common.unit.TimeValue.timeValueMillis;
|
||||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
|
||||||
import static org.elasticsearch.common.xcontent.XContentHelper.createParser;
|
import static org.elasticsearch.common.xcontent.XContentHelper.createParser;
|
||||||
import static org.elasticsearch.xpack.watcher.support.Exceptions.ioException;
|
import static org.elasticsearch.xpack.watcher.support.Exceptions.ioException;
|
||||||
import static org.joda.time.DateTimeZone.UTC;
|
import static org.joda.time.DateTimeZone.UTC;
|
||||||
|
|
||||||
public class Watch implements TriggerEngine.Job, ToXContent {
|
public class Watch implements TriggerEngine.Job, ToXContentObject {
|
||||||
|
|
||||||
public static final String ALL_ACTIONS_ID = "_all";
|
public static final String ALL_ACTIONS_ID = "_all";
|
||||||
public static final String INCLUDE_STATUS_KEY = "include_status";
|
public static final String INCLUDE_STATUS_KEY = "include_status";
|
||||||
|
@ -197,12 +194,6 @@ public class Watch implements TriggerEngine.Job, ToXContent {
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BytesReference getAsBytes() throws IOException {
|
|
||||||
// we don't want to cache this and instead rebuild it every time on demand. The watch is in
|
|
||||||
// memory and we don't need this redundancy
|
|
||||||
return toXContent(jsonBuilder(), WatcherParams.builder().put(Watch.INCLUDE_STATUS_KEY, true).build()).bytes();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class Parser extends AbstractComponent {
|
public static class Parser extends AbstractComponent {
|
||||||
|
|
||||||
private final TriggerService triggerService;
|
private final TriggerService triggerService;
|
||||||
|
|
|
@ -12,6 +12,7 @@ import org.elasticsearch.common.io.stream.StreamInput;
|
||||||
import org.elasticsearch.common.io.stream.StreamOutput;
|
import org.elasticsearch.common.io.stream.StreamOutput;
|
||||||
import org.elasticsearch.common.io.stream.Streamable;
|
import org.elasticsearch.common.io.stream.Streamable;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContent;
|
||||||
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.xpack.watcher.actions.Action;
|
import org.elasticsearch.xpack.watcher.actions.Action;
|
||||||
|
@ -35,7 +36,7 @@ import static org.elasticsearch.xpack.watcher.support.WatcherDateTimeUtils.write
|
||||||
import static org.elasticsearch.xpack.watcher.support.WatcherDateTimeUtils.writeOptionalDate;
|
import static org.elasticsearch.xpack.watcher.support.WatcherDateTimeUtils.writeOptionalDate;
|
||||||
import static org.joda.time.DateTimeZone.UTC;
|
import static org.joda.time.DateTimeZone.UTC;
|
||||||
|
|
||||||
public class WatchStatus implements ToXContent, Streamable {
|
public class WatchStatus implements ToXContentObject, Streamable {
|
||||||
|
|
||||||
private State state;
|
private State state;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue