import { validate } from '@kbn/securitysolution-io-ts-utils' ; import { transformError } from '@kbn/securitysolution-es-utils' ; import { createEndpointListSchema } from '@kbn/securitysolution-io-ts-list-types' ; import { ENDPOINT_LIST_URL } from '@kbn/securitysolution-list-constants' ; import type { ListsPluginRouter } from '../types' ; import { buildSiemResponse } from './utils' ; import { getExceptionListClient } from './utils/get_exception_list_client' ; param router export const createEndpointListRoute = ( router ) : void => { router . post ( { options : { tags : [ 'access:lists-all' ] , } , path : ENDPOINT_LIST_URL , validate : false , } , async ( context , _ , response ) => { const siemResponse = buildSiemResponse ( response ) ; try { const exceptionLists = getExceptionListClient ( context ) ; const createdList = await exceptionLists . createEndpointList ( ) ; const body = createdList ?? { } ; const [ validated , errors ] = validate ( body , createEndpointListSchema ) ; if ( errors != null ) { return siemResponse . error ( { body : errors , statusCode : 500 } ) ; } else { return response . ok ( { body : validated ?? { } } ) ; } } catch ( err ) { const error = transformError ( err ) ; return siemResponse . error ( { body : error . message , statusCode : error . statusCode , } ) ; } } ) ; } ;