-
Notifications
You must be signed in to change notification settings - Fork 24
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
Provider implements a include filter to define relevant notifications #91
Provider implements a include filter to define relevant notifications #91
Conversation
@glennmatthews , take this as a proposal, it's just a draft, I will add tests and improve it (I believe it's time to make the keywords data type standard), but just raising to get early feedback on the overall idea |
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.
I like the design here - relatively simple to implement or add to individual providers' filters, but flexible and powerful as well.
@@ -49,6 +50,10 @@ class GenericProvider(BaseModel): | |||
that will be used. Default: `[SimpleProcessor(data_parsers=[ICal])]`. | |||
_default_organizer (optional): Defines a default `organizer`, an email address, to be used to create a | |||
`Maintenance` in absence of the information in the original notification. | |||
_include_filter (optional): Dictionary that defines matching string per data type to take a notification into | |||
account. |
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.
Would be good to flesh this out with an example or two - it's not obvious from just reading this how a valid _include_filter
would be structured.
@@ -172,6 +214,8 @@ class HGC(GenericProvider): | |||
class Lumen(GenericProvider): | |||
"""Lumen provider custom class.""" | |||
|
|||
_include_filter = {EMAIL_HEADER_SUBJECT: ["Scheduled Maintenance Window"]} |
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.
Looking at more examples that I have locally, I think just "Scheduled Maintenance" would be better here. I see some subject lines like Lumen Scheduled Maintenance #: 22194642, Scheduled
that appear to me to be valid maintenance notifications.
…f github.com:networktocode/circuitmaint-parser into enable-filtering-relevant-notifications-per-provider
Co-authored-by: Glenn Matthews <[email protected]>
Addressing #82
The goal is to make the
Provider
capable of filtering in (and implicitly out), which are the relevant notifications that must be parsed and if not successful aProviderError
must be raised.With the
_include_filter
dictionary, theProvider
can define a dictionary of different data_type to match some string in, and if the filter exists, and the notification doens't match, instead of raising error, returns an empty list ofMaintenances
TODO, once approach is approved: