Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Response Ops][Cases] Use deprecation object #201004

Merged
merged 19 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion docs/upgrade-notes.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,24 @@ For Elastic Security solution release information, refer to {security-guide}/rel


[discrete]
[[breaking-201004]]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you find out these needed to be updated too?

Copy link
Contributor Author

@jcger jcger Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the link to the docs' reference is this value. I just kept "breaking" because of consistency with the other references

That said, I'm still not sure it's working :) I'm waiting for CI to generate the docs

.[Cases] Legacy deprecations (9.0.0)
[%collapsible]
====
*Details* +
- `GET /api/cases/status` has been deprecated with no replacement
- `GET /api/cases/{case_id}/comments` has been replaced by `GET /api/cases/{case_id}/comments/_find` released in 7.13
- `GET /api/cases/<case_id>/user_actions` has been replaced by `GET /api/cases/<case_id>/user_actions/_find` released in 8.7
- `includeComments` parameter in `GET /api/cases/{case_id}`has been deprecated. Use `GET /api/cases/{case_id}/comments/_find` instead, released in 7.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 endpoints listed as deprecated by it's replacement. See `Details` section
jcger marked this conversation as resolved.
Show resolved Hide resolved
====

[[breaking-199656]]
.Removed all security v1 endpoints (9.0.0)
[%collapsible]
Expand Down Expand Up @@ -112,4 +130,3 @@ To access the assistant, go to **Stack Management** > **Upgrade Assistant**.




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 @@ -1004,5 +1004,8 @@ export const getDocLinks = ({ kibanaBranch, buildFlavor }: GetDocLinkOptions): D
inferenceManagement: {
inferenceAPIDocumentation: `${ELASTIC_WEBSITE_URL}docs/api/doc/elasticsearch/operation/operation-inference-put`,
},
cases: {
legacyDeprecations: `${KIBANA_DOCS}breaking-changes-summary.html#breaking-201004`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: legacyApiDeprecations

},
});
};
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 @@ -679,6 +679,9 @@ export interface DocLinks {
readonly inferenceManagement: {
readonly inferenceAPIDocumentation: string;
};
readonly cases: {
readonly legacyDeprecations: 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,16 +6,30 @@
*/

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');
expect(router.routerOptions?.deprecated).toMatchInlineSnapshot(`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think it would be better if we had a dedicated test for the deprecation object check. The object is available in all flavors, serverless or non-serverless. Same for all test files.

Object {
"documentationUrl": "https://www.elastic.co/guide/en/kibana/test-branch/breaking-changes-summary.html#breaking-201004",
"reason": Object {
"newApiMethod": "GET",
"newApiPath": "/api/cases/{case_id}/comments/_find",
"type": "migrate",
},
"severity": "warning",
}
`);
});

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');
});
Expand Down
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.legacyDeprecations,
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
16 changes: 14 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,28 @@
*/

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(`
Object {
"documentationUrl": "https://www.elastic.co/guide/en/kibana/test-branch/breaking-changes-summary.html#breaking-201004",
"reason": Object {
"type": "deprecate",
},
"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.legacyDeprecations,
severity: 'warning',
reason: {
type: 'deprecate',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be remove as the API will be removed in 9.0.

},
},
},
handler: async ({ context, request, response }) => {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,30 @@
*/

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(`
Object {
"documentationUrl": "https://www.elastic.co/guide/en/kibana/test-branch/breaking-changes-summary.html#breaking-201004",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

   "documentationUrl": "https://www.elastic.co/guide/en/kibana/test-branch/breaking-changes-summary.html#breaking-201004",

If it's at all possible to make this a fuzzier match that would be a good idea IMO since the initial part of that URL is almost certain to change as we migrate to the new docs system.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will test that the url ends with #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.legacyDeprecations,
severity: 'warning',
reason: {
type: 'migrate',
newApiMethod: 'GET',
newApiPath: '/api/cases/<case_id>/user_actions/_find',
},
},
},
handler: async ({ context, request, response }) => {
try {
Expand Down