[ResponseOps][MaintenanceWindow] Public maintenance window API#216756
[ResponseOps][MaintenanceWindow] Public maintenance window API#216756
Conversation
Closes #208882 Closes #208879 Closes #208880 This PR introduces 3 new public APIs for the maintenance window. GET, POST, and DELETE maintenance window. **Please consider the following while reviewing the PR:** - I wanted the first PR to be just `GET` but that wasn't enough to have functional tests. This is why I also added POST and DELETE. - **This branch is being merged into a feature branch**. It will allow for small changes in the schema until all APIs are done. - The PR has many changes but most relate to the existing internal API, which was moved to `/internal`. Those files don't need to be reviewed. - The `schedule` schema is being developed in a separate PR. Some changes will come **after** this PR. The places that need to be changed have been tagged with `// TODO schedule schema`. - Route locations: - `alerting/server/routes/maintenance_window/apis/external/get/` - `alerting/server/routes/maintenance_window/apis/external/create/` - `alerting/server/routes/maintenance_window/apis/external/delete/` - Transforms: - `alerting/server/routes/maintenance_window/apis/external/common/transforms/` - there are also route-specific transforms inside `alerting/server/routes/maintenance_window/apis/external/*` - Schemas: - `alerting/common/routes/maintenance_window/external/apis/get/schemas/` - `alerting/common/routes/maintenance_window/external/apis/create/schemas/` - `alerting/common/routes/maintenance_window/external/apis/delete/schemas/` - `alerting/common/routes/maintenance_window/external/response/schemas/` - Types: - `alerting/common/routes/maintenance_window/external/apis/get/types/` - `alerting/common/routes/maintenance_window/external/apis/create/types/` - `alerting/common/routes/maintenance_window/external/apis/delete/types/` - `alerting/common/routes/maintenance_window/external/response/types/` - Functional tests: - `x-pack/test/alerting_api_integration/security_and_spaces/group3/tests/maintenance_window/external/` --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Closes #211181 ## Summary This PR introduces a public API for archiving maintenance windows. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
…ance Window public APIs (#214747) Merging into a feature branch. ## Summary - Add the newly created custom schedule schema to `createMaintenanceWindowRequestBodySchema` and `maintenanceWindowResponseSchema`. - Update `transformInternalMaintenanceWindowToExternal`. - Update `transformCreateBody`. - Update tests. ## Testing The API URL is: - `https://localhost:5601/api/alerting/maintenance_window` Here is an example request for creating a maintenance window in Postman: ``` { "title": "test-maintenance-window", "schedule": { "custom": { "duration": "1d", "start": "1992-01-01T05:00:00.200Z", "recurring": { "every": "10d", "onWeekDay": ["MO", "FR"] } } }, "scope": { "alerting": { "query": { "kql": "_id: '1234'" } } } } ```
Closes #208881 ## Merging into a feature branch ## Summary Public PATCH maintenance window API. - Partial updates. - `category_id` is not updated. - The validation in the maintenance window client that requires scoped queries to be sent with a `category_id`, has been removed. ## Testing A Maintenance window has first to be created. It can be done via the UI or the new public API. The API URL is: - `https://localhost:5601/api/alerting/maintenance_window` Here is an example request for **creating** a maintenance window in Postman: ``` { "title": "test-maintenance-window", "schedule": { "custom": { "duration": "1d", "start": "1992-01-01T05:00:00.200Z", "recurring": { "every": "10d", "onWeekDay": ["MO", "FR"] } } }, "scope": { "alerting": { "query": { "kql": "_id: '1234'" } } } } ``` The maintenance window can now be updated by sending a patch request to the same URL with the maintenance window ID appended to it. - PATCH to `https://localhost:5601/api/alerting/maintenance_window/<MW_ID>` The request body is the same as for the POST request. The only difference is every field is now optional.
|
Pinging @elastic/response-ops (Team:ResponseOps) |
cnasikas
left a comment
There was a problem hiding this comment.
Great work 🚀 ! LGTM! I left some minor comments. Also:
-
The public routes do not have any tag like we have for alerting. Should we add
tags: ['oas-tag:maintenance_window']? @lcawl Wdyt? We want a dedicated category, outside of alerting, for the new public Maintenance Window APIs/ -
Some routes are missing the
400in the response. Should we add it? -
A disabled MW is shown as running in the UI. Unrelated to the PR. Could you please create an issue and link it to the MW GA meta issue?
-
If I set
everymore that1dtheonWeekDay(day selection) is not shown in the UI. Unrelated to the PR. Could you please create an issue and link it to the MW GA meta issue? -
If I create a MW from the UI I can get: "duration": "2.0208333333333335d". Unrelated to the PR. Could you please create an issue to always return an integer (to the first unit that you can do it) and link it to the MW GA meta issue?
-
From the UI I can create a MW with
duration>everybut from the APIs I cannot. I remember deciding that but could you please remind me why?
.../plugins/shared/alerting/common/routes/maintenance_window/external/apis/create/schemas/v1.ts
Outdated
Show resolved
Hide resolved
.../plugins/shared/alerting/common/routes/maintenance_window/external/apis/update/schemas/v1.ts
Outdated
Show resolved
Hide resolved
...orm/plugins/shared/alerting/common/routes/maintenance_window/external/response/schemas/v1.ts
Outdated
Show resolved
Hide resolved
...ver/routes/maintenance_window/apis/external/archive/archive_maintenance_window_route.test.ts
Outdated
Show resolved
Hide resolved
...ing/server/routes/maintenance_window/apis/external/create/create_maintenance_window_route.ts
Outdated
Show resolved
Hide resolved
...d/alerting/server/routes/maintenance_window/apis/external/update/transform_update_body/v1.ts
Outdated
Show resolved
Hide resolved
...ing/server/routes/maintenance_window/apis/external/update/update_maintenance_window_route.ts
Outdated
Show resolved
Hide resolved
...n/security_and_spaces/group3/tests/maintenance_window/external/archive_maintenance_window.ts
Show resolved
Hide resolved
...security_and_spaces/group3/tests/maintenance_window/external/unarchive_maintenance_window.ts
Show resolved
Hide resolved
...security_and_spaces/group3/tests/maintenance_window/external/unarchive_maintenance_window.ts
Show resolved
Hide resolved
|
Thanks for the review @cnasikas 👍
We can wait for lisa's comment but I added the tags anyway for now. It seems like a reasonable suggestion.
Added.
Maybe @js-jankisalvi can chip in here? The API validation comes from the custom schedule. |
This is because creating MW from UI still uses internal api |
lcawl
left a comment
There was a problem hiding this comment.
Thanks for adding the oas-tag, it is indeed necessary for that info to show up properly in the docs.
IMO in addition to the operation summary, an operation description will ultimately be necsesary for the "archive" and "unarchive" endpoints, since it's not obvious what that accomplishes.
...g/server/routes/maintenance_window/apis/external/archive/archive_maintenance_window_route.ts
Outdated
Show resolved
Hide resolved
...ver/routes/maintenance_window/apis/external/archive/archive_maintenance_window_route.test.ts
Outdated
Show resolved
Hide resolved
...erver/routes/maintenance_window/apis/external/delete/delete_maintenance_window_route.test.ts
Outdated
Show resolved
Hide resolved
...ing/server/routes/maintenance_window/apis/external/delete/delete_maintenance_window_route.ts
Outdated
Show resolved
Hide resolved
...ting/server/routes/maintenance_window/apis/external/get/get_maintenance_window_route.test.ts
Outdated
Show resolved
Hide resolved
.../alerting/server/routes/maintenance_window/apis/external/get/get_maintenance_window_route.ts
Outdated
Show resolved
Hide resolved
...routes/maintenance_window/apis/external/unarchive/unarchive_maintenance_window_route.test.ts
Outdated
Show resolved
Hide resolved
...rver/routes/maintenance_window/apis/external/unarchive/unarchive_maintenance_window_route.ts
Outdated
Show resolved
Hide resolved
|
/ci |
### Merging into a feature branch ## Summary I recently added a few public routes for managing maintenance windows. I will need to generate documentation for these routes for my' on week' task. - Updated `capture_oas_snapshot` to include `/api/alerting/maintenance_window` - Added `tags` to the maintenance window routes --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: lcawl <lcawley@elastic.co>
💔 Build Failed
Failed CI StepsTest Failures
Metrics [docs]Public APIs missing comments
Page load bundle
Unknown metric groupsAPI count
ESLint disabled line counts
Total ESLint disabled count
History
cc @adcoelho |
|
Starting backport for target branches: 8.x |
💔 All backports failed
Manual backportTo create the backport manually run: Questions ?Please refer to the Backport tool documentation |
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
…ic#216756) Closes elastic#198685 ## Summary This PR creates a public Maintenance Window API. The work was done on a feature branch over multiple separate PRs. Here we will merge the feature branch into `main`. - elastic#209734 - elastic#213694 - elastic#214747 - elastic#213771 The [documentation PR](elastic#212377) still needs to be merged. ## Release Notes Publish new public APIs for the Maintenance Window. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: lcawl <lcawley@elastic.co> (cherry picked from commit 08d0717) # Conflicts: # .buildkite/scripts/steps/checks/capture_oas_snapshot.sh # oas_docs/overlays/kibana.overlays.shared.yaml
…#216756) (#218532) # Backport This will backport the following commits from `main` to `8.19`: - [[ResponseOps][MaintenanceWindow] Public maintenance window API (#216756)](#216756) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Antonio","email":"antonio.coelho@elastic.co"},"sourceCommit":{"committedDate":"2025-04-16T09:39:38Z","message":"[ResponseOps][MaintenanceWindow] Public maintenance window API (#216756)\n\nCloses #198685\n\n## Summary\n\nThis PR creates a public Maintenance Window API.\n\nThe work was done on a feature branch over multiple separate PRs. Here\nwe will merge the feature branch into `main`.\n- https://github.com/elastic/kibana/pull/209734\n- https://github.com/elastic/kibana/pull/213694\n- https://github.com/elastic/kibana/pull/214747\n- https://github.com/elastic/kibana/pull/213771\n\nThe [documentation PR](https://github.com/elastic/kibana/pull/212377)\nstill needs to be merged.\n\n## Release Notes\n\nPublish new public APIs for the Maintenance Window.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: lcawl <lcawley@elastic.co>","sha":"08d0717d46dbe2896d13de728c6fdf519a93e4d8","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:ResponseOps","release_note:feature","backport:version","v9.1.0","v8.19.0"],"title":"[ResponseOps][MaintenanceWindow] Public maintenance window API","number":216756,"url":"https://github.com/elastic/kibana/pull/216756","mergeCommit":{"message":"[ResponseOps][MaintenanceWindow] Public maintenance window API (#216756)\n\nCloses #198685\n\n## Summary\n\nThis PR creates a public Maintenance Window API.\n\nThe work was done on a feature branch over multiple separate PRs. Here\nwe will merge the feature branch into `main`.\n- https://github.com/elastic/kibana/pull/209734\n- https://github.com/elastic/kibana/pull/213694\n- https://github.com/elastic/kibana/pull/214747\n- https://github.com/elastic/kibana/pull/213771\n\nThe [documentation PR](https://github.com/elastic/kibana/pull/212377)\nstill needs to be merged.\n\n## Release Notes\n\nPublish new public APIs for the Maintenance Window.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: lcawl <lcawley@elastic.co>","sha":"08d0717d46dbe2896d13de728c6fdf519a93e4d8"}},"sourceBranch":"main","suggestedTargetBranches":["8.19"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/216756","number":216756,"mergeCommit":{"message":"[ResponseOps][MaintenanceWindow] Public maintenance window API (#216756)\n\nCloses #198685\n\n## Summary\n\nThis PR creates a public Maintenance Window API.\n\nThe work was done on a feature branch over multiple separate PRs. Here\nwe will merge the feature branch into `main`.\n- https://github.com/elastic/kibana/pull/209734\n- https://github.com/elastic/kibana/pull/213694\n- https://github.com/elastic/kibana/pull/214747\n- https://github.com/elastic/kibana/pull/213771\n\nThe [documentation PR](https://github.com/elastic/kibana/pull/212377)\nstill needs to be merged.\n\n## Release Notes\n\nPublish new public APIs for the Maintenance Window.\n\n---------\n\nCo-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>\nCo-authored-by: lcawl <lcawley@elastic.co>","sha":"08d0717d46dbe2896d13de728c6fdf519a93e4d8"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
…ic#216756) Closes elastic#198685 ## Summary This PR creates a public Maintenance Window API. The work was done on a feature branch over multiple separate PRs. Here we will merge the feature branch into `main`. - elastic#209734 - elastic#213694 - elastic#214747 - elastic#213771 The [documentation PR](elastic#212377) still needs to be merged. ## Release Notes Publish new public APIs for the Maintenance Window. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: lcawl <lcawley@elastic.co>
Closes #198685
Summary
This PR creates a public Maintenance Window API.
The work was done on a feature branch over multiple separate PRs. Here we will merge the feature branch into
main.The documentation PR still needs to be merged.
Release Notes
Publish new public APIs for the Maintenance Window.