kibana/packages/kbn-check-mappings-update-cli
Mykola Harmash b50f5387fc
[Infra] Add endpoints to manage Custom Dashboards (#176612)
Closes https://github.com/elastic/kibana/issues/176069

## Summary

This adds the logic to register a new Saved Object type to store custom
dashboards for Asset Details and adds endpoints to fetch and save custom
dashboards.

Changes highlights:
* Renamed the `enableInfrastructureHostsCustomDashboards` to
`enableInfrastructureAssetCustomDashboards` to make it more generic and
support additional asset types in the future
* Added a new Saved Object type
* Moved initialization of all Infra endpoints to plugin's `start`. This
one one of the points on [the BE tech debt
ticket](https://github.com/elastic/kibana/issues/175975). Having
endpoint initialization in `start` makes it more convenient to access
start dependencies which almost all endpoints require.
* Added `savedObjectClient` and `uiSettingsClient` to the custom request
context (also one of the ideas for endpoints improvement). Right now
infra endpoints use custom `libs` object with all dependencies required
for routes, the idea is to rely on the request context instead because
it automatically available for every route handler and by default
includes some useful things like scoped service clients.
* Added a wrapper `handleRouteErrors` to avoid error handling
duplication which we now have in a few routes. In the future we could do
something similar right within `registerRoutes` framework function, but
this would require a bit of refactoring.

## Hot to Test

1. Toggle the UI setting off in Advanced Settings
![CleanShot 2024-02-13 at 16 01
36@2x](fc3772a1-a075-42bd-bdc3-2c7e83278844)
2. Go to the Dev Tools and try the endpoints, both should respond with
403
```
GET kbn:api/infra/custom-dashboards/host

POST kbn:api/infra/custom-dashboards
{
  "assetType": "host",
  "dashboardIdList": ["0", "1"]
}
```
3. Toggle the UI setting on
4. Try the endpoints again, now they should work as expected

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2024-02-22 11:56:33 +01:00
..
src Sort printed mappings and fields in update check CLI (#176493) 2024-02-08 10:15:42 -06:00
current_fields.json [Infra] Add endpoints to manage Custom Dashboards (#176612) 2024-02-22 11:56:33 +01:00
current_mappings.json [Infra] Add endpoints to manage Custom Dashboards (#176612) 2024-02-22 11:56:33 +01:00
jest.config.js [Saved Objects] Compatible mappings PR check (#148656) 2023-04-27 15:42:31 +02:00
kibana.jsonc [Saved Objects] Compatible mappings PR check (#148656) 2023-04-27 15:42:31 +02:00
package.json [Saved Objects] Compatible mappings PR check (#148656) 2023-04-27 15:42:31 +02:00
README.md [Saved Objects] Compatible mappings PR check (#148656) 2023-04-27 15:42:31 +02:00
tsconfig.json Sort printed mappings and fields in update check CLI (#176493) 2024-02-08 10:15:42 -06:00

@kbn/check-mappings-update-cli

Saved Objects CLI tool that can be used to check whether a snapshot of current mappings (i.e., mappings on main) is compatible with mappings we can extract from the current code.

See node scripts/check_mappings_update --help for more info.