import { GetStoppedPartitionResult , GetDatafeedResultsChartDataResult , } from '../../../../common/types/results' ; import { HttpService } from '../http_service' ; import { basePath } from './index' ; import { JobId } from '../../../../common/types/anomaly_detection_jobs' ; import { JOB_ID , PARTITION_FIELD_VALUE } from '../../../../common/constants/anomalies' ; import { PartitionFieldsDefinition } from '../results_service/result_service_rx' ; import { PartitionFieldsConfig } from '../../../../common/types/storage' ; import { ESSearchRequest , ESSearchResponse , } from '../../../../../../../src/core/types/elasticsearch' ; import { MLAnomalyDoc } from '../../../../common/types/anomalies' ; export const resultsApiProvider = ( httpService ) => ( { getAnomaliesTableData ( jobIds , criteriaFields , influencers , aggregationInterval , threshold , earliestMs , latestMs , dateFormatTz , maxRecords , maxExamples ? , influencersFilterQuery ? , functionDescription ? ) { const body = JSON . stringify ( { jobIds , criteriaFields , influencers , aggregationInterval , threshold , earliestMs , latestMs , dateFormatTz , maxRecords , maxExamples , influencersFilterQuery , functionDescription , } ) ; return httpService . http$ < any > ( { path : `${ basePath ( ) }/results/anomalies_table_data` , method : 'POST' , body , } ) ; } , getMaxAnomalyScore ( jobIds , earliestMs , latestMs ) { const body = JSON . stringify ( { jobIds , earliestMs , latestMs , } ) ; return httpService . http < any > ( { path : `${ basePath ( ) }/results/max_anomaly_score` , method : 'POST' , body , } ) ; } , getCategoryDefinition ( jobId , categoryId ) { const body = JSON . stringify ( { jobId , categoryId } ) ; return httpService . http < any > ( { path : `${ basePath ( ) }/results/category_definition` , method : 'POST' , body , } ) ; } , getCategoryExamples ( jobId , categoryIds , maxExamples ) { const body = JSON . stringify ( { jobId , categoryIds , maxExamples , } ) ; return httpService . http < any > ( { path : `${ basePath ( ) }/results/category_examples` , method : 'POST' , body , } ) ; } , fetchPartitionFieldsValues ( jobId , searchTerm , criteriaFields , earliestMs , latestMs , fieldsConfig ? ) { const body = JSON . stringify ( { jobId , searchTerm , criteriaFields , earliestMs , latestMs , fieldsConfig , } ) ; return httpService . http$ < PartitionFieldsDefinition > ( { path : `${ basePath ( ) }/results/partition_fields_values` , method : 'POST' , body , } ) ; } , anomalySearch ( query , jobIds ) { const body = JSON . stringify ( { query , jobIds } ) ; return httpService . http < ESSearchResponse < MLAnomalyDoc > > ( { path : `${ basePath ( ) }/results/anomaly_search` , method : 'POST' , body , } ) ; } , anomalySearch$ ( query , jobIds ) { const body = JSON . stringify ( { query , jobIds } ) ; return httpService . http$ < ESSearchResponse < MLAnomalyDoc > > ( { path : `${ basePath ( ) }/results/anomaly_search` , method : 'POST' , body , } ) ; } , getCategoryStoppedPartitions ( jobIds , fieldToBucket ? ) { const body = JSON . stringify ( { jobIds , fieldToBucket , } ) ; return httpService . http < GetStoppedPartitionResult > ( { path : `${ basePath ( ) }/results/category_stopped_partitions` , method : 'POST' , body , } ) ; } , getDatafeedResultChartData ( jobId , start , end ) { const body = JSON . stringify ( { jobId , start , end , } ) ; return httpService . http < GetDatafeedResultsChartDataResult > ( { path : `${ basePath ( ) }/results/datafeed_results_chart` , method : 'POST' , body , } ) ; } , } ) ;