Notebooks >> Scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

43 lines
1.1 KiB

import apprise
from airflow.models import BaseOperator
from airflow.utils.decorators import apply_defaults
from typing import Dict, Optional
# Can be low, moderate, normal, high, or emergency; the default is normal if a priority isn't specified.
class PushoverOperator(BaseOperator):
# Create an Apprise instance
# pover://{user_key}@{token}?priority={priority}
@apply_defaults
def __init__(
self,
message: str = "",
title: str = "",
priority: Optional[str] = "normal",
sound: Optional[str] = "pushover",
*args,
**kwargs,
):
super(PushoverOperator, self).__init__(*args, **kwargs)
self.message = message
self.title = title
self.priority = priority
self.sound = sound
def execute(self, context):
notify = apprise.Apprise()
notify.add(
"pover://umjiu36dxwwaj8pnfx3n6y2xbm3ssx@aejghiy6af1bshe8mbdksmkzeon3ip?priority={self.priority}"
)
notify.notify(
body=self.message,
title=self.title,
)