-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HWKALERTS-68 #78
HWKALERTS-68 #78
Changes from 13 commits
36c36d4
ee8bbef
40c5638
311a552
e9b33f2
866e994
fdfa775
3b89462
3488b10
dfc49c3
174629e
2ec8682
e06363d
63f25b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.hawkular.alerts.actions.api; | ||
|
||
import java.lang.annotation.ElementType; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
/** | ||
* Define an alerts actions plugin implementation | ||
* Plugin must have a valid name that will be used at registration phase | ||
* Plugin must implement ActionPluginListener interface | ||
* | ||
* @author Lucas Ponce | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target(ElementType.TYPE) | ||
public @interface ActionPlugin { | ||
String name(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.hawkular.alerts.actions.api; | ||
|
||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
/** | ||
* A listener that will initialize the plugin and process incoming messages. | ||
* | ||
* @author Lucas Ponce | ||
*/ | ||
public interface ActionPluginListener { | ||
|
||
/** | ||
* The alerts engine registers the plugins available with their properties. | ||
* This method is invoked at plugin registration time. | ||
* | ||
* @return a list of properties available on this plugin | ||
*/ | ||
Set<String> getProperties(); | ||
|
||
/** | ||
* The alerts engine registers the plugins available with their default values. | ||
* This method is invoked at plugin registration time. | ||
* Default values can be modified by the alerts engine. | ||
* | ||
* | ||
* @return a list of default values for properties available on this plugin | ||
*/ | ||
Map<String, String> getDefaultProperties(); | ||
|
||
/** | ||
* This method is invoked by the ActionService to process a new action generated by the engine. | ||
* | ||
* @param msg PluginMessage received to be processed by the plugin | ||
* @throws Exception any problem | ||
*/ | ||
void process(PluginMessage msg) throws Exception; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.hawkular.alerts.actions.api; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import java.util.Map; | ||
import org.hawkular.alerts.api.model.action.Action; | ||
|
||
/** | ||
* A message sent to the plugin from the alerts engine | ||
* It has the alert payload as well as action properties | ||
* | ||
* @author Lucas Ponce | ||
*/ | ||
public interface PluginMessage { | ||
|
||
@JsonInclude | ||
Action getAction(); | ||
|
||
@JsonInclude | ||
Map<String, String> getProperties(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* Copyright 2015 Red Hat, Inc. and/or its affiliates | ||
* and other contributors as indicated by the @author tags. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.hawkular.alerts.actions.api; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
/** | ||
* A message sent to the alerts engine from the plugin | ||
* It defines a code of operation and payloads | ||
* | ||
* It used for plugin registration but additional operations should be supported | ||
* | ||
* @author Lucas Ponce | ||
*/ | ||
public interface PluginOpMessage { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personal preference, less abbreviation: PluginOperationMessage. Having said that. "Operation" is a term that may be getting overused. Perhaps PluginMessageType. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer PluginOperationMessage. PluginMessageType is not meaningful here - I think - as this is an operation message sent by the plugin. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. +1 |
||
|
||
enum Operation { | ||
REGISTRATION | ||
} | ||
|
||
@JsonInclude | ||
Operation getOperation(); | ||
|
||
@JsonInclude | ||
String getActionPlugin(); | ||
|
||
@JsonInclude | ||
Set<String> getPropertyNames(); | ||
|
||
@JsonInclude | ||
Map<String, String> getDefaultProperties(); | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, what is a valid name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question.
At the moment there is not any strict validation, the plugin must be just a string.
But I think that in the future we can add some regexp for valid (i.e. not starting with number, special characters, etc).
So, no restriction on this version now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1