Skip to content

Commit

Permalink
Merge branch 'main' into siem-ea-11005
Browse files Browse the repository at this point in the history
  • Loading branch information
machadoum authored Nov 7, 2024
2 parents de2d156 + 7b81bcf commit 21b05ae
Show file tree
Hide file tree
Showing 161 changed files with 1,268 additions and 8,084 deletions.
10 changes: 3 additions & 7 deletions docs/api/synthetics/monitors/delete-monitor-api.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,13 @@ Deletes one or more monitors from the Synthetics app.
You must have `all` privileges for the *Synthetics* feature in the *{observability}* section of the
<<kibana-feature-privileges,{kib} feature privileges>>.

You must have `all` privileges for the *Synthetics* feature in the *{observability}* section of the
<<kibana-feature-privileges,{kib} feature privileges>>.


[[delete-monitor-api-path-params]]
=== {api-path-parms-title}

`config_id`::
(Required, string) The ID of the monitor that you want to delete.


Here is an example of a DELETE request to delete a monitor by ID:

[source,sh]
Expand All @@ -37,7 +33,7 @@ DELETE /api/synthetics/monitors/monitor1-id

==== Bulk Delete Monitors

You can delete multiple monitors by sending a list of config ids to a DELETE request to the `/api/synthetics/monitors` endpoint.
You can delete multiple monitors by sending a list of config ids to a POST request to the `/api/synthetics/monitors/_bulk_delete` endpoint.


[[monitors-delete-request-body]]
Expand All @@ -49,11 +45,11 @@ The request body should contain an array of monitors IDs that you want to delete
(Required, array of strings) An array of monitor IDs to delete.


Here is an example of a DELETE request to delete a list of monitors by ID:
Here is an example of a POST request to delete a list of monitors by ID:

[source,sh]
--------------------------------------------------
DELETE /api/synthetics/monitors
POST /api/synthetics/monitors/_bulk_delete
{
"ids": [
"monitor1-id",
Expand Down
44 changes: 24 additions & 20 deletions docs/api/synthetics/params/delete-param.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ Deletes one or more parameters from the Synthetics app.

=== {api-request-title}

`DELETE <kibana host>:<port>/api/synthetics/params`
`DELETE <kibana host>:<port>/api/synthetics/params/<param_id>`

`DELETE <kibana host>:<port>/s/<space_id>/api/synthetics/params`
`DELETE <kibana host>:<port>/s/<space_id>/api/synthetics/params/<param_id>`

=== {api-prereq-title}

Expand All @@ -20,26 +20,19 @@ You must have `all` privileges for the *Synthetics* feature in the *{observabili
You must have `all` privileges for the *Synthetics* feature in the *{observability}* section of the
<<kibana-feature-privileges,{kib} feature privileges>>.

[[parameters-delete-request-body]]
==== Request Body
[[parameters-delete-path-param]]
==== Path Parameters

The request body should contain an array of parameter IDs that you want to delete.

`ids`::
(Required, array of strings) An array of parameter IDs to delete.
`param_id`::
(Required, string) An id of parameter to delete.


Here is an example of a DELETE request to delete a list of parameters by ID:
Here is an example of a DELETE request to delete a parameter by its ID:

[source,sh]
--------------------------------------------------
DELETE /api/synthetics/params
{
"ids": [
"param1-id",
"param2-id"
]
}
DELETE /api/synthetics/params/param_id1
--------------------------------------------------

[[parameters-delete-response-example]]
Expand All @@ -58,10 +51,21 @@ Here's an example response for deleting multiple parameters:
{
"id": "param1-id",
"deleted": true
},
{
"id": "param2-id",
"deleted": true
}
]
--------------------------------------------------
--------------------------------------------------

==== Bulk delete parameters
To delete multiple parameters, you can send a POST request to `/api/synthetics/params/_bulk_delete` with an array of parameter IDs to delete via body.

Here is an example of a POST request to delete multiple parameters:

[source,sh]
--------------------------------------------------
POST /api/synthetics/params/_bulk_delete
{
"ids": ["param1-id", "param2-id"]
}
--------------------------------------------------


4 changes: 2 additions & 2 deletions docs/management/connectors/action-types/jira.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The Jira connector uses the https://developer.atlassian.com/cloud/jira/platform/
[[jira-compatibility]]
=== Compatibility

Jira on-premise deployments (Server and Data Center) are not supported.
Jira Cloud and Jira Data Center are supported. Jira on-premise deployments are not supported.

[float]
[[define-jira-ui]]
Expand All @@ -37,7 +37,7 @@ Name:: The name of the connector.
URL:: Jira instance URL.
Project key:: Jira project key.
Email:: The account email for HTTP Basic authentication.
API token:: Jira API authentication token for HTTP Basic authentication.
API token:: Jira API authentication token for HTTP Basic authentication. For Jira Data Center, this value should be the password associated with the email owner.

[float]
[[jira-action-configuration]]
Expand Down
6 changes: 6 additions & 0 deletions packages/kbn-search-types/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,11 @@ export interface ISearchOptions {
* To pass an abort signal, use {@link ISearchOptions.abortSignal}
*/
transport?: Omit<TransportRequestOptions, 'signal'>;

/**
* When set es results are streamed back to the caller without any parsing of the content.
*/
stream?: boolean;
}

/**
Expand All @@ -130,4 +135,5 @@ export type ISearchOptionsSerializable = Pick<
| 'isRestore'
| 'retrieveResults'
| 'executionContext'
| 'stream'
>;
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@
*/

export * from './types';
export * from './response_utils';
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { getTotalLoaded, toKibanaSearchResponse, shimHitsTotal } from './response_utils';
import { getTotalLoaded, shimHitsTotal } from './response_utils';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';

describe('response utils', () => {
Expand All @@ -29,34 +29,6 @@ describe('response utils', () => {
});
});

describe('toKibanaSearchResponse', () => {
it('returns rawResponse, isPartial, isRunning, total, and loaded', () => {
const result = toKibanaSearchResponse({
_shards: {
successful: 10,
failed: 5,
skipped: 5,
total: 100,
},
} as unknown as estypes.SearchResponse<unknown>);

expect(result).toEqual({
rawResponse: {
_shards: {
successful: 10,
failed: 5,
skipped: 5,
total: 100,
},
},
isRunning: false,
isPartial: false,
total: 100,
loaded: 15,
});
});
});

describe('shimHitsTotal', () => {
test('returns the total if it is already numeric', () => {
const result = shimHitsTotal({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,8 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import type { ConnectionRequestParams } from '@elastic/transport';
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import { ISearchOptions } from '@kbn/search-types';
import { sanitizeRequestParams } from '../../sanitize_request_params';

/**
* Get the `total`/`loaded` for this response (see `IKibanaSearchResponse`). Note that `skipped` is
Expand All @@ -23,23 +21,6 @@ export function getTotalLoaded(response: estypes.SearchResponse<unknown>) {
return { total, loaded };
}

/**
* Get the Kibana representation of this response (see `IKibanaSearchResponse`).
* @internal
*/
export function toKibanaSearchResponse(
rawResponse: estypes.SearchResponse<unknown>,
requestParams?: ConnectionRequestParams
) {
return {
rawResponse,
isPartial: false,
isRunning: false,
...(requestParams ? { requestParams: sanitizeRequestParams(requestParams) } : {}),
...getTotalLoaded(rawResponse),
};
}

/**
* Temporary workaround until https://github.com/elastic/kibana/issues/26356 is addressed.
* Since we are setting `track_total_hits` in the request, `hits.total` will be an object
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/data/common/search/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ import { AggTypesDependencies } from '..';
/**
* @returns true if response is abort
*/
export const isAbortResponse = (response?: IKibanaSearchResponse) => {
return !response || !response.rawResponse;
export const isAbortResponse = (
response?: IKibanaSearchResponse | { response: IKibanaSearchResponse }
) => {
return !response || !('rawResponse' in response || 'response' in response);
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,19 @@ import type {
} from '@kbn/search-types';
import { createEsError, isEsError, renderSearchError } from '@kbn/search-errors';
import type { IKibanaSearchResponse, ISearchOptions } from '@kbn/search-types';
import {
AsyncSearchGetResponse,
ErrorResponseBase,
SqlGetAsyncResponse,
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
import {
ENHANCED_ES_SEARCH_STRATEGY,
ESQL_ASYNC_SEARCH_STRATEGY,
getTotalLoaded,
IAsyncSearchOptions,
isRunningResponse,
pollSearch,
shimHitsTotal,
UI_SETTINGS,
} from '../../../common';
import { SearchUsageCollector } from '../collectors';
Expand Down Expand Up @@ -445,14 +453,75 @@ export class SearchInterceptor {
if (this.bFetchDisabled) {
const { executionContext, strategy, ...searchOptions } = this.getSerializableOptions(options);
return this.deps.http
.post(`/internal/search/${strategy}${request.id ? `/${request.id}` : ''}`, {
version: '1',
signal: abortSignal,
context: executionContext,
body: JSON.stringify({
...request,
...searchOptions,
}),
.post<IKibanaSearchResponse | ErrorResponseBase>(
`/internal/search/${strategy}${request.id ? `/${request.id}` : ''}`,
{
version: '1',
signal: abortSignal,
context: executionContext,
body: JSON.stringify({
...request,
...searchOptions,
stream:
strategy === ESQL_ASYNC_SEARCH_STRATEGY ||
strategy === ENHANCED_ES_SEARCH_STRATEGY ||
strategy === undefined, // undefined strategy is treated as enhanced ES
}),
asResponse: true,
}
)
.then((rawResponse) => {
const warning = rawResponse.response?.headers.get('warning');
const requestParams =
rawResponse.body && 'requestParams' in rawResponse.body
? rawResponse.body.requestParams
: JSON.parse(rawResponse.response?.headers.get('kbn-search-request-params') || '{}');
const isRestored =
rawResponse.body && 'isRestored' in rawResponse.body
? rawResponse.body.isRestored
: rawResponse.response?.headers.get('kbn-search-is-restored') === '?1';

if (rawResponse.body && 'error' in rawResponse.body) {
// eslint-disable-next-line no-throw-literal
throw {
attributes: {
error: rawResponse.body.error,
rawResponse: rawResponse.body,
requestParams,
isRestored,
},
};
}

switch (strategy) {
case ENHANCED_ES_SEARCH_STRATEGY:
if (rawResponse.body?.rawResponse) return rawResponse.body;
const typedResponse = rawResponse.body as unknown as AsyncSearchGetResponse;
const shimmedResponse = shimHitsTotal(typedResponse.response, {
legacyHitsTotal: searchOptions.legacyHitsTotal,
});
return {
id: typedResponse.id,
isPartial: typedResponse.is_partial,
isRunning: typedResponse.is_running,
rawResponse: shimmedResponse,
warning,
requestParams,
isRestored,
...getTotalLoaded(shimmedResponse),
};
case ESQL_ASYNC_SEARCH_STRATEGY:
const esqlResponse = rawResponse.body as unknown as SqlGetAsyncResponse;
return {
id: esqlResponse.id,
rawResponse: esqlResponse,
isPartial: esqlResponse.is_partial,
isRunning: esqlResponse.is_running,
warning,
};
default:
return rawResponse.body;
}
})
.catch((e: IHttpFetchError<KibanaServerError>) => {
if (e?.body) {
Expand Down
3 changes: 2 additions & 1 deletion src/plugins/data/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,13 @@ export type {
AsyncSearchStatusResponse,
} from './search';
export {
shimHitsTotal,
SearchSessionService,
NoSearchIdInSessionError,
INITIAL_SEARCH_SESSION_REST_VERSION,
} from './search';

export { shimHitsTotal } from '../common/search';

// Search namespace
export const search = {
aggs: {
Expand Down
Loading

0 comments on commit 21b05ae

Please sign in to comment.