Skip to content

Commit

Permalink
Fix deprecated arguments for HipChat Operator
Browse files Browse the repository at this point in the history
Fix models.py:2390: PendingDeprecationWarning: 

Invalid arguments were passed to HipChatAPISendRoomNotificationOperator. 

Support for passing such arguments will be dropped in Airflow 2.0. 
https://github.com/apache/incubator-airflow/blob/8715bc45b448c9c346/airflow/models.py#L2382

Invalid arguments were:
```
*args: ()
**kwargs: {'color': 'green'}
```

  category=PendingDeprecationWarning
  • Loading branch information
elgalu committed Jul 26, 2018
1 parent 06e1767 commit 83fc940
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions airflow/contrib/operators/hipchat_operator.py
Expand Up @@ -99,24 +99,21 @@ class HipChatAPISendRoomNotificationOperator(HipChatAPIOperator):
:param card: HipChat-defined card object
:type card: dict
"""
template_fields = ('token', 'room_id', 'message')
template_fields = ('token', 'room_id', 'message', 'message_format', 'color', 'frm', 'attach_to', 'notify', 'card')
ui_color = '#2980b9'

@apply_defaults
def __init__(self, room_id, message, *args, **kwargs):
def __init__(self, room_id, message, message_format='html', color='yellow', frm='airflow', attach_to=None, notify=False, card=None, *args, **kwargs):
super(HipChatAPISendRoomNotificationOperator, self).__init__(*args, **kwargs)
self.room_id = room_id
self.message = message
default_options = {
'message_format': 'html',
'color': 'yellow',
'frm': 'airflow',
'attach_to': None,
'notify': False,
'card': None
}
for (prop, default) in default_options.items():
setattr(self, prop, kwargs.get(prop, default))
self.message_format = message_format
self.color = color
self.frm = frm
self.attach_to = attach_to
self.notify = notify
self.card = card


def prepare_request(self):
params = {
Expand Down

0 comments on commit 83fc940

Please sign in to comment.