-
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
[data views] Use versioned router for REST routes #158608
Conversation
Pinging @elastic/kibana-data-discovery (Team:DataDiscovery) |
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.
Looking good! Have some questions about the scope:
Is it required or not to pass INITIAL_REST_VERSION
or 1
where that API is called?
Is it required or not to type API responses?
src/plugins/data_views/server/rest_api_routes/default_data_view.ts
Outdated
Show resolved
Hide resolved
{ | ||
path, | ||
validate: {}, | ||
version: '1', // INITIAL_REST_VERSION, |
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.
version: '1', // INITIAL_REST_VERSION, | |
version: '1', |
@@ -38,6 +38,8 @@ export const parseFields = (fields: string | string[]): string[] => { | |||
}; | |||
|
|||
const path = '/api/index_patterns/_fields_for_wildcard'; | |||
const version = '1'; | |||
const access = 'internal'; |
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.
Is it okay to keep /api
in the path if it's an internal 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.
I think ideally all internal routes should be prefixed with /internal
, but I don't think we included this one in the audit either.
cc @thomasneirynck looks like /api/index_patterns/_fields_for_wildcard
is another candidate for making internal.
…ana into data_views_versioned_router
…w.ts Co-authored-by: Julia Rechkunova <[email protected]>
…ana into data_views_versioned_router
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.
timeSeriesDimension: schema.maybe(schema.boolean()), | ||
}); | ||
|
||
const validate: FullValidationConfig<any, any, any> = { |
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.
Just curious what the types marked any
are for?
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.
export interface RouteValidatorConfig<P, Q, B> {
/**
* Validation logic for the URL params
* @public
*/
params?: RouteValidationSpec<P>;
/**
* Validation logic for the Query params
* @public
*/
query?: RouteValidationSpec<Q>;
/**
* Validation logic for the body payload
* @public
*/
body?: RouteValidationSpec<B>;
}
...I could probably do a better job using these
@davismcphee I must have fixed those and then unfixed them. At any rate, they should be working now. One item -
The problem is a lack of |
@@ -41,21 +41,6 @@ export default function ({ getService }: FtrProviderContext) { | |||
|
|||
expect(response4.status).to.be(404); | |||
}); |
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 removed this test because there was a weird relationship between it at and the versioned router. The versioned router would provide a weird message even though the task completed successfully and this is the circumstance under which this test would pass. Now the api returns no body and I'm no longer testing for its emptiness - which wasn't registering as emptiness in this test for some reason.
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.
What was it registering as instead?
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.
res.ok()
on the sender side results in an empty object for the body
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.
@davismcphee I must have fixed those and then unfixed them. At any rate, they should be working now. One item -
Tested again and looks like the issues are fixed now 👍 thanks! Just a couple of questions to answer first, then this will be good to merge on my end.
And the update runtime field endpoint returns 400:
The problem is a lack of
type
value. As best I can tell that poor error message is a bug in the schema validation error messages. Supply"type": "keyword",
and it should work.
Yup, looks like that fixed it, thanks! Although the docs I pulled this example from show an update without the type
prop: https://www.elastic.co/guide/en/kibana/master/data-views-runtime-field-api-update.html#data-views-runtime-field-update-example. Is it the docs that are wrong and need to be updated or did we used to allow updates without specifying the type
?
@@ -41,21 +41,6 @@ export default function ({ getService }: FtrProviderContext) { | |||
|
|||
expect(response4.status).to.be(404); | |||
}); |
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.
What was it registering as instead?
An empty object - I restored the test and it now checks for an empty object instead of an empty value. |
@davismcphee You're right and the docs are right - I added validation that didn't allow updating a runtime field without specifying the type. I'll address this. |
💚 Build Succeeded
Metrics [docs]Page load bundle
Unknown metric groupsAPI count
ESLint disabled in files
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @mattkime |
@davismcphee I added a test for partial runtime field updates and fixed the corresponding schema issues. |
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.
Latest code changes look good and the update runtime field endpoint works without type
now. Thanks for updating/adding tests too! LGTM 👍
* main: (199 commits) [Lens] Add custom formatter within the Lens editor (elastic#158468) [Uptime] Hide app if no data is available (elastic#159118) [CodeEditor] Add grok highlighting (elastic#159334) Expose decoded cloudId components from the cloud plugin's contract (elastic#159442) [Profiling] Use collector and symbolizer integrations in the add data page (elastic#159481) [Infrastructure UI] Hosts View: Unified Search bar with auto-refresh enabled (elastic#157011) [APM] Add feature flag for not available apm schema (elastic#158911) [Lens] Remove deprecated componentWillReceiveProps usage (elastic#159502) [api-docs] 2023-06-13 Daily api_docs build (elastic#159536) [data views] Use versioned router for REST routes (elastic#158608) [maps] fix geo line source not loaded unless maps application is opened (elastic#159432) [Enterprise Search][Search application]Fix Create Api key url (elastic#159519) [Security Solution] Increase timeout for indexing hosts (elastic#159518) dashboard Reset button disable (elastic#159430) [Security Solution] Unskip Endpoint API tests after package fix (elastic#159484) [Synthetics] adjust alert timing (elastic#159511) [ResponseOps][rule registry] Remove usages of `refresh: true` (elastic#159252) Revert "Remove unused package (elastic#158597)" [Serverless] Adding config to disable authentication on task manager background worker utilization API (elastic#159505) Remove unused package (elastic#158597) ...
Summary
Version alllll the data view routes.
Best viewed with whitespace hidden - https://github.com/elastic/kibana/pull/158608/files?diff=unified&w=1
In this PR:
response
types, separate from internal api types. This is to help prevent unacknowledged changes to the api.For follow up PRs:
internal
path for internal routesfields_for_wildcard
filterCloses #157099
Closes #157100