Skip to content

Commit

Permalink
[ML] Fix http routes.
Browse files Browse the repository at this point in the history
  • Loading branch information
walterra committed Mar 6, 2020
1 parent 3c44a7c commit d759ac9
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions x-pack/plugins/transform/public/app/hooks/use_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

import { TransformId, TransformEndpointRequest, TransformEndpointResult } from '../../../common';
import { API_BASE_PATH } from '../../../common/constants';

import { useAppDependencies } from '../app_dependencies';
import { PreviewRequestBody } from '../common';
Expand All @@ -14,52 +15,49 @@ import { EsIndex } from './use_api_types';
export const useApi = () => {
const { http } = useAppDependencies();

const basePath = http.basePath.prepend('/api/transform');
const indicesBasePath = http.basePath.prepend('/api');

return {
getTransforms(transformId?: TransformId): Promise<any> {
const transformIdString = transformId !== undefined ? `/${transformId}` : '';
return http.get(`${basePath}/transforms${transformIdString}`);
return http.get(`${API_BASE_PATH}transforms${transformIdString}`);
},
getTransformsStats(transformId?: TransformId): Promise<any> {
if (transformId !== undefined) {
return http.get(`${basePath}/transforms/${transformId}/_stats`);
return http.get(`${API_BASE_PATH}transforms/${transformId}/_stats`);
}

return http.get(`${basePath}/transforms/_stats`);
return http.get(`${API_BASE_PATH}transforms/_stats`);
},
createTransform(transformId: TransformId, transformConfig: any): Promise<any> {
return http.put(`${basePath}/transforms/${transformId}`, {
return http.put(`${API_BASE_PATH}transforms/${transformId}`, {
body: JSON.stringify(transformConfig),
});
},
deleteTransforms(transformsInfo: TransformEndpointRequest[]): Promise<TransformEndpointResult> {
return http.post(`${basePath}/delete_transforms`, {
return http.post(`${API_BASE_PATH}delete_transforms`, {
body: JSON.stringify(transformsInfo),
});
},
getTransformsPreview(obj: PreviewRequestBody): Promise<any> {
return http.post(`${basePath}/transforms/_preview`, { body: JSON.stringify(obj) });
return http.post(`${API_BASE_PATH}transforms/_preview`, { body: JSON.stringify(obj) });
},
startTransforms(transformsInfo: TransformEndpointRequest[]): Promise<TransformEndpointResult> {
return http.post(`${basePath}/start_transforms`, {
return http.post(`${API_BASE_PATH}start_transforms`, {
body: JSON.stringify(transformsInfo),
});
},
stopTransforms(transformsInfo: TransformEndpointRequest[]): Promise<TransformEndpointResult> {
return http.post(`${basePath}/stop_transforms`, {
return http.post(`${API_BASE_PATH}stop_transforms`, {
body: JSON.stringify(transformsInfo),
});
},
getTransformAuditMessages(transformId: TransformId): Promise<any> {
return http.get(`${basePath}/transforms/${transformId}/messages`);
return http.get(`${API_BASE_PATH}transforms/${transformId}/messages`);
},
esSearch(payload: any): Promise<any> {
return http.post(`${basePath}/es_search`, { body: JSON.stringify(payload) });
return http.post(`${API_BASE_PATH}es_search`, { body: JSON.stringify(payload) });
},
getIndices(): Promise<EsIndex[]> {
return http.get(`${indicesBasePath}/index_management/indices`);
return http.get(`/api/index_management/indices`);
},
};
};

0 comments on commit d759ac9

Please sign in to comment.