[Security Solution][Endpoint] Adapt exception list api calls to versioned router (#165658)

## Summary

- Adds version to http calls for endpoint exceptions at Lists API.
- Fixes unit test.

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
David Sánchez 2023-09-07 17:35:15 +02:00 committed by GitHub
parent 84275f0c29
commit 6a0fa94cbb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
18 changed files with 85 additions and 3 deletions

View file

@ -43,6 +43,8 @@ import {
} from '@kbn/securitysolution-list-constants';
import { toError, toPromise } from '../fp_utils';
const version = '2023-10-31';
/**
* Add new ExceptionList
*
@ -62,6 +64,7 @@ const addExceptionList = async ({
body: JSON.stringify(list),
method: 'POST',
signal,
version,
});
const addExceptionListWithValidation = async ({
@ -105,6 +108,7 @@ const addExceptionListItem = async ({
body: JSON.stringify(listItem),
method: 'POST',
signal,
version,
});
const addExceptionListItemWithValidation = async ({
@ -148,6 +152,7 @@ const updateExceptionList = async ({
body: JSON.stringify(list),
method: 'PUT',
signal,
version,
});
const updateExceptionListWithValidation = async ({
@ -191,6 +196,7 @@ const updateExceptionListItem = async ({
body: JSON.stringify(listItem),
method: 'PUT',
signal,
version,
});
const updateExceptionListItemWithValidation = async ({
@ -247,6 +253,7 @@ const fetchExceptionLists = async ({
method: 'GET',
query,
signal,
version,
});
};
@ -298,6 +305,7 @@ const fetchExceptionListById = async ({
method: 'GET',
query: { id, namespace_type: namespaceType },
signal,
version,
});
const fetchExceptionListByIdWithValidation = async ({
@ -361,6 +369,7 @@ const fetchExceptionListsItemsByListIds = async ({
method: 'GET',
query,
signal,
version,
});
};
@ -414,6 +423,7 @@ const fetchExceptionListItemById = async ({
method: 'GET',
query: { id, namespace_type: namespaceType },
signal,
version,
});
const fetchExceptionListItemByIdWithValidation = async ({
@ -450,6 +460,7 @@ const deleteExceptionListById = async ({
method: 'DELETE',
query: { id, namespace_type: namespaceType },
signal,
version,
});
const deleteExceptionListByIdWithValidation = async ({
@ -486,6 +497,7 @@ const deleteExceptionListItemById = async ({
method: 'DELETE',
query: { id, namespace_type: namespaceType },
signal,
version,
});
const deleteExceptionListItemByIdWithValidation = async ({
@ -518,6 +530,7 @@ const addEndpointExceptionList = async ({
http.fetch<ExceptionListItemSchema>(ENDPOINT_LIST_URL, {
method: 'POST',
signal,
version,
});
const addEndpointExceptionListWithValidation = async ({
@ -561,6 +574,7 @@ export const exportExceptionList = async ({
include_expired_exceptions: includeExpiredExceptions,
},
signal,
version,
});
/**
@ -647,4 +661,5 @@ export const duplicateExceptionList = async ({
include_expired_exceptions: includeExpiredExceptions,
},
signal,
version,
});

View file

@ -57,6 +57,8 @@ export type {
ImportListParams,
} from './types';
const version = '2023-10-31';
const findLists = async ({
http,
cursor,
@ -79,6 +81,7 @@ const findLists = async ({
sort_order,
},
signal,
version,
});
};
@ -167,6 +170,7 @@ const importList = async ({
method: 'POST',
query: { list_id, type },
signal,
version,
});
};
@ -207,6 +211,7 @@ const deleteList = async ({
method: 'DELETE',
query: { deleteReferences, id, ignoreReferences },
signal,
version,
});
const deleteListWithValidation = async ({
@ -236,6 +241,7 @@ const exportList = async ({
method: 'POST',
query: { list_id },
signal,
version,
});
const exportListWithValidation = async ({
@ -256,6 +262,7 @@ const readListIndex = async ({ http, signal }: ApiParams): Promise<ListItemIndex
http.fetch<ListItemIndexExistSchema>(LIST_INDEX, {
method: 'GET',
signal,
version,
});
const readListIndexWithValidation = async ({
@ -273,15 +280,16 @@ export { readListIndexWithValidation as readListIndex };
// TODO add types and validation
export const readListPrivileges = async ({ http, signal }: ApiParams): Promise<unknown> =>
http.fetch<unknown>(LIST_PRIVILEGES_URL, {
version: '2023-10-31',
method: 'GET',
signal,
version,
});
const createListIndex = async ({ http, signal }: ApiParams): Promise<AcknowledgeSchema> =>
http.fetch<AcknowledgeSchema>(LIST_INDEX, {
method: 'POST',
signal,
version,
});
const createListIndexWithValidation = async ({