Skip to content

Commit ef4755a

Browse files
[EDR Workflows] Deprecate public endpoint/suggestions api endpoint in favour of an internal one (#194832)
New internal GET `/internal/api/endpoint/suggestions/{suggestion_type}` route. Current public GET `/api/endpoint/suggestions/{suggestion_type}` route is set to deprecated. UI uses now the internal GET `/internal/api/endpoint/suggestions/{suggestion_type}` api route --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
1 parent ca1d375 commit ef4755a

13 files changed

Lines changed: 91 additions & 9 deletions

File tree

oas_docs/output/kibana.serverless.staging.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8096,6 +8096,7 @@ paths:
80968096
- Security Endpoint Management API
80978097
/api/endpoint/suggestions/{suggestion_type}:
80988098
post:
8099+
deprecated: true
80998100
operationId: GetEndpointSuggestions
81008101
parameters:
81018102
- in: path

oas_docs/output/kibana.serverless.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8096,6 +8096,7 @@ paths:
80968096
- Security Endpoint Management API
80978097
/api/endpoint/suggestions/{suggestion_type}:
80988098
post:
8099+
deprecated: true
80998100
operationId: GetEndpointSuggestions
81008101
parameters:
81018102
- in: path

oas_docs/output/kibana.staging.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11468,6 +11468,7 @@ paths:
1146811468
- Security Endpoint Management API
1146911469
/api/endpoint/suggestions/{suggestion_type}:
1147011470
post:
11471+
deprecated: true
1147111472
operationId: GetEndpointSuggestions
1147211473
parameters:
1147311474
- in: path

oas_docs/output/kibana.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11468,6 +11468,7 @@ paths:
1146811468
- Security Endpoint Management API
1146911469
/api/endpoint/suggestions/{suggestion_type}:
1147011470
post:
11471+
deprecated: true
1147111472
operationId: GetEndpointSuggestions
1147211473
parameters:
1147311474
- in: path

x-pack/plugins/security_solution/common/api/endpoint/suggestions/get_suggestions.schema.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ info:
55
paths:
66
/api/endpoint/suggestions/{suggestion_type}:
77
post:
8+
deprecated: true
89
summary: Get suggestions
910
operationId: GetEndpointSuggestions
1011
x-codegen-enabled: true

x-pack/plugins/security_solution/common/endpoint/constants.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ export const FILE_STORAGE_DATA_INDEX = getFileDataIndexName('endpoint');
6060

6161
// Location from where all Endpoint related APIs are mounted
6262
export const BASE_ENDPOINT_ROUTE = '/api/endpoint';
63+
export const BASE_INTERNAL_ENDPOINT_ROUTE = `/internal${BASE_ENDPOINT_ROUTE}`;
6364

6465
// Endpoint API routes
6566
export const HOST_METADATA_LIST_ROUTE = `${BASE_ENDPOINT_ROUTE}/metadata`;
@@ -72,7 +73,9 @@ export const AGENT_POLICY_SUMMARY_ROUTE = `${BASE_POLICY_ROUTE}/summaries`;
7273
export const PROTECTION_UPDATES_NOTE_ROUTE = `${BASE_ENDPOINT_ROUTE}/protection_updates_note/{package_policy_id}`;
7374

7475
/** Suggestions routes */
76+
/** @deprecated public route, use {@link SUGGESTIONS_INTERNAL_ROUTE} internal route */
7577
export const SUGGESTIONS_ROUTE = `${BASE_ENDPOINT_ROUTE}/suggestions/{suggestion_type}`;
78+
export const SUGGESTIONS_INTERNAL_ROUTE = `${BASE_INTERNAL_ENDPOINT_ROUTE}/suggestions/{suggestion_type}`;
7679

7780
/**
7881
* Action Response Routes

x-pack/plugins/security_solution/docs/openapi/ess/security_solution_endpoint_management_api_2023_10_31.bundled.schema.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ paths:
545545
- Security Endpoint Management API
546546
/api/endpoint/suggestions/{suggestion_type}:
547547
post:
548+
deprecated: true
548549
operationId: GetEndpointSuggestions
549550
parameters:
550551
- in: path

x-pack/plugins/security_solution/docs/openapi/serverless/security_solution_endpoint_management_api_2023_10_31.bundled.schema.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,7 @@ paths:
495495
- Security Endpoint Management API
496496
/api/endpoint/suggestions/{suggestion_type}:
497497
post:
498+
deprecated: true
498499
operationId: GetEndpointSuggestions
499500
parameters:
500501
- in: path
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
3+
* or more contributor license agreements. Licensed under the Elastic License
4+
* 2.0; you may not use this file except in compliance with the Elastic License
5+
* 2.0.
6+
*/
7+
8+
import type { HttpSetup } from '@kbn/core-http-browser';
9+
import { EventFiltersApiClient } from './api_client';
10+
import { coreMock } from '@kbn/core/public/mocks';
11+
import { SUGGESTIONS_INTERNAL_ROUTE } from '../../../../../common/endpoint/constants';
12+
import { resolvePathVariables } from '../../../../common/utils/resolve_path_variables';
13+
14+
describe('EventFiltersApiClient', () => {
15+
let fakeHttpServices: jest.Mocked<HttpSetup>;
16+
let eventFiltersApiClient: EventFiltersApiClient;
17+
18+
beforeAll(() => {
19+
fakeHttpServices = coreMock.createStart().http as jest.Mocked<HttpSetup>;
20+
eventFiltersApiClient = new EventFiltersApiClient(fakeHttpServices);
21+
});
22+
23+
beforeEach(() => {
24+
jest.clearAllMocks();
25+
});
26+
27+
it('should call the SUGGESTIONS_INTERNAL_ROUTE with correct URL and body', async () => {
28+
await eventFiltersApiClient.getSuggestions({
29+
field: 'host.name',
30+
query: 'test',
31+
});
32+
33+
expect(fakeHttpServices.post).toHaveBeenCalledWith(
34+
resolvePathVariables(SUGGESTIONS_INTERNAL_ROUTE, { suggestion_type: 'eventFilters' }),
35+
{
36+
version: '1',
37+
body: JSON.stringify({
38+
field: 'host.name',
39+
query: 'test',
40+
}),
41+
}
42+
);
43+
});
44+
});

x-pack/plugins/security_solution/public/management/pages/event_filters/service/api_client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import type {
1212
UpdateExceptionListItemSchema,
1313
} from '@kbn/securitysolution-io-ts-list-types';
1414
import { removeIdFromExceptionItemsEntries } from '@kbn/securitysolution-list-hooks';
15+
import { SUGGESTIONS_INTERNAL_ROUTE } from '../../../../../common/endpoint/constants';
1516
import type { EndpointSuggestionsBody } from '../../../../../common/api/endpoint';
16-
import { SUGGESTIONS_ROUTE } from '../../../../../common/endpoint/constants';
1717
import { resolvePathVariables } from '../../../../common/utils/resolve_path_variables';
1818
import { ExceptionsListApiClient } from '../../../services/exceptions_list/exceptions_list_api_client';
1919
import { EVENT_FILTER_LIST_DEFINITION } from '../constants';
@@ -55,9 +55,9 @@ export class EventFiltersApiClient extends ExceptionsListApiClient {
5555
*/
5656
async getSuggestions(body: EndpointSuggestionsBody): Promise<string[]> {
5757
const result: string[] = await this.getHttp().post(
58-
resolvePathVariables(SUGGESTIONS_ROUTE, { suggestion_type: 'eventFilters' }),
58+
resolvePathVariables(SUGGESTIONS_INTERNAL_ROUTE, { suggestion_type: 'eventFilters' }),
5959
{
60-
version: this.version,
60+
version: '1',
6161
body: JSON.stringify(body),
6262
}
6363
);

0 commit comments

Comments
 (0)