Skip to content

Commit

Permalink
[ES body removal] @elastic/kibana-management (#204871)
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo authored Jan 10, 2025
1 parent ec3013c commit 2687f4f
Show file tree
Hide file tree
Showing 23 changed files with 31 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
HealthStatus,
IndicesStatsIndexMetadataState,
Uuid,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
} from '@elastic/elasticsearch/lib/api/types';
import type { ScopedHistory } from '@kbn/core-application-browser';
import type { SerializableRecord } from '@kbn/utility-types';
import type { LocatorPublic } from '@kbn/share-plugin/public';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { schema, TypeOf } from '@kbn/config-schema';

import { SlmPolicyEs, PolicyIndicesResponse } from '../../../common/types';
Expand Down Expand Up @@ -47,7 +46,7 @@ export function registerPolicyRoutes({
body: {
policies: Object.entries(policiesByName).map(([name, policy]) => {
// TODO: Figure out why our {@link SlmPolicyEs} is not compatible with:
// import type { SnapshotLifecyclePolicyMetadata } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
// import type { SnapshotLifecyclePolicyMetadata } from '@elastic/elasticsearch/lib/api/types';
return deserializePolicy(name, policy as SlmPolicyEs, managedPolicies);
}),
},
Expand Down Expand Up @@ -119,9 +118,9 @@ export function registerPolicyRoutes({
try {
// Otherwise create new policy
const response = await clusterClient.asCurrentUser.slm.putLifecycle({
// TODO: bring {@link SlmPolicyEs['policy']} in line with {@link PutSnapshotLifecycleRequest}
...serializePolicy(policy),
policy_id: name,
// TODO: bring {@link SlmPolicyEs['policy']} in line with {@link PutSnapshotLifecycleRequest['body']}
body: serializePolicy(policy) as unknown as estypes.SlmPutLifecycleRequest['body'],
});

return res.ok({ body: response });
Expand Down Expand Up @@ -149,9 +148,9 @@ export function registerPolicyRoutes({

// Otherwise update policy
const response = await clusterClient.asCurrentUser.slm.putLifecycle({
// TODO: bring {@link SlmPolicyEs['policy']} in line with {@link PutSnapshotLifecycleRequest}
...serializePolicy(policy),
policy_id: name,
// TODO: bring {@link SlmPolicyEs['policy']} in line with {@link PutSnapshotLifecycleRequest['body']}
body: serializePolicy(policy) as unknown as estypes.SlmPutLifecycleRequest['body'],
});

return res.ok({ body: response });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { TypeOf } from '@kbn/config-schema';
import type {
SnapshotGetRepositoryResponse,
PluginStats,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
} from '@elastic/elasticsearch/lib/api/types';

import {
ON_PREM_REPOSITORY_TYPES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
*/

import { schema, TypeOf } from '@kbn/config-schema';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';

import { SnapshotRestore, SnapshotRestoreShardEs } from '../../../common/types';
import { serializeRestoreSettings } from '../../../common/lib';
Expand Down Expand Up @@ -114,10 +113,10 @@ export function registerRestoreRoutes({

try {
const response = await clusterClient.asCurrentUser.snapshot.restore({
// TODO: Bring {@link RestoreSettingsEs} in line with {@link RestoreRequest}
...serializeRestoreSettings(restoreSettings),
repository,
snapshot,
// TODO: Bring {@link RestoreSettingsEs} in line with {@link RestoreRequest['body']}
body: serializeRestoreSettings(restoreSettings) as estypes.SnapshotRestoreRequest['body'],
});

return res.ok({ body: response });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { HealthReportImpact } from '@elastic/elasticsearch/lib/api/types';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
import { SavedObject } from '@kbn/core/types';

export type DeprecationSource = 'Kibana' | 'Elasticsearch';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type * as estypes from '@elastic/elasticsearch/lib/api/types';

export const diskIndicatorGreen: estypes.HealthReportDiskIndicator = {
status: 'green',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { i18n } from '@kbn/i18n';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
import { IScopedClusterClient } from '@kbn/core/server';
import { EnrichedDeprecationInfo } from '../../../common/types';

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

import _ from 'lodash';
import { elasticsearchServiceMock } from '@kbn/core/server/mocks';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type * as estypes from '@elastic/elasticsearch/lib/api/types';

import fakeDeprecations from '../__fixtures__/fake_deprecations.json';
import * as healthIndicatorsMock from '../__fixtures__/health_indicators';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import type {
MigrationDeprecationsResponse,
MigrationDeprecationsDeprecation,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
} from '@elastic/elasticsearch/lib/api/types';
import { IScopedClusterClient } from '@kbn/core-elasticsearch-server';
import _ from 'lodash';
import { EnrichedDeprecationInfo } from '../../../common/types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type * as estypes from '@elastic/elasticsearch/lib/api/types';

interface Mapping {
type?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import type { ClusterGetSettingsResponse } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { ClusterGetSettingsResponse } from '@elastic/elasticsearch/lib/api/types';
import { ByteSizeValue } from '@kbn/config-schema';
import { API_BASE_PATH } from '../../common/constants';
import { versionCheckHandlerWrapper } from '../lib/es_version_precheck';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import type { Moment } from 'moment';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type * as estypes from '@elastic/elasticsearch/lib/api/types';

import { ACTION_STATES, WATCH_STATES, WATCH_STATE_COMMENTS } from '../constants';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
import { IScopedClusterClient } from '@kbn/core/server';
import { get } from 'lodash';
import { ES_SCROLL_SETTINGS } from '../../../common/constants';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
import { schema } from '@kbn/config-schema';
import { IScopedClusterClient } from '@kbn/core/server';
import { reduce, size } from 'lodash';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
import { schema } from '@kbn/config-schema';
import { IScopedClusterClient } from '@kbn/core/server';
import { RouteDependencies } from '../../../types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import { v4 as uuidv4 } from 'uuid';

import { cloneDeep } from 'lodash';
import { InferenceServiceSettings } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { InferenceServiceSettings } from '@elastic/elasticsearch/lib/api/types';
import { LocalInferenceServiceSettings } from '@kbn/ml-trained-models-utils/src/constants/trained_models';
import {
ChildFieldName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { METRIC_TYPE } from '@kbn/analytics';
import type { SerializedEnrichPolicy } from '@kbn/index-management-shared-types';
import { IndicesStatsResponse } from '@elastic/elasticsearch/lib/api/types';
import { InferenceAPIConfigResponse } from '@kbn/ml-trained-models-utils';
import { MappingTypeMapping } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { MappingTypeMapping } from '@elastic/elasticsearch/lib/api/types';
import {
API_BASE_PATH,
INTERNAL_API_BASE_PATH,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { schema } from '@kbn/config-schema';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type * as estypes from '@elastic/elasticsearch/lib/api/types';

import { RouteDependencies } from '../../../types';
import { addBasePath } from '..';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { forEach, keys, sortBy, reduce, size } from 'lodash';
import { flatMap, flow, groupBy, values as valuesFP, map, pickBy } from 'lodash/fp';

import type { IScopedClusterClient } from '@kbn/core/server';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
import type { FieldCapsResponse } from '@elastic/elasticsearch/lib/api/types';

export type FieldCapsList = FieldCapsResponse['fields'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { schema } from '@kbn/config-schema';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type * as estypes from '@elastic/elasticsearch/lib/api/types';

import { RouteDependencies } from '../../../types';
import { addBasePath } from '..';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
import { schema, TypeOf } from '@kbn/config-schema';

import { RouteDependencies } from '../../../types';
Expand Down Expand Up @@ -40,15 +40,11 @@ export function registerSimulateRoute({ router, lib: { handleEsError } }: RouteD
const params: estypes.IndicesSimulateTemplateRequest = templateName
? {
name: templateName,
body: {
index_patterns,
},
index_patterns,
}
: {
body: {
...template,
index_patterns,
},
...template,
index_patterns,
};

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
import { Pipeline, Processor } from '../types';

export function deserializePipelines(pipelinesByName: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
import { schema } from '@kbn/config-schema';

import { API_BASE_PATH } from '../../../common/constants';
Expand Down

0 comments on commit 2687f4f

Please sign in to comment.