[v11.2.x] Alerting: Support for optimistic concurrency in priovisioning Tempate API (#92251)

Alerting: Support for optimistic concurrency in priovisioning Tempate API (#91195)

* support optimistic concurrency in template service

* update request handler to get version from query parameter

* return not found if a new template is set with version

* update PUT api to set version

* update documentation + for mute timings

---------

Co-authored-by: brendamuir <100768211+brendamuir@users.noreply.github.com>
(cherry picked from commit 1108a00668)

Co-authored-by: Yuri Tseretyan <yuriy.tseretyan@grafana.com>
This commit is contained in:
grafana-delivery-bot[bot]
2024-08-21 17:54:28 -04:00
committed by GitHub
co-authored by Yuri Tseretyan
parent 0c1d03e21a
commit 25c9b9d58e
12 changed files with 371 additions and 53 deletions
@@ -461,15 +461,17 @@ DELETE /api/v1/provisioning/mute-timings/:name
#### Parameters
| Name | Source | Type | Go type | Separator | Required | Default | Description |
| ---- | ------ | ------ | -------- | --------- | :------: | ------- | ---------------- |
| name | `path` | string | `string` | | ✓ | | Mute timing name |
| Name | Source | Type | Go type | Separator | Required | Default | Description |
| ------- | ------- | ------ | -------- | --------- | :------: | ------- | ------------------------------------------------------------------------------------------------------------- |
| name | `path` | string | `string` | | ✓ | | Mute timing name |
| version | `query` | string | `string` | | | | Current version of the resource. Used for optimistic concurrency validation. Keep empty to bypass validation. |
#### All responses
| Code | Status | Description | Has headers | Schema |
| ------------------------------------ | ---------- | ----------------------------------------- | :---------: | ---------------------------------------------- |
| [204](#route-delete-mute-timing-204) | No Content | The mute timing was deleted successfully. | | [schema](#route-delete-mute-timing-204-schema) |
| [409](#route-delete-mute-timing-409) | Conflict | GenericPublicError | | [schema](#route-delete-mute-timing-409-schema) |
#### Responses
@@ -479,6 +481,14 @@ Status: No Content
###### <span id="route-delete-mute-timing-204-schema"></span> Schema
##### <span id="route-delete-mute-timing-409"></span> 409 - Conflict
Status: Conflict
###### <span id="route-delete-mute-timing-409-schema"></span> Schema
[GenericPublicError](#generic-public-error)
### <span id="route-delete-template"></span> Delete a template. (_RouteDeleteTemplate_)
```
@@ -487,15 +497,17 @@ DELETE /api/v1/provisioning/templates/:name
#### Parameters
| Name | Source | Type | Go type | Separator | Required | Default | Description |
| ---- | ------ | ------ | -------- | --------- | :------: | ------- | ------------- |
| name | `path` | string | `string` | | ✓ | | Template Name |
| Name | Source | Type | Go type | Separator | Required | Default | Description |
| ------- | ------- | ------ | -------- | --------- | :------: | ------- | ------------------------------------------------------------------------------------------------------------- |
| name | `path` | string | `string` | | ✓ | | Template Name |
| version | `query` | string | `string` | | | | Current version of the resource. Used for optimistic concurrency validation. Keep empty to bypass validation. |
#### All responses
| Code | Status | Description | Has headers | Schema |
| --------------------------------- | ---------- | -------------------------------------- | :---------: | ------------------------------------------- |
| [204](#route-delete-template-204) | No Content | The template was deleted successfully. | | [schema](#route-delete-template-204-schema) |
| [409](#route-delete-template-409) | Conflict | GenericPublicError | | [schema](#route-delete-template-409-schema) |
#### Responses
@@ -505,6 +517,14 @@ Status: No Content
###### <span id="route-delete-template-204-schema"></span> Schema
##### <span id="route-delete-template-409"></span> 409 - Conflict
Status: Conflict
###### <span id="route-delete-template-409-schema"></span> Schema
[GenericPublicError](#generic-public-error)
### <span id="route-get-alert-rule"></span> Get a specific alert rule by UID. (_RouteGetAlertRule_)
```
@@ -1367,10 +1387,11 @@ PUT /api/v1/provisioning/mute-timings/:name
#### All responses
| Code | Status | Description | Has headers | Schema |
| --------------------------------- | ----------- | ---------------- | :---------: | ------------------------------------------- |
| [200](#route-put-mute-timing-200) | OK | MuteTimeInterval | | [schema](#route-put-mute-timing-200-schema) |
| [400](#route-put-mute-timing-400) | Bad Request | ValidationError | | [schema](#route-put-mute-timing-400-schema) |
| Code | Status | Description | Has headers | Schema |
| --------------------------------- | ----------- | ------------------ | :---------: | ------------------------------------------- |
| [200](#route-put-mute-timing-200) | OK | MuteTimeInterval | | [schema](#route-put-mute-timing-200-schema) |
| [400](#route-put-mute-timing-400) | Bad Request | ValidationError | | [schema](#route-put-mute-timing-400-schema) |
| [409](#route-put-mute-timing-409) | Conflict | GenericPublicError | | [schema](#route-put-mute-timing-409-schema) |
#### Responses
@@ -1390,6 +1411,14 @@ Status: Bad Request
[ValidationError](#validation-error)
##### <span id="route-put-mute-timing-409"></span> 409 - Conflict
Status: Conflict
###### <span id="route-put-mute-timing-409-schema"></span> Schema
[GenericPublicError](#generic-public-error)
### <span id="route-put-policy-tree"></span> Sets the notification policy tree. (_RoutePutPolicyTree_)
```
@@ -1456,6 +1485,7 @@ PUT /api/v1/provisioning/templates/:name
| ------------------------------ | ----------- | -------------------- | :---------: | ---------------------------------------- |
| [202](#route-put-template-202) | Accepted | NotificationTemplate | | [schema](#route-put-template-202-schema) |
| [400](#route-put-template-400) | Bad Request | ValidationError | | [schema](#route-put-template-400-schema) |
| [409](#route-put-template-409) | Conflict | GenericPublicError | | [schema](#route-put-template-409-schema) |
#### Responses
@@ -1475,6 +1505,14 @@ Status: Bad Request
[ValidationError](#validation-error)
##### <span id="route-put-template-409"></span> 409 - Conflict
Status: Conflict
###### <span id="route-put-template-409-schema"></span> Schema
[GenericPublicError](#generic-public-error)
### <span id="route-reset-policy-tree"></span> Clears the notification policy tree. (_RouteResetPolicyTree_)
```
@@ -1689,10 +1727,11 @@ Status: Accepted
{{% responsive-table %}}
| Name | Type | Go type | Required | Default | Description | Example |
| -------------- | -------------------------------- | ----------------- | :------: | ------- | ----------- | ------- |
| name | string | `string` | | | | |
| time_intervals | [][TimeInterval](#time-interval) | `[]*TimeInterval` | | | | |
| Name | Type | Go type | Required | Default | Description | Example |
| -------------- | -------------------------------- | ----------------- | :------: | ------- | ------------------- | ------- |
| name | string | `string` | | | | |
| time_intervals | [][TimeInterval](#time-interval) | `[]*TimeInterval` | | | | |
| version | string | `string` | | | Version of resource | |
{{% /responsive-table %}}
@@ -1727,11 +1766,12 @@ Status: Accepted
{{% responsive-table %}}
| Name | Type | Go type | Required | Default | Description | Example |
| ---------- | ------------------------- | ------------ | :------: | ------- | ----------- | ------- |
| name | string | `string` | | | | |
| provenance | [Provenance](#provenance) | `Provenance` | | | | |
| template | string | `string` | | | | |
| Name | Type | Go type | Required | Default | Description | Example |
| ---------- | ------------------------- | ------------ | :------: | ------- | ------------------- | ------- |
| name | string | `string` | | | | |
| provenance | [Provenance](#provenance) | `Provenance` | | | | |
| template | string | `string` | | | | |
| version | string | `string` | | | Version of resource | |
{{% /responsive-table %}}
@@ -1741,9 +1781,10 @@ Status: Accepted
{{% responsive-table %}}
| Name | Type | Go type | Required | Default | Description | Example |
| -------- | ------ | -------- | :------: | ------- | ----------- | ------- |
| template | string | `string` | | | | |
| Name | Type | Go type | Required | Default | Description | Example |
| -------- | ------ | -------- | :------: | ------- | ------------------------------------------------------- | ------- |
| template | string | `string` | | | | |
| version | string | `string` | | | Version of resource. Should be empty for new templates. | |
{{% /responsive-table %}}
@@ -1931,3 +1972,18 @@ Status: Accepted
| msg | string | `string` | | | | `error message` |
{{% /responsive-table %}}
### <span id="generic-public-error"></span> GenericPublicError
**Properties**
{{% responsive-table %}}
| Name | Type | Go type | Required | Default | Description | Example |
| ---------- | ---------- | ---------------- | :------: | ------- | ------------------------------------------------------------------------ | ------- |
| statusCode | string | `string` | ✓ | | HTTP Status Code | |
| messageId | string | `string` | ✓ | | Unique code of the error | |
| message | string | `string` | | | Error message | |
| extra | map of any | `map[string]any` | | | Extra information about the error. Format is specific to the error code. | |
{{% /responsive-table %}}