[2.0.1-prepare]revert alert plugin novalid change
This commit is contained in:
parent
1a139342f9
commit
70e67dfc67
|
|
@ -27,9 +27,9 @@ public interface AlertChannelFactory {
|
|||
String name();
|
||||
|
||||
AlertChannel create();
|
||||
|
||||
/**
|
||||
* Returns the configurable parameters that this plugin needs to display on the web ui
|
||||
*/
|
||||
List<PluginParams> params();
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ public final class AlertConstants {
|
|||
/**
|
||||
* the field name of alert show type
|
||||
**/
|
||||
public static final String SHOW_TYPE = "$t('showType')";
|
||||
public static final String SHOW_TYPE = "show_type";
|
||||
|
||||
public static final String NAME_SHOW_TYPE = "showType";
|
||||
|
||||
|
|
|
|||
|
|
@ -43,52 +43,53 @@ public final class DingTalkAlertChannelFactory implements AlertChannelFactory {
|
|||
return "DingTalk";
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlertChannel create() {
|
||||
return new DingTalkAlertChannel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PluginParams> params() {
|
||||
InputParam webHookParam = InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_WEB_HOOK, DingTalkParamsConstants.DING_TALK_WEB_HOOK)
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
.build();
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
.build();
|
||||
InputParam keywordParam = InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_KEYWORD, DingTalkParamsConstants.DING_TALK_KEYWORD)
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
.build();
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
.build();
|
||||
RadioParam isEnableProxy =
|
||||
RadioParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PROXY_ENABLE, DingTalkParamsConstants.DING_TALK_PROXY_ENABLE)
|
||||
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
|
||||
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
|
||||
.setValue(STRING_TRUE)
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false)
|
||||
.build())
|
||||
.build();
|
||||
RadioParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PROXY_ENABLE, DingTalkParamsConstants.NAME_DING_TALK_PROXY_ENABLE)
|
||||
.addParamsOptions(new ParamsOptions(STRING_YES, STRING_TRUE, false))
|
||||
.addParamsOptions(new ParamsOptions(STRING_NO, STRING_FALSE, false))
|
||||
.setValue(STRING_TRUE)
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false)
|
||||
.build())
|
||||
.build();
|
||||
InputParam proxyParam =
|
||||
InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PROXY, DingTalkParamsConstants.DING_TALK_PROXY)
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false).build())
|
||||
.build();
|
||||
InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PROXY, DingTalkParamsConstants.DING_TALK_PROXY)
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false).build())
|
||||
.build();
|
||||
|
||||
InputParam portParam = InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PORT, DingTalkParamsConstants.DING_TALK_PORT)
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false).build())
|
||||
.build();
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false).build())
|
||||
.build();
|
||||
|
||||
InputParam userParam =
|
||||
InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_USER, DingTalkParamsConstants.DING_TALK_USER)
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false).build())
|
||||
.build();
|
||||
InputParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_USER, DingTalkParamsConstants.DING_TALK_USER)
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(false).build())
|
||||
.build();
|
||||
PasswordParam passwordParam = PasswordParam.newBuilder(DingTalkParamsConstants.NAME_DING_TALK_PASSWORD, DingTalkParamsConstants.DING_TALK_PASSWORD)
|
||||
.setPlaceholder("if enable use authentication, you need input password")
|
||||
.build();
|
||||
.setPlaceholder("if enable use authentication, you need input password")
|
||||
.build();
|
||||
|
||||
return Arrays.asList(webHookParam, keywordParam, isEnableProxy, proxyParam, portParam, userParam, passwordParam);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AlertChannel create() {
|
||||
return new DingTalkAlertChannel();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,25 +18,19 @@
|
|||
package org.apache.dolphinscheduler.plugin.alert.dingtalk;
|
||||
|
||||
public final class DingTalkParamsConstants {
|
||||
static final String DING_TALK_PROXY_ENABLE = "$t('isEnableProxy')";
|
||||
static final String NAME_DING_TALK_PROXY_ENABLE = "IsEnableProxy";
|
||||
|
||||
static final String DING_TALK_WEB_HOOK = "$t('webhook')";
|
||||
static final String DING_TALK_PROXY_ENABLE = "isEnableProxy";
|
||||
static final String DING_TALK_WEB_HOOK = "webhook";
|
||||
static final String NAME_DING_TALK_WEB_HOOK = "WebHook";
|
||||
|
||||
static final String DING_TALK_KEYWORD = "$t('keyword')";
|
||||
static final String DING_TALK_KEYWORD = "keyword";
|
||||
static final String NAME_DING_TALK_KEYWORD = "Keyword";
|
||||
|
||||
static final String DING_TALK_PROXY = "$t('proxy')";
|
||||
static final String NAME_DING_TALK_PROXY_ENABLE = "IsEnableProxy";
|
||||
static final String DING_TALK_PROXY = "proxy";
|
||||
static final String NAME_DING_TALK_PROXY = "Proxy";
|
||||
|
||||
static final String DING_TALK_PORT = "$t('port')";
|
||||
static final String DING_TALK_PORT = "port";
|
||||
static final String NAME_DING_TALK_PORT = "Port";
|
||||
|
||||
static final String DING_TALK_USER = "$t('user')";
|
||||
static final String DING_TALK_USER = "user";
|
||||
static final String NAME_DING_TALK_USER = "User";
|
||||
|
||||
static final String DING_TALK_PASSWORD = "$t('password')";
|
||||
static final String DING_TALK_PASSWORD = "password";
|
||||
static final String NAME_DING_TALK_PASSWORD = "Password";
|
||||
|
||||
private DingTalkParamsConstants() {
|
||||
|
|
|
|||
|
|
@ -196,6 +196,7 @@ public final class DingTalkSender {
|
|||
this.errmsg = errmsg;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == this) {
|
||||
return true;
|
||||
|
|
@ -217,6 +218,7 @@ public final class DingTalkSender {
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int PRIME = 59;
|
||||
int result = 1;
|
||||
|
|
@ -227,6 +229,7 @@ public final class DingTalkSender {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "DingTalkSender.DingTalkSendMsgResponse(errcode=" + this.getErrcode() + ", errmsg=" + this.getErrmsg() + ")";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,39 +18,41 @@
|
|||
package org.apache.dolphinscheduler.plugin.alert.email;
|
||||
|
||||
public final class MailParamsConstants {
|
||||
|
||||
public static final String PLUGIN_DEFAULT_EMAIL_RECEIVERS = "$t('receivers')";
|
||||
public static final String NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS = "receivers";
|
||||
|
||||
public static final String PLUGIN_DEFAULT_EMAIL_RECEIVERCCS = "$t('receiverCcs')";
|
||||
public static final String NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERCCS = "receiverCcs";
|
||||
|
||||
public static final String MAIL_PROTOCOL = "transport.protocol";
|
||||
public static final String NAME_MAIL_PROTOCOL = "mail.protocol";
|
||||
|
||||
public static final String MAIL_SMTP_HOST = "$t('mailSmtpHost')";
|
||||
public static final String MAIL_SMTP_HOST = "mail.smtp.host";
|
||||
public static final String NAME_MAIL_SMTP_HOST = "serverHost";
|
||||
|
||||
public static final String MAIL_SMTP_PORT = "$t('mailSmtpPort')";
|
||||
public static final String MAIL_SMTP_PORT = "mail.smtp.port";
|
||||
public static final String NAME_MAIL_SMTP_PORT = "serverPort";
|
||||
|
||||
public static final String MAIL_SENDER = "$t('mailSender')";
|
||||
public static final String MAIL_SENDER = "mail.sender";
|
||||
public static final String NAME_MAIL_SENDER = "sender";
|
||||
|
||||
public static final String MAIL_SMTP_AUTH = "$t('mailSmtpAuth')";
|
||||
public static final String MAIL_SMTP_AUTH = "mail.smtp.auth";
|
||||
public static final String NAME_MAIL_SMTP_AUTH = "enableSmtpAuth";
|
||||
|
||||
public static final String MAIL_USER = "$t('mailUser')";
|
||||
public static final String NAME_MAIL_USER = "User";
|
||||
public static final String MAIL_USER = "mail.user";
|
||||
public static final String NAME_MAIL_USER = "user";
|
||||
|
||||
public static final String MAIL_PASSWD = "$t('mailPasswd')";
|
||||
public static final String NAME_MAIL_PASSWD = "Password";
|
||||
public static final String MAIL_PASSWD = "mail.passwd";
|
||||
public static final String NAME_MAIL_PASSWD = "passwd";
|
||||
|
||||
public static final String MAIL_SMTP_STARTTLS_ENABLE = "$t('mailSmtpStarttlsEnable')";
|
||||
public static final String MAIL_SMTP_STARTTLS_ENABLE = "mail.smtp.starttls.enable";
|
||||
public static final String NAME_MAIL_SMTP_STARTTLS_ENABLE = "starttlsEnable";
|
||||
|
||||
public static final String MAIL_SMTP_SSL_ENABLE = "$t('mailSmtpSslEnable')";
|
||||
public static final String MAIL_SMTP_SSL_ENABLE = "mail.smtp.ssl.enable";
|
||||
public static final String NAME_MAIL_SMTP_SSL_ENABLE = "sslEnable";
|
||||
|
||||
public static final String MAIL_SMTP_SSL_TRUST = "$t('mailSmtpSslTrust')";
|
||||
public static final String MAIL_SMTP_SSL_TRUST = "mail.smtp.ssl.trust";
|
||||
public static final String NAME_MAIL_SMTP_SSL_TRUST = "smtpSslTrust";
|
||||
|
||||
private MailParamsConstants() {
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@ import org.junit.Assert;
|
|||
import org.junit.Test;
|
||||
|
||||
public class EmailAlertChannelTest {
|
||||
|
||||
/**
|
||||
* Method: process(AlertInfo info)
|
||||
*/
|
||||
@Test
|
||||
public void testProcess() {
|
||||
EmailAlertChannel emailAlertChannel = new EmailAlertChannel();
|
||||
|
|
@ -55,9 +59,9 @@ public class EmailAlertChannelTest {
|
|||
String mapjson = JSONUtils.toJsonString(maps);
|
||||
|
||||
alertData.setId(10)
|
||||
.setContent(mapjson)
|
||||
.setLog("10")
|
||||
.setTitle("test");
|
||||
.setContent(mapjson)
|
||||
.setLog("10")
|
||||
.setTitle("test");
|
||||
AlertInfo alertInfo = new AlertInfo();
|
||||
alertInfo.setAlertData(alertData);
|
||||
Map<String, String> paramsMap = PluginParamsTransfer.getPluginParamsMap(getEmailAlertParams());
|
||||
|
|
@ -70,74 +74,74 @@ public class EmailAlertChannelTest {
|
|||
|
||||
public String getEmailAlertParams() {
|
||||
List<PluginParams> paramsList = new ArrayList<>();
|
||||
InputParam receivesParam = InputParam.newBuilder(MailParamsConstants.NAME_PLUGIN_DEFAULT_EMAIL_RECEIVERS, "receivers")
|
||||
.setValue("540957506@qq.com")
|
||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||
.build();
|
||||
InputParam receivesParam = InputParam.newBuilder("receivers", "receivers")
|
||||
.setValue("540957506@qq.com")
|
||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||
.build();
|
||||
|
||||
InputParam mailSmtpHost = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_HOST, "smtp.host")
|
||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||
.setValue("smtp.126.com")
|
||||
.build();
|
||||
InputParam mailSmtpHost = InputParam.newBuilder("serverHost", "smtp.host")
|
||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||
.setValue("smtp.126.com")
|
||||
.build();
|
||||
|
||||
InputParam mailSmtpPort = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_PORT, "smtp.port")
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
.setValue("25")
|
||||
.build();
|
||||
InputParam mailSmtpPort = InputParam.newBuilder("serverPort", "smtp.port")
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
.setValue("25")
|
||||
.build();
|
||||
|
||||
InputParam mailSender = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SENDER, "sender")
|
||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||
.setValue("dolphinscheduler@126.com")
|
||||
.build();
|
||||
InputParam mailSender = InputParam.newBuilder("sender", "sender")
|
||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||
.setValue("dolphinscheduler@126.com")
|
||||
.build();
|
||||
|
||||
RadioParam enableSmtpAuth = RadioParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_AUTH, "smtp.auth")
|
||||
.addParamsOptions(new ParamsOptions("YES", "true", false))
|
||||
.addParamsOptions(new ParamsOptions("NO", "false", false))
|
||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||
.setValue("false")
|
||||
.build();
|
||||
RadioParam enableSmtpAuth = RadioParam.newBuilder("enableSmtpAuth", "smtp.auth")
|
||||
.addParamsOptions(new ParamsOptions("YES", "true", false))
|
||||
.addParamsOptions(new ParamsOptions("NO", "false", false))
|
||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||
.setValue("false")
|
||||
.build();
|
||||
|
||||
InputParam mailUser = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_USER, "user")
|
||||
.setPlaceholder("if enable use authentication, you need input user")
|
||||
.setValue("dolphinscheduler@126.com")
|
||||
.build();
|
||||
InputParam mailUser = InputParam.newBuilder("user", "user")
|
||||
.setPlaceholder("if enable use authentication, you need input user")
|
||||
.setValue("dolphinscheduler@126.com")
|
||||
.build();
|
||||
|
||||
PasswordParam mailPassword = PasswordParam.newBuilder(MailParamsConstants.NAME_MAIL_PASSWD, "passwd")
|
||||
.setPlaceholder("if enable use authentication, you need input password")
|
||||
.setValue("escheduler123")
|
||||
.build();
|
||||
PasswordParam mailPassword = PasswordParam.newBuilder("passwd", "passwd")
|
||||
.setPlaceholder("if enable use authentication, you need input password")
|
||||
.setValue("escheduler123")
|
||||
.build();
|
||||
|
||||
RadioParam enableTls = RadioParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_STARTTLS_ENABLE, "starttls.enable")
|
||||
.addParamsOptions(new ParamsOptions("YES", "true", false))
|
||||
.addParamsOptions(new ParamsOptions("NO", "false", false))
|
||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||
.setValue("true")
|
||||
.build();
|
||||
RadioParam enableTls = RadioParam.newBuilder("starttlsEnable", "starttls.enable")
|
||||
.addParamsOptions(new ParamsOptions("YES", "true", false))
|
||||
.addParamsOptions(new ParamsOptions("NO", "false", false))
|
||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||
.setValue("true")
|
||||
.build();
|
||||
|
||||
RadioParam enableSsl = RadioParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_SSL_ENABLE, "smtp.ssl.enable")
|
||||
.addParamsOptions(new ParamsOptions("YES", "true", false))
|
||||
.addParamsOptions(new ParamsOptions("NO", "false", false))
|
||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||
.setValue("true")
|
||||
.build();
|
||||
RadioParam enableSsl = RadioParam.newBuilder("sslEnable", "smtp.ssl.enable")
|
||||
.addParamsOptions(new ParamsOptions("YES", "true", false))
|
||||
.addParamsOptions(new ParamsOptions("NO", "false", false))
|
||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||
.setValue("true")
|
||||
.build();
|
||||
|
||||
InputParam sslTrust = InputParam.newBuilder(MailParamsConstants.NAME_MAIL_SMTP_SSL_TRUST, "smtp.ssl.trust")
|
||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||
.setValue("smtp.126.com")
|
||||
.build();
|
||||
InputParam sslTrust = InputParam.newBuilder("smtpSslTrust", "smtp.ssl.trust")
|
||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||
.setValue("smtp.126.com")
|
||||
.build();
|
||||
|
||||
List<ParamsOptions> emailShowTypeList = new ArrayList<>();
|
||||
emailShowTypeList.add(new ParamsOptions(ShowType.TABLE.getDescp(), ShowType.TABLE.getDescp(), false));
|
||||
emailShowTypeList.add(new ParamsOptions(ShowType.TEXT.getDescp(), ShowType.TEXT.getDescp(), false));
|
||||
emailShowTypeList.add(new ParamsOptions(ShowType.ATTACHMENT.getDescp(), ShowType.ATTACHMENT.getDescp(), false));
|
||||
emailShowTypeList.add(new ParamsOptions(ShowType.TABLEATTACHMENT.getDescp(), ShowType.TABLEATTACHMENT.getDescp(), false));
|
||||
RadioParam showType = RadioParam.newBuilder(AlertConstants.NAME_SHOW_TYPE, "showType")
|
||||
.setOptions(emailShowTypeList)
|
||||
.setValue(ShowType.TABLE.getDescp())
|
||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||
.build();
|
||||
RadioParam showType = RadioParam.newBuilder(AlertConstants.SHOW_TYPE, "showType")
|
||||
.setOptions(emailShowTypeList)
|
||||
.setValue(ShowType.TABLE.getDescp())
|
||||
.addValidate(Validate.newBuilder().setRequired(true).build())
|
||||
.build();
|
||||
|
||||
paramsList.add(receivesParam);
|
||||
paramsList.add(mailSmtpHost);
|
||||
|
|
|
|||
|
|
@ -18,26 +18,29 @@
|
|||
package org.apache.dolphinscheduler.plugin.alert.feishu;
|
||||
|
||||
public final class FeiShuParamsConstants {
|
||||
public static final String FEI_SHU_PROXY_ENABLE = "$t('isEnableProxy')";
|
||||
static final String WEB_HOOK = "$t('webhook')";
|
||||
static final String NAME_WEB_HOOK = "WebHook";
|
||||
static final String NAME_FEI_SHU_PROXY_ENABLE = "IsEnableProxy";
|
||||
static final String WEB_HOOK = "webhook";
|
||||
|
||||
static final String FEI_SHU_PROXY = "$t('proxy')";
|
||||
static final String NAME_WEB_HOOK = "webHook";
|
||||
|
||||
static final String NAME_FEI_SHU_PROXY = "Proxy";
|
||||
public static final String FEI_SHU_PROXY_ENABLE = "isEnableProxy";
|
||||
|
||||
static final String FEI_SHU_PORT = "$t('port')";
|
||||
static final String NAME_FEI_SHU_PROXY_ENABLE = "isEnableProxy";
|
||||
|
||||
static final String NAME_FEI_SHU_PORT = "Port";
|
||||
static final String FEI_SHU_PROXY = "proxy";
|
||||
|
||||
static final String FEI_SHU_USER = "$t('user')";
|
||||
static final String NAME_FEI_SHU_PROXY = "proxy";
|
||||
|
||||
static final String NAME_FEI_SHU_USER = "User";
|
||||
static final String FEI_SHU_PORT = "port";
|
||||
|
||||
static final String FEI_SHU_PASSWORD = "$t('password')";
|
||||
static final String NAME_FEI_SHU_PORT = "port";
|
||||
|
||||
static final String NAME_FEI_SHU_PASSWORD = "Password";
|
||||
static final String FEI_SHU_USER = "user";
|
||||
|
||||
static final String NAME_FEI_SHU_USER = "user";
|
||||
|
||||
static final String FEI_SHU_PASSWORD = "password";
|
||||
|
||||
static final String NAME_FEI_SHU_PASSWORD = "password";
|
||||
|
||||
private FeiShuParamsConstants() {
|
||||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
||||
|
|
|
|||
|
|
@ -38,31 +38,31 @@ public final class HttpAlertChannelFactory implements AlertChannelFactory {
|
|||
@Override
|
||||
public List<PluginParams> params() {
|
||||
|
||||
InputParam url = InputParam.newBuilder(HttpAlertConstants.NAME_URL, HttpAlertConstants.URL)
|
||||
InputParam url = InputParam.newBuilder(HttpAlertConstants.URL, HttpAlertConstants.URL)
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
InputParam headerParams = InputParam.newBuilder(HttpAlertConstants.NAME_HEADER_PARAMS, HttpAlertConstants.HEADER_PARAMS)
|
||||
InputParam headerParams = InputParam.newBuilder(HttpAlertConstants.HEADER_PARAMS, HttpAlertConstants.HEADER_PARAMS)
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
InputParam bodyParams = InputParam.newBuilder(HttpAlertConstants.NAME_BODY_PARAMS, HttpAlertConstants.BODY_PARAMS)
|
||||
InputParam bodyParams = InputParam.newBuilder(HttpAlertConstants.BODY_PARAMS, HttpAlertConstants.BODY_PARAMS)
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
InputParam contentField = InputParam.newBuilder(HttpAlertConstants.NAME_CONTENT_FIELD, HttpAlertConstants.CONTENT_FIELD)
|
||||
InputParam contentField = InputParam.newBuilder(HttpAlertConstants.CONTENT_FIELD, HttpAlertConstants.CONTENT_FIELD)
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
.build();
|
||||
|
||||
InputParam requestType = InputParam.newBuilder(HttpAlertConstants.NAME_REQUEST_TYPE, HttpAlertConstants.REQUEST_TYPE)
|
||||
InputParam requestType = InputParam.newBuilder(HttpAlertConstants.REQUEST_TYPE, HttpAlertConstants.REQUEST_TYPE)
|
||||
.addValidate(Validate.newBuilder()
|
||||
.setRequired(true)
|
||||
.build())
|
||||
|
|
|
|||
|
|
@ -18,25 +18,15 @@
|
|||
package org.apache.dolphinscheduler.plugin.alert.http;
|
||||
|
||||
public final class HttpAlertConstants {
|
||||
public static final String URL = "$t('url')";
|
||||
public static final String URL = "url";
|
||||
|
||||
public static final String NAME_URL = "url";
|
||||
public static final String HEADER_PARAMS = "headerParams";
|
||||
|
||||
public static final String HEADER_PARAMS = "$t('headerParams')";
|
||||
public static final String BODY_PARAMS = "bodyParams";
|
||||
|
||||
public static final String NAME_HEADER_PARAMS = "headerParams";
|
||||
public static final String CONTENT_FIELD = "contentField";
|
||||
|
||||
public static final String BODY_PARAMS = "$t('bodyParams')";
|
||||
|
||||
public static final String NAME_BODY_PARAMS = "bodyParams";
|
||||
|
||||
public static final String CONTENT_FIELD = "$t('contentField')";
|
||||
|
||||
public static final String NAME_CONTENT_FIELD = "contentField";
|
||||
|
||||
public static final String REQUEST_TYPE = "$t('requestType')";
|
||||
|
||||
public static final String NAME_REQUEST_TYPE = "requestType";
|
||||
public static final String REQUEST_TYPE = "requestType";
|
||||
|
||||
private HttpAlertConstants() {
|
||||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
||||
|
|
|
|||
|
|
@ -56,11 +56,11 @@ public final class HttpSender {
|
|||
|
||||
public HttpSender(Map<String, String> paramsMap) {
|
||||
|
||||
url = paramsMap.get(HttpAlertConstants.NAME_URL);
|
||||
headerParams = paramsMap.get(HttpAlertConstants.NAME_HEADER_PARAMS);
|
||||
bodyParams = paramsMap.get(HttpAlertConstants.NAME_BODY_PARAMS);
|
||||
contentField = paramsMap.get(HttpAlertConstants.NAME_CONTENT_FIELD);
|
||||
requestType = paramsMap.get(HttpAlertConstants.NAME_REQUEST_TYPE);
|
||||
url = paramsMap.get(HttpAlertConstants.URL);
|
||||
headerParams = paramsMap.get(HttpAlertConstants.HEADER_PARAMS);
|
||||
bodyParams = paramsMap.get(HttpAlertConstants.BODY_PARAMS);
|
||||
contentField = paramsMap.get(HttpAlertConstants.CONTENT_FIELD);
|
||||
requestType = paramsMap.get(HttpAlertConstants.REQUEST_TYPE);
|
||||
}
|
||||
|
||||
public AlertResult send(String msg) {
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@ public class HttpSenderTest {
|
|||
@Test
|
||||
public void sendTest() {
|
||||
Map<String, String> paramsMap = new HashMap<>();
|
||||
paramsMap.put(HttpAlertConstants.NAME_URL, "http://www.baidu.com");
|
||||
paramsMap.put(HttpAlertConstants.NAME_REQUEST_TYPE, "POST");
|
||||
paramsMap.put(HttpAlertConstants.NAME_HEADER_PARAMS, "{\"Content-Type\":\"application/json\"}");
|
||||
paramsMap.put(HttpAlertConstants.NAME_BODY_PARAMS, "{\"number\":\"13457654323\"}");
|
||||
paramsMap.put(HttpAlertConstants.NAME_CONTENT_FIELD, "content");
|
||||
paramsMap.put(HttpAlertConstants.URL, "http://www.baidu.com");
|
||||
paramsMap.put(HttpAlertConstants.REQUEST_TYPE, "POST");
|
||||
paramsMap.put(HttpAlertConstants.HEADER_PARAMS, "{\"Content-Type\":\"application/json\"}");
|
||||
paramsMap.put(HttpAlertConstants.BODY_PARAMS, "{\"number\":\"13457654323\"}");
|
||||
paramsMap.put(HttpAlertConstants.CONTENT_FIELD, "content");
|
||||
HttpSender httpSender = new HttpSender(paramsMap);
|
||||
AlertResult alertResult = httpSender.send("Fault tolerance warning");
|
||||
Assert.assertEquals("true", alertResult.getStatus());
|
||||
|
|
|
|||
|
|
@ -18,15 +18,16 @@
|
|||
package org.apache.dolphinscheduler.plugin.alert.script;
|
||||
|
||||
public final class ScriptParamsConstants {
|
||||
static final String SCRIPT_TYPE = "$t('scriptType')";
|
||||
|
||||
static final String SCRIPT_TYPE = "type";
|
||||
|
||||
static final String NAME_SCRIPT_TYPE = "type";
|
||||
|
||||
static final String SCRIPT_PATH = "$t('scriptPath')";
|
||||
static final String SCRIPT_PATH = "path";
|
||||
|
||||
static final String NAME_SCRIPT_PATH = "path";
|
||||
|
||||
static final String SCRIPT_USER_PARAMS = "$t('userParams')";
|
||||
static final String SCRIPT_USER_PARAMS = "user.params";
|
||||
|
||||
static final String NAME_SCRIPT_USER_PARAMS = "userParams";
|
||||
|
||||
|
|
|
|||
|
|
@ -18,13 +18,12 @@
|
|||
package org.apache.dolphinscheduler.plugin.alert.slack;
|
||||
|
||||
public final class SlackParamsConstants {
|
||||
public static final String SLACK_WEB_HOOK_URL = "$t('webhook')";
|
||||
public static final String SLACK_WEN_HOOK_URL_NAME = "webHook";
|
||||
public static final String SLACK_BOT = "$t('Username')";
|
||||
public static final String SLACK_WEB_HOOK_URL = "webhook";
|
||||
public static final String SLACK_WEN_HOOK_URL_NAME = "WebHook";
|
||||
public static final String SLACK_BOT = "username";
|
||||
public static final String SLACK_BOT_NAME = "username";
|
||||
public static final String TEXT = "text";
|
||||
public static final String ATTACHMENT = "attachments";
|
||||
|
||||
public static final Integer MAX_SHOW_NUMBER = 100;
|
||||
|
||||
private SlackParamsConstants() {
|
||||
|
|
|
|||
|
|
@ -18,19 +18,36 @@
|
|||
package org.apache.dolphinscheduler.plugin.alert.wechat;
|
||||
|
||||
public final class WeChatAlertParamsConstants {
|
||||
static final String ENTERPRISE_WE_CHAT_CORP_ID = "$t('corpId')";
|
||||
static final String ENTERPRISE_WE_CHAT_CORP_ID = "corp.id";
|
||||
|
||||
static final String NAME_ENTERPRISE_WE_CHAT_CORP_ID = "corpId";
|
||||
static final String ENTERPRISE_WE_CHAT_SECRET = "$t('secret')";
|
||||
|
||||
|
||||
static final String ENTERPRISE_WE_CHAT_SECRET = "secret";
|
||||
|
||||
static final String NAME_ENTERPRISE_WE_CHAT_SECRET = "secret";
|
||||
static final String ENTERPRISE_WE_CHAT_TEAM_SEND_MSG = "$t('teamSendMsg')";
|
||||
|
||||
static final String ENTERPRISE_WE_CHAT_TEAM_SEND_MSG = "team.send.msg";
|
||||
|
||||
static final String NAME_ENTERPRISE_WE_CHAT_TEAM_SEND_MSG = "teamSendMsg";
|
||||
static final String ENTERPRISE_WE_CHAT_USER_SEND_MSG = "$t('userSendMsg')";
|
||||
|
||||
|
||||
static final String ENTERPRISE_WE_CHAT_USER_SEND_MSG = "user.send.msg";
|
||||
|
||||
static final String NAME_ENTERPRISE_WE_CHAT_USER_SEND_MSG = "userSendMsg";
|
||||
static final String ENTERPRISE_WE_CHAT_AGENT_ID = "$t('agentId')";
|
||||
|
||||
|
||||
static final String ENTERPRISE_WE_CHAT_AGENT_ID = "agent.id";
|
||||
|
||||
static final String NAME_ENTERPRISE_WE_CHAT_AGENT_ID = "agentId";
|
||||
static final String ENTERPRISE_WE_CHAT_USERS = "$t('users')";
|
||||
|
||||
|
||||
static final String ENTERPRISE_WE_CHAT_USERS = "users";
|
||||
|
||||
|
||||
static final String NAME_ENTERPRISE_WE_CHAT_USERS = "users";
|
||||
|
||||
|
||||
private WeChatAlertParamsConstants() {
|
||||
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue