Skip to content

Commit

Permalink
adds deprecation info to all deprecated SO routes, updates integratio…
Browse files Browse the repository at this point in the history
…n tests
  • Loading branch information
TinaHeiligers committed Oct 29, 2024
1 parent e3edb55 commit a465b21
Show file tree
Hide file tree
Showing 26 changed files with 323 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ import {
logWarnOnExternalRequest,
throwIfAnyTypeNotVisibleByAPI,
} from './utils';
import { DeprecationInfo } from '.';

interface RouteDependencies {
config: SavedObjectConfig;
coreUsageData: InternalCoreUsageDataSetup;
logger: Logger;
access: RouteAccess;
deprecationInfo: DeprecationInfo;
}

export const registerBulkCreateRoute = (
router: InternalSavedObjectRouter,
{ config, coreUsageData, logger, access }: RouteDependencies
{ config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies
) => {
const { allowHttpApiAccess } = config;
router.post(
Expand All @@ -38,8 +40,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({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ import {
logWarnOnExternalRequest,
throwIfAnyTypeNotVisibleByAPI,
} from './utils';
import { DeprecationInfo } from '.';

interface RouteDependencies {
config: SavedObjectConfig;
coreUsageData: InternalCoreUsageDataSetup;
logger: Logger;
access: RouteAccess;
deprecationInfo: DeprecationInfo;
}

export const registerBulkDeleteRoute = (
router: InternalSavedObjectRouter,
{ config, coreUsageData, logger, access }: RouteDependencies
{ config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies
) => {
const { allowHttpApiAccess } = config;
router.post(
Expand All @@ -38,8 +40,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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ import {
logWarnOnExternalRequest,
throwIfAnyTypeNotVisibleByAPI,
} from './utils';
import { DeprecationInfo } from '.';

interface RouteDependencies {
config: SavedObjectConfig;
coreUsageData: InternalCoreUsageDataSetup;
logger: Logger;
access: RouteAccess;
deprecationInfo: DeprecationInfo;
}

export const registerBulkGetRoute = (
router: InternalSavedObjectRouter,
{ config, coreUsageData, logger, access }: RouteDependencies
{ config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies
) => {
const { allowHttpApiAccess } = config;
router.post(
Expand All @@ -38,8 +40,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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ import {
logWarnOnExternalRequest,
throwIfAnyTypeNotVisibleByAPI,
} from './utils';
import { DeprecationInfo } from '.';

interface RouteDependencies {
config: SavedObjectConfig;
coreUsageData: InternalCoreUsageDataSetup;
logger: Logger;
access: RouteAccess;
deprecationInfo: DeprecationInfo;
}

export const registerBulkResolveRoute = (
router: InternalSavedObjectRouter,
{ config, coreUsageData, logger, access }: RouteDependencies
{ config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies
) => {
const { allowHttpApiAccess } = config;
router.post(
Expand All @@ -38,8 +40,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.`,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@ import {
logWarnOnExternalRequest,
throwIfAnyTypeNotVisibleByAPI,
} from './utils';
import { DeprecationInfo } from '.';

interface RouteDependencies {
config: SavedObjectConfig;
coreUsageData: InternalCoreUsageDataSetup;
logger: Logger;
access: RouteAccess;
deprecationInfo: DeprecationInfo;
}

export const registerBulkUpdateRoute = (
router: InternalSavedObjectRouter,
{ config, coreUsageData, logger, access }: RouteDependencies
{ config, coreUsageData, logger, access, deprecationInfo }: RouteDependencies
) => {
const { allowHttpApiAccess } = config;
router.put(
Expand All @@ -38,8 +40,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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,41 @@ export function registerRoutes({
access: internalOnServerless,
deprecationInfo,
});
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 });
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,
});

registerExportRoute(router, { config, coreUsageData });
registerImportRoute(router, { config, coreUsageData });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,20 @@ 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 });
const deprecationMock = {
documentationUrl: 'http://elastic.co',
severity: 'warning' as const,
reason: {
type: 'remove' as const,
},
};
registerBulkCreateRoute(router, {
config,
coreUsageData,
logger,
access,
deprecationInfo: deprecationMock,
});

await server.start();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,20 @@ describe('POST /api/saved_objects/_bulk_delete with allowApiAccess as true', ()

const config = setupConfig(true);
const access = 'public';

registerBulkDeleteRoute(router, { config, coreUsageData, logger, access });
const deprecationMock = {
documentationUrl: 'http://elastic.co',
severity: 'warning' as const,
reason: {
type: 'remove' as const,
},
};
registerBulkDeleteRoute(router, {
config,
coreUsageData,
logger,
access,
deprecationInfo: deprecationMock,
});

await server.start();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,20 @@ describe('POST /api/saved_objects/_bulk_get with allowApiAccess true', () => {

const config = setupConfig(true);
const access = 'public';
registerBulkGetRoute(router, { config, coreUsageData, logger, access });
const deprecationMock = {
documentationUrl: 'http://elastic.co',
severity: 'warning' as const,
reason: {
type: 'remove' as const,
},
};
registerBulkGetRoute(router, {
config,
coreUsageData,
logger,
access,
deprecationInfo: deprecationMock,
});

await server.start();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,20 @@ describe('POST /api/saved_objects/_bulk_resolve with allowApiAccess true', () =>

const config = setupConfig(true);
const access = 'public';
registerBulkResolveRoute(router, { config, coreUsageData, logger, access });
const deprecationMock = {
documentationUrl: 'http://elastic.co',
severity: 'warning' as const,
reason: {
type: 'remove' as const,
},
};
registerBulkResolveRoute(router, {
config,
coreUsageData,
logger,
access,
deprecationInfo: deprecationMock,
});

await server.start();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,20 @@ describe('PUT /api/saved_objects/_bulk_update with allowApiAccess true', () => {

const config = setupConfig(true);
const access = 'public';
registerBulkUpdateRoute(router, { config, coreUsageData, logger, access });
const deprecationMock = {
documentationUrl: 'http://elastic.co',
severity: 'warning' as const,
reason: {
type: 'remove' as const,
},
};
registerBulkUpdateRoute(router, {
config,
coreUsageData,
logger,
access,
deprecationInfo: deprecationMock,
});

await server.start();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,20 @@ 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 });
const deprecationMock = {
documentationUrl: 'http://elastic.co',
severity: 'warning' as const,
reason: {
type: 'remove' as const,
},
};
registerCreateRoute(router, {
config,
coreUsageData,
logger,
access,
deprecationInfo: deprecationMock,
});

handlerContext.savedObjects.typeRegistry.getType.mockImplementation((typename: string) => {
return testTypes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,20 @@ 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 });
const deprecationMock = {
documentationUrl: 'http://elastic.co',
severity: 'warning' as const,
reason: {
type: 'remove' as const,
},
};
registerDeleteRoute(router, {
config,
coreUsageData,
logger,
access,
deprecationInfo: deprecationMock,
});

await server.start();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,20 @@ describe('GET /api/saved_objects/_find with allowApiAccess true', () => {

const config = setupConfig(true);
const access = 'public';

registerFindRoute(router, { config, coreUsageData, logger, access });
const deprecationMock = {
documentationUrl: 'http://elastic.co',
severity: 'warning' as const,
reason: {
type: 'remove' as const,
},
};
registerFindRoute(router, {
config,
coreUsageData,
logger,
access,
deprecationInfo: deprecationMock,
});

await server.start();
});
Expand Down
Loading

0 comments on commit a465b21

Please sign in to comment.