Alerting: Allow provenance disable in alerting provisioning API (#63650)

* Allow provenance None in alert rule update and rule group replace

* Allow provenance None in contact point update

* Allow updating policies to none by sending x-disable-provenance header

* Allow mute timings to disable provenance with x-disable-provenance header

* Allow disabling provenance by using x-disable-provenance header

* Add provenance helper to lower the cyclomatic complexity

* Do not downgrade provenance except un ReplaceRuleGroup

* Add function explanation and change error handling

* Add docs for x-disable-provenance changes (#66300)

* Add docs for x-disable-provenance changes

* Apply suggestions from code review

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>

* Update _index.md

---------

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>

* Update docs/sources/alerting/set-up/provision-alerting-resources/_index.md

Co-authored-by: George Robinson <george.robinson@grafana.com>

* Add error message check in tests

* Change docs

---------

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
Co-authored-by: George Robinson <george.robinson@grafana.com>
This commit is contained in:
Alex Moreno
2023-04-18 15:10:36 +02:00
committed by GitHub
parent 614427c602
commit f64a89727e
8 changed files with 157 additions and 136 deletions

View File

@ -96,9 +96,10 @@ DELETE /api/v1/provisioning/alert-rules/{UID}
#### Parameters
| Name | Source | Type | Go type | Separator | Required | Default | Description |
| ---- | ------ | ------ | -------- | --------- | :------: | ------- | -------------- |
| UID | `path` | string | `string` | | ✓ | | Alert rule UID |
| Name | Source | Type | Go type | Separator | Required | Default | Description |
| -------------------- | -------- | ------ | -------- | --------- | :------: | ------- | -------------- |
| UID | `path` | string | `string` | | ✓ | | Alert rule UID |
| X-Disable-Provenance | `header` | string | `string` | | | | |
#### All responses
@ -637,9 +638,10 @@ POST /api/v1/provisioning/contact-points
#### Parameters
| Name | Source | Type | Go type | Separator | Required | Default | Description |
| ---- | ------ | ----------------------------------------------- | ----------------------------- | --------- | :------: | ------- | ----------- |
| Body | `body` | [EmbeddedContactPoint](#embedded-contact-point) | `models.EmbeddedContactPoint` | | | | |
| Name | Source | Type | Go type | Separator | Required | Default | Description |
| -------------------- | -------- | ----------------------------------------------- | ----------------------------- | --------- | :------: | ------- | ----------- |
| X-Disable-Provenance | `header` | string | `string` | | | | |
| Body | `body` | [EmbeddedContactPoint](#embedded-contact-point) | `models.EmbeddedContactPoint` | | | | |
#### All responses
@ -678,9 +680,10 @@ POST /api/v1/provisioning/mute-timings
#### Parameters
| Name | Source | Type | Go type | Separator | Required | Default | Description |
| ---- | ------ | --------------------------------------- | ------------------------- | --------- | :------: | ------- | ----------- |
| Body | `body` | [MuteTimeInterval](#mute-time-interval) | `models.MuteTimeInterval` | | | | |
| Name | Source | Type | Go type | Separator | Required | Default | Description |
| -------------------- | -------- | --------------------------------------- | ------------------------- | --------- | :------: | ------- | ----------- |
| X-Disable-Provenance | `header` | string | `string` | | | | |
| Body | `body` | [MuteTimeInterval](#mute-time-interval) | `models.MuteTimeInterval` | | | | |
#### All responses
@ -762,11 +765,12 @@ PUT /api/v1/provisioning/folder/{FolderUID}/rule-groups/{Group}
#### Parameters
| Name | Source | Type | Go type | Separator | Required | Default | Description |
| --------- | ------ | ----------------------------------- | ----------------------- | --------- | :------: | ------- | ----------- |
| FolderUID | `path` | string | `string` | | ✓ | | |
| Group | `path` | string | `string` | | ✓ | | |
| Body | `body` | [AlertRuleGroup](#alert-rule-group) | `models.AlertRuleGroup` | | | | |
| Name | Source | Type | Go type | Separator | Required | Default | Description |
| -------------------- | -------- | ----------------------------------- | ----------------------- | --------- | :------: | ------- | ----------- |
| FolderUID | `path` | string | `string` | | ✓ | | |
| Group | `path` | string | `string` | | ✓ | | |
| X-Disable-Provenance | `header` | string | `string` | | | | |
| Body | `body` | [AlertRuleGroup](#alert-rule-group) | `models.AlertRuleGroup` | | | | |
#### All responses
@ -805,10 +809,11 @@ PUT /api/v1/provisioning/contact-points/{UID}
#### Parameters
| Name | Source | Type | Go type | Separator | Required | Default | Description |
| ---- | ------ | ----------------------------------------------- | ----------------------------- | --------- | :------: | ------- | ------------------------------------------ |
| UID | `path` | string | `string` | | ✓ | | UID is the contact point unique identifier |
| Body | `body` | [EmbeddedContactPoint](#embedded-contact-point) | `models.EmbeddedContactPoint` | | | | |
| Name | Source | Type | Go type | Separator | Required | Default | Description |
| -------------------- | -------- | ----------------------------------------------- | ----------------------------- | --------- | :------: | ------- | ------------------------------------------ |
| UID | `path` | string | `string` | | ✓ | | UID is the contact point unique identifier |
| X-Disable-Provenance | `header` | string | `string` | | | | |
| Body | `body` | [EmbeddedContactPoint](#embedded-contact-point) | `models.EmbeddedContactPoint` | | | | |
#### All responses
@ -847,10 +852,11 @@ PUT /api/v1/provisioning/mute-timings/{name}
#### Parameters
| Name | Source | Type | Go type | Separator | Required | Default | Description |
| ---- | ------ | --------------------------------------- | ------------------------- | --------- | :------: | ------- | ---------------- |
| name | `path` | string | `string` | | ✓ | | Mute timing name |
| Body | `body` | [MuteTimeInterval](#mute-time-interval) | `models.MuteTimeInterval` | | | | |
| Name | Source | Type | Go type | Separator | Required | Default | Description |
| -------------------- | -------- | --------------------------------------- | ------------------------- | --------- | :------: | ------- | ---------------- |
| name | `path` | string | `string` | | ✓ | | Mute timing name |
| X-Disable-Provenance | `header` | string | `string` | | | | |
| Body | `body` | [MuteTimeInterval](#mute-time-interval) | `models.MuteTimeInterval` | | | | |
#### All responses
@ -889,9 +895,10 @@ PUT /api/v1/provisioning/policies
#### Parameters
| Name | Source | Type | Go type | Separator | Required | Default | Description |
| ---- | ------ | --------------- | -------------- | --------- | :------: | ------- | ---------------------------------------- |
| Body | `body` | [Route](#route) | `models.Route` | | | | The new notification routing tree to use |
| Name | Source | Type | Go type | Separator | Required | Default | Description |
| -------------------- | -------- | --------------- | -------------- | --------- | :------: | ------- | ---------------------------------------- |
| X-Disable-Provenance | `header` | string | `string` | | | | |
| Body | `body` | [Route](#route) | `models.Route` | | | | The new notification routing tree to use |
#### All responses
@ -930,10 +937,11 @@ PUT /api/v1/provisioning/templates/{name}
#### Parameters
| Name | Source | Type | Go type | Separator | Required | Default | Description |
| ---- | ------ | ------------------------------------------------------------- | ------------------------------------ | --------- | :------: | ------- | ------------- |
| name | `path` | string | `string` | | ✓ | | Template Name |
| Body | `body` | [NotificationTemplateContent](#notification-template-content) | `models.NotificationTemplateContent` | | | | |
| Name | Source | Type | Go type | Separator | Required | Default | Description |
| -------------------- | -------- | ------------------------------------------------------------- | ------------------------------------ | --------- | :------: | ------- | ------------- |
| name | `path` | string | `string` | | ✓ | | Template Name |
| X-Disable-Provenance | `header` | string | `string` | | | | |
| Body | `body` | [NotificationTemplateContent](#notification-template-content) | `models.NotificationTemplateContent` | | | | |
#### All responses