import { SavedObjectsClientContract } from 'kibana/server' ; import type { ExceptionListSchema , IdOrUndefined , ListIdOrUndefined , NamespaceType , } from '@kbn/securitysolution-io-ts-list-types' ; import { getSavedObjectType } from '@kbn/securitysolution-list-utils' ; import { getExceptionList } from './get_exception_list' ; import { deleteExceptionListItemByList } from './delete_exception_list_items_by_list' ; interface DeleteExceptionListOptions { listId : ListIdOrUndefined ; id : IdOrUndefined ; namespaceType : NamespaceType ; savedObjectsClient : SavedObjectsClientContract ; } export const deleteExceptionList = async ( { listId , id , namespaceType , savedObjectsClient , } ) : Promise < ExceptionListSchema | null > => { const savedObjectType = getSavedObjectType ( { namespaceType } ) ; const exceptionList = await getExceptionList ( { id , listId , namespaceType , savedObjectsClient } ) ; if ( exceptionList == null ) { return null ; } else { await deleteExceptionListItemByList ( { listId : exceptionList . list_id , namespaceType , savedObjectsClient , } ) ; await savedObjectsClient . delete ( savedObjectType , exceptionList . id ) ; return exceptionList ; } } ;