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>
This commit is contained in:
Yuri Tseretyan
2024-08-09 11:40:07 -04:00
committed by GitHub
co-authored by brendamuir
parent d20510a1db
commit 1108a00668
12 changed files with 371 additions and 53 deletions
@@ -457,15 +457,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
@@ -475,6 +477,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_)
```
@@ -483,15 +493,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
@@ -501,6 +513,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_)
```
@@ -1363,10 +1383,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
@@ -1386,6 +1407,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_)
```
@@ -1452,6 +1481,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
@@ -1471,6 +1501,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_)
```
@@ -1685,10 +1723,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 %}}
@@ -1723,11 +1762,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 %}}
@@ -1737,9 +1777,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 %}}
@@ -1927,3 +1968,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 %}}