diff --git a/docs/upgrade-notes.asciidoc b/docs/upgrade-notes.asciidoc index 98f7feeac2d6a..1b1a76ccfcbaa 100644 --- a/docs/upgrade-notes.asciidoc +++ b/docs/upgrade-notes.asciidoc @@ -1432,6 +1432,35 @@ The `/agent_status` Fleet API now returns the following statuses: * `active` — All active ==== +[discrete] +[[kibana-150267]] +.Deprecated Saved objects APIs. (8.7) +[%collapsible] +==== +*Details* + +The following saved objects APIs have been deprecated. + +[source,text] +-- +/api/saved_objects/{type}/{id} +/api/saved_objects/resolve/{type}/{id} +/api/saved_objects/{type}/{id?} +/api/saved_objects/{type}/{id} +/api/saved_objects/_find +/api/saved_objects/{type}/{id} +/api/saved_objects/_bulk_get +/api/saved_objects/_bulk_create +/api/saved_objects/_bulk_resolve +/api/saved_objects/_bulk_update +/api/saved_objects/_bulk_delete +-- + +For more information, refer to ({kibana-pull}150267[#150267]). + +*Impact* + +Use dedicated public APIs instead, for example use <> to manage Data Views. +==== + [discrete] [[deprecation-119494]] .Updates Fleet API to improve consistency. (8.0) diff --git a/oas_docs/output/kibana.serverless.yaml b/oas_docs/output/kibana.serverless.yaml index 78c8541059d26..9c9c3797d7dbc 100644 --- a/oas_docs/output/kibana.serverless.yaml +++ b/oas_docs/output/kibana.serverless.yaml @@ -50524,7 +50524,7 @@ tags: name: ml - name: roles - description: > - Export sets of saved objects that you want to import into {kib}, resolve + Export sets of saved objects that you want to import into Kibana, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs. diff --git a/oas_docs/output/kibana.yaml b/oas_docs/output/kibana.yaml index 64d227b91979d..afa0c850be734 100644 --- a/oas_docs/output/kibana.yaml +++ b/oas_docs/output/kibana.yaml @@ -37229,7 +37229,7 @@ paths: description: > Indicates a successful call. NOTE: This HTTP response code indicates that the bulk operation succeeded. Errors pertaining to individual - objects will be returned in the response body. + objects will be returned in the response body. '400': content: application/json; Elastic-Api-Version=2023-10-31: @@ -37263,7 +37263,7 @@ paths: description: > Indicates a successful call. NOTE: This HTTP response code indicates that the bulk operation succeeded. Errors pertaining to individual - objects will be returned in the response body. + objects will be returned in the response body. '400': content: application/json; Elastic-Api-Version=2023-10-31: @@ -58900,7 +58900,7 @@ tags: name: ml - name: roles - description: > - Export sets of saved objects that you want to import into {kib}, resolve + Export sets of saved objects that you want to import into Kibana, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs. diff --git a/packages/core/deprecations/core-deprecations-server-internal/src/routes/post_validation_handler.ts b/packages/core/deprecations/core-deprecations-server-internal/src/routes/post_validation_handler.ts index b93c17af2f536..6719f8b99ff50 100644 --- a/packages/core/deprecations/core-deprecations-server-internal/src/routes/post_validation_handler.ts +++ b/packages/core/deprecations/core-deprecations-server-internal/src/routes/post_validation_handler.ts @@ -11,7 +11,7 @@ import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-server-int import type { CoreKibanaRequest } from '@kbn/core-http-router-server-internal'; import type { InternalHttpServiceSetup } from '@kbn/core-http-server-internal'; import { isObject } from 'lodash'; -import { RouteDeprecationInfo } from '@kbn/core-http-server/src/router/route'; +import { RouteDeprecationInfo } from '@kbn/core-http-server/src/router/route'; // shouldn't use deep imports import { buildApiDeprecationId } from '../deprecations'; interface Dependencies { diff --git a/packages/core/http/core-http-server/index.ts b/packages/core/http/core-http-server/index.ts index 9c12f6a09ac45..d2c4cfb5c16f7 100644 --- a/packages/core/http/core-http-server/index.ts +++ b/packages/core/http/core-http-server/index.ts @@ -120,6 +120,7 @@ export type { RouteSecurity, RouteSecurityGetter, InternalRouteSecurity, + RouteDeprecationInfo, } from './src/router'; export { validBodyOutput, diff --git a/packages/core/http/core-http-server/src/router/index.ts b/packages/core/http/core-http-server/src/router/index.ts index 8e2b9373c43bd..30a1b6a5c9cc1 100644 --- a/packages/core/http/core-http-server/src/router/index.ts +++ b/packages/core/http/core-http-server/src/router/index.ts @@ -64,6 +64,7 @@ export type { RouteSecurity, Privilege, PrivilegeSet, + RouteDeprecationInfo, } from './route'; export { validBodyOutput, ReservedPrivilegesSet } from './route'; diff --git a/packages/core/root/core-root-server-internal/src/server.ts b/packages/core/root/core-root-server-internal/src/server.ts index 5082a27930e87..d38a52b73494b 100644 --- a/packages/core/root/core-root-server-internal/src/server.ts +++ b/packages/core/root/core-root-server-internal/src/server.ts @@ -309,6 +309,7 @@ export class Server { elasticsearch: elasticsearchServiceSetup, deprecations: deprecationsSetup, coreUsageData: coreUsageDataSetup, + docLinks: docLinksSetup, }); const uiSettingsSetup = await this.uiSettings.setup({ diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_create.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_create.ts index c9a8656b3f753..c0df8b57094eb 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_create.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_create.ts @@ -8,7 +8,7 @@ */ import { schema } from '@kbn/config-schema'; -import type { RouteAccess } from '@kbn/core-http-server'; +import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server'; import { SavedObjectConfig } from '@kbn/core-saved-objects-base-server-internal'; import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal'; import type { Logger } from '@kbn/logging'; @@ -24,11 +24,12 @@ interface RouteDependencies { coreUsageData: InternalCoreUsageDataSetup; logger: Logger; access: RouteAccess; + deprecationInfo: RouteDeprecationInfo; } export const registerBulkCreateRoute = ( router: InternalSavedObjectRouter, - { config, coreUsageData, logger, access }: RouteDependencies + { config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies ) => { const { allowHttpApiAccess } = config; router.post( @@ -38,8 +39,7 @@ export const registerBulkCreateRoute = ( summary: `Create saved objects`, tags: ['oas-tag:saved objects'], access, - // @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo} - deprecated: true, + deprecated: deprecationInfo, }, validate: { query: schema.object({ diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_delete.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_delete.ts index 65209a6072748..21ea532cae170 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_delete.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_delete.ts @@ -8,7 +8,7 @@ */ import { schema } from '@kbn/config-schema'; -import type { RouteAccess } from '@kbn/core-http-server'; +import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server'; import { SavedObjectConfig } from '@kbn/core-saved-objects-base-server-internal'; import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal'; import type { Logger } from '@kbn/logging'; @@ -24,11 +24,12 @@ interface RouteDependencies { coreUsageData: InternalCoreUsageDataSetup; logger: Logger; access: RouteAccess; + deprecationInfo: RouteDeprecationInfo; } export const registerBulkDeleteRoute = ( router: InternalSavedObjectRouter, - { config, coreUsageData, logger, access }: RouteDependencies + { config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies ) => { const { allowHttpApiAccess } = config; router.post( @@ -38,8 +39,7 @@ export const registerBulkDeleteRoute = ( summary: `Delete saved objects`, tags: ['oas-tag:saved objects'], access, - // @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo} - deprecated: true, + deprecated: deprecationInfo, }, validate: { body: schema.arrayOf( diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_get.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_get.ts index 3f87ca12248ae..1a97377f872f6 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_get.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_get.ts @@ -8,7 +8,7 @@ */ import { schema } from '@kbn/config-schema'; -import type { RouteAccess } from '@kbn/core-http-server'; +import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server'; import { SavedObjectConfig } from '@kbn/core-saved-objects-base-server-internal'; import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal'; import type { Logger } from '@kbn/logging'; @@ -24,11 +24,12 @@ interface RouteDependencies { coreUsageData: InternalCoreUsageDataSetup; logger: Logger; access: RouteAccess; + deprecationInfo: RouteDeprecationInfo; } export const registerBulkGetRoute = ( router: InternalSavedObjectRouter, - { config, coreUsageData, logger, access }: RouteDependencies + { config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies ) => { const { allowHttpApiAccess } = config; router.post( @@ -38,8 +39,7 @@ export const registerBulkGetRoute = ( summary: `Get saved objects`, tags: ['oas-tag:saved objects'], access, - // @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo} - deprecated: true, + deprecated: deprecationInfo, }, validate: { body: schema.arrayOf( diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_resolve.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_resolve.ts index 8e19114e798e0..b464e06ac15c8 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_resolve.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_resolve.ts @@ -8,7 +8,7 @@ */ import { schema } from '@kbn/config-schema'; -import type { RouteAccess } from '@kbn/core-http-server'; +import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server'; import { SavedObjectConfig } from '@kbn/core-saved-objects-base-server-internal'; import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal'; import type { Logger } from '@kbn/logging'; @@ -24,11 +24,12 @@ interface RouteDependencies { coreUsageData: InternalCoreUsageDataSetup; logger: Logger; access: RouteAccess; + deprecationInfo: RouteDeprecationInfo; } export const registerBulkResolveRoute = ( router: InternalSavedObjectRouter, - { config, coreUsageData, logger, access }: RouteDependencies + { config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies ) => { const { allowHttpApiAccess } = config; router.post( @@ -38,8 +39,7 @@ export const registerBulkResolveRoute = ( summary: `Resolve saved objects`, tags: ['oas-tag:saved objects'], access, - // @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo} - deprecated: true, + deprecated: deprecationInfo, description: `Retrieve multiple Kibana saved objects by ID, using any legacy URL aliases if they exist. Under certain circumstances, when Kibana is upgraded, saved object migrations may necessitate regenerating some object IDs to enable new features. When an object's ID is regenerated, a legacy URL alias is created for that object, preserving its old ID. In such a scenario, that object can be retrieved with the bulk resolve API using either its new ID or its old ID.`, }, diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_update.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_update.ts index 825a5f95482c0..7793484e01819 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_update.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/bulk_update.ts @@ -8,7 +8,7 @@ */ import { schema } from '@kbn/config-schema'; -import type { RouteAccess } from '@kbn/core-http-server'; +import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server'; import { SavedObjectConfig } from '@kbn/core-saved-objects-base-server-internal'; import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal'; import type { Logger } from '@kbn/logging'; @@ -24,11 +24,12 @@ interface RouteDependencies { coreUsageData: InternalCoreUsageDataSetup; logger: Logger; access: RouteAccess; + deprecationInfo: RouteDeprecationInfo; } export const registerBulkUpdateRoute = ( router: InternalSavedObjectRouter, - { config, coreUsageData, logger, access }: RouteDependencies + { config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies ) => { const { allowHttpApiAccess } = config; router.put( @@ -38,8 +39,7 @@ export const registerBulkUpdateRoute = ( summary: `Update saved objects`, tags: ['oas-tag:saved objects'], access, - // @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo} - deprecated: true, + deprecated: deprecationInfo, }, validate: { body: schema.arrayOf( diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/create.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/create.ts index 57f4a10ed9377..4b6a58b107f12 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/create.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/create.ts @@ -8,7 +8,7 @@ */ import { schema } from '@kbn/config-schema'; -import type { RouteAccess } from '@kbn/core-http-server'; +import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server'; import { SavedObjectConfig } from '@kbn/core-saved-objects-base-server-internal'; import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal'; import type { Logger } from '@kbn/logging'; @@ -24,11 +24,12 @@ interface RouteDependencies { coreUsageData: InternalCoreUsageDataSetup; logger: Logger; access: RouteAccess; + deprecationInfo: RouteDeprecationInfo; } export const registerCreateRoute = ( router: InternalSavedObjectRouter, - { config, coreUsageData, logger, access }: RouteDependencies + { config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies ) => { const { allowHttpApiAccess } = config; router.post( @@ -38,8 +39,7 @@ export const registerCreateRoute = ( summary: `Create a saved object`, tags: ['oas-tag:saved objects'], access, - // @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo} - deprecated: true, + deprecated: deprecationInfo, }, validate: { params: schema.object({ diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/delete.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/delete.ts index 69287821d8049..b3e1bdab6da47 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/delete.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/delete.ts @@ -8,7 +8,7 @@ */ import { schema } from '@kbn/config-schema'; -import type { RouteAccess } from '@kbn/core-http-server'; +import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server'; import { SavedObjectConfig } from '@kbn/core-saved-objects-base-server-internal'; import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal'; import type { Logger } from '@kbn/logging'; @@ -24,11 +24,12 @@ interface RouteDependencies { coreUsageData: InternalCoreUsageDataSetup; logger: Logger; access: RouteAccess; + deprecationInfo: RouteDeprecationInfo; } export const registerDeleteRoute = ( router: InternalSavedObjectRouter, - { config, coreUsageData, logger, access }: RouteDependencies + { config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies ) => { const { allowHttpApiAccess } = config; router.delete( @@ -38,8 +39,7 @@ export const registerDeleteRoute = ( summary: `Delete a saved object`, tags: ['oas-tag:saved objects'], access, - // @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo} - deprecated: true, + deprecated: deprecationInfo, }, validate: { params: schema.object({ diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/find.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/find.ts index 884ba1ed5c423..534d765080be2 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/find.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/find.ts @@ -8,7 +8,7 @@ */ import { schema } from '@kbn/config-schema'; -import type { RouteAccess } from '@kbn/core-http-server'; +import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server'; import { SavedObjectConfig } from '@kbn/core-saved-objects-base-server-internal'; import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal'; import type { Logger } from '@kbn/logging'; @@ -21,11 +21,12 @@ interface RouteDependencies { coreUsageData: InternalCoreUsageDataSetup; logger: Logger; access: RouteAccess; + deprecationInfo: RouteDeprecationInfo; } export const registerFindRoute = ( router: InternalSavedObjectRouter, - { config, coreUsageData, logger, access }: RouteDependencies + { config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies ) => { const referenceSchema = schema.object({ type: schema.string(), @@ -42,8 +43,7 @@ export const registerFindRoute = ( summary: `Search for saved objects`, tags: ['oas-tag:saved objects'], access, - // @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo} - deprecated: true, + deprecated: deprecationInfo, }, validate: { query: schema.object({ diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/get.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/get.ts index 9fe3aa8ff20c7..12c9c774ae7b4 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/get.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/get.ts @@ -8,7 +8,7 @@ */ import { schema } from '@kbn/config-schema'; -import type { RouteAccess } from '@kbn/core-http-server'; +import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server'; import { SavedObjectConfig } from '@kbn/core-saved-objects-base-server-internal'; import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal'; import type { Logger } from '@kbn/logging'; @@ -24,11 +24,12 @@ interface RouteDependencies { coreUsageData: InternalCoreUsageDataSetup; logger: Logger; access: RouteAccess; + deprecationInfo: RouteDeprecationInfo; } export const registerGetRoute = ( router: InternalSavedObjectRouter, - { config, coreUsageData, logger, access }: RouteDependencies + { config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies ) => { const { allowHttpApiAccess } = config; router.get( @@ -38,8 +39,7 @@ export const registerGetRoute = ( summary: `Get a saved object`, tags: ['oas-tag:saved objects'], access, - // @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo} - deprecated: true, + deprecated: deprecationInfo, }, validate: { params: schema.object({ diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/index.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/index.ts index 48ac75e045148..a9a83d55a0daa 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/index.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/index.ts @@ -14,6 +14,8 @@ import type { IKibanaMigrator, } from '@kbn/core-saved-objects-base-server-internal'; import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal'; +import { DocLinksServiceSetup } from '@kbn/core-doc-links-server'; +import { RouteDeprecationInfo } from '@kbn/core-http-server'; import type { InternalSavedObjectsRequestHandlerContext } from '../internal_types'; import { registerGetRoute } from './get'; import { registerResolveRoute } from './resolve'; @@ -43,6 +45,7 @@ export function registerRoutes({ kibanaVersion, kibanaIndex, isServerless, + docLinks, }: { http: InternalHttpServiceSetup; coreUsageData: InternalCoreUsageDataSetup; @@ -52,28 +55,105 @@ export function registerRoutes({ kibanaVersion: string; kibanaIndex: string; isServerless: boolean; + docLinks: DocLinksServiceSetup; }) { const router = http.createRouter('/api/saved_objects/'); const internalOnServerless = isServerless ? 'internal' : 'public'; + const deprecationInfo: RouteDeprecationInfo = { + documentationUrl: `${docLinks.links.management.savedObjectsApiList}`, + severity: 'warning' as const, // will not break deployment upon upgrade + reason: { + type: 'deprecate' as const, + }, + }; - registerGetRoute(router, { config, coreUsageData, logger, access: internalOnServerless }); - registerResolveRoute(router, { config, coreUsageData, logger, access: internalOnServerless }); + const legacyDeprecationInfo = { + documentationUrl: `${docLinks.links.kibana.dashboardImportExport}`, + severity: 'warning' as const, // will not break deployment upon upgrade + reason: { + type: 'remove' as const, // no alternative for posting `.json`, requires file format change to `.ndjson` + }, + }; + + registerGetRoute(router, { + config, + coreUsageData, + logger, + access: internalOnServerless, + deprecationInfo, + }); + registerResolveRoute(router, { + config, + coreUsageData, + logger, + access: internalOnServerless, + deprecationInfo, + }); registerCreateRoute(router, { config, coreUsageData, logger, access: internalOnServerless, + deprecationInfo, + }); + registerDeleteRoute(router, { + config, + coreUsageData, + logger, + access: internalOnServerless, + deprecationInfo, + }); + registerFindRoute(router, { + config, + coreUsageData, + logger, + access: internalOnServerless, + deprecationInfo, + }); + registerUpdateRoute(router, { + config, + coreUsageData, + logger, + access: internalOnServerless, + deprecationInfo, + }); + registerBulkGetRoute(router, { + config, + coreUsageData, + logger, + access: internalOnServerless, + deprecationInfo, + }); + registerBulkCreateRoute(router, { + config, + coreUsageData, + logger, + access: internalOnServerless, + deprecationInfo, + }); + registerBulkResolveRoute(router, { + config, + coreUsageData, + logger, + access: internalOnServerless, + deprecationInfo, + }); + registerBulkUpdateRoute(router, { + config, + coreUsageData, + logger, + access: internalOnServerless, + deprecationInfo, + }); + registerBulkDeleteRoute(router, { + config, + coreUsageData, + logger, + access: internalOnServerless, + deprecationInfo, }); - registerDeleteRoute(router, { config, coreUsageData, logger, access: internalOnServerless }); - registerFindRoute(router, { config, coreUsageData, logger, access: internalOnServerless }); - registerUpdateRoute(router, { config, coreUsageData, logger, access: internalOnServerless }); - registerBulkGetRoute(router, { config, coreUsageData, logger, access: internalOnServerless }); - registerBulkCreateRoute(router, { config, coreUsageData, logger, access: internalOnServerless }); - registerBulkResolveRoute(router, { config, coreUsageData, logger, access: internalOnServerless }); - registerBulkUpdateRoute(router, { config, coreUsageData, logger, access: internalOnServerless }); - registerBulkDeleteRoute(router, { config, coreUsageData, logger, access: internalOnServerless }); registerExportRoute(router, { config, coreUsageData }); registerImportRoute(router, { config, coreUsageData }); @@ -85,12 +165,14 @@ export function registerRoutes({ coreUsageData, logger, access: internalOnServerless, + legacyDeprecationInfo, }); registerLegacyExportRoute(legacyRouter, { kibanaVersion, coreUsageData, logger, access: internalOnServerless, + legacyDeprecationInfo, }); const internalRouter = http.createRouter( diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/legacy_import_export/export.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/legacy_import_export/export.ts index f3cf776f7d977..6da4acf798e1b 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/legacy_import_export/export.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/legacy_import_export/export.ts @@ -11,7 +11,7 @@ import moment from 'moment'; import { schema } from '@kbn/config-schema'; import type { Logger } from '@kbn/logging'; import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal'; -import type { RouteAccess } from '@kbn/core-http-server'; +import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server'; import type { InternalSavedObjectRouter } from '../../internal_types'; import { exportDashboards } from './lib'; @@ -22,11 +22,13 @@ export const registerLegacyExportRoute = ( coreUsageData, logger, access, + legacyDeprecationInfo, }: { kibanaVersion: string; coreUsageData: InternalCoreUsageDataSetup; logger: Logger; access: RouteAccess; + legacyDeprecationInfo: RouteDeprecationInfo; } ) => { router.get( @@ -39,6 +41,7 @@ export const registerLegacyExportRoute = ( }, options: { access, + deprecated: legacyDeprecationInfo, tags: ['api'], }, }, diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/legacy_import_export/import.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/legacy_import_export/import.ts index e45ef3205af18..ad205bf65f841 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/legacy_import_export/import.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/legacy_import_export/import.ts @@ -11,7 +11,7 @@ import { schema } from '@kbn/config-schema'; import type { Logger } from '@kbn/logging'; import type { SavedObject } from '@kbn/core-saved-objects-server'; import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal'; -import type { RouteAccess } from '@kbn/core-http-server'; +import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server'; import type { InternalSavedObjectRouter } from '../../internal_types'; import { importDashboards } from './lib'; @@ -22,11 +22,13 @@ export const registerLegacyImportRoute = ( coreUsageData, logger, access, + legacyDeprecationInfo, }: { maxImportPayloadBytes: number; coreUsageData: InternalCoreUsageDataSetup; logger: Logger; access: RouteAccess; + legacyDeprecationInfo: RouteDeprecationInfo; } ) => { router.post( @@ -50,6 +52,7 @@ export const registerLegacyImportRoute = ( body: { maxBytes: maxImportPayloadBytes, }, + deprecated: legacyDeprecationInfo, }, }, async (context, request, response) => { diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/resolve.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/resolve.ts index 28a6c82e9ffdf..debbacbb06337 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/resolve.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/resolve.ts @@ -8,7 +8,7 @@ */ import { schema } from '@kbn/config-schema'; -import type { RouteAccess } from '@kbn/core-http-server'; +import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server'; import { SavedObjectConfig } from '@kbn/core-saved-objects-base-server-internal'; import type { InternalCoreUsageDataSetup } from '@kbn/core-usage-data-base-server-internal'; import type { Logger } from '@kbn/logging'; @@ -20,11 +20,12 @@ interface RouteDependencies { coreUsageData: InternalCoreUsageDataSetup; logger: Logger; access: RouteAccess; + deprecationInfo: RouteDeprecationInfo; } export const registerResolveRoute = ( router: InternalSavedObjectRouter, - { config, coreUsageData, logger, access }: RouteDependencies + { config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies ) => { const { allowHttpApiAccess } = config; router.get( @@ -34,8 +35,7 @@ export const registerResolveRoute = ( summary: `Resolve a saved object`, tags: ['oas-tag:saved objects'], access, - // @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo} - deprecated: true, + deprecated: deprecationInfo, description: `Retrieve a single Kibana saved object by ID, using any legacy URL alias if it exists. Under certain circumstances, when Kibana is upgraded, saved object migrations may necessitate regenerating some object IDs to enable new features. When an object's ID is regenerated, a legacy URL alias is created for that object, preserving its old ID. In such a scenario, that object can be retrieved with the resolve API using either its new ID or its old ID.`, }, diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/update.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/update.ts index cfedc3ce03d2a..6f372235070b4 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/update.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/routes/update.ts @@ -7,7 +7,7 @@ * License v3.0 only", or the "Server Side Public License, v 1". */ -import type { RouteAccess } from '@kbn/core-http-server'; +import type { RouteAccess, RouteDeprecationInfo } from '@kbn/core-http-server'; import { schema } from '@kbn/config-schema'; import type { SavedObjectsUpdateOptions } from '@kbn/core-saved-objects-api-server'; import type { Logger } from '@kbn/logging'; @@ -25,11 +25,12 @@ interface RouteDependencies { coreUsageData: InternalCoreUsageDataSetup; logger: Logger; access: RouteAccess; + deprecationInfo: RouteDeprecationInfo; } export const registerUpdateRoute = ( router: InternalSavedObjectRouter, - { config, coreUsageData, logger, access }: RouteDependencies + { config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies ) => { const { allowHttpApiAccess } = config; router.put( @@ -39,8 +40,7 @@ export const registerUpdateRoute = ( summary: `Update a saved object`, tags: ['oas-tag:saved objects'], access, - // @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo} - deprecated: true, + deprecated: deprecationInfo, }, validate: { params: schema.object({ diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/saved_objects_service.test.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/saved_objects_service.test.ts index 667c4a5cea915..70e8fcf17c797 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/saved_objects_service.test.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/saved_objects_service.test.ts @@ -98,6 +98,7 @@ describe('SavedObjectsService', () => { elasticsearch: elasticsearchMock, deprecations: deprecationsSetup, coreUsageData: createCoreUsageDataSetupMock(), + docLinks: docLinksServiceMock.createSetupContract(), }; }; @@ -180,6 +181,18 @@ describe('SavedObjectsService', () => { expect(registerRoutesMock).toHaveBeenCalledWith(expect.objectContaining({ kibanaVersion })); }); + it('calls registerRoutes with docLinks', async () => { + const coreContext = createCoreContext(); + const mockedLinks = docLinksServiceMock.createSetupContract(); + + const soService = new SavedObjectsService(coreContext); + await soService.setup(createSetupDeps()); + + expect(registerRoutesMock).toHaveBeenCalledWith( + expect.objectContaining({ docLinks: mockedLinks }) + ); + }); + describe('#setClientFactoryProvider', () => { it('registers the factory to the clientProvider', async () => { const coreContext = createCoreContext(); diff --git a/packages/core/saved-objects/core-saved-objects-server-internal/src/saved_objects_service.ts b/packages/core/saved-objects/core-saved-objects-server-internal/src/saved_objects_service.ts index 522a8e1943a28..04be2f5929f0b 100644 --- a/packages/core/saved-objects/core-saved-objects-server-internal/src/saved_objects_service.ts +++ b/packages/core/saved-objects/core-saved-objects-server-internal/src/saved_objects_service.ts @@ -13,7 +13,7 @@ import type { Logger } from '@kbn/logging'; import { stripVersionQualifier } from '@kbn/std'; import type { ServiceStatus } from '@kbn/core-status-common'; import type { CoreContext, CoreService } from '@kbn/core-base-server-internal'; -import type { DocLinksServiceStart } from '@kbn/core-doc-links-server'; +import type { DocLinksServiceSetup, DocLinksServiceStart } from '@kbn/core-doc-links-server'; import type { KibanaRequest } from '@kbn/core-http-server'; import type { InternalHttpServiceSetup } from '@kbn/core-http-server-internal'; import type { @@ -99,6 +99,7 @@ export interface SavedObjectsSetupDeps { elasticsearch: InternalElasticsearchServiceSetup; coreUsageData: InternalCoreUsageDataSetup; deprecations: DeprecationRegistryProvider; + docLinks: DocLinksServiceSetup; } /** @internal */ @@ -135,7 +136,7 @@ export class SavedObjectsService this.logger.debug('Setting up SavedObjects service'); this.setupDeps = setupDeps; - const { http, elasticsearch, coreUsageData, deprecations } = setupDeps; + const { http, elasticsearch, coreUsageData, deprecations, docLinks } = setupDeps; const savedObjectsConfig = await firstValueFrom( this.coreContext.configService.atPath('savedObjects') @@ -164,6 +165,7 @@ export class SavedObjectsService kibanaIndex: MAIN_SAVED_OBJECT_INDEX, kibanaVersion: this.kibanaVersion, isServerless: this.coreContext.env.packageInfo.buildFlavor === 'serverless', + docLinks, }); registerCoreObjectTypes(this.typeRegistry); diff --git a/packages/core/saved-objects/docs/openapi/bundled.json b/packages/core/saved-objects/docs/openapi/bundled.json index 5b8f30b0f34c1..45cfdd7fa5055 100644 --- a/packages/core/saved-objects/docs/openapi/bundled.json +++ b/packages/core/saved-objects/docs/openapi/bundled.json @@ -21,7 +21,7 @@ { "name": "saved objects", "x-displayName": "Saved objects", - "description": "Export sets of saved objects that you want to import into {kib}, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs.\n\nTo manage a specific type of saved object, use the corresponding APIs.\nFor example, use:\n\n* [Data views](../group/endpoint-data-views)\n* [Spaces](https://www.elastic.co/guide/en/kibana/current/spaces-api.html)\n* [Short URLs](https://www.elastic.co/guide/en/kibana/current/short-urls-api.html)\n\nWarning: Do not write documents directly to the `.kibana` index. When you write directly to the `.kibana` index, the data becomes corrupted and permanently breaks future Kibana versions.\n" + "description": "Export sets of saved objects that you want to import into Kibana, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs.\n\nTo manage a specific type of saved object, use the corresponding APIs.\nFor example, use:\n\n* [Data views](../group/endpoint-data-views)\n* [Spaces](https://www.elastic.co/guide/en/kibana/current/spaces-api.html)\n* [Short URLs](https://www.elastic.co/guide/en/kibana/current/short-urls-api.html)\n\nWarning: Do not write documents directly to the `.kibana` index. When you write directly to the `.kibana` index, the data becomes corrupted and permanently breaks future Kibana versions.\n" } ], "paths": { @@ -1423,4 +1423,4 @@ } } } -} \ No newline at end of file +} diff --git a/packages/core/saved-objects/docs/openapi/bundled.yaml b/packages/core/saved-objects/docs/openapi/bundled.yaml index 68c79b406c2b0..9b5aad6e54958 100644 --- a/packages/core/saved-objects/docs/openapi/bundled.yaml +++ b/packages/core/saved-objects/docs/openapi/bundled.yaml @@ -14,7 +14,7 @@ tags: - name: saved objects x-displayName: Saved objects description: | - Export sets of saved objects that you want to import into {kib}, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs. + Export sets of saved objects that you want to import into Kibana, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs. To manage a specific type of saved object, use the corresponding APIs. For example, use: @@ -216,7 +216,7 @@ paths: responses: '200': description: | - Indicates a successful call. NOTE: This HTTP response code indicates that the bulk operation succeeded. Errors pertaining to individual objects will be returned in the response body. + Indicates a successful call. NOTE: This HTTP response code indicates that the bulk operation succeeded. Errors pertaining to individual objects will be returned in the response body. content: application/json: schema: @@ -248,7 +248,7 @@ paths: responses: '200': description: | - Indicates a successful call. NOTE: This HTTP response code indicates that the bulk operation succeeded. Errors pertaining to individual objects will be returned in the response body. + Indicates a successful call. NOTE: This HTTP response code indicates that the bulk operation succeeded. Errors pertaining to individual objects will be returned in the response body. content: application/json: schema: diff --git a/packages/core/saved-objects/docs/openapi/bundled_serverless.json b/packages/core/saved-objects/docs/openapi/bundled_serverless.json index fe4b832c495b7..67b8a710b5bcd 100644 --- a/packages/core/saved-objects/docs/openapi/bundled_serverless.json +++ b/packages/core/saved-objects/docs/openapi/bundled_serverless.json @@ -26,7 +26,7 @@ { "name": "saved objects", "x-displayName": "Saved objects", - "description": "Export sets of saved objects that you want to import into {kib}, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs.\n\nTo manage a specific type of saved object, use the corresponding APIs.\nFor example, use:\n\n[Data views](../group/endpoint-data-views)\n\nWarning: Do not write documents directly to the `.kibana` index. When you write directly to the `.kibana` index, the data becomes corrupted and permanently breaks future Kibana versions.\n" + "description": "Export sets of saved objects that you want to import into Kibana, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs.\n\nTo manage a specific type of saved object, use the corresponding APIs.\nFor example, use:\n\n[Data views](../group/endpoint-data-views)\n\nWarning: Do not write documents directly to the `.kibana` index. When you write directly to the `.kibana` index, the data becomes corrupted and permanently breaks future Kibana versions.\n" } ], "paths": { @@ -358,4 +358,4 @@ } } } -} \ No newline at end of file +} diff --git a/packages/core/saved-objects/docs/openapi/bundled_serverless.yaml b/packages/core/saved-objects/docs/openapi/bundled_serverless.yaml index 4517629a29a61..b874f0e32361b 100644 --- a/packages/core/saved-objects/docs/openapi/bundled_serverless.yaml +++ b/packages/core/saved-objects/docs/openapi/bundled_serverless.yaml @@ -17,7 +17,7 @@ tags: - name: saved objects x-displayName: Saved objects description: | - Export sets of saved objects that you want to import into {kib}, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs. + Export sets of saved objects that you want to import into Kibana, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs. To manage a specific type of saved object, use the corresponding APIs. For example, use: diff --git a/packages/core/saved-objects/docs/openapi/entrypoint.yaml b/packages/core/saved-objects/docs/openapi/entrypoint.yaml index 5cd9039988186..adb960a06dc4e 100644 --- a/packages/core/saved-objects/docs/openapi/entrypoint.yaml +++ b/packages/core/saved-objects/docs/openapi/entrypoint.yaml @@ -12,8 +12,8 @@ tags: - name: saved objects x-displayName: Saved objects description: | - Export sets of saved objects that you want to import into {kib}, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs. - + Export sets of saved objects that you want to import into Kibana, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs. + To manage a specific type of saved object, use the corresponding APIs. For example, use: diff --git a/packages/core/saved-objects/docs/openapi/entrypoint_serverless.yaml b/packages/core/saved-objects/docs/openapi/entrypoint_serverless.yaml index 69c742a8d7acd..f0d0be2ccf76b 100644 --- a/packages/core/saved-objects/docs/openapi/entrypoint_serverless.yaml +++ b/packages/core/saved-objects/docs/openapi/entrypoint_serverless.yaml @@ -12,8 +12,8 @@ tags: - name: saved objects x-displayName: Saved objects description: | - Export sets of saved objects that you want to import into {kib}, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs. - + Export sets of saved objects that you want to import into Kibana, resolve import errors, and rotate an encryption key for encrypted saved objects with the saved objects APIs. + To manage a specific type of saved object, use the corresponding APIs. For example, use: diff --git a/packages/kbn-doc-links/src/get_doc_links.ts b/packages/kbn-doc-links/src/get_doc_links.ts index 1294f72b9f208..4605dabf6eb94 100644 --- a/packages/kbn-doc-links/src/get_doc_links.ts +++ b/packages/kbn-doc-links/src/get_doc_links.ts @@ -355,6 +355,8 @@ export const getDocLinks = ({ kibanaBranch, buildFlavor }: GetDocLinkOptions): D autocompleteSuggestions: `${KIBANA_DOCS}kibana-concepts-analysts.html#autocomplete-suggestions`, secureSavedObject: `${KIBANA_DOCS}xpack-security-secure-saved-objects.html`, xpackSecurity: `${KIBANA_DOCS}xpack-security.html`, + restApis: `${KIBANA_DOCS}api.html`, + dashboardImportExport: `${KIBANA_DOCS}dashboard-api.html`, }, upgradeAssistant: { overview: `${KIBANA_DOCS}upgrade-assistant.html`, diff --git a/packages/kbn-doc-links/src/types.ts b/packages/kbn-doc-links/src/types.ts index 0bfb1c69fd6bb..f1a6a8d4b578d 100644 --- a/packages/kbn-doc-links/src/types.ts +++ b/packages/kbn-doc-links/src/types.ts @@ -314,6 +314,7 @@ export interface DocLinks { readonly autocompleteSuggestions: string; readonly secureSavedObject: string; readonly xpackSecurity: string; + readonly dashboardImportExport: string; }; readonly upgradeAssistant: { readonly overview: string; diff --git a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/bulk_create.test.ts b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/bulk_create.test.ts index 8d40280806379..e824e5124f6c6 100644 --- a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/bulk_create.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/bulk_create.test.ts @@ -21,7 +21,7 @@ import { } from '@kbn/core-saved-objects-server-internal'; import { createHiddenTypeVariants, setupServer } from '@kbn/core-test-helpers-test-utils'; import { loggerMock } from '@kbn/logging-mocks'; -import { setupConfig } from '../routes_test_utils'; +import { deprecationMock, setupConfig } from '../routes_test_utils'; type SetupServerReturn = Awaited>; @@ -56,7 +56,14 @@ describe('POST /api/saved_objects/_bulk_create with allowApiAccess true', () => const logger = loggerMock.create(); const config = setupConfig(true); const access = 'public'; - registerBulkCreateRoute(router, { config, coreUsageData, logger, access }); + + registerBulkCreateRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); await server.start(); }); diff --git a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/bulk_delete.test.ts b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/bulk_delete.test.ts index 26a2d22403bc1..114b682fa51b4 100644 --- a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/bulk_delete.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/bulk_delete.test.ts @@ -20,7 +20,7 @@ import { type InternalSavedObjectsRequestHandlerContext, } from '@kbn/core-saved-objects-server-internal'; import { loggerMock } from '@kbn/logging-mocks'; -import { setupConfig } from '../routes_test_utils'; +import { deprecationMock, setupConfig } from '../routes_test_utils'; type SetupServerReturn = Awaited>; @@ -61,7 +61,13 @@ describe('POST /api/saved_objects/_bulk_delete with allowApiAccess as true', () const config = setupConfig(true); const access = 'public'; - registerBulkDeleteRoute(router, { config, coreUsageData, logger, access }); + registerBulkDeleteRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); await server.start(); }); diff --git a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/bulk_get.test.ts b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/bulk_get.test.ts index da491110b0717..bd6caca6233c8 100644 --- a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/bulk_get.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/bulk_get.test.ts @@ -20,7 +20,7 @@ import { type InternalSavedObjectsRequestHandlerContext, } from '@kbn/core-saved-objects-server-internal'; import { loggerMock } from '@kbn/logging-mocks'; -import { setupConfig } from '../routes_test_utils'; +import { deprecationMock, setupConfig } from '../routes_test_utils'; type SetupServerReturn = Awaited>; @@ -58,7 +58,14 @@ describe('POST /api/saved_objects/_bulk_get with allowApiAccess true', () => { const config = setupConfig(true); const access = 'public'; - registerBulkGetRoute(router, { config, coreUsageData, logger, access }); + + registerBulkGetRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); await server.start(); }); diff --git a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/bulk_resolve.test.ts b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/bulk_resolve.test.ts index 054f55f518a66..f297f1b6a8cb4 100644 --- a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/bulk_resolve.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/bulk_resolve.test.ts @@ -20,7 +20,7 @@ import { type InternalSavedObjectsRequestHandlerContext, } from '@kbn/core-saved-objects-server-internal'; import { loggerMock } from '@kbn/logging-mocks'; -import { setupConfig } from '../routes_test_utils'; +import { deprecationMock, setupConfig } from '../routes_test_utils'; type SetupServerReturn = Awaited>; @@ -59,7 +59,14 @@ describe('POST /api/saved_objects/_bulk_resolve with allowApiAccess true', () => const config = setupConfig(true); const access = 'public'; - registerBulkResolveRoute(router, { config, coreUsageData, logger, access }); + + registerBulkResolveRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); await server.start(); }); diff --git a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/bulk_update.test.ts b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/bulk_update.test.ts index 275e803f6ceb3..7625334bbe638 100644 --- a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/bulk_update.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/bulk_update.test.ts @@ -19,7 +19,7 @@ import { type InternalSavedObjectsRequestHandlerContext, } from '@kbn/core-saved-objects-server-internal'; import { loggerMock } from '@kbn/logging-mocks'; -import { setupConfig } from '../routes_test_utils'; +import { deprecationMock, setupConfig } from '../routes_test_utils'; type SetupServerReturn = Awaited>; const testTypes = [ @@ -52,7 +52,14 @@ describe('PUT /api/saved_objects/_bulk_update with allowApiAccess true', () => { const config = setupConfig(true); const access = 'public'; - registerBulkUpdateRoute(router, { config, coreUsageData, logger, access }); + + registerBulkUpdateRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); await server.start(); }); diff --git a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/create.test.ts b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/create.test.ts index 478c233466727..632b41fe886b2 100644 --- a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/create.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/create.test.ts @@ -20,7 +20,7 @@ import { type InternalSavedObjectsRequestHandlerContext, } from '@kbn/core-saved-objects-server-internal'; import { loggerMock } from '@kbn/logging-mocks'; -import { setupConfig } from '../routes_test_utils'; +import { deprecationMock, setupConfig } from '../routes_test_utils'; type SetupServerReturn = Awaited>; @@ -58,7 +58,14 @@ describe('POST /api/saved_objects/{type} with allowApiAccess true', () => { const logger = loggerMock.create(); const config = setupConfig(true); const access = 'public'; - registerCreateRoute(router, { config, coreUsageData, logger, access }); + + registerCreateRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); handlerContext.savedObjects.typeRegistry.getType.mockImplementation((typename: string) => { return testTypes diff --git a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/delete.test.ts b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/delete.test.ts index 83cb90ab4d8d7..a1f3ff0bc60ec 100644 --- a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/delete.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/delete.test.ts @@ -20,7 +20,7 @@ import { type InternalSavedObjectsRequestHandlerContext, } from '@kbn/core-saved-objects-server-internal'; import { loggerMock } from '@kbn/logging-mocks'; -import { setupConfig } from '../routes_test_utils'; +import { deprecationMock, setupConfig } from '../routes_test_utils'; type SetupServerReturn = Awaited>; @@ -55,7 +55,14 @@ describe('DELETE /api/saved_objects/{type}/{id} with allowApiAccess true', () => const logger = loggerMock.create(); const config = setupConfig(true); const access = 'public'; - registerDeleteRoute(router, { config, coreUsageData, logger, access }); + + registerDeleteRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); await server.start(); }); diff --git a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/find.test.ts b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/find.test.ts index 3f7e0b815662e..c87546ea4887a 100644 --- a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/find.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/find.test.ts @@ -21,7 +21,7 @@ import { registerFindRoute, type InternalSavedObjectsRequestHandlerContext, } from '@kbn/core-saved-objects-server-internal'; -import { setupConfig } from '../routes_test_utils'; +import { deprecationMock, setupConfig } from '../routes_test_utils'; type SetupServerReturn = Awaited>; @@ -72,7 +72,13 @@ describe('GET /api/saved_objects/_find with allowApiAccess true', () => { const config = setupConfig(true); const access = 'public'; - registerFindRoute(router, { config, coreUsageData, logger, access }); + registerFindRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); await server.start(); }); diff --git a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/get.test.ts b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/get.test.ts index c97ae350c0386..6220de6540685 100644 --- a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/get.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/get.test.ts @@ -25,7 +25,7 @@ import { } from '@kbn/core-saved-objects-server-internal'; import { createHiddenTypeVariants } from '@kbn/core-test-helpers-test-utils'; import { loggerMock } from '@kbn/logging-mocks'; -import { setupConfig } from '../routes_test_utils'; +import { deprecationMock, setupConfig } from '../routes_test_utils'; const coreId = Symbol('core'); const testTypes = [ @@ -80,7 +80,14 @@ describe('GET /api/saved_objects/{type}/{id} with allowApiAccess true', () => { const config = setupConfig(true); const access = 'public'; - registerGetRoute(router, { config, coreUsageData, logger, access }); + + registerGetRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); await server.start(); }); diff --git a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/resolve.test.ts b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/resolve.test.ts index bc00a418a13b2..f1f7fd1d6153e 100644 --- a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/resolve.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/resolve.test.ts @@ -25,7 +25,7 @@ import { } from '@kbn/core-saved-objects-server-internal'; import { createHiddenTypeVariants } from '@kbn/core-test-helpers-test-utils'; import { loggerMock } from '@kbn/logging-mocks'; -import { setupConfig } from '../routes_test_utils'; +import { deprecationMock, setupConfig } from '../routes_test_utils'; const coreId = Symbol('core'); @@ -81,7 +81,13 @@ describe('GET /api/saved_objects/resolve/{type}/{id} with allowApiAccess true', const config = setupConfig(true); const access = 'public'; - registerResolveRoute(router, { config, coreUsageData, logger, access }); + registerResolveRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); await server.start(); }); diff --git a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/update.test.ts b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/update.test.ts index 25da93b526285..2a086f29d75d1 100644 --- a/src/core/server/integration_tests/saved_objects/routes/allow_api_access/update.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/allow_api_access/update.test.ts @@ -20,7 +20,7 @@ import { type InternalSavedObjectsRequestHandlerContext, } from '@kbn/core-saved-objects-server-internal'; import { loggerMock } from '@kbn/logging-mocks'; -import { setupConfig } from '../routes_test_utils'; +import { deprecationMock, setupConfig } from '../routes_test_utils'; type SetupServerReturn = Awaited>; @@ -56,7 +56,14 @@ describe('PUT /api/saved_objects/{type}/{id?} with allowApiAccess true', () => { const config = setupConfig(true); const access = 'public'; - registerUpdateRoute(router, { config, coreUsageData, logger, access }); + + registerUpdateRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); await server.start(); }); diff --git a/src/core/server/integration_tests/saved_objects/routes/bulk_create.test.ts b/src/core/server/integration_tests/saved_objects/routes/bulk_create.test.ts index 3eaf3bbdc8865..033a5570c588a 100644 --- a/src/core/server/integration_tests/saved_objects/routes/bulk_create.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/bulk_create.test.ts @@ -21,7 +21,7 @@ import { } from '@kbn/core-saved-objects-server-internal'; import { createHiddenTypeVariants, setupServer } from '@kbn/core-test-helpers-test-utils'; import { loggerMock } from '@kbn/logging-mocks'; -import { setupConfig } from './routes_test_utils'; +import { deprecationMock, setupConfig } from './routes_test_utils'; type SetupServerReturn = Awaited>; @@ -37,6 +37,7 @@ describe('POST /api/saved_objects/_bulk_create', () => { let savedObjectsClient: ReturnType; let coreUsageStatsClient: jest.Mocked; let loggerWarnSpy: jest.SpyInstance; + let registrationSpy: jest.SpyInstance; beforeEach(async () => { ({ server, httpSetup, handlerContext } = await setupServer()); @@ -57,11 +58,18 @@ describe('POST /api/saved_objects/_bulk_create', () => { const logger = loggerMock.create(); loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation(); + registrationSpy = jest.spyOn(router, 'post'); const config = setupConfig(); const access = 'public'; - registerBulkCreateRoute(router, { config, coreUsageData, logger, access }); + registerBulkCreateRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); await server.start(); }); @@ -194,4 +202,24 @@ describe('POST /api/saved_objects/_bulk_create', () => { .expect(200); expect(loggerWarnSpy).toHaveBeenCalledTimes(1); }); + + it('passes deprecation config to the router arguments', async () => { + await supertest(httpSetup.server.listener) + .post('/api/saved_objects/_bulk_create') + .set('x-elastic-internal-origin', 'kibana') + .send([ + { + id: 'abc1234', + type: 'index-pattern', + attributes: { + title: 'foo', + }, + references: [], + }, + ]) + .expect(200); + expect(registrationSpy.mock.calls[0][0]).toMatchObject({ + options: { deprecated: deprecationMock }, + }); + }); }); diff --git a/src/core/server/integration_tests/saved_objects/routes/bulk_delete.test.ts b/src/core/server/integration_tests/saved_objects/routes/bulk_delete.test.ts index 24f2cf29fe14f..9421d5207b211 100644 --- a/src/core/server/integration_tests/saved_objects/routes/bulk_delete.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/bulk_delete.test.ts @@ -20,7 +20,7 @@ import { type InternalSavedObjectsRequestHandlerContext, } from '@kbn/core-saved-objects-server-internal'; import { loggerMock } from '@kbn/logging-mocks'; -import { setupConfig } from './routes_test_utils'; +import { deprecationMock, setupConfig } from './routes_test_utils'; type SetupServerReturn = Awaited>; @@ -36,6 +36,7 @@ describe('POST /api/saved_objects/_bulk_delete', () => { let savedObjectsClient: ReturnType; let coreUsageStatsClient: jest.Mocked; let loggerWarnSpy: jest.SpyInstance; + let registrationSpy: jest.SpyInstance; beforeEach(async () => { ({ server, httpSetup, handlerContext } = await setupServer()); @@ -59,11 +60,18 @@ describe('POST /api/saved_objects/_bulk_delete', () => { const logger = loggerMock.create(); loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation(); + registrationSpy = jest.spyOn(router, 'post'); const config = setupConfig(); const access = 'public'; - registerBulkDeleteRoute(router, { config, coreUsageData, logger, access }); + registerBulkDeleteRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); await server.start(); }); @@ -163,4 +171,21 @@ describe('POST /api/saved_objects/_bulk_delete', () => { .expect(400); expect(loggerWarnSpy).toHaveBeenCalledTimes(1); }); + + it('passes deprecation configuration to the router arguments', async () => { + await supertest(httpSetup.server.listener) + .post('/api/saved_objects/_bulk_delete') + .set('x-elastic-internal-origin', 'kibana') + .send([ + { + id: 'hiddenID', + type: 'hidden-from-http', + }, + ]) + .expect(400); + + expect(registrationSpy.mock.calls[0][0]).toMatchObject({ + options: { deprecated: deprecationMock }, + }); + }); }); diff --git a/src/core/server/integration_tests/saved_objects/routes/bulk_get.test.ts b/src/core/server/integration_tests/saved_objects/routes/bulk_get.test.ts index 519bdbb5f6c74..8d16ca5787350 100644 --- a/src/core/server/integration_tests/saved_objects/routes/bulk_get.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/bulk_get.test.ts @@ -20,7 +20,7 @@ import { type InternalSavedObjectsRequestHandlerContext, } from '@kbn/core-saved-objects-server-internal'; import { loggerMock } from '@kbn/logging-mocks'; -import { setupConfig } from './routes_test_utils'; +import { deprecationMock, setupConfig } from './routes_test_utils'; type SetupServerReturn = Awaited>; @@ -36,6 +36,7 @@ describe('POST /api/saved_objects/_bulk_get', () => { let savedObjectsClient: ReturnType; let coreUsageStatsClient: jest.Mocked; let loggerWarnSpy: jest.SpyInstance; + let registrationSpy: jest.SpyInstance; beforeEach(async () => { ({ server, httpSetup, handlerContext } = await setupServer()); @@ -57,11 +58,18 @@ describe('POST /api/saved_objects/_bulk_get', () => { const coreUsageData = coreUsageDataServiceMock.createSetupContract(coreUsageStatsClient); const logger = loggerMock.create(); loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation(); + registrationSpy = jest.spyOn(router, 'post'); const config = setupConfig(); const access = 'public'; - registerBulkGetRoute(router, { config, coreUsageData, logger, access }); + registerBulkGetRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); await server.start(); }); @@ -150,4 +158,20 @@ describe('POST /api/saved_objects/_bulk_get', () => { .expect(200); expect(loggerWarnSpy).toHaveBeenCalledTimes(1); }); + + it('passes deprecation config to the router arguments', async () => { + await supertest(httpSetup.server.listener) + .post('/api/saved_objects/_bulk_get') + .set('x-elastic-internal-origin', 'kibana') + .send([ + { + id: 'abc123', + type: 'index-pattern', + }, + ]) + .expect(200); + expect(registrationSpy.mock.calls[0][0]).toMatchObject({ + options: { deprecated: deprecationMock }, + }); + }); }); diff --git a/src/core/server/integration_tests/saved_objects/routes/bulk_resolve.test.ts b/src/core/server/integration_tests/saved_objects/routes/bulk_resolve.test.ts index 2636d38fc28b5..800fccb00324d 100644 --- a/src/core/server/integration_tests/saved_objects/routes/bulk_resolve.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/bulk_resolve.test.ts @@ -20,7 +20,7 @@ import { type InternalSavedObjectsRequestHandlerContext, } from '@kbn/core-saved-objects-server-internal'; import { loggerMock } from '@kbn/logging-mocks'; -import { setupConfig } from './routes_test_utils'; +import { deprecationMock, setupConfig } from './routes_test_utils'; type SetupServerReturn = Awaited>; @@ -36,6 +36,7 @@ describe('POST /api/saved_objects/_bulk_resolve', () => { let savedObjectsClient: ReturnType; let coreUsageStatsClient: jest.Mocked; let loggerWarnSpy: jest.SpyInstance; + let registrationSpy: jest.SpyInstance; beforeEach(async () => { ({ server, httpSetup, handlerContext } = await setupServer()); @@ -58,11 +59,17 @@ describe('POST /api/saved_objects/_bulk_resolve', () => { const coreUsageData = coreUsageDataServiceMock.createSetupContract(coreUsageStatsClient); const logger = loggerMock.create(); loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation(); + registrationSpy = jest.spyOn(router, 'post'); const config = setupConfig(); const access = 'public'; - - registerBulkResolveRoute(router, { config, coreUsageData, logger, access }); + registerBulkResolveRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); await server.start(); }); @@ -154,4 +161,20 @@ describe('POST /api/saved_objects/_bulk_resolve', () => { .expect(200); expect(loggerWarnSpy).toHaveBeenCalledTimes(1); }); + + it('passes deprecation configuration to the router arguments', async () => { + await supertest(httpSetup.server.listener) + .post('/api/saved_objects/_bulk_resolve') + .set('x-elastic-internal-origin', 'kibana') + .send([ + { + id: 'abc123', + type: 'index-pattern', + }, + ]) + .expect(200); + expect(registrationSpy.mock.calls[0][0]).toMatchObject({ + options: { deprecated: deprecationMock }, + }); + }); }); diff --git a/src/core/server/integration_tests/saved_objects/routes/bulk_update.test.ts b/src/core/server/integration_tests/saved_objects/routes/bulk_update.test.ts index 8ea206b4d902e..d746d1d5b9ca8 100644 --- a/src/core/server/integration_tests/saved_objects/routes/bulk_update.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/bulk_update.test.ts @@ -20,7 +20,7 @@ import { type InternalSavedObjectsRequestHandlerContext, } from '@kbn/core-saved-objects-server-internal'; import { loggerMock } from '@kbn/logging-mocks'; -import { setupConfig } from './routes_test_utils'; +import { deprecationMock, setupConfig } from './routes_test_utils'; type SetupServerReturn = Awaited>; const testTypes = [ @@ -37,6 +37,7 @@ describe('PUT /api/saved_objects/_bulk_update', () => { let savedObjectsClient: ReturnType; let coreUsageStatsClient: jest.Mocked; let loggerWarnSpy: jest.SpyInstance; + let registrationSpy: jest.SpyInstance; beforeEach(async () => { ({ server, httpSetup, handlerContext } = await setupServer()); @@ -56,11 +57,18 @@ describe('PUT /api/saved_objects/_bulk_update', () => { const coreUsageData = coreUsageDataServiceMock.createSetupContract(coreUsageStatsClient); const logger = loggerMock.create(); loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation(); + registrationSpy = jest.spyOn(router, 'put'); const config = setupConfig(); const access = 'public'; - registerBulkUpdateRoute(router, { config, coreUsageData, logger, access }); + registerBulkUpdateRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); await server.start(); }); @@ -180,6 +188,7 @@ describe('PUT /api/saved_objects/_bulk_update', () => { }, ]) .expect(400); + expect(result.body.message).toContain('Unsupported saved object type(s):'); }); @@ -205,5 +214,35 @@ describe('PUT /api/saved_objects/_bulk_update', () => { ]) .expect(200); expect(loggerWarnSpy).toHaveBeenCalledTimes(1); + expect(registrationSpy.mock.calls[0][0]).toMatchObject({ + options: { deprecated: deprecationMock }, + }); + }); + + it('passes deprecation configuration to the router arguments', async () => { + await supertest(httpSetup.server.listener) + .put('/api/saved_objects/_bulk_update') + .set('x-elastic-internal-origin', 'kibana') + .send([ + { + type: 'visualization', + id: 'dd7caf20-9efd-11e7-acb3-3dab96693fab', + attributes: { + title: 'An existing visualization', + }, + }, + { + type: 'dashboard', + id: 'be3733a0-9efe-11e7-acb3-3dab96693fab', + attributes: { + title: 'An existing dashboard', + }, + }, + ]) + .expect(200); + + expect(registrationSpy.mock.calls[0][0]).toMatchObject({ + options: { deprecated: deprecationMock }, + }); }); }); diff --git a/src/core/server/integration_tests/saved_objects/routes/create.test.ts b/src/core/server/integration_tests/saved_objects/routes/create.test.ts index 3fe9f5fcc6f05..f2471e14fc128 100644 --- a/src/core/server/integration_tests/saved_objects/routes/create.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/create.test.ts @@ -20,7 +20,7 @@ import { type InternalSavedObjectsRequestHandlerContext, } from '@kbn/core-saved-objects-server-internal'; import { loggerMock } from '@kbn/logging-mocks'; -import { setupConfig } from './routes_test_utils'; +import { deprecationMock, setupConfig } from './routes_test_utils'; type SetupServerReturn = Awaited>; @@ -36,6 +36,7 @@ describe('POST /api/saved_objects/{type}', () => { let savedObjectsClient: ReturnType; let coreUsageStatsClient: jest.Mocked; let loggerWarnSpy: jest.SpyInstance; + let registrationSpy: jest.SpyInstance; const clientResponse = { id: 'logstash-*', @@ -58,10 +59,18 @@ describe('POST /api/saved_objects/{type}', () => { const coreUsageData = coreUsageDataServiceMock.createSetupContract(coreUsageStatsClient); const logger = loggerMock.create(); loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation(); + registrationSpy = jest.spyOn(router, 'post'); + const config = setupConfig(); const access = 'public'; - registerCreateRoute(router, { config, coreUsageData, logger, access }); + registerCreateRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); handlerContext.savedObjects.typeRegistry.getType.mockImplementation((typename: string) => { return testTypes @@ -178,4 +187,19 @@ describe('POST /api/saved_objects/{type}', () => { .expect(200); expect(loggerWarnSpy).toHaveBeenCalledTimes(1); }); + + it('passes deprecation configuration to the router arguments', async () => { + await supertest(httpSetup.server.listener) + .post('/api/saved_objects/index-pattern') + .set('x-elastic-internal-origin', 'kibana') + .send({ + attributes: { + title: 'Logging test', + }, + }) + .expect(200); + expect(registrationSpy.mock.calls[0][0]).toMatchObject({ + options: { deprecated: deprecationMock }, + }); + }); }); diff --git a/src/core/server/integration_tests/saved_objects/routes/delete.test.ts b/src/core/server/integration_tests/saved_objects/routes/delete.test.ts index ba5c797469aa3..70d811cd97521 100644 --- a/src/core/server/integration_tests/saved_objects/routes/delete.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/delete.test.ts @@ -20,7 +20,7 @@ import { type InternalSavedObjectsRequestHandlerContext, } from '@kbn/core-saved-objects-server-internal'; import { loggerMock } from '@kbn/logging-mocks'; -import { setupConfig } from './routes_test_utils'; +import { deprecationMock, setupConfig } from './routes_test_utils'; type SetupServerReturn = Awaited>; @@ -37,6 +37,7 @@ describe('DELETE /api/saved_objects/{type}/{id}', () => { let savedObjectsClient: ReturnType; let coreUsageStatsClient: jest.Mocked; let loggerWarnSpy: jest.SpyInstance; + let registrationSpy: jest.SpyInstance; beforeEach(async () => { ({ server, httpSetup, handlerContext } = await setupServer()); @@ -55,9 +56,17 @@ describe('DELETE /api/saved_objects/{type}/{id}', () => { const coreUsageData = coreUsageDataServiceMock.createSetupContract(coreUsageStatsClient); const logger = loggerMock.create(); loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation(); + registrationSpy = jest.spyOn(router, 'delete'); + const config = setupConfig(); const access = 'public'; - registerDeleteRoute(router, { config, coreUsageData, logger, access }); + registerDeleteRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); await server.start(); }); @@ -120,4 +129,13 @@ describe('DELETE /api/saved_objects/{type}/{id}', () => { .expect(200); expect(loggerWarnSpy).toHaveBeenCalledTimes(1); }); + + it('passes deprecation configuration to the router arguments', async () => { + await supertest(httpSetup.server.listener) + .delete('/api/saved_objects/index-pattern/logstash-*') + .expect(200); + expect(registrationSpy.mock.calls[0][0]).toMatchObject({ + options: { deprecated: deprecationMock }, + }); + }); }); diff --git a/src/core/server/integration_tests/saved_objects/routes/find.test.ts b/src/core/server/integration_tests/saved_objects/routes/find.test.ts index b7d193db42525..d2048ba13b634 100644 --- a/src/core/server/integration_tests/saved_objects/routes/find.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/find.test.ts @@ -22,7 +22,7 @@ import { registerFindRoute, type InternalSavedObjectsRequestHandlerContext, } from '@kbn/core-saved-objects-server-internal'; -import { setupConfig } from './routes_test_utils'; +import { deprecationMock, setupConfig } from './routes_test_utils'; type SetupServerReturn = Awaited>; @@ -42,6 +42,7 @@ describe('GET /api/saved_objects/_find', () => { let savedObjectsClient: ReturnType; let coreUsageStatsClient: jest.Mocked; let loggerWarnSpy: jest.SpyInstance; + let registrationSpy: jest.SpyInstance; const clientResponse = { total: 0, @@ -71,11 +72,18 @@ describe('GET /api/saved_objects/_find', () => { const logger = loggerMock.create(); loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation(); + registrationSpy = jest.spyOn(router, 'get'); const config = setupConfig(); const access = 'public'; - registerFindRoute(router, { config, coreUsageData, logger, access }); + registerFindRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); await server.start(); }); @@ -471,4 +479,14 @@ describe('GET /api/saved_objects/_find', () => { .expect(200); expect(loggerWarnSpy).toHaveBeenCalledTimes(1); }); + + it('passes deprecation configuration to the router arguments', async () => { + await supertest(httpSetup.server.listener) + .get('/api/saved_objects/_find?type=foo&type=bar') + .set('x-elastic-internal-origin', 'kibana') + .expect(200); + expect(registrationSpy.mock.calls[0][0]).toMatchObject({ + options: { deprecated: deprecationMock }, + }); + }); }); diff --git a/src/core/server/integration_tests/saved_objects/routes/get.test.ts b/src/core/server/integration_tests/saved_objects/routes/get.test.ts index 97868b9cc23d2..bb748ca478e8a 100644 --- a/src/core/server/integration_tests/saved_objects/routes/get.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/get.test.ts @@ -25,7 +25,7 @@ import { } from '@kbn/core-saved-objects-server-internal'; import { createHiddenTypeVariants } from '@kbn/core-test-helpers-test-utils'; import { loggerMock } from '@kbn/logging-mocks'; -import { setupConfig } from './routes_test_utils'; +import { deprecationMock, setupConfig } from './routes_test_utils'; const coreId = Symbol('core'); const testTypes = [ @@ -41,6 +41,7 @@ describe('GET /api/saved_objects/{type}/{id}', () => { let savedObjectsClient: ReturnType; let coreUsageStatsClient: jest.Mocked; let loggerWarnSpy: jest.SpyInstance; + let registrationSpy: jest.SpyInstance; beforeEach(async () => { const coreContext = createCoreContext({ coreId }); @@ -80,10 +81,18 @@ describe('GET /api/saved_objects/{type}/{id}', () => { const logger = loggerMock.create(); loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation(); + registrationSpy = jest.spyOn(router, 'get'); + const config = setupConfig(); const access = 'public'; - registerGetRoute(router, { config, coreUsageData, logger, access }); + registerGetRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); await server.start(); }); @@ -144,4 +153,14 @@ describe('GET /api/saved_objects/{type}/{id}', () => { .expect(200); expect(loggerWarnSpy).toHaveBeenCalledTimes(1); }); + + it('passes deprecation configuration to the router arguments', async () => { + await supertest(httpSetup.server.listener) + .get('/api/saved_objects/index-pattern/logstash-*') + .set('x-elastic-internal-origin', 'kibana') + .expect(200); + expect(registrationSpy.mock.calls[0][0]).toMatchObject({ + options: { deprecated: deprecationMock }, + }); + }); }); diff --git a/src/core/server/integration_tests/saved_objects/routes/legacy_import_export/export.test.ts b/src/core/server/integration_tests/saved_objects/routes/legacy_import_export/export.test.ts index 008ad527e03e3..73f1ce075272c 100644 --- a/src/core/server/integration_tests/saved_objects/routes/legacy_import_export/export.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/legacy_import_export/export.test.ts @@ -41,6 +41,7 @@ import { registerLegacyExportRoute, type InternalSavedObjectsRequestHandlerContext, } from '@kbn/core-saved-objects-server-internal'; +import { legacyDeprecationMock } from '../routes_test_utils'; type SetupServerReturn = Awaited>; let coreUsageStatsClient: jest.Mocked; @@ -58,11 +59,13 @@ describe('POST /api/dashboards/export', () => { coreUsageStatsClient = coreUsageStatsClientMock.create(); coreUsageStatsClient.incrementLegacyDashboardsExport.mockRejectedValue(new Error('Oh no!')); // intentionally throw this error, which is swallowed, so we can assert that the operation does not fail const coreUsageData = coreUsageDataServiceMock.createSetupContract(coreUsageStatsClient); + registerLegacyExportRoute(router, { kibanaVersion: 'mockversion', coreUsageData, logger: loggerMock.create(), access: 'public', + legacyDeprecationInfo: legacyDeprecationMock, }); handlerContext.savedObjects.client.bulkGet diff --git a/src/core/server/integration_tests/saved_objects/routes/legacy_import_export/import.test.ts b/src/core/server/integration_tests/saved_objects/routes/legacy_import_export/import.test.ts index 0355ac7d39706..c96c0e1d9011a 100644 --- a/src/core/server/integration_tests/saved_objects/routes/legacy_import_export/import.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/legacy_import_export/import.test.ts @@ -41,6 +41,7 @@ import { registerLegacyImportRoute, type InternalSavedObjectsRequestHandlerContext, } from '@kbn/core-saved-objects-server-internal'; +import { legacyDeprecationMock } from '../routes_test_utils'; type SetupServerReturn = Awaited>; let coreUsageStatsClient: jest.Mocked; @@ -58,11 +59,13 @@ describe('POST /api/dashboards/import', () => { coreUsageStatsClient = coreUsageStatsClientMock.create(); coreUsageStatsClient.incrementLegacyDashboardsImport.mockRejectedValue(new Error('Oh no!')); // intentionally throw this error, which is swallowed, so we can assert that the operation does not fail const coreUsageData = coreUsageDataServiceMock.createSetupContract(coreUsageStatsClient); + registerLegacyImportRoute(router, { maxImportPayloadBytes: 26214400, coreUsageData, logger: loggerMock.create(), access: 'public', + legacyDeprecationInfo: legacyDeprecationMock, }); handlerContext.savedObjects.client.bulkCreate.mockResolvedValueOnce({ diff --git a/src/core/server/integration_tests/saved_objects/routes/resolve.test.ts b/src/core/server/integration_tests/saved_objects/routes/resolve.test.ts index e96c7ee9fb089..7812081e5329c 100644 --- a/src/core/server/integration_tests/saved_objects/routes/resolve.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/resolve.test.ts @@ -25,7 +25,7 @@ import { } from '@kbn/core-saved-objects-server-internal'; import { createHiddenTypeVariants } from '@kbn/core-test-helpers-test-utils'; import { loggerMock } from '@kbn/logging-mocks'; -import { setupConfig } from './routes_test_utils'; +import { deprecationMock, setupConfig } from './routes_test_utils'; const coreId = Symbol('core'); @@ -42,6 +42,7 @@ describe('GET /api/saved_objects/resolve/{type}/{id}', () => { let savedObjectsClient: ReturnType; let coreUsageStatsClient: jest.Mocked; let loggerWarnSpy: jest.SpyInstance; + let registrationSpy: jest.SpyInstance; beforeEach(async () => { const coreContext = createCoreContext({ coreId }); @@ -79,10 +80,18 @@ describe('GET /api/saved_objects/resolve/{type}/{id}', () => { const coreUsageData = coreUsageDataServiceMock.createSetupContract(coreUsageStatsClient); const logger = loggerMock.create(); loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation(); + registrationSpy = jest.spyOn(router, 'get'); + const config = setupConfig(); const access = 'public'; - registerResolveRoute(router, { config, coreUsageData, logger, access }); + registerResolveRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); await server.start(); }); @@ -142,4 +151,14 @@ describe('GET /api/saved_objects/resolve/{type}/{id}', () => { .expect(200); expect(loggerWarnSpy).toHaveBeenCalledTimes(1); }); + + it('passes deprecation configuration to the router arguments', async () => { + await supertest(httpSetup.server.listener) + .get('/api/saved_objects/resolve/index-pattern/logstash-*') + .set('x-elastic-internal-origin', 'kibana') + .expect(200); + expect(registrationSpy.mock.calls[0][0]).toMatchObject({ + options: { deprecated: deprecationMock }, + }); + }); }); diff --git a/src/core/server/integration_tests/saved_objects/routes/routes_test_utils.ts b/src/core/server/integration_tests/saved_objects/routes/routes_test_utils.ts index b27b2b72aba97..3c78b4e7f0e3b 100644 --- a/src/core/server/integration_tests/saved_objects/routes/routes_test_utils.ts +++ b/src/core/server/integration_tests/saved_objects/routes/routes_test_utils.ts @@ -15,3 +15,19 @@ export function setupConfig(allowAccess: boolean = false) { } as SavedObjectConfig; return config; } + +export const deprecationMock = { + documentationUrl: 'http://elastic.co', + severity: 'warning' as const, + reason: { + type: 'deprecate' as const, + }, +}; + +export const legacyDeprecationMock = { + documentationUrl: 'http://elastic.co', + severity: 'warning' as const, + reason: { + type: 'remove' as const, + }, +}; diff --git a/src/core/server/integration_tests/saved_objects/routes/update.test.ts b/src/core/server/integration_tests/saved_objects/routes/update.test.ts index 47f3ef4b73652..909121429aefb 100644 --- a/src/core/server/integration_tests/saved_objects/routes/update.test.ts +++ b/src/core/server/integration_tests/saved_objects/routes/update.test.ts @@ -20,7 +20,7 @@ import { type InternalSavedObjectsRequestHandlerContext, } from '@kbn/core-saved-objects-server-internal'; import { loggerMock } from '@kbn/logging-mocks'; -import { setupConfig } from './routes_test_utils'; +import { deprecationMock, setupConfig } from './routes_test_utils'; type SetupServerReturn = Awaited>; @@ -37,6 +37,7 @@ describe('PUT /api/saved_objects/{type}/{id?}', () => { let savedObjectsClient: ReturnType; let coreUsageStatsClient: jest.Mocked; let loggerWarnSpy: jest.SpyInstance; + let registrationSpy: jest.SpyInstance; beforeEach(async () => { const clientResponse = { @@ -66,10 +67,17 @@ describe('PUT /api/saved_objects/{type}/{id?}', () => { const coreUsageData = coreUsageDataServiceMock.createSetupContract(coreUsageStatsClient); const logger = loggerMock.create(); loggerWarnSpy = jest.spyOn(logger, 'warn').mockImplementation(); + registrationSpy = jest.spyOn(router, 'put'); const config = setupConfig(); const access = 'public'; - registerUpdateRoute(router, { config, coreUsageData, logger, access }); + registerUpdateRoute(router, { + config, + coreUsageData, + logger, + access, + deprecationInfo: deprecationMock, + }); await server.start(); }); @@ -145,4 +153,15 @@ describe('PUT /api/saved_objects/{type}/{id?}', () => { .expect(200); expect(loggerWarnSpy).toHaveBeenCalledTimes(1); }); + + it('passes deprecation configuration to the router arguments', async () => { + await supertest(httpSetup.server.listener) + .put('/api/saved_objects/index-pattern/logstash-*') + .set('x-elastic-internal-origin', 'kibana') + .send({ attributes: { title: 'Logging test' }, version: 'log' }) + .expect(200); + expect(registrationSpy.mock.calls[0][0]).toMatchObject({ + options: { deprecated: deprecationMock }, + }); + }); });