oncall-engine/engine/apps/webhooks/presets/simple.py
Michael Derynck 60ef4348f5
Allow OnCall API to use Grafana Service Accounts (#3189)
# What this PR does
Allows public OnCall API to use Grafana service accounts for
authorization. In cloud requests using a Grafana service account token
also needs to provide headers for `X-Grafana-Org-Slug` and
`X-Grafana-Instance-Slug`

This is **alpha** functionality, it may break or be removed in the
future. Going to use this on one endpoint (resolution notes) before we
consider the implications across all of public API.

## Which issue(s) this PR fixes

## Checklist

- [x] Unit, integration, and e2e (if applicable) tests updated
- [x] Documentation added (or `pr:no public docs` PR label added if not
required)
- [x] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not
required)
2023-11-23 16:42:27 +00:00

37 lines
1.2 KiB
Python

import typing
from apps.webhooks.models import Webhook
from apps.webhooks.presets.preset import WebhookPreset, WebhookPresetMetadata
class SimpleWebhookPreset(WebhookPreset):
def _metadata(self) -> WebhookPresetMetadata:
return WebhookPresetMetadata(
id="simple_webhook",
name="Simple",
logo="webhook",
description="A simple webhook which sends the alert group data to a given URL. Triggered as an escalation step.",
controlled_fields=[
"trigger_type",
"http_method",
"integration_filter",
"headers",
"username",
"password",
"authorization_header",
"trigger_template",
"forward_all",
"data",
],
)
def override_parameters_before_save(self, webhook: Webhook):
webhook.http_method = "POST"
webhook.trigger_type = Webhook.TRIGGER_ESCALATION_STEP
webhook.forward_all = True
def override_parameters_at_runtime(self, webhook: Webhook):
pass
def get_masked_headers(self) -> typing.List[str]:
return []