Skip to content

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

Merged
potiuk merged 7 commits into
apache:mainfrom
GuidoTournois:pagerduty_tokens
Oct 12, 2021
Merged

Make a separate hook for interacting with the Pagerduty Events API#18784
potiuk merged 7 commits into
apache:mainfrom
GuidoTournois:pagerduty_tokens

Conversation

@GuidoTournois

@GuidoTournois GuidoTournois commented Oct 6, 2021

Copy link
Copy Markdown
Contributor

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

Comment thread airflow/providers/pagerduty/hooks/pagerduty.py Outdated
@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

@potiuk potiuk left a comment

Copy link
Copy Markdown
Member

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