import { schema } from '@kbn/config-schema' ; import { IRouter } from '../../http' ; import { SavedObjectsErrorHelpers } from '../../saved_objects' ; import { CannotOverrideError } from '../ui_settings_errors' ; const validate = { params : schema . object ( { key : schema . string ( ) , } ) , } ; export function registerDeleteRoute ( router ) { router . delete ( { path : '/api/kibana/settings/{key}' , validate } , async ( context , request , response ) => { try { const uiSettingsClient = context . core . uiSettings . client ; await uiSettingsClient . remove ( request . params . key ) ; return response . ok ( { body : { settings : await uiSettingsClient . getUserProvided ( ) , } , } ) ; } catch ( error ) { if ( SavedObjectsErrorHelpers . isSavedObjectsClientError ( error ) ) { return response . customError ( { body : error , statusCode : error . output . statusCode , } ) ; } if ( error instanceof CannotOverrideError ) { return response . badRequest ( { body : error } ) ; } throw error ; } } ) ; }