Closed lindycoder closed 5 years ago
Hi @lindycoder,
Thank you for pointing this out. While the current documented behavior of EventsAPISession.trigger
(as of the latest version) actually does specify that the contents of the payload
argument override the other arguments that go into the default payload, I realize the way that it does this (complete replacement) is problematic and definitely not as documented. It doesn't merge with the default payload but rather replaces it.
Instead of this:
event['payload'] = payload
it should be doing this:
event['payload'].update(payload)
According to the docstring:
payload (dict) – Set the payload directly. Can be used in conjunction with other parameters that also set payload properties; these properties will be merged into the default payload, and any properties in this parameter will take precedence except with regard to
custom_details
I do like your idea of switching to **kwargs
, and might implement this.
Thanks again!
New package (3.1.2) is published.
That was fast! Thank you very much!
Hello!
I've been tinkering with the EventsAPISession and notice that if you set a
payload
it will completely ignore thesummary
,source
andseverity
instead of merging it with the payload as the docstring says.Here's the override: https://github.com/PagerDuty/pdpyras/blob/master/pdpyras.py#L641
I wouldn't mind setting either kwargs OR payload, but right now to make a valid event with any of the fields not supported by the kwargs (
component
,group
andclass
) if have to do it like this becausesummary
andsource
are not optional:So maybe:
Just a suggestion, Thank you