-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
## Summary Backport #196081
- Loading branch information
Showing
129 changed files
with
2,046 additions
and
315 deletions.
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
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.