Skip to content
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

Make a separate hook for interacting with the Pagerduty Events API #18784

Merged
merged 7 commits into from
Oct 12, 2021

Conversation

GuidoTournois
Copy link
Contributor

@GuidoTournois GuidoTournois commented Oct 6, 2021

In order to make use of the PagerDuty Events API, you need to provide two API keys in the PagerdutyHook connection, even though one of them is not required for the Events API.

  1. token: used to access the general Pagerduty rest API. Set in init and can't be None
  2. routing_key: used to access the Events API.

The proposed setup is two have two separate hooks, one for accessing the general Pagerduty API, the other hook for interacting with the EventsAPI.

So I made the new PagerdutyEventsHook, which sole purpose is to interact with the Pagerduty Events API. However, in order to be back compatible the original PagerdutyHook still contains a method to interact with the EventsAPI, which under the hood makes use of the other hook.

closes: #18771

@GuidoTournois GuidoTournois marked this pull request as ready for review October 8, 2021 14:51
:param integration_key: PagerDuty Events API token
:param pagerduty_conn_id: connection that has PagerDuty integration key in the Pagerduty API token field
"""

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we create a separate "pagerduty_events" type of connection ? Seems that those two different connection types have two different keys ? This is perfectly fine to define second type of connection for the the new hook.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! Yes indeed, the two different hook required different types of api keys.

I think we have a few options:

  • keep it as is (probably causes some confusion to airflow users).
  • a single connection type with two separate fields for the two tokens. The password field can be renamed as one token, and we can either rename an existing field or use an extra field for the other token. However, in that case only one of the tokens would behave as a password (as is automatically hidden from logs). Thinking about it, that is the current situation as well with the routing_key in the extra field.
  • two separate connection types as you mentioned.

I think I would agree with you. Better to be explicit and have both token be hidden from logs.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have pushed the changes to make it into two separate connection types

Copy link
Member

@potiuk potiuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice one!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Current implementation of PagerdutyHook requires two tokens to be present in connection
3 participants