Skip to content

Commit

Permalink
[data views] Remove fields for time pattern functionality (#133075)
Browse files Browse the repository at this point in the history
* remove fields for time pattern functionality
  • Loading branch information
mattkime authored May 30, 2022
1 parent 5bab21e commit f692443
Show file tree
Hide file tree
Showing 18 changed files with 2 additions and 669 deletions.
1 change: 0 additions & 1 deletion src/plugins/data/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ export type {
SavedObjectsClientCommonFindArgs,
SavedObjectsClientCommon,
GetFieldsOptions,
GetFieldsOptionsTimePattern,
IDataViewsApiClient,
SavedObject,
AggregationRestrictions,
Expand Down
1 change: 0 additions & 1 deletion src/plugins/data_views/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ export type {
SavedObjectsClientCommonFindArgs,
SavedObjectsClientCommon,
GetFieldsOptions,
GetFieldsOptionsTimePattern,
IDataViewsApiClient,
SavedObject,
AggregationRestrictions,
Expand Down
8 changes: 0 additions & 8 deletions src/plugins/data_views/common/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,15 +168,7 @@ export interface GetFieldsOptions {
filter?: QueryDslQueryContainer;
}

export interface GetFieldsOptionsTimePattern {
pattern: string;
metaFields: string[];
lookBack: number;
interval: string;
}

export interface IDataViewsApiClient {
getFieldsForTimePattern: (options: GetFieldsOptionsTimePattern) => Promise<any>;
getFieldsForWildcard: (options: GetFieldsOptions) => Promise<any>;
hasUserIndexPattern: () => Promise<boolean>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,6 @@ describe('IndexPatternsApiClient', () => {
indexPatternsApiClient = new DataViewsApiClient(http);
});

test('uses the right URI to fetch fields for time patterns', async function () {
const expectedPath = '/api/index_patterns/_fields_for_time_pattern';

await indexPatternsApiClient.getFieldsForTimePattern({
pattern: 'blah',
metaFields: [],
lookBack: 5,
interval: '',
});

expect(fetchSpy).toHaveBeenCalledWith(expectedPath, expect.any(Object));
});

test('uses the right URI to fetch fields for wildcard', async function () {
const expectedPath = '/api/index_patterns/_fields_for_wildcard';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import { HttpSetup } from '@kbn/core/public';
import { DataViewMissingIndices } from '../../common/lib';
import { GetFieldsOptions, IDataViewsApiClient, GetFieldsOptionsTimePattern } from '../../common';
import { GetFieldsOptions, IDataViewsApiClient } from '../../common';

const API_BASE_URL: string = `/api/index_patterns/`;

Expand Down Expand Up @@ -37,18 +37,6 @@ export class DataViewsApiClient implements IDataViewsApiClient {
return API_BASE_URL + path.filter(Boolean).map(encodeURIComponent).join('/');
}

getFieldsForTimePattern(options: GetFieldsOptionsTimePattern) {
const { pattern, lookBack, metaFields } = options;

const url = this._getUrl(['_fields_for_time_pattern']);

return this._request(url, {
pattern,
look_back: lookBack,
meta_fields: metaFields,
}).then((resp: any) => resp.fields);
}

getFieldsForWildcard({
pattern,
metaFields,
Expand Down
31 changes: 0 additions & 31 deletions src/plugins/data_views/server/fetcher/index_patterns_fetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ import type { QueryDslQueryContainer } from '../../common/types';

import {
getFieldCapabilities,
resolveTimePattern,
createNoMatchingIndicesError,
getCapabilitiesForRollupIndices,
mergeCapabilitiesWithFields,
} from './lib';
Expand Down Expand Up @@ -101,35 +99,6 @@ export class IndexPatternsFetcher {
return fieldCapsResponse;
}

/**
* Get a list of field objects for a time pattern
*
* @param {Object} [options={}]
* @property {String} options.pattern The moment compatible time pattern
* @property {Number} options.lookBack The number of indices we will pull mappings for
* @property {Number} options.metaFields The list of underscore prefixed fields that should
* be left in the field list (all others are removed).
* @return {Promise<Array<Fields>>}
*/
async getFieldsForTimePattern(options: {
pattern: string;
metaFields: string[];
lookBack: number;
interval: string;
}) {
const { pattern, lookBack, metaFields } = options;
const { matches } = await resolveTimePattern(this.elasticsearchClient, pattern);
const indices = matches.slice(0, lookBack);
if (indices.length === 0) {
throw createNoMatchingIndicesError(pattern);
}
return await getFieldCapabilities({
callCluster: this.elasticsearchClient,
indices,
metaFields,
});
}

/**
* Returns an index pattern list of only those index pattern strings in the given list that return indices
*
Expand Down
1 change: 0 additions & 1 deletion src/plugins/data_views/server/fetcher/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
*/

export { getFieldCapabilities, shouldReadFieldFromDocValues } from './field_capabilities';
export { resolveTimePattern } from './resolve_time_pattern';
export { createNoMatchingIndicesError } from './errors';
export * from './merge_capabilities_with_fields';
export * from './map_capabilities';
110 changes: 0 additions & 110 deletions src/plugins/data_views/server/fetcher/lib/resolve_time_pattern.test.js

This file was deleted.

67 changes: 0 additions & 67 deletions src/plugins/data_views/server/fetcher/lib/resolve_time_pattern.ts

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit f692443

Please sign in to comment.