[ML] New Platform server shim: update recognize modules routes to use new platform router#57206
Conversation
|
Pinging @elastic/ml-ui (:ml) |
There was a problem hiding this comment.
I think it would be a good idea to name this this.callAsCurrentUser to be consistent with the other updated route models
There was a problem hiding this comment.
What do you think about moving this to a schema file to be consistent with the other converted routes?
There are also enough schema files in the new_platform directory that I think it warrants creating a schemas dir in there. I'm happy to do that part but would be good to get these body schemas in a separate file.
There was a problem hiding this comment.
Wouldn't some of these types be string?
There was a problem hiding this comment.
It actually might be worth checking that this.savedObjectsClient exists here instead of using non-null assertion here. Even though right now loadIndexPatterns is only used after savedObjectsClient has been set this check would guard against any future updates/additions to this class that might try to use this method differently.
There was a problem hiding this comment.
I believe it should be passed to the constructor, not the method. In that case, no check is required. I just wanted to avoid any code changes in this PR, but probably it worth a small refactoring.
There was a problem hiding this comment.
As mentioned above, might be worth checking that savedObjectsClient has been set.
There was a problem hiding this comment.
I'm not familiar with this - why is it needed?
There was a problem hiding this comment.
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html#const-assertions
But I added const assertion here by mistake, will remove
There was a problem hiding this comment.
Would be good to know what is being ignored here - to be consistent
There was a problem hiding this comment.
For some reason, the issue is numeral from @elastic/numeral. It complains that value prop does not exist.
There was a problem hiding this comment.
i'm unsure about using getSavedObjectsClient here as it uses the elevated internal user to create the saved object repository which could be a security risk.
The original version used the getSavedObjectsClient from the request which I imagine had the current user's level of privileges.
I'm unsure about this and I think is worth investigating.
Also, I didn't realise that the savedObjects being passed to the router are of the type SavedObjectsLegacyService.
I wonder if it's possible to use the non-legacy version of the saved objects client in our plugin right now, before we move it to the new platform proper.
There was a problem hiding this comment.
Agreed 🤔 I think we should be to use NP's context.core.savedObjects.client which is meant to replace request.getSavedObjectsClient (https://github.com/elastic/kibana/blob/master/src/core/MIGRATION.md#server-side)
Since context is scoped like the previously used legacy request this should give us the same behavior, I'd think.
There was a problem hiding this comment.
prefix should be optional.
See documentation here:
https://github.com/elastic/ml-team/blob/master/ui/rest_api/modules/modules_api_setup.md
1f975d4 to
63ea75b
Compare
jgowdyelastic
left a comment
There was a problem hiding this comment.
One small change needed, but otherwise LGTM
| export const setupModuleBodySchema = schema.object({ | ||
| prefix: schema.maybe(schema.string()), | ||
| groups: schema.maybe(schema.arrayOf(schema.string())), | ||
| indexPatternName: schema.string(), |
There was a problem hiding this comment.
indexPatternName needs to be optional
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
… new platform router (elastic#57206) * [ML] modules with NP router * [ML] use extendedRouteInitializationDeps * [ML] add apidoc annotations * [ML] address PR comments * [ML] convert data_recognizer test to jest * [ML] optional indexPatternName
* master: (27 commits) Include actions new platform plugin for codeowners (elastic#57252) [APM][docs] 7.6 documentation updates (elastic#57124) Expressions refactor (elastic#54342) [ML] New Platform server shim: update annotation routes to use new platform router (elastic#57067) Remove injected ui app vars from Canvas (elastic#56190) update max_anomaly_score route schema to handle possible undefined values (elastic#57339) [Add panel flyout] Moving create new to the top of SavedObjectFinder (elastic#56428) Add mock of a legacy ui api to re-enable Canvas storybook (elastic#56673) [monitoring] Removes noisy event received log (elastic#57275) Remove use of copied MANAGEMENT_BREADCRUMBS and use `setBreadcrumbs` from management section's mount (elastic#57324) Advanced Settings management app to kibana platform plugin (elastic#56931) [ML] New Platform server shim: update recognize modules routes to use new platform router (elastic#57206) [ML] Fix overall stats for saved search on the Data Visualizer page (elastic#57312) [ML] [NP] Removing ui imports (elastic#56358) [SIEM] Fixes failing Cypress tests (elastic#57202) Create observability CODEOWNERS reference (elastic#57109) fix results service schema (elastic#57217) don't register a wrapper if browser side function exists. (elastic#57196) Ui Actions explorer example (elastic#57006) Fix update alert API to still work when AAD is out of sync (elastic#57039) ...
Summary
Part of #49743. Updates recognize module routes to use the new platform router.
Checklist