Skip to content

Commit

Permalink
[ES body removal] @elastic/response-ops (elastic#204882)
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo authored Jan 21, 2025
1 parent 17be4e6 commit 7bb2dad
Show file tree
Hide file tree
Showing 121 changed files with 860 additions and 961 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type {
QueryDslFieldAndFormat,
QueryDslQueryContainer,
SortCombinations,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
} from '@elastic/elasticsearch/lib/api/types';
import type { Alert } from './alert_type';

export type RuleRegistrySearchRequest = IEsSearchRequest & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import type {
QueryDslFieldAndFormat,
QueryDslQueryContainer,
SortCombinations,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
} from '@elastic/elasticsearch/lib/api/types';
import type { EsQuerySnapshot, LegacyField } from '../../types';

export interface SearchAlertsParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type {
AggregationsAggregationContainer,
QueryDslQueryContainer,
SortCombinations,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
} from '@elastic/elasticsearch/lib/api/types';
import { BASE_RAC_ALERTS_API_PATH } from '../constants';

export interface UseGetAlertsGroupAggregationsQueryProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import type {
Script,
MappingRuntimeField,
MappingRuntimeFields,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
} from '@elastic/elasticsearch/lib/api/types';
import type { RuntimeFieldSpec, RuntimePrimitiveTypes } from '@kbn/data-views-plugin/common';
import type { BoolQuery } from '@kbn/es-query';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type * as estypes from '@elastic/elasticsearch/lib/api/types';

type RunTimeMappings =
| Record<string, Omit<RuntimeFieldSpec, 'type'> & { type: RuntimePrimitiveTypes }>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Get all actions with in-memory connectors
*/
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import * as estypes from '@elastic/elasticsearch/lib/api/types';
import { AuditLogger } from '@kbn/security-plugin-types-server';
import { ElasticsearchClient, Logger } from '@kbn/core/server';
import { omit } from 'lodash';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import * as estypes from '@elastic/elasticsearch/lib/api/types';
import { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
import { SavedObjectsClient } from '@kbn/core/server';

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

import { KueryNode } from '@kbn/es-query';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type * as estypes from '@elastic/elasticsearch/lib/api/types';
import Boom from '@hapi/boom';
import { flatMap, get, isEmpty } from 'lodash';
import { AggregateEventsBySavedObjectResult } from '@kbn/event-log-plugin/server';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import type {
AggregationsKeyedPercentiles,
AggregationsPercentilesAggregateBase,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
} from '@elastic/elasticsearch/lib/api/types';
import { MonitoringCollectionSetup } from '@kbn/monitoring-collection-plugin/server';
import { aggregateTaskOverduePercentilesForType } from '@kbn/task-manager-plugin/server';
import { CoreSetup } from '@kbn/core/server';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
import { ElasticsearchClient, Logger } from '@kbn/core/server';
import { AggregationsTermsAggregateBase } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { AggregationsTermsAggregateBase } from '@elastic/elasticsearch/lib/api/types';
import {
AvgActionRunOutcomeByConnectorTypeBucket,
parseActionRunOutcomeByConnectorTypesBucket,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { AggregationsBuckets } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { AggregationsBuckets } from '@elastic/elasticsearch/lib/api/types';
import { replaceFirstAndLastDotSymbols } from '../actions_telemetry';

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

import type { MappingTypeMapping } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import type { MappingTypeMapping } from '@elastic/elasticsearch/lib/api/types';
import { set } from '@kbn/safer-lodash-set';
import type { FieldMap, MultiField } from '@kbn/alerts-as-data-utils';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import type {
AggregationsAggregationContainer,
AggregationsCompositeAggregation,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
} from '@elastic/elasticsearch/lib/api/types';
import type { AggregateOptions } from '../server/application/rule/methods/aggregate/types';

export type RuleTagsAggregationOptions = Pick<AggregateOptions, 'filter' | 'search'> & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,18 +442,16 @@ describe('Alerts Client', () => {
);

expect(clusterClient.search).toHaveBeenCalledWith({
body: {
query: {
bool: {
filter: [
{ term: { 'kibana.alert.rule.uuid': '1' } },
{ terms: { 'kibana.alert.uuid': ['abc', 'def', 'xyz'] } },
],
},
query: {
bool: {
filter: [
{ term: { 'kibana.alert.rule.uuid': '1' } },
{ terms: { 'kibana.alert.uuid': ['abc', 'def', 'xyz'] } },
],
},
seq_no_primary_term: true,
size: 3,
},
seq_no_primary_term: true,
size: 3,
index: useDataStreamForAlerts
? '.alerts-test.alerts-default'
: '.internal.alerts-test.alerts-default-*',
Expand Down Expand Up @@ -516,18 +514,16 @@ describe('Alerts Client', () => {
);

expect(clusterClient.search).toHaveBeenCalledWith({
body: {
query: {
bool: {
filter: [
{ term: { 'kibana.alert.rule.uuid': '1' } },
{ terms: { 'kibana.alert.uuid': ['abc'] } },
],
},
query: {
bool: {
filter: [
{ term: { 'kibana.alert.rule.uuid': '1' } },
{ terms: { 'kibana.alert.uuid': ['abc'] } },
],
},
size: 1,
seq_no_primary_term: true,
},
size: 1,
seq_no_primary_term: true,
index: useDataStreamForAlerts
? '.alerts-test.alerts-default'
: '.internal.alerts-test.alerts-default-*',
Expand Down Expand Up @@ -570,7 +566,7 @@ describe('Alerts Client', () => {
index: '.alerts-test.alerts-default',
refresh: 'wait_for',
require_alias: !useDataStreamForAlerts,
body: [
operations: [
{
create: { _id: uuid1, ...(useDataStreamForAlerts ? {} : { require_alias: true }) },
},
Expand Down Expand Up @@ -617,7 +613,7 @@ describe('Alerts Client', () => {
index: '.alerts-test.alerts-default',
refresh: true,
require_alias: !useDataStreamForAlerts,
body: [
operations: [
{
create: { _id: uuid1, ...(useDataStreamForAlerts ? {} : { require_alias: true }) },
},
Expand Down Expand Up @@ -710,7 +706,7 @@ describe('Alerts Client', () => {
index: '.alerts-test.alerts-default',
refresh: 'wait_for',
require_alias: !useDataStreamForAlerts,
body: [
operations: [
{
index: {
_id: 'abc',
Expand Down Expand Up @@ -783,7 +779,7 @@ describe('Alerts Client', () => {
index: '.alerts-test.alerts-default',
refresh: 'wait_for',
require_alias: !useDataStreamForAlerts,
body: [
operations: [
{
index: {
_id: 'abc',
Expand Down Expand Up @@ -918,7 +914,7 @@ describe('Alerts Client', () => {
index: '.alerts-test.alerts-default',
refresh: 'wait_for',
require_alias: !useDataStreamForAlerts,
body: [
operations: [
{
create: {
_id: 'abc',
Expand Down Expand Up @@ -991,7 +987,7 @@ describe('Alerts Client', () => {
index: '.alerts-test.alerts-default',
refresh: 'wait_for',
require_alias: !useDataStreamForAlerts,
body: [
operations: [
{
index: {
_id: 'def',
Expand Down Expand Up @@ -1090,7 +1086,7 @@ describe('Alerts Client', () => {
index: '.alerts-test.alerts-default',
refresh: 'wait_for',
require_alias: !useDataStreamForAlerts,
body: [
operations: [
{
index: {
_id: 'def',
Expand Down Expand Up @@ -1247,7 +1243,7 @@ describe('Alerts Client', () => {
index: '.alerts-test.alerts-default',
refresh: 'wait_for',
require_alias: !useDataStreamForAlerts,
body: [
operations: [
{
index: {
_id: 'def',
Expand Down Expand Up @@ -1365,7 +1361,7 @@ describe('Alerts Client', () => {
index: '.alerts-test.alerts-default',
refresh: 'wait_for',
require_alias: !useDataStreamForAlerts,
body: [
operations: [
{
index: {
_id: 'def',
Expand Down Expand Up @@ -1569,7 +1565,7 @@ describe('Alerts Client', () => {
index: '.alerts-test.alerts-default',
refresh: 'wait_for',
require_alias: !useDataStreamForAlerts,
body: [
operations: [
{
index: {
_id: 'def',
Expand Down Expand Up @@ -2540,7 +2536,7 @@ describe('Alerts Client', () => {
index: '.alerts-test.alerts-default',
refresh: 'wait_for',
require_alias: !useDataStreamForAlerts,
body: [
operations: [
{
create: { _id: uuid1, ...(useDataStreamForAlerts ? {} : { require_alias: true }) },
},
Expand Down Expand Up @@ -2814,7 +2810,7 @@ describe('Alerts Client', () => {
index: '.alerts-test.alerts-default',
refresh: 'wait_for',
require_alias: !useDataStreamForAlerts,
body: [
operations: [
{
create: {
_id: expect.any(String),
Expand Down Expand Up @@ -2915,7 +2911,7 @@ describe('Alerts Client', () => {
index: '.alerts-test.alerts-default',
refresh: 'wait_for',
require_alias: !useDataStreamForAlerts,
body: [
operations: [
{
create: {
_id: 'abc',
Expand Down Expand Up @@ -3012,7 +3008,7 @@ describe('Alerts Client', () => {
index: '.alerts-test.alerts-default',
refresh: 'wait_for',
require_alias: !useDataStreamForAlerts,
body: [
operations: [
{
index: {
_id: 'abc',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
ALERT_MAINTENANCE_WINDOW_IDS,
} from '@kbn/rule-data-utils';
import { chunk, flatMap, get, isEmpty, keys } from 'lodash';
import { SearchRequest } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { SearchRequest } from '@elastic/elasticsearch/lib/api/types';
import type { Alert } from '@kbn/alerts-as-data-utils';
import { DEFAULT_NAMESPACE_STRING } from '@kbn/core-saved-objects-utils-server';
import { DeepPartial } from '@kbn/utility-types';
Expand Down Expand Up @@ -231,7 +231,7 @@ export class AlertsClient<
}

public async search<Aggregation = unknown>(
queryBody: SearchRequest['body']
queryBody: SearchRequest
): Promise<SearchResult<AlertData, Aggregation>> {
const esClient = await this.options.elasticsearchClientPromise;
const index = this.isUsingDataStreams()
Expand All @@ -242,7 +242,7 @@ export class AlertsClient<
aggregations,
} = await esClient.search<Alert & AlertData, Aggregation>({
index,
body: queryBody,
...queryBody,
ignore_unavailable: true,
});

Expand Down Expand Up @@ -568,7 +568,7 @@ export class AlertsClient<
refresh: this.isServerless ? true : 'wait_for',
index: this.indexTemplateAndPattern.alias,
require_alias: !this.isUsingDataStreams(),
body: bulkBody,
operations: bulkBody,
});

// If there were individual indexing errors, they will be returned in the success response
Expand Down
Loading

0 comments on commit 7bb2dad

Please sign in to comment.