Refactor/to x content fragments2 (elastic/x-pack-elasticsearch#2329)
* Moves more classes over to ToXContentObject/Fragment * Removes ToXContentToBytes * Removes ToXContent from Enums * review comment fix * slight change to use XContantHelper Original commit: elastic/x-pack-elasticsearch@0f2d3f328b
This commit is contained in:
parent
18d15ef2d2
commit
de6c275dca
|
@ -5,16 +5,13 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.common.http;
|
package org.elasticsearch.xpack.common.http;
|
||||||
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
import static org.elasticsearch.xpack.watcher.support.Exceptions.illegalArgument;
|
import static org.elasticsearch.xpack.watcher.support.Exceptions.illegalArgument;
|
||||||
|
|
||||||
public enum HttpContentType implements ToXContent {
|
public enum HttpContentType {
|
||||||
|
|
||||||
JSON() {
|
JSON() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -39,11 +36,6 @@ public enum HttpContentType implements ToXContent {
|
||||||
|
|
||||||
public abstract XContentType contentType();
|
public abstract XContentType contentType();
|
||||||
|
|
||||||
@Override
|
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
|
||||||
return builder.value(id());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return id();
|
return id();
|
||||||
|
|
|
@ -5,13 +5,9 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.common.http;
|
package org.elasticsearch.xpack.common.http;
|
||||||
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public enum HttpMethod implements ToXContent {
|
public enum HttpMethod {
|
||||||
|
|
||||||
HEAD("HEAD"),
|
HEAD("HEAD"),
|
||||||
GET("GET"),
|
GET("GET"),
|
||||||
|
@ -47,9 +43,7 @@ public enum HttpMethod implements ToXContent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String value() {
|
||||||
@Override
|
return name().toLowerCase(Locale.ROOT);
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
|
||||||
return builder.value(name().toLowerCase(Locale.ROOT));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -140,8 +140,8 @@ public class HttpRequest implements ToXContentObject {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
builder.field(Field.HOST.getPreferredName(), host);
|
builder.field(Field.HOST.getPreferredName(), host);
|
||||||
builder.field(Field.PORT.getPreferredName(), port);
|
builder.field(Field.PORT.getPreferredName(), port);
|
||||||
builder.field(Field.SCHEME.getPreferredName(), scheme, params);
|
builder.field(Field.SCHEME.getPreferredName(), scheme.value());
|
||||||
builder.field(Field.METHOD.getPreferredName(), method, params);
|
builder.field(Field.METHOD.getPreferredName(), method.value());
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
builder.field(Field.PATH.getPreferredName(), path);
|
builder.field(Field.PATH.getPreferredName(), path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
package org.elasticsearch.xpack.common.http;
|
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.Strings;
|
import org.elasticsearch.common.Strings;
|
||||||
|
@ -162,10 +163,10 @@ public class HttpRequestTemplate implements ToXContentObject {
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws IOException {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
builder.field(HttpRequest.Field.SCHEME.getPreferredName(), scheme, params);
|
builder.field(HttpRequest.Field.SCHEME.getPreferredName(), scheme.value());
|
||||||
builder.field(HttpRequest.Field.HOST.getPreferredName(), host);
|
builder.field(HttpRequest.Field.HOST.getPreferredName(), host);
|
||||||
builder.field(HttpRequest.Field.PORT.getPreferredName(), port);
|
builder.field(HttpRequest.Field.PORT.getPreferredName(), port);
|
||||||
builder.field(HttpRequest.Field.METHOD.getPreferredName(), method, params);
|
builder.field(HttpRequest.Field.METHOD.getPreferredName(), method.value());
|
||||||
if (path != null) {
|
if (path != null) {
|
||||||
builder.field(HttpRequest.Field.PATH.getPreferredName(), path, params);
|
builder.field(HttpRequest.Field.PATH.getPreferredName(), path, params);
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,13 +5,9 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.common.http;
|
package org.elasticsearch.xpack.common.http;
|
||||||
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public enum Scheme implements ToXContent {
|
public enum Scheme {
|
||||||
|
|
||||||
HTTP("http", 80),
|
HTTP("http", 80),
|
||||||
HTTPS("https", 443);
|
HTTPS("https", 443);
|
||||||
|
@ -44,9 +40,7 @@ public enum Scheme implements ToXContent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String value() {
|
||||||
@Override
|
return name().toLowerCase(Locale.ROOT);
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
|
||||||
return builder.value(name().toLowerCase(Locale.ROOT));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class BasicAuth implements HttpAuth {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
builder.field(Field.USERNAME.getPreferredName(), username);
|
builder.field(Field.USERNAME.getPreferredName(), username);
|
||||||
if (!WatcherParams.hideSecrets(params)) {
|
if (!WatcherParams.hideSecrets(params)) {
|
||||||
builder.field(Field.PASSWORD.getPreferredName(), password, params);
|
builder.field(Field.PASSWORD.getPreferredName(), password.value());
|
||||||
}
|
}
|
||||||
return builder.endObject();
|
return builder.endObject();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,14 +5,12 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.common.secret;
|
package org.elasticsearch.xpack.common.secret;
|
||||||
|
|
||||||
|
import org.elasticsearch.xpack.security.crypto.CryptoService;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
public class Secret {
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
||||||
import org.elasticsearch.xpack.security.crypto.CryptoService;
|
|
||||||
|
|
||||||
public class Secret implements ToXContent {
|
|
||||||
|
|
||||||
protected final char[] text;
|
protected final char[] text;
|
||||||
|
|
||||||
|
@ -27,9 +25,8 @@ public class Secret implements ToXContent {
|
||||||
return service.decrypt(text);
|
return service.decrypt(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public String value() throws IOException {
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
return new String(text);
|
||||||
return builder.value(new String(text));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -9,8 +9,6 @@ import org.elasticsearch.Version;
|
||||||
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.Writeable;
|
import org.elasticsearch.common.io.stream.Writeable;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -21,7 +19,7 @@ import java.util.Locale;
|
||||||
* When a job is created it is initialised in to the state closed
|
* When a job is created it is initialised in to the state closed
|
||||||
* i.e. it is not running.
|
* i.e. it is not running.
|
||||||
*/
|
*/
|
||||||
public enum JobState implements ToXContent, Writeable {
|
public enum JobState implements Writeable {
|
||||||
|
|
||||||
CLOSING, CLOSED, OPENED, FAILED, OPENING;
|
CLOSING, CLOSED, OPENED, FAILED, OPENING;
|
||||||
|
|
||||||
|
@ -43,15 +41,8 @@ public enum JobState implements ToXContent, Writeable {
|
||||||
out.writeEnum(state);
|
out.writeEnum(state);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public String value() {
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
return name().toLowerCase(Locale.ROOT);
|
||||||
builder.value(name().toLowerCase(Locale.ROOT));
|
|
||||||
return builder;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isFragment() {
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ public class JobTaskStatus implements Task.Status {
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
builder.field(STATE.getPreferredName(), state, params);
|
builder.field(STATE.getPreferredName(), state.value());
|
||||||
builder.field(ALLOCATION_ID.getPreferredName(), allocationId);
|
builder.field(ALLOCATION_ID.getPreferredName(), allocationId);
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
return builder;
|
return builder;
|
||||||
|
|
|
@ -8,7 +8,6 @@ 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.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
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;
|
||||||
|
@ -119,13 +118,13 @@ public class Email implements ToXContentObject {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
builder.field(Field.ID.getPreferredName(), id);
|
builder.field(Field.ID.getPreferredName(), id);
|
||||||
if (from != null) {
|
if (from != null) {
|
||||||
builder.field(Field.FROM.getPreferredName(), from, params);
|
builder.field(Field.FROM.getPreferredName(), from.toUnicodeString());
|
||||||
}
|
}
|
||||||
if (replyTo != null) {
|
if (replyTo != null) {
|
||||||
builder.field(Field.REPLY_TO.getPreferredName(), replyTo, params);
|
builder.field(Field.REPLY_TO.getPreferredName(), replyTo, params);
|
||||||
}
|
}
|
||||||
if (priority != null) {
|
if (priority != null) {
|
||||||
builder.field(Field.PRIORITY.getPreferredName(), priority, params);
|
builder.field(Field.PRIORITY.getPreferredName(), priority.value());
|
||||||
}
|
}
|
||||||
builder.field(Field.SENT_DATE.getPreferredName(), sentDate);
|
builder.field(Field.SENT_DATE.getPreferredName(), sentDate);
|
||||||
if (to != null) {
|
if (to != null) {
|
||||||
|
@ -362,7 +361,7 @@ public class Email implements ToXContentObject {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Priority implements ToXContent {
|
public enum Priority {
|
||||||
|
|
||||||
HIGHEST(1),
|
HIGHEST(1),
|
||||||
HIGH(2),
|
HIGH(2),
|
||||||
|
@ -382,10 +381,8 @@ public class Email implements ToXContentObject {
|
||||||
message.setHeader(HEADER, String.valueOf(value));
|
message.setHeader(HEADER, String.valueOf(value));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String value() {
|
||||||
@Override
|
return name().toLowerCase(Locale.ROOT);
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
|
||||||
return builder.value(name().toLowerCase(Locale.ROOT));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Priority resolve(String name) {
|
public static Priority resolve(String name) {
|
||||||
|
@ -420,7 +417,7 @@ public class Email implements ToXContentObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Address extends javax.mail.internet.InternetAddress implements ToXContent {
|
public static class Address extends javax.mail.internet.InternetAddress {
|
||||||
|
|
||||||
public static final ParseField ADDRESS_NAME_FIELD = new ParseField("name");
|
public static final ParseField ADDRESS_NAME_FIELD = new ParseField("name");
|
||||||
public static final ParseField ADDRESS_EMAIL_FIELD = new ParseField("email");
|
public static final ParseField ADDRESS_EMAIL_FIELD = new ParseField("email");
|
||||||
|
@ -433,11 +430,6 @@ public class Email implements ToXContentObject {
|
||||||
super(address, personal, StandardCharsets.UTF_8.name());
|
super(address, personal, StandardCharsets.UTF_8.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
|
||||||
return builder.value(toUnicodeString());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Address parse(String field, XContentParser.Token token, XContentParser parser) throws IOException {
|
public static Address parse(String field, XContentParser.Token token, XContentParser parser) throws IOException {
|
||||||
if (token == XContentParser.Token.VALUE_STRING) {
|
if (token == XContentParser.Token.VALUE_STRING) {
|
||||||
String text = parser.text();
|
String text = parser.text();
|
||||||
|
@ -523,7 +515,7 @@ public class Email implements ToXContentObject {
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
builder.startArray();
|
builder.startArray();
|
||||||
for (Address address : addresses) {
|
for (Address address : addresses) {
|
||||||
address.toXContent(builder, params);
|
builder.value(address.toUnicodeString());
|
||||||
}
|
}
|
||||||
return builder.endArray();
|
return builder.endArray();
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,9 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.notification.email;
|
package org.elasticsearch.xpack.notification.email;
|
||||||
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import java.io.IOException;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import javax.mail.Message;
|
import javax.mail.Message;
|
||||||
import javax.mail.MessagingException;
|
import javax.mail.MessagingException;
|
||||||
|
@ -14,15 +15,12 @@ import javax.mail.Session;
|
||||||
import javax.mail.internet.MimeBodyPart;
|
import javax.mail.internet.MimeBodyPart;
|
||||||
import javax.mail.internet.MimeMessage;
|
import javax.mail.internet.MimeMessage;
|
||||||
import javax.mail.internet.MimeMultipart;
|
import javax.mail.internet.MimeMultipart;
|
||||||
import java.io.IOException;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A profile of an email client, can be seen as a strategy to emulate a real world email client
|
* A profile of an email client, can be seen as a strategy to emulate a real world email client
|
||||||
* (different clients potentially support different mime message structures)
|
* (different clients potentially support different mime message structures)
|
||||||
*/
|
*/
|
||||||
public enum Profile implements ToXContent {
|
public enum Profile {
|
||||||
|
|
||||||
STANDARD() {
|
STANDARD() {
|
||||||
|
|
||||||
|
@ -172,11 +170,6 @@ public enum Profile implements ToXContent {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
|
||||||
return builder.value(name().toLowerCase(Locale.ROOT));
|
|
||||||
}
|
|
||||||
|
|
||||||
static MimeMessage createCommon(Email email, Session session) throws MessagingException {
|
static MimeMessage createCommon(Email email, Session session) throws MessagingException {
|
||||||
MimeMessage message = new MimeMessage(session);
|
MimeMessage message = new MimeMessage(session);
|
||||||
message.setHeader(MESSAGE_ID_HEADER, email.id);
|
message.setHeader(MESSAGE_ID_HEADER, email.id);
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.notification.email.attachment;
|
package org.elasticsearch.xpack.notification.email.attachment;
|
||||||
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentFragment;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.xpack.notification.email.Attachment;
|
import org.elasticsearch.xpack.notification.email.Attachment;
|
||||||
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
import org.elasticsearch.xpack.watcher.execution.WatchExecutionContext;
|
||||||
|
@ -19,7 +19,7 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
public interface EmailAttachmentParser<T extends EmailAttachmentParser.EmailAttachment> {
|
public interface EmailAttachmentParser<T extends EmailAttachmentParser.EmailAttachment> {
|
||||||
|
|
||||||
interface EmailAttachment extends ToXContent {
|
interface EmailAttachment extends ToXContentFragment {
|
||||||
/**
|
/**
|
||||||
* @return A type to identify the email attachment, same as the parser identifier
|
* @return A type to identify the email attachment, same as the parser identifier
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -9,8 +9,6 @@ import org.apache.logging.log4j.Logger;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.settings.SettingsException;
|
import org.elasticsearch.common.settings.SettingsException;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.xpack.common.http.HttpClient;
|
import org.elasticsearch.xpack.common.http.HttpClient;
|
||||||
import org.elasticsearch.xpack.common.http.HttpProxy;
|
import org.elasticsearch.xpack.common.http.HttpProxy;
|
||||||
|
@ -60,7 +58,7 @@ public abstract class HipChatAccount {
|
||||||
|
|
||||||
public abstract SentMessages send(HipChatMessage message, @Nullable HttpProxy proxy);
|
public abstract SentMessages send(HipChatMessage message, @Nullable HttpProxy proxy);
|
||||||
|
|
||||||
public enum Profile implements ToXContent {
|
public enum Profile {
|
||||||
|
|
||||||
V1() {
|
V1() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -87,11 +85,6 @@ public abstract class HipChatAccount {
|
||||||
abstract HipChatAccount createAccount(String name, Settings settings, HipChatServer defaultServer, HttpClient httpClient,
|
abstract HipChatAccount createAccount(String name, Settings settings, HipChatServer defaultServer, HttpClient httpClient,
|
||||||
Logger logger);
|
Logger logger);
|
||||||
|
|
||||||
@Override
|
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
|
||||||
return builder.value(name().toLowerCase(Locale.ROOT));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String value() {
|
public String value() {
|
||||||
return name().toLowerCase(Locale.ROOT);
|
return name().toLowerCase(Locale.ROOT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ 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.settings.Settings;
|
import org.elasticsearch.common.settings.Settings;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
|
||||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
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;
|
||||||
|
@ -124,10 +123,10 @@ public class HipChatMessage implements ToXContentObject {
|
||||||
}
|
}
|
||||||
builder.field(Field.BODY.getPreferredName(), body);
|
builder.field(Field.BODY.getPreferredName(), body);
|
||||||
if (format != null) {
|
if (format != null) {
|
||||||
builder.field(Field.FORMAT.getPreferredName(), format, params);
|
builder.field(Field.FORMAT.getPreferredName(), format.value());
|
||||||
}
|
}
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
builder.field(Field.COLOR.getPreferredName(), color, params);
|
builder.field(Field.COLOR.getPreferredName(), color.value());
|
||||||
}
|
}
|
||||||
if (notify != null) {
|
if (notify != null) {
|
||||||
builder.field(Field.NOTIFY.getPreferredName(), notify);
|
builder.field(Field.NOTIFY.getPreferredName(), notify);
|
||||||
|
@ -224,7 +223,7 @@ public class HipChatMessage implements ToXContentObject {
|
||||||
}
|
}
|
||||||
builder.field(Field.BODY.getPreferredName(), body, params);
|
builder.field(Field.BODY.getPreferredName(), body, params);
|
||||||
if (format != null) {
|
if (format != null) {
|
||||||
builder.field(Field.FORMAT.getPreferredName(), format, params);
|
builder.field(Field.FORMAT.getPreferredName(), format.value());
|
||||||
}
|
}
|
||||||
if (color != null) {
|
if (color != null) {
|
||||||
builder.field(Field.COLOR.getPreferredName(), color, params);
|
builder.field(Field.COLOR.getPreferredName(), color, params);
|
||||||
|
@ -390,7 +389,7 @@ public class HipChatMessage implements ToXContentObject {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public enum Color implements ToXContent {
|
public enum Color {
|
||||||
YELLOW, GREEN, RED, PURPLE, GRAY, RANDOM;
|
YELLOW, GREEN, RED, PURPLE, GRAY, RANDOM;
|
||||||
|
|
||||||
private final TextTemplate template = new TextTemplate(name());
|
private final TextTemplate template = new TextTemplate(name());
|
||||||
|
@ -399,11 +398,6 @@ public class HipChatMessage implements ToXContentObject {
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
|
||||||
return builder.value(name().toLowerCase(Locale.ROOT));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String value() {
|
public String value() {
|
||||||
return name().toLowerCase(Locale.ROOT);
|
return name().toLowerCase(Locale.ROOT);
|
||||||
}
|
}
|
||||||
|
@ -433,7 +427,7 @@ public class HipChatMessage implements ToXContentObject {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Format implements ToXContent {
|
public enum Format {
|
||||||
|
|
||||||
TEXT,
|
TEXT,
|
||||||
HTML;
|
HTML;
|
||||||
|
@ -444,11 +438,6 @@ public class HipChatMessage implements ToXContentObject {
|
||||||
return template;
|
return template;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
|
||||||
return builder.value(name().toLowerCase(Locale.ROOT));
|
|
||||||
}
|
|
||||||
|
|
||||||
public String value() {
|
public String value() {
|
||||||
return name().toLowerCase(Locale.ROOT);
|
return name().toLowerCase(Locale.ROOT);
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,11 +6,11 @@
|
||||||
package org.elasticsearch.xpack.persistent;
|
package org.elasticsearch.xpack.persistent;
|
||||||
|
|
||||||
import org.elasticsearch.common.io.stream.NamedWriteable;
|
import org.elasticsearch.common.io.stream.NamedWriteable;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parameters used to start persistent task
|
* Parameters used to start persistent task
|
||||||
*/
|
*/
|
||||||
public interface PersistentTaskParams extends NamedWriteable, ToXContent {
|
public interface PersistentTaskParams extends NamedWriteable, ToXContentObject {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,6 @@ package org.elasticsearch.xpack.watcher.actions;
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
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.ToXContentFragment;
|
import org.elasticsearch.common.xcontent.ToXContentFragment;
|
||||||
import org.elasticsearch.common.xcontent.ToXContentObject;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
@ -22,7 +21,7 @@ public interface Action extends ToXContentObject {
|
||||||
|
|
||||||
abstract class Result implements ToXContentFragment {
|
abstract class Result implements ToXContentFragment {
|
||||||
|
|
||||||
public enum Status implements ToXContent {
|
public enum Status {
|
||||||
SUCCESS,
|
SUCCESS,
|
||||||
FAILURE,
|
FAILURE,
|
||||||
PARTIAL_FAILURE,
|
PARTIAL_FAILURE,
|
||||||
|
@ -31,9 +30,8 @@ public interface Action extends ToXContentObject {
|
||||||
CONDITION_FAILED,
|
CONDITION_FAILED,
|
||||||
SIMULATED;
|
SIMULATED;
|
||||||
|
|
||||||
@Override
|
public String value() {
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
return name().toLowerCase(Locale.ROOT);
|
||||||
return builder.value(name().toLowerCase(Locale.ROOT));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -296,7 +296,7 @@ public class ActionWrapper implements ToXContentObject {
|
||||||
builder.startObject();
|
builder.startObject();
|
||||||
builder.field(Field.ID.getPreferredName(), id);
|
builder.field(Field.ID.getPreferredName(), id);
|
||||||
builder.field(Field.TYPE.getPreferredName(), action.type());
|
builder.field(Field.TYPE.getPreferredName(), action.type());
|
||||||
builder.field(Field.STATUS.getPreferredName(), action.status(), params);
|
builder.field(Field.STATUS.getPreferredName(), action.status().value());
|
||||||
if (condition != null) {
|
if (condition != null) {
|
||||||
builder.field(Watch.Field.CONDITION.getPreferredName(), condition, params);
|
builder.field(Watch.Field.CONDITION.getPreferredName(), condition, params);
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ public class EmailAction implements Action {
|
||||||
if (auth != null) {
|
if (auth != null) {
|
||||||
builder.field(Field.USER.getPreferredName(), auth.user());
|
builder.field(Field.USER.getPreferredName(), auth.user());
|
||||||
if (WatcherParams.hideSecrets(params) == false) {
|
if (WatcherParams.hideSecrets(params) == false) {
|
||||||
builder.field(Field.PASSWORD.getPreferredName(), auth.password(), params);
|
builder.field(Field.PASSWORD.getPreferredName(), auth.password().value());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (profile != null) {
|
if (profile != null) {
|
||||||
|
|
|
@ -10,8 +10,8 @@ import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
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.common.text.TextTemplate;
|
import org.elasticsearch.xpack.common.text.TextTemplate;
|
||||||
|
import org.elasticsearch.xpack.watcher.actions.Action;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
@ -61,7 +61,7 @@ public class LoggingAction implements Action {
|
||||||
if (category != null) {
|
if (category != null) {
|
||||||
builder.field(Field.CATEGORY.getPreferredName(), category);
|
builder.field(Field.CATEGORY.getPreferredName(), category);
|
||||||
}
|
}
|
||||||
builder.field(Field.LEVEL.getPreferredName(), level, params);
|
builder.field(Field.LEVEL.getPreferredName(), level.value());
|
||||||
builder.field(Field.TEXT.getPreferredName(), text, params);
|
builder.field(Field.TEXT.getPreferredName(), text, params);
|
||||||
return builder.endObject();
|
return builder.endObject();
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,13 +7,10 @@ package org.elasticsearch.xpack.watcher.actions.logging;
|
||||||
|
|
||||||
import org.apache.logging.log4j.Logger;
|
import org.apache.logging.log4j.Logger;
|
||||||
import org.elasticsearch.common.SuppressLoggerChecks;
|
import org.elasticsearch.common.SuppressLoggerChecks;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public enum LoggingLevel implements ToXContent {
|
public enum LoggingLevel {
|
||||||
|
|
||||||
ERROR() {
|
ERROR() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -53,9 +50,7 @@ public enum LoggingLevel implements ToXContent {
|
||||||
|
|
||||||
abstract void log(Logger logger, String text);
|
abstract void log(Logger logger, String text);
|
||||||
|
|
||||||
|
public String value() {
|
||||||
@Override
|
return name().toLowerCase(Locale.ROOT);
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
|
||||||
return builder.value(name().toLowerCase(Locale.ROOT));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,12 +5,15 @@
|
||||||
*/
|
*/
|
||||||
package org.elasticsearch.xpack.watcher.client;
|
package org.elasticsearch.xpack.watcher.client;
|
||||||
|
|
||||||
import org.elasticsearch.action.support.ToXContentToBytes;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
import org.elasticsearch.common.Nullable;
|
import org.elasticsearch.common.Nullable;
|
||||||
|
import org.elasticsearch.common.bytes.BytesReference;
|
||||||
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.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||||
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
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;
|
||||||
import org.elasticsearch.xpack.watcher.condition.AlwaysCondition;
|
import org.elasticsearch.xpack.watcher.condition.AlwaysCondition;
|
||||||
|
@ -29,7 +32,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;
|
||||||
|
|
||||||
public class WatchSourceBuilder extends ToXContentToBytes implements ToXContentObject {
|
public class WatchSourceBuilder implements ToXContentObject {
|
||||||
|
|
||||||
private Trigger trigger;
|
private Trigger trigger;
|
||||||
private Input input = NoneInput.INSTANCE;
|
private Input input = NoneInput.INSTANCE;
|
||||||
|
@ -165,6 +168,19 @@ public class WatchSourceBuilder extends ToXContentToBytes implements ToXContentO
|
||||||
return builder.endObject();
|
return builder.endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a {@link org.elasticsearch.common.bytes.BytesReference}
|
||||||
|
* containing the {@link ToXContent} output in binary format. Builds the
|
||||||
|
* request as the provided <code>contentType</code>
|
||||||
|
*/
|
||||||
|
public final BytesReference buildAsBytes(XContentType contentType) {
|
||||||
|
try {
|
||||||
|
return XContentHelper.toXContent(this, contentType, false);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ElasticsearchException("Failed to build ToXContent", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static class TransformedAction implements ToXContentObject {
|
static class TransformedAction implements ToXContentObject {
|
||||||
|
|
||||||
private final String id;
|
private final String id;
|
||||||
|
|
|
@ -10,10 +10,10 @@ import org.elasticsearch.common.Nullable;
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
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.input.Input;
|
|
||||||
import org.elasticsearch.xpack.common.http.HttpContentType;
|
import org.elasticsearch.xpack.common.http.HttpContentType;
|
||||||
import org.elasticsearch.xpack.common.http.HttpRequest;
|
import org.elasticsearch.xpack.common.http.HttpRequest;
|
||||||
import org.elasticsearch.xpack.common.http.HttpRequestTemplate;
|
import org.elasticsearch.xpack.common.http.HttpRequestTemplate;
|
||||||
|
import org.elasticsearch.xpack.watcher.input.Input;
|
||||||
import org.elasticsearch.xpack.watcher.watch.Payload;
|
import org.elasticsearch.xpack.watcher.watch.Payload;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -64,7 +64,7 @@ public class HttpInput implements Input {
|
||||||
builder.field(Field.EXTRACT.getPreferredName(), extractKeys);
|
builder.field(Field.EXTRACT.getPreferredName(), extractKeys);
|
||||||
}
|
}
|
||||||
if (expectedResponseXContentType != null) {
|
if (expectedResponseXContentType != null) {
|
||||||
builder.field(Field.RESPONSE_CONTENT_TYPE.getPreferredName(), expectedResponseXContentType, params);
|
builder.field(Field.RESPONSE_CONTENT_TYPE.getPreferredName(), expectedResponseXContentType.id());
|
||||||
}
|
}
|
||||||
builder.endObject();
|
builder.endObject();
|
||||||
return builder;
|
return builder;
|
||||||
|
|
|
@ -8,7 +8,6 @@ package org.elasticsearch.xpack.watcher.transform;
|
||||||
import org.elasticsearch.ElasticsearchException;
|
import org.elasticsearch.ElasticsearchException;
|
||||||
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.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;
|
||||||
|
@ -16,7 +15,7 @@ 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 Transform extends ToXContent {
|
public interface Transform extends ToXContentObject {
|
||||||
|
|
||||||
ParseField TRANSFORM = new ParseField("transform");
|
ParseField TRANSFORM = new ParseField("transform");
|
||||||
|
|
||||||
|
|
|
@ -6,14 +6,11 @@
|
||||||
package org.elasticsearch.xpack.watcher.trigger.schedule.support;
|
package org.elasticsearch.xpack.watcher.trigger.schedule.support;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public enum DayOfWeek implements ToXContent {
|
public enum DayOfWeek {
|
||||||
|
|
||||||
SUNDAY("SUN"),
|
SUNDAY("SUN"),
|
||||||
MONDAY("MON"),
|
MONDAY("MON"),
|
||||||
|
@ -29,11 +26,6 @@ public enum DayOfWeek implements ToXContent {
|
||||||
this.cronKey = cronKey;
|
this.cronKey = cronKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
|
||||||
return builder.value(name().toLowerCase(Locale.ROOT));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String cronPart(EnumSet<DayOfWeek> days) {
|
public static String cronPart(EnumSet<DayOfWeek> days) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (DayOfWeek day : days) {
|
for (DayOfWeek day : days) {
|
||||||
|
|
|
@ -6,14 +6,11 @@
|
||||||
package org.elasticsearch.xpack.watcher.trigger.schedule.support;
|
package org.elasticsearch.xpack.watcher.trigger.schedule.support;
|
||||||
|
|
||||||
import org.elasticsearch.ElasticsearchParseException;
|
import org.elasticsearch.ElasticsearchParseException;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
|
||||||
public enum Month implements ToXContent {
|
public enum Month {
|
||||||
|
|
||||||
JANUARY("JAN"),
|
JANUARY("JAN"),
|
||||||
FEBRUARY("FEB"),
|
FEBRUARY("FEB"),
|
||||||
|
@ -34,11 +31,6 @@ public enum Month implements ToXContent {
|
||||||
this.cronKey = cronKey;
|
this.cronKey = cronKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
|
||||||
return builder.value(name().toLowerCase(Locale.ROOT));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String cronPart(EnumSet<Month> days) {
|
public static String cronPart(EnumSet<Month> days) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (Month day : days) {
|
for (Month day : days) {
|
||||||
|
|
|
@ -6,9 +6,9 @@
|
||||||
package org.elasticsearch.xpack.watcher.trigger.schedule.support;
|
package org.elasticsearch.xpack.watcher.trigger.schedule.support;
|
||||||
|
|
||||||
import org.elasticsearch.common.ParseField;
|
import org.elasticsearch.common.ParseField;
|
||||||
import org.elasticsearch.common.xcontent.ToXContent;
|
import org.elasticsearch.common.xcontent.ToXContentObject;
|
||||||
|
|
||||||
public interface Times extends ToXContent {
|
public interface Times extends ToXContentObject {
|
||||||
|
|
||||||
ParseField MONTH_FIELD = new ParseField("in", "month");
|
ParseField MONTH_FIELD = new ParseField("in", "month");
|
||||||
ParseField DAY_FIELD = new ParseField("on", "day");
|
ParseField DAY_FIELD = new ParseField("on", "day");
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
package org.elasticsearch.xpack.watcher.watch;
|
package org.elasticsearch.xpack.watcher.watch;
|
||||||
|
|
||||||
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.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
|
||||||
|
@ -18,7 +17,7 @@ import java.util.Objects;
|
||||||
|
|
||||||
import static org.elasticsearch.xpack.watcher.support.WatcherUtils.responseToData;
|
import static org.elasticsearch.xpack.watcher.support.WatcherUtils.responseToData;
|
||||||
|
|
||||||
public interface Payload extends ToXContent {
|
public interface Payload extends ToXContentObject {
|
||||||
|
|
||||||
Simple EMPTY = new Simple(Collections.emptyMap());
|
Simple EMPTY = new Simple(Collections.emptyMap());
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ public class HipChatMessageTests extends ESTestCase {
|
||||||
HipChatMessage.Format format = null;
|
HipChatMessage.Format format = null;
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
format = randomFrom(HipChatMessage.Format.values());
|
format = randomFrom(HipChatMessage.Format.values());
|
||||||
jsonBuilder.field("format", format, ToXContent.EMPTY_PARAMS);
|
jsonBuilder.field("format", format.value());
|
||||||
}
|
}
|
||||||
Boolean notify = null;
|
Boolean notify = null;
|
||||||
if (randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
|
|
|
@ -14,6 +14,7 @@ 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.ToXContentObject;
|
||||||
import org.elasticsearch.common.xcontent.XContentBuilder;
|
import org.elasticsearch.common.xcontent.XContentBuilder;
|
||||||
|
import org.elasticsearch.common.xcontent.XContentHelper;
|
||||||
import org.elasticsearch.common.xcontent.XContentParser;
|
import org.elasticsearch.common.xcontent.XContentParser;
|
||||||
import org.elasticsearch.common.xcontent.XContentType;
|
import org.elasticsearch.common.xcontent.XContentType;
|
||||||
import org.elasticsearch.index.query.QueryBuilders;
|
import org.elasticsearch.index.query.QueryBuilders;
|
||||||
|
@ -192,7 +193,7 @@ public class WatcherUtilsTests extends ESTestCase {
|
||||||
SearchSourceBuilder searchSourceBuilder = SearchSourceBuilder.searchSource().query(QueryBuilders.matchAllQuery()).size(11);
|
SearchSourceBuilder searchSourceBuilder = SearchSourceBuilder.searchSource().query(QueryBuilders.matchAllQuery()).size(11);
|
||||||
XContentBuilder searchSourceJsonBuilder = jsonBuilder();
|
XContentBuilder searchSourceJsonBuilder = jsonBuilder();
|
||||||
searchSourceBuilder.toXContent(searchSourceJsonBuilder, ToXContent.EMPTY_PARAMS);
|
searchSourceBuilder.toXContent(searchSourceJsonBuilder, ToXContent.EMPTY_PARAMS);
|
||||||
source = searchSourceBuilder.buildAsBytes(XContentType.JSON);
|
source = XContentHelper.toXContent(searchSourceBuilder, XContentType.JSON, false);
|
||||||
builder.rawField("body", source);
|
builder.rawField("body", source);
|
||||||
}
|
}
|
||||||
Script template = null;
|
Script template = null;
|
||||||
|
|
|
@ -244,7 +244,7 @@ public class ChainTransformTests extends ESTestCase {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException {
|
||||||
return builder.startObject().endArray();
|
return builder.startObject().endObject();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue