import { API_BASE_PATH } from '../../../../common/constants' ; import { RestoreSettings } from '../../../../common/types' ; import { UIM_RESTORE_CREATE } from '../../constants' ; import { UiMetricService } from '../ui_metric' ; import { sendRequest , useRequest } from './use_request' ; let uiMetricService ; export const setUiMetricServiceRestore = ( _uiMetricService ) => { uiMetricService = _uiMetricService ; } ; export const executeRestore = async ( repository , snapshot , restoreSettings ) => { const result = await sendRequest ( { path : `${ API_BASE_PATH }restore/${ encodeURIComponent ( repository ) }/${ encodeURIComponent ( snapshot ) }` , method : 'post' , body : restoreSettings , } ) ; uiMetricService . trackUiMetric ( UIM_RESTORE_CREATE ) ; return result ; } ; export const useLoadRestores = ( pollIntervalMs ? ) => { return useRequest ( { path : `${ API_BASE_PATH }restores` , method : 'get' , initialData : [ ] , pollIntervalMs , } ) ; } ;