Skip to content
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 41 commits into from
Oct 22, 2024
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
4b24857
finish feature
Bamieh Oct 14, 2024
a46da40
Merge branch 'main' of github.com:elastic/kibana into core/api-deprec…
Bamieh Oct 14, 2024
0ba7595
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine Oct 14, 2024
fe1edbf
revert testing example
Bamieh Oct 14, 2024
4642236
update i18n messages
Bamieh Oct 14, 2024
98e1928
Merge branch 'core/api-deprecations' of github.com:Bamieh/kibana into…
Bamieh Oct 14, 2024
f6552c7
remove version example
Bamieh Oct 14, 2024
e4a4b21
i18n_check
Bamieh Oct 14, 2024
e14ff56
fix types
Bamieh Oct 14, 2024
62a3a61
Merge branch 'main' of github.com:elastic/kibana into core/api-deprec…
Bamieh Oct 15, 2024
96d88ef
code review changes
Bamieh Oct 15, 2024
cf26b2b
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine Oct 15, 2024
7b003e9
finish deprecated service unit tests
Bamieh Oct 17, 2024
e627a21
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine Oct 17, 2024
2f47efd
[CI] Auto-commit changed files from 'make api-docs && make api-docs-s…
kibanamachine Oct 17, 2024
563f5cc
merge main and update types
Bamieh Oct 17, 2024
e34ccc1
tina code reviews
Bamieh Oct 17, 2024
bb3fea6
Merge branch 'core/api-deprecations' of github.com:Bamieh/kibana into…
Bamieh Oct 17, 2024
309b35a
openApi spec fixes
Bamieh Oct 20, 2024
2484b9a
merge main
Bamieh Oct 20, 2024
098e0a8
finalize open spec
Bamieh Oct 20, 2024
f1dc0bb
[CI] Auto-commit changed files from 'node scripts/capture_oas_snapsho…
kibanamachine Oct 20, 2024
4626672
[CI] Auto-commit changed files from 'make api-docs && make api-docs-s…
kibanamachine Oct 20, 2024
15eaa47
deprecated routes example
Bamieh Oct 20, 2024
21653e8
Merge branch 'core/api-deprecations' of github.com:Bamieh/kibana into…
Bamieh Oct 20, 2024
ae0d20b
update readme
Bamieh Oct 20, 2024
7d66a9f
[CI] Auto-commit changed files from 'node scripts/notice'
kibanamachine Oct 20, 2024
77cb2d4
fix more tests
Bamieh Oct 20, 2024
72c6184
Merge branch 'core/api-deprecations' of github.com:Bamieh/kibana into…
Bamieh Oct 20, 2024
0a7d698
add integration test
Bamieh Oct 21, 2024
ecf62ad
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine Oct 21, 2024
43f9a1e
add integration test
Bamieh Oct 21, 2024
a6e14d4
merge main
Bamieh Oct 21, 2024
00c79db
Merge branch 'core/api-deprecations' of github.com:Bamieh/kibana into…
Bamieh Oct 21, 2024
ffda5c3
Merge branch 'main' of github.com:elastic/kibana into core/api-deprec…
Bamieh Oct 21, 2024
a6a0608
update integration test
Bamieh Oct 22, 2024
1370c50
Merge branch 'main' of github.com:elastic/kibana into core/api-deprec…
Bamieh Oct 22, 2024
a1405a7
Update x-pack/plugins/upgrade_assistant/public/application/components…
Bamieh Oct 22, 2024
23c5126
fix type -> replace
Bamieh Oct 22, 2024
6bdb7fd
Merge branch 'core/api-deprecations' of github.com:Bamieh/kibana into…
Bamieh Oct 22, 2024
2e37e03
Merge branch 'main' into core/api-deprecations
elasticmachine Oct 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .buildkite/ftr_platform_stateful_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ enabled:
- x-pack/test/task_manager_claimer_mget/config.ts
- x-pack/test/ui_capabilities/security_and_spaces/config.ts
- x-pack/test/ui_capabilities/spaces_only/config.ts
- x-pack/test/upgrade_assistant_integration/config.js
- x-pack/test/upgrade_assistant_integration/config.ts
- x-pack/test/usage_collection/config.ts
- x-pack/performance/journeys_e2e/aiops_log_rate_analysis.ts
- x-pack/performance/journeys_e2e/ecommerce_dashboard.ts
Expand Down
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ module.exports = {
'x-pack/test/*/*config.*ts',
'x-pack/test/saved_object_api_integration/*/apis/**/*',
'x-pack/test/ui_capabilities/*/tests/**/*',
'x-pack/test/upgrade_assistant_integration/**/*',
'x-pack/test/performance/**/*.ts',
'**/cypress.config.{js,ts}',
'x-pack/test_serverless/**/config*.ts',
Expand Down
6 changes: 6 additions & 0 deletions examples/routing_example/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ export const POST_MESSAGE_ROUTE_PATH = '/api/post_message';

// Internal APIs should use the `internal` prefix, instead of the `api` prefix.
export const INTERNAL_GET_MESSAGE_BY_ID_ROUTE = '/internal/get_message';

export const DEPRECATED_ROUTES = {
REMOVED_ROUTE: '/api/routing_example/d/removed_route',
MIGRATED_ROUTE: '/api/routing_example/d/migrated_route',
VERSIONED_ROUTE: '/api/routing_example/d/versioned',
};
3 changes: 2 additions & 1 deletion examples/routing_example/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
*/

import { Plugin, CoreSetup, CoreStart } from '@kbn/core/server';
import { registerRoutes } from './routes';
import { registerRoutes, registerDeprecatedRoutes } from './routes';

export class RoutingExamplePlugin implements Plugin<{}, {}> {
public setup(core: CoreSetup) {
const router = core.http.createRouter();

registerRoutes(router);
registerDeprecatedRoutes(router);

return {};
}
Expand Down
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);
}
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.' },
});
}
);
};
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',
Copy link
Contributor

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?

Copy link
Member Author

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

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')
);
};
1 change: 1 addition & 0 deletions examples/routing_example/server/routes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
*/

export { registerRoutes } from './register_routes';
export { registerDeprecatedRoutes } from './deprecated_routes';
1 change: 1 addition & 0 deletions examples/routing_example/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@
"@kbn/core-http-browser",
"@kbn/config-schema",
"@kbn/react-kibana-context-render",
"@kbn/core-http-server",
]
}
11 changes: 0 additions & 11 deletions oas_docs/bundle.json
Original file line number Diff line number Diff line change
Expand Up @@ -6409,7 +6409,6 @@
},
"/api/fleet/agent-status": {
"get": {
"deprecated": true,
"operationId": "%2Fapi%2Ffleet%2Fagent-status#0",
"parameters": [
{
Expand Down Expand Up @@ -17136,7 +17135,6 @@
]
},
"put": {
"deprecated": true,
"operationId": "%2Fapi%2Ffleet%2Fagents%2F%7BagentId%7D%2Freassign#0",
"parameters": [
{
Expand Down Expand Up @@ -17836,7 +17834,6 @@
},
"/api/fleet/enrollment-api-keys": {
"get": {
"deprecated": true,
"operationId": "%2Fapi%2Ffleet%2Fenrollment-api-keys#0",
"parameters": [
{
Expand Down Expand Up @@ -17883,7 +17880,6 @@
"tags": []
},
"post": {
"deprecated": true,
"operationId": "%2Fapi%2Ffleet%2Fenrollment-api-keys#1",
"parameters": [
{
Expand Down Expand Up @@ -17940,7 +17936,6 @@
},
"/api/fleet/enrollment-api-keys/{keyId}": {
"delete": {
"deprecated": true,
"operationId": "%2Fapi%2Ffleet%2Fenrollment-api-keys%2F%7BkeyId%7D#1",
"parameters": [
{
Expand Down Expand Up @@ -17979,7 +17974,6 @@
"tags": []
},
"get": {
"deprecated": true,
"operationId": "%2Fapi%2Ffleet%2Fenrollment-api-keys%2F%7BkeyId%7D#0",
"parameters": [
{
Expand Down Expand Up @@ -24710,7 +24704,6 @@
},
"/api/fleet/epm/packages/{pkgkey}": {
"delete": {
"deprecated": true,
"operationId": "%2Fapi%2Ffleet%2Fepm%2Fpackages%2F%7Bpkgkey%7D#3",
"parameters": [
{
Expand Down Expand Up @@ -24768,7 +24761,6 @@
"tags": []
},
"get": {
"deprecated": true,
"operationId": "%2Fapi%2Ffleet%2Fepm%2Fpackages%2F%7Bpkgkey%7D#0",
"parameters": [
{
Expand Down Expand Up @@ -24830,7 +24822,6 @@
"tags": []
},
"post": {
"deprecated": true,
"operationId": "%2Fapi%2Ffleet%2Fepm%2Fpackages%2F%7Bpkgkey%7D#2",
"parameters": [
{
Expand Down Expand Up @@ -24914,7 +24905,6 @@
"tags": []
},
"put": {
"deprecated": true,
"operationId": "%2Fapi%2Ffleet%2Fepm%2Fpackages%2F%7Bpkgkey%7D#1",
"parameters": [
{
Expand Down Expand Up @@ -40129,7 +40119,6 @@
},
"/api/fleet/service-tokens": {
"post": {
"deprecated": true,
"description": "Create a service token",
"operationId": "%2Fapi%2Ffleet%2Fservice-tokens#0",
"parameters": [
Expand Down
11 changes: 0 additions & 11 deletions oas_docs/bundle.serverless.json
Original file line number Diff line number Diff line change
Expand Up @@ -6409,7 +6409,6 @@
},
"/api/fleet/agent-status": {
"get": {
"deprecated": true,
"operationId": "%2Fapi%2Ffleet%2Fagent-status#0",
"parameters": [
{
Expand Down Expand Up @@ -17136,7 +17135,6 @@
]
},
"put": {
"deprecated": true,
"operationId": "%2Fapi%2Ffleet%2Fagents%2F%7BagentId%7D%2Freassign#0",
"parameters": [
{
Expand Down Expand Up @@ -17836,7 +17834,6 @@
},
"/api/fleet/enrollment-api-keys": {
"get": {
"deprecated": true,
"operationId": "%2Fapi%2Ffleet%2Fenrollment-api-keys#0",
"parameters": [
{
Expand Down Expand Up @@ -17883,7 +17880,6 @@
"tags": []
},
"post": {
"deprecated": true,
"operationId": "%2Fapi%2Ffleet%2Fenrollment-api-keys#1",
"parameters": [
{
Expand Down Expand Up @@ -17940,7 +17936,6 @@
},
"/api/fleet/enrollment-api-keys/{keyId}": {
"delete": {
"deprecated": true,
"operationId": "%2Fapi%2Ffleet%2Fenrollment-api-keys%2F%7BkeyId%7D#1",
"parameters": [
{
Expand Down Expand Up @@ -17979,7 +17974,6 @@
"tags": []
},
"get": {
"deprecated": true,
"operationId": "%2Fapi%2Ffleet%2Fenrollment-api-keys%2F%7BkeyId%7D#0",
"parameters": [
{
Expand Down Expand Up @@ -24710,7 +24704,6 @@
},
"/api/fleet/epm/packages/{pkgkey}": {
"delete": {
"deprecated": true,
"operationId": "%2Fapi%2Ffleet%2Fepm%2Fpackages%2F%7Bpkgkey%7D#3",
"parameters": [
{
Expand Down Expand Up @@ -24768,7 +24761,6 @@
"tags": []
},
"get": {
"deprecated": true,
"operationId": "%2Fapi%2Ffleet%2Fepm%2Fpackages%2F%7Bpkgkey%7D#0",
"parameters": [
{
Expand Down Expand Up @@ -24830,7 +24822,6 @@
"tags": []
},
"post": {
"deprecated": true,
"operationId": "%2Fapi%2Ffleet%2Fepm%2Fpackages%2F%7Bpkgkey%7D#2",
"parameters": [
{
Expand Down Expand Up @@ -24914,7 +24905,6 @@
"tags": []
},
"put": {
"deprecated": true,
"operationId": "%2Fapi%2Ffleet%2Fepm%2Fpackages%2F%7Bpkgkey%7D#1",
"parameters": [
{
Expand Down Expand Up @@ -40129,7 +40119,6 @@
},
"/api/fleet/service-tokens": {
"post": {
"deprecated": true,
"description": "Create a service token",
"operationId": "%2Fapi%2Ffleet%2Fservice-tokens#0",
"parameters": [
Expand Down
Loading