-
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
[Core] [UA] Support API Deprecations #196081
Merged
Merged
Changes from 34 commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
4b24857
finish feature
Bamieh a46da40
Merge branch 'main' of github.com:elastic/kibana into core/api-deprec…
Bamieh 0ba7595
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine fe1edbf
revert testing example
Bamieh 4642236
update i18n messages
Bamieh 98e1928
Merge branch 'core/api-deprecations' of github.com:Bamieh/kibana into…
Bamieh f6552c7
remove version example
Bamieh e4a4b21
i18n_check
Bamieh e14ff56
fix types
Bamieh 62a3a61
Merge branch 'main' of github.com:elastic/kibana into core/api-deprec…
Bamieh 96d88ef
code review changes
Bamieh cf26b2b
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine 7b003e9
finish deprecated service unit tests
Bamieh e627a21
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine 2f47efd
[CI] Auto-commit changed files from 'make api-docs && make api-docs-s…
kibanamachine 563f5cc
merge main and update types
Bamieh e34ccc1
tina code reviews
Bamieh bb3fea6
Merge branch 'core/api-deprecations' of github.com:Bamieh/kibana into…
Bamieh 309b35a
openApi spec fixes
Bamieh 2484b9a
merge main
Bamieh 098e0a8
finalize open spec
Bamieh f1dc0bb
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine 4626672
[CI] Auto-commit changed files from 'make api-docs && make api-docs-s…
kibanamachine 15eaa47
deprecated routes example
Bamieh 21653e8
Merge branch 'core/api-deprecations' of github.com:Bamieh/kibana into…
Bamieh ae0d20b
update readme
Bamieh 7d66a9f
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine 77cb2d4
fix more tests
Bamieh 72c6184
Merge branch 'core/api-deprecations' of github.com:Bamieh/kibana into…
Bamieh 0a7d698
add integration test
Bamieh ecf62ad
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 43f9a1e
add integration test
Bamieh a6e14d4
merge main
Bamieh 00c79db
Merge branch 'core/api-deprecations' of github.com:Bamieh/kibana into…
Bamieh ffda5c3
Merge branch 'main' of github.com:elastic/kibana into core/api-deprec…
Bamieh a6a0608
update integration test
Bamieh 1370c50
Merge branch 'main' of github.com:elastic/kibana into core/api-deprec…
Bamieh a1405a7
Update x-pack/plugins/upgrade_assistant/public/application/components…
Bamieh 23c5126
fix type -> replace
Bamieh 6bdb7fd
Merge branch 'core/api-deprecations' of github.com:Bamieh/kibana into…
Bamieh 2e37e03
Merge branch 'main' into core/api-deprecations
elasticmachine 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
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
17 changes: 17 additions & 0 deletions
17
examples/routing_example/server/routes/deprecated_routes/index.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,17 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import { IRouter } from '@kbn/core/server'; | ||
import { registerDeprecatedRoute } from './unversioned'; | ||
import { registerVersionedDeprecatedRoute } from './versioned'; | ||
|
||
export function registerDeprecatedRoutes(router: IRouter) { | ||
registerDeprecatedRoute(router); | ||
registerVersionedDeprecatedRoute(router); | ||
} |
62 changes: 62 additions & 0 deletions
62
examples/routing_example/server/routes/deprecated_routes/unversioned.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,62 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import type { IRouter } from '@kbn/core/server'; | ||
import { schema } from '@kbn/config-schema'; | ||
import { DEPRECATED_ROUTES } from '../../../common'; | ||
|
||
export const registerDeprecatedRoute = (router: IRouter) => { | ||
router.get( | ||
{ | ||
path: DEPRECATED_ROUTES.REMOVED_ROUTE, | ||
validate: false, | ||
options: { | ||
access: 'public', | ||
deprecated: { | ||
documentationUrl: 'https://elastic.co/', | ||
severity: 'critical', | ||
reason: { type: 'remove' }, | ||
}, | ||
}, | ||
}, | ||
async (ctx, req, res) => { | ||
return res.ok({ | ||
body: { result: 'Called deprecated route. Check UA to see the deprecation.' }, | ||
}); | ||
} | ||
); | ||
|
||
router.post( | ||
{ | ||
path: DEPRECATED_ROUTES.MIGRATED_ROUTE, | ||
validate: { | ||
body: schema.object({ | ||
test: schema.maybe(schema.boolean()), | ||
}), | ||
}, | ||
options: { | ||
access: 'public', | ||
deprecated: { | ||
documentationUrl: 'https://elastic.co/', | ||
severity: 'critical', | ||
reason: { | ||
type: 'migrate', | ||
newApiMethod: 'GET', | ||
newApiPath: `${DEPRECATED_ROUTES.VERSIONED_ROUTE}?apiVersion=2`, | ||
}, | ||
}, | ||
}, | ||
}, | ||
async (ctx, req, res) => { | ||
return res.ok({ | ||
body: { result: 'Called deprecated route. Check UA to see the deprecation.' }, | ||
}); | ||
} | ||
); | ||
}; |
53 changes: 53 additions & 0 deletions
53
examples/routing_example/server/routes/deprecated_routes/versioned.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,53 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
import type { RequestHandler } from '@kbn/core-http-server'; | ||
import type { IRouter } from '@kbn/core/server'; | ||
import { DEPRECATED_ROUTES } from '../../../common'; | ||
|
||
const createDummyHandler = | ||
(version: string): RequestHandler => | ||
(ctx, req, res) => { | ||
return res.ok({ body: { result: `API version ${version}.` } }); | ||
}; | ||
|
||
export const registerVersionedDeprecatedRoute = (router: IRouter) => { | ||
const versionedRoute = router.versioned.get({ | ||
path: DEPRECATED_ROUTES.VERSIONED_ROUTE, | ||
description: 'Routing example plugin deprecated versioned route.', | ||
access: 'internal', | ||
options: { | ||
excludeFromOAS: true, | ||
}, | ||
enableQueryVersion: true, | ||
}); | ||
|
||
versionedRoute.addVersion( | ||
{ | ||
options: { | ||
deprecated: { | ||
documentationUrl: 'https://elastic.co/', | ||
severity: 'warning', | ||
reason: { type: 'bump', newApiVersion: '2' }, | ||
}, | ||
}, | ||
validate: false, | ||
version: '1', | ||
}, | ||
createDummyHandler('1') | ||
); | ||
|
||
versionedRoute.addVersion( | ||
{ | ||
version: '2', | ||
validate: false, | ||
}, | ||
createDummyHandler('2') | ||
); | ||
}; |
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
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.
FMI, are you testing anything specific w.r.t. internal routes?
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.
no but non-internal routes dont accept custom versioning. they all must be set to a sepcific date