Skip to content

[8.x] [ResponseOps][Rules] Allow users to create a snooze schedule for rule via API (#210584)#214566

Merged
js-jankisalvi merged 3 commits intoelastic:8.xfrom
js-jankisalvi:backport/8.x/pr-210584
Mar 14, 2025
Merged

[8.x] [ResponseOps][Rules] Allow users to create a snooze schedule for rule via API (#210584)#214566
js-jankisalvi merged 3 commits intoelastic:8.xfrom
js-jankisalvi:backport/8.x/pr-210584

Conversation

@js-jankisalvi
Copy link
Contributor

Backport

This will backport the following commits from main to 8.x:

Questions ?

Please refer to the Backport tool documentation

… via API (elastic#210584)

## Summary

Resolves first part of elastic#198783
(snooze API)
Creates a public API for adding snooze schedule to rules.
For this purpose we created new schedule schema which will be used as
standard schedule schema across rules and alerting framework.

**Note**
The code to be reviewed for public API is under `common/routes/schedule`
and inside `external` folders.
Rest of the code is just moving existing internal API route and its code
to `/internal` folders.

### Checklist

- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### How to test
- Create a rule in kibana
- Snooze that rule via new public API
```typescript
Path: https://localhost:5601/api/alerting/rule/<rule_id>/snooze_schedule
Method: POST
Body:
{
    "schedule": {
       "custom": {
         "start": "2025-02-25T18:00:00.000Z",
         "duration": "15m",
         "recurring": {
            "every": "1w",
            "onWeekDay": ["TU", "FR"],
            "occurrences": 10
         }
       }
    }
}
```
- Verify various snooze schedule scenarios are generated correctly

#### Flaky test runner:
https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/8009

### Release note
Allow users to create a snooze schedule for rule via API

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: lcawl <lcawley@elastic.co>
(cherry picked from commit 14871c3)

# Conflicts:
#	x-pack/platform/plugins/shared/alerting/tsconfig.json
#	x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group4/snooze.ts
@js-jankisalvi js-jankisalvi merged commit 979987f into elastic:8.x Mar 14, 2025
8 checks passed
@js-jankisalvi js-jankisalvi deleted the backport/8.x/pr-210584 branch March 14, 2025 21:09
@elasticmachine
Copy link
Contributor

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Unknown metric groups

ESLint disabled line counts

id before after diff
@kbn/test-suites-xpack 748 750 +2

Total ESLint disabled count

id before after diff
@kbn/test-suites-xpack 774 776 +2

History

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This PR is a backport of another PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants