import { HttpService } from '../http_service' ; import { basePath } from './index' ; import { JobType , CanDeleteJobResponse , SyncSavedObjectResponse , InitializeSavedObjectResponse , SavedObjectResult , JobsSpacesResponse , SyncCheckResponse , } from '../../../../common/types/saved_objects' ; export const savedObjectsApiProvider = ( httpService ) => ( { jobsSpaces ( ) { return httpService . http < JobsSpacesResponse > ( { path : `${ basePath ( ) }/saved_objects/jobs_spaces` , method : 'GET' , } ) ; } , updateJobsSpaces ( jobType , jobIds , spacesToAdd , spacesToRemove ) { const body = JSON . stringify ( { jobType , jobIds , spacesToAdd , spacesToRemove } ) ; return httpService . http < SavedObjectResult > ( { path : `${ basePath ( ) }/saved_objects/update_jobs_spaces` , method : 'POST' , body , } ) ; } , removeJobFromCurrentSpace ( jobType , jobIds ) { const body = JSON . stringify ( { jobType , jobIds } ) ; return httpService . http < SavedObjectResult > ( { path : `${ basePath ( ) }/saved_objects/remove_job_from_current_space` , method : 'POST' , body , } ) ; } , syncSavedObjects ( simulate = false ) { return httpService . http < SyncSavedObjectResponse > ( { path : `${ basePath ( ) }/saved_objects/sync` , method : 'GET' , query : { simulate } , } ) ; } , initSavedObjects ( simulate = false ) { return httpService . http < InitializeSavedObjectResponse > ( { path : `${ basePath ( ) }/saved_objects/initialize` , method : 'GET' , query : { simulate } , } ) ; } , syncCheck ( jobType ? ) { const body = JSON . stringify ( { jobType } ) ; return httpService . http < SyncCheckResponse > ( { path : `${ basePath ( ) }/saved_objects/sync_check` , method : 'POST' , body , } ) ; } , canDeleteJob ( jobType , jobIds ) { const body = JSON . stringify ( { jobIds } ) ; return httpService . http < CanDeleteJobResponse > ( { path : `${ basePath ( ) }/saved_objects/can_delete_job/${ jobType }` , method : 'POST' , body , } ) ; } , } ) ;