Skip to content

Commit bc75830

Browse files
author
Aaron Caldwell
committed
Revise index calls to use kibana https fetch. Remove http service
1 parent 2dd166d commit bc75830

2 files changed

Lines changed: 15 additions & 75 deletions

File tree

x-pack/plugins/maps/public/classes/layers/new_vector_layer_wizard/utils/http_service.ts

Lines changed: 0 additions & 63 deletions
This file was deleted.

x-pack/plugins/maps/public/classes/layers/new_vector_layer_wizard/utils/indexing_service.ts

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,22 @@
55
* 2.0.
66
*/
77

8-
import { http as httpService } from './http_service';
9-
import { getSavedObjectsClient } from '../../../../kibana_services';
8+
import { getSavedObjectsClient, getHttp } from '../../../../kibana_services';
109
import { INDEX_FEATURE_PATH, INDEX_SOURCE_API_PATH } from '../../../../../common';
1110

1211
export const getExistingIndexNames = async () => {
13-
const indexes = await httpService({
14-
url: `/api/index_management/indices`,
12+
const indexes = await getHttp().fetch({
13+
path: `/api/index_management/indices`,
1514
method: 'GET',
1615
});
1716
return indexes ? indexes.map(({ name }: { name: string }) => name) : [];
1817
};
1918

2019
export const createNewIndexAndPattern = async (indexName: string) => {
21-
return await httpService({
22-
url: `/${INDEX_SOURCE_API_PATH}`,
20+
return await getHttp().fetch({
21+
path: `/${INDEX_SOURCE_API_PATH}`,
2322
method: 'POST',
24-
data: {
23+
body: convertObjectToBlob({
2524
index: indexName,
2625
// Initially set to static mappings
2726
mappings: {
@@ -31,23 +30,27 @@ export const createNewIndexAndPattern = async (indexName: string) => {
3130
},
3231
},
3332
},
34-
},
33+
}),
3534
});
3635
};
3736

3837
export const addFeatureToIndex = async (indexName: string, geometry: unknown) => {
39-
return await httpService({
40-
url: `/${INDEX_FEATURE_PATH}`,
38+
return await getHttp().fetch({
39+
path: `/${INDEX_FEATURE_PATH}`,
4140
method: 'POST',
42-
data: {
41+
body: convertObjectToBlob({
4342
index: indexName,
4443
data: {
4544
coordinates: geometry,
4645
},
47-
},
46+
}),
4847
});
4948
};
5049

50+
const convertObjectToBlob = (obj: unknown) => {
51+
return new Blob([JSON.stringify(obj)], { type: 'application/json' });
52+
};
53+
5154
export const getExistingIndexPatternNames = async () => {
5255
const indexPatterns = await getSavedObjectsClient()
5356
.find({

0 commit comments

Comments
 (0)