Skip to content

Commit

Permalink
[Response Ops][Cases] Use deprecation object (elastic#201004)
Browse files Browse the repository at this point in the history
## Summary

Adds deprecation object in deprecated cases routes

Closes [elastic#196557](elastic#196557)

---------

Co-authored-by: Lisa Cawley <[email protected]>
(cherry picked from commit 0735ab8)
  • Loading branch information
jcger committed Nov 27, 2024
1 parent c7ecbec commit 5ac3783
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 21 deletions.
22 changes: 21 additions & 1 deletion docs/upgrade-notes.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,27 @@ For Elastic Security release information, refer to {security-guide}/release-note
==== Kibana APIs

[discrete]
[[breaking-201004]]
.[Cases] Legacy deprecations (9.0.0)
[%collapsible]
====
*Details* +
`GET /api/cases/status` has been deprecated with no replacement. Deleted in v9.0.0
`GET /api/cases/{case_id}/comments` has been replaced by `GET /api/cases/{case_id}/comments/_find` released in v7.13
`GET /api/cases/<case_id>/user_actions` has been replaced by `GET /api/cases/<case_id>/user_actions/_find` released in v8.7
`includeComments` parameter in `GET /api/cases/{case_id}` has been deprecated. Use `GET /api/cases/{case_id}/comments/_find` instead, released in v7.13
*Impact* +
Deprecated endpoints will fail with a 404 status code starting from version 9.0.0
*Action* +
Remove references to `GET /api/cases/status` endpoint.
Replace references to deprecated endpoints with the replacements listed in the breaking change details.
====

[[breaking-199656]]
.Removed all security v1 endpoints (9.0.0)
[%collapsible]
Expand Down Expand Up @@ -1832,4 +1853,3 @@ NOTE: For the complete Elastic Security solution release information, refer to {




3 changes: 3 additions & 0 deletions packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1008,5 +1008,8 @@ export const getDocLinks = ({ kibanaBranch, buildFlavor }: GetDocLinkOptions): D
inferenceManagement: {
inferenceAPIDocumentation: `${ELASTIC_WEBSITE_URL}docs/api/doc/elasticsearch/operation/operation-inference-put`,
},
cases: {
legacyApiDeprecations: `${KIBANA_DOCS}breaking-changes-summary.html#breaking-201004`,
},
});
};
3 changes: 3 additions & 0 deletions packages/kbn-doc-links/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,9 @@ export interface DocLinks {
readonly inferenceManagement: {
readonly inferenceAPIDocumentation: string;
};
readonly cases: {
readonly legacyApiDeprecations: string;
};
}

export type BuildFlavor = 'serverless' | 'traditional';
2 changes: 1 addition & 1 deletion x-pack/plugins/cases/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ export class CasePlugin
registerRoutes({
router,
routes: [
...getExternalRoutes({ isServerless }),
...getExternalRoutes({ isServerless, docLinks: core.docLinks }),
...getInternalRoutes(this.userProfileService),
],
logger: this.logger,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,40 @@
*/

import { getAllCommentsRoute } from './get_all_comment';
import { docLinksServiceMock } from '@kbn/core/server/mocks';

describe('getAllCommentsRoute', () => {
const docLinks = docLinksServiceMock.createSetupContract();

it('marks the endpoint internal in serverless', async () => {
const router = getAllCommentsRoute({ isServerless: true });
const router = getAllCommentsRoute({ isServerless: true, docLinks });

expect(router.routerOptions?.access).toBe('internal');
});

it('marks the endpoint public in non-serverless', async () => {
const router = getAllCommentsRoute({ isServerless: false });
const router = getAllCommentsRoute({ isServerless: false, docLinks });

expect(router.routerOptions?.access).toBe('public');
});

it('should be deprecated', () => {
const router = getAllCommentsRoute({ docLinks });
expect(router.routerOptions?.deprecated).toMatchInlineSnapshot(
{
documentationUrl: expect.stringMatching(/#breaking-201004$/),
},
`
Object {
"documentationUrl": StringMatching /#breaking-201004\\$/,
"reason": Object {
"newApiMethod": "GET",
"newApiPath": "/api/cases/{case_id}/comments/_find",
"type": "migrate",
},
"severity": "warning",
}
`
);
});
});
20 changes: 17 additions & 3 deletions x-pack/plugins/cases/server/routes/api/comments/get_all_comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import { schema } from '@kbn/config-schema';

import type { DocLinksServiceSetup } from '@kbn/core/server';
import { CASE_COMMENTS_URL } from '../../../../common/constants';
import { createCaseError } from '../../../common/error';
import { createCasesRoute } from '../create_cases_route';
Expand All @@ -15,7 +16,13 @@ import type { attachmentDomainV1 } from '../../../../common/types/domain';
/**
* @deprecated since version 8.1.0
*/
export const getAllCommentsRoute = ({ isServerless }: { isServerless?: boolean }) =>
export const getAllCommentsRoute = ({
isServerless,
docLinks,
}: {
isServerless?: boolean;
docLinks: DocLinksServiceSetup;
}) =>
createCasesRoute({
method: 'get',
path: CASE_COMMENTS_URL,
Expand All @@ -32,8 +39,15 @@ export const getAllCommentsRoute = ({ isServerless }: { isServerless?: boolean }
summary: `Gets all case comments`,
tags: ['oas-tag:cases'],
// description: 'You must have `read` privileges for the **Cases** feature in the **Management**, **Observability**, or **Security** section of the Kibana feature privileges, depending on the owner of the cases with the comments you\'re seeking.',
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
deprecated: true,
deprecated: {
documentationUrl: docLinks.links.cases.legacyApiDeprecations,
severity: 'warning',
reason: {
type: 'migrate',
newApiMethod: 'GET',
newApiPath: '/api/cases/{case_id}/comments/_find',
},
},
},
handler: async ({ context, request, response }) => {
try {
Expand Down
15 changes: 11 additions & 4 deletions x-pack/plugins/cases/server/routes/api/get_external_routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import type { DocLinksServiceSetup } from '@kbn/core/server';
import { getCasesByAlertIdRoute } from './cases/alerts/get_cases';
import { deleteCaseRoute } from './cases/delete_cases';
import { findCaseRoute } from './cases/find_cases';
Expand Down Expand Up @@ -32,7 +33,13 @@ import { getAllAlertsAttachedToCaseRoute } from './comments/get_alerts';
import { findUserActionsRoute } from './user_actions/find_user_actions';
import { postFileRoute } from './files/post_file';

export const getExternalRoutes = ({ isServerless }: { isServerless?: boolean }) =>
export const getExternalRoutes = ({
isServerless,
docLinks,
}: {
isServerless?: boolean;
docLinks: DocLinksServiceSetup;
}) =>
[
deleteCaseRoute,
findCaseRoute,
Expand All @@ -42,16 +49,16 @@ export const getExternalRoutes = ({ isServerless }: { isServerless?: boolean })
postCaseRoute,
pushCaseRoute,
findUserActionsRoute,
getUserActionsRoute({ isServerless }),
getStatusRoute({ isServerless }),
getUserActionsRoute({ isServerless, docLinks }),
getStatusRoute({ isServerless, docLinks }),
getCasesByAlertIdRoute,
getReportersRoute,
getTagsRoute,
deleteCommentRoute,
deleteAllCommentsRoute,
findCommentsRoute,
getCommentRoute,
getAllCommentsRoute({ isServerless }),
getAllCommentsRoute({ isServerless, docLinks }),
patchCommentRoute,
postCommentRoute,
getCaseConfigureRoute,
Expand Down
21 changes: 19 additions & 2 deletions x-pack/plugins/cases/server/routes/api/stats/get_status.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,33 @@
*/

import { getStatusRoute } from './get_status';
import { docLinksServiceMock } from '@kbn/core/server/mocks';

describe('getStatusRoute', () => {
const docLinks = docLinksServiceMock.createSetupContract();

it('marks the endpoint internal in serverless', async () => {
const router = getStatusRoute({ isServerless: true });
const router = getStatusRoute({ isServerless: true, docLinks });

expect(router.routerOptions?.access).toBe('internal');
expect(router.routerOptions?.deprecated).toMatchInlineSnapshot(
{
documentationUrl: expect.stringMatching(/#breaking-201004$/),
},
`
Object {
"documentationUrl": StringMatching /#breaking-201004\\$/,
"reason": Object {
"type": "remove",
},
"severity": "warning",
}
`
);
});

it('marks the endpoint public in non-serverless', async () => {
const router = getStatusRoute({ isServerless: false });
const router = getStatusRoute({ isServerless: false, docLinks });

expect(router.routerOptions?.access).toBe('public');
});
Expand Down
18 changes: 15 additions & 3 deletions x-pack/plugins/cases/server/routes/api/stats/get_status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* 2.0.
*/

import type { DocLinksServiceSetup } from '@kbn/core/server';
import type { CaseRoute } from '../types';

import { CASE_STATUS_URL } from '../../../../common/constants';
Expand All @@ -15,7 +16,13 @@ import type { statsApiV1 } from '../../../../common/types/api';
/**
* @deprecated since version 8.1.0
*/
export const getStatusRoute = ({ isServerless }: { isServerless?: boolean }): CaseRoute =>
export const getStatusRoute = ({
isServerless,
docLinks,
}: {
isServerless?: boolean;
docLinks: DocLinksServiceSetup;
}): CaseRoute =>
createCasesRoute({
method: 'get',
path: CASE_STATUS_URL,
Expand All @@ -27,8 +34,13 @@ export const getStatusRoute = ({ isServerless }: { isServerless?: boolean }): Ca
description:
'Returns the number of cases that are open, closed, and in progress in the default space.',
// You must have `read` privileges for the **Cases** feature in the **Management**, **Observability**, or **Security** section of the Kibana feature privileges, depending on the owner of the cases you're seeking.
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
deprecated: true,
deprecated: {
documentationUrl: docLinks.links.cases.legacyApiDeprecations,
severity: 'warning',
reason: {
type: 'remove',
},
},
},
handler: async ({ context, request, response }) => {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,35 @@
*/

import { getUserActionsRoute } from './get_all_user_actions';
import { docLinksServiceMock } from '@kbn/core/server/mocks';

describe('getUserActionsRoute', () => {
const docLinks = docLinksServiceMock.createSetupContract();

it('marks the endpoint internal in serverless', async () => {
const router = getUserActionsRoute({ isServerless: true });
const router = getUserActionsRoute({ isServerless: true, docLinks });

expect(router.routerOptions?.access).toBe('internal');
expect(router.routerOptions?.deprecated).toMatchInlineSnapshot(
{
documentationUrl: expect.stringMatching(/#breaking-201004$/),
},
`
Object {
"documentationUrl": StringMatching /#breaking-201004\\$/,
"reason": Object {
"newApiMethod": "GET",
"newApiPath": "/api/cases/<case_id>/user_actions/_find",
"type": "migrate",
},
"severity": "warning",
}
`
);
});

it('marks the endpoint public in non-serverless', async () => {
const router = getUserActionsRoute({ isServerless: false });
const router = getUserActionsRoute({ isServerless: false, docLinks });

expect(router.routerOptions?.access).toBe('public');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import { schema } from '@kbn/config-schema';

import type { DocLinksServiceSetup } from '@kbn/core/server';
import type { userActionApiV1 } from '../../../../common/types/api';
import { CASE_USER_ACTIONS_URL } from '../../../../common/constants';
import { createCaseError } from '../../../common/error';
Expand All @@ -15,7 +16,13 @@ import { createCasesRoute } from '../create_cases_route';
/**
* @deprecated since version 8.1.0
*/
export const getUserActionsRoute = ({ isServerless }: { isServerless?: boolean }) =>
export const getUserActionsRoute = ({
isServerless,
docLinks,
}: {
isServerless?: boolean;
docLinks: DocLinksServiceSetup;
}) =>
createCasesRoute({
method: 'get',
path: CASE_USER_ACTIONS_URL,
Expand All @@ -31,8 +38,15 @@ export const getUserActionsRoute = ({ isServerless }: { isServerless?: boolean }
description: `Returns all user activity for a case.`,
// You must have `read` privileges for the **Cases** feature in the **Management**, **Observability**, or **Security** section of the Kibana feature privileges, depending on the owner of the case you're seeking.
tags: ['oas-tag:cases'],
// @ts-expect-error TODO(https://github.com/elastic/kibana/issues/196095): Replace {RouteDeprecationInfo}
deprecated: true,
deprecated: {
documentationUrl: docLinks.links.cases.legacyApiDeprecations,
severity: 'warning',
reason: {
type: 'migrate',
newApiMethod: 'GET',
newApiPath: '/api/cases/<case_id>/user_actions/_find',
},
},
},
handler: async ({ context, request, response }) => {
try {
Expand Down

0 comments on commit 5ac3783

Please sign in to comment.