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

Webhook behavior customization and delivery records #1338

Merged
merged 13 commits into from
Jul 25, 2024
Merged

Conversation

tdruez
Copy link
Contributor

@tdruez tdruez commented Jul 24, 2024

This PR expands on the existing WebhookSubscription model by adding a few fields to configure the behavior of the Webhook, and moving some of the fields to a new WebhookDelivery model, which captures the results of a WebhookSubscription "delivery".

@JonoYang Could you give it a try and see if the current addition would work for your needs in the context of the PurlDB workers?

For example, adding a Webhook from the code:

project.add_webhook_subscription(
    target_url="URL",
    trigger_on_each_run=False,
    include_summary=True,
    include_results=True,
)

Also available using the API:

data = {
    "name": "Project1",
    "webhooks": [
        {
            "target_url": "URL",
            "trigger_on_each_run": False,
            "include_summary": True,
            "include_results": True,
            "is_active": True,
        }
    ],
}

tdruez added 8 commits July 24, 2024 09:20
WebhookSubscription defines the Webhook behavior
WebhookDelivery stores historical data about deliveries

Signed-off-by: tdruez <tdruez@nexb.com>
Signed-off-by: tdruez <tdruez@nexb.com>
Signed-off-by: tdruez <tdruez@nexb.com>
Signed-off-by: tdruez <tdruez@nexb.com>
Signed-off-by: tdruez <tdruez@nexb.com>
Signed-off-by: tdruez <tdruez@nexb.com>
Signed-off-by: tdruez <tdruez@nexb.com>
Signed-off-by: tdruez <tdruez@nexb.com>
Copy link
Member

@JonoYang JonoYang left a comment

Choose a reason for hiding this comment

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

The updates look good and I'm able to use the new webhook subscriptions, but I'm running into a problem with authentication when sending the results back to purldb.


logger.info(f"Sending Webhook uuid={self.uuid}.")
try:
response = requests.post(
Copy link
Member

Choose a reason for hiding this comment

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

I am having trouble sending the project results back to purldb because the authentication token is not used here.

tdruez added 4 commits July 25, 2024 14:14
Signed-off-by: tdruez <tdruez@nexb.com>
Signed-off-by: tdruez <tdruez@nexb.com>
Signed-off-by: tdruez <tdruez@nexb.com>
Signed-off-by: tdruez <tdruez@nexb.com>
@tdruez tdruez merged commit 0654894 into main Jul 25, 2024
9 checks passed
@tdruez tdruez deleted the 1325-webhooks-trigger branch July 25, 2024 12:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants