-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ML] New Platform server shim: update annotation routes to use new platform router #57067
Merged
alvarezmelissa87
merged 5 commits into
elastic:master
from
alvarezmelissa87:ml-new-platform-annotation-routes
Feb 11, 2020
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
da77d5f
update annotation routes to use NP router
alvarezmelissa87 b44ced4
create ts file for feature check
alvarezmelissa87 f65d53f
update schema to allow null value for earliest/latestMs
alvarezmelissa87 8ec7007
update annotations model test
alvarezmelissa87 8a9892a
use NP security plugin to access user info
alvarezmelissa87 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
x-pack/legacy/plugins/ml/server/lib/check_annotations/index.d.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { IScopedClusterClient } from 'src/core/server'; | ||
|
||
export function isAnnotationsFeatureAvailable( | ||
callAsCurrentUser: IScopedClusterClient['callAsCurrentUser'] | ||
): boolean; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
x-pack/legacy/plugins/ml/server/new_platform/annotations_schema.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { schema } from '@kbn/config-schema'; | ||
|
||
export const indexAnnotationSchema = { | ||
timestamp: schema.number(), | ||
end_timestamp: schema.number(), | ||
annotation: schema.string(), | ||
job_id: schema.string(), | ||
type: schema.string(), | ||
create_time: schema.maybe(schema.number()), | ||
create_username: schema.maybe(schema.string()), | ||
modified_time: schema.maybe(schema.number()), | ||
modified_username: schema.maybe(schema.string()), | ||
_id: schema.maybe(schema.string()), | ||
key: schema.maybe(schema.string()), | ||
}; | ||
|
||
export const getAnnotationsSchema = { | ||
jobIds: schema.arrayOf(schema.string()), | ||
earliestMs: schema.oneOf([schema.nullable(schema.number()), schema.maybe(schema.number())]), | ||
latestMs: schema.oneOf([schema.nullable(schema.number()), schema.maybe(schema.number())]), | ||
maxAnnotations: schema.number(), | ||
}; | ||
|
||
export const deleteAnnotationSchema = { annotationId: schema.string() }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we work around this in another way? The styleguide says to avoid non-null assertions https://github.com/elastic/kibana/blob/master/STYLEGUIDE.md#avoid-non-null-assertions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, this has been bothering me too in the recent NP work.
Does
ml
need to be optional in ourRequestHandlerContext
interface? especially as we're asserting that it isn't optional in every route.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding
ml
to theRequestHandlerContext
interface was initially made optional to prevent issues with other plugins usingRequestHandlerContext
. This was the suggested definition from kibana-platform.Had a chat with Josh about this and looks like they'll be improving this by adding a generic type arg to
core.http.createRouter
so you can specify your own type forRequestHandlerContext
. The PR should be up soon. Then we'll be able to get rid of the non-null assertions. 🙌So we're stuck with this for now but once that PR is in we can add the change in the next routes PR 👌