From c82269df62265b44c4058e33d11a666b23c800fa Mon Sep 17 00:00:00 2001 From: Maxim Palenov Date: Tue, 13 Aug 2024 00:50:22 +0300 Subject: [PATCH] [Security Solution] Use more specific bulk action operationIds (#190040) **Addresses:** https://github.com/elastic/kibana/issues/190035 ## Summary This PR fixes `operationId` conflicts in Security Solution OpenAPI specs. ## Details API reference documentation platform (Bump.sh) expects unique `operationId`s to build proper navigation on the documentation page. It's expected each `operationId` throughout whole Kibana since Kibana API reference documentation will contain all available API endpoints. --- ...sistant_api_2023_10_31.bundled.schema.yaml | 4 +- ...sistant_api_2023_10_31.bundled.schema.yaml | 4 +- ...ulk_crud_anonymization_fields_route.gen.ts | 17 ++- ...rud_anonymization_fields_route.schema.yaml | 2 +- .../prompts/bulk_crud_prompts_route.gen.ts | 14 +- .../bulk_crud_prompts_route.schema.yaml | 2 +- .../bulk_update_anonymization_fields.ts | 8 +- .../api/prompts/bulk_update_prompts.ts | 8 +- .../system_prompt_editor.tsx | 2 +- .../system_prompt_modal/types.ts | 2 +- .../use_system_prompt_editor.tsx | 2 +- .../quick_prompt_editor.tsx | 2 +- .../quick_prompt_settings.tsx | 2 +- .../use_quick_prompt_editor.tsx | 2 +- .../use_settings_updater.tsx | 10 +- .../settings/anonymization_settings/index.tsx | 6 +- .../use_anonymization_list_update.tsx | 6 +- .../context_editor_modal/index.tsx | 6 +- .../anonymization_fields_schema.mock.ts | 17 +-- .../server/__mocks__/prompts_schema.mock.ts | 4 +- .../bulk_actions_route.ts | 12 +- .../routes/prompts/bulk_actions_route.ts | 12 +- .../bulk_actions/bulk_actions_route.gen.ts | 20 +-- .../bulk_actions/bulk_actions_route.mock.ts | 6 +- .../bulk_actions_route.schema.yaml | 2 +- .../bulk_actions/bulk_actions_route.test.ts | 124 +++++++++--------- ...ections_api_2023_10_31.bundled.schema.yaml | 2 +- ...ections_api_2023_10_31.bundled.schema.yaml | 2 +- .../rule_management/api/api.ts | 4 +- .../api/hooks/use_bulk_action_mutation.ts | 12 +- .../api/rules/bulk_actions/route.ts | 16 ++- .../services/security_solution_api.gen.ts | 12 +- .../perform_bulk_action.ts | 26 ++-- .../perform_bulk_action_dry_run.ts | 22 ++-- .../perform_bulk_action_ess.ts | 31 +++-- 35 files changed, 229 insertions(+), 194 deletions(-) diff --git a/x-pack/packages/kbn-elastic-assistant-common/docs/openapi/ess/elastic_assistant_api_2023_10_31.bundled.schema.yaml b/x-pack/packages/kbn-elastic-assistant-common/docs/openapi/ess/elastic_assistant_api_2023_10_31.bundled.schema.yaml index 34d7625691d25..7648273ce32a0 100644 --- a/x-pack/packages/kbn-elastic-assistant-common/docs/openapi/ess/elastic_assistant_api_2023_10_31.bundled.schema.yaml +++ b/x-pack/packages/kbn-elastic-assistant-common/docs/openapi/ess/elastic_assistant_api_2023_10_31.bundled.schema.yaml @@ -16,7 +16,7 @@ paths: description: >- The bulk action is applied to all anonymization fields that match the filter or to the list of anonymization fields by their IDs. - operationId: PerformBulkAction + operationId: PerformAnonymizationFieldsBulkAction requestBody: content: application/json: @@ -422,7 +422,7 @@ paths: description: >- The bulk action is applied to all prompts that match the filter or to the list of prompts by their IDs. - operationId: PerformBulkAction + operationId: PerformPromptsBulkAction requestBody: content: application/json: diff --git a/x-pack/packages/kbn-elastic-assistant-common/docs/openapi/serverless/elastic_assistant_api_2023_10_31.bundled.schema.yaml b/x-pack/packages/kbn-elastic-assistant-common/docs/openapi/serverless/elastic_assistant_api_2023_10_31.bundled.schema.yaml index 4e5d49eb12051..cbb6e28359adb 100644 --- a/x-pack/packages/kbn-elastic-assistant-common/docs/openapi/serverless/elastic_assistant_api_2023_10_31.bundled.schema.yaml +++ b/x-pack/packages/kbn-elastic-assistant-common/docs/openapi/serverless/elastic_assistant_api_2023_10_31.bundled.schema.yaml @@ -16,7 +16,7 @@ paths: description: >- The bulk action is applied to all anonymization fields that match the filter or to the list of anonymization fields by their IDs. - operationId: PerformBulkAction + operationId: PerformAnonymizationFieldsBulkAction requestBody: content: application/json: @@ -422,7 +422,7 @@ paths: description: >- The bulk action is applied to all prompts that match the filter or to the list of prompts by their IDs. - operationId: PerformBulkAction + operationId: PerformPromptsBulkAction requestBody: content: application/json: diff --git a/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/anonymization_fields/bulk_crud_anonymization_fields_route.gen.ts b/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/anonymization_fields/bulk_crud_anonymization_fields_route.gen.ts index f72fb2f5423e9..4aed90462893c 100644 --- a/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/anonymization_fields/bulk_crud_anonymization_fields_route.gen.ts +++ b/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/anonymization_fields/bulk_crud_anonymization_fields_route.gen.ts @@ -124,13 +124,20 @@ export const AnonymizationFieldUpdateProps = z.object({ anonymized: z.boolean().optional(), }); -export type PerformBulkActionRequestBody = z.infer; -export const PerformBulkActionRequestBody = z.object({ +export type PerformAnonymizationFieldsBulkActionRequestBody = z.infer< + typeof PerformAnonymizationFieldsBulkActionRequestBody +>; +export const PerformAnonymizationFieldsBulkActionRequestBody = z.object({ delete: BulkActionBase.optional(), create: z.array(AnonymizationFieldCreateProps).optional(), update: z.array(AnonymizationFieldUpdateProps).optional(), }); -export type PerformBulkActionRequestBodyInput = z.input; +export type PerformAnonymizationFieldsBulkActionRequestBodyInput = z.input< + typeof PerformAnonymizationFieldsBulkActionRequestBody +>; -export type PerformBulkActionResponse = z.infer; -export const PerformBulkActionResponse = AnonymizationFieldsBulkCrudActionResponse; +export type PerformAnonymizationFieldsBulkActionResponse = z.infer< + typeof PerformAnonymizationFieldsBulkActionResponse +>; +export const PerformAnonymizationFieldsBulkActionResponse = + AnonymizationFieldsBulkCrudActionResponse; diff --git a/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/anonymization_fields/bulk_crud_anonymization_fields_route.schema.yaml b/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/anonymization_fields/bulk_crud_anonymization_fields_route.schema.yaml index 8e9d5700f577e..0180e4b556b40 100644 --- a/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/anonymization_fields/bulk_crud_anonymization_fields_route.schema.yaml +++ b/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/anonymization_fields/bulk_crud_anonymization_fields_route.schema.yaml @@ -7,7 +7,7 @@ paths: post: x-codegen-enabled: true x-labels: [ess, serverless] - operationId: PerformBulkAction + operationId: PerformAnonymizationFieldsBulkAction summary: Applies a bulk action to multiple anonymization fields description: The bulk action is applied to all anonymization fields that match the filter or to the list of anonymization fields by their IDs. tags: diff --git a/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/prompts/bulk_crud_prompts_route.gen.ts b/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/prompts/bulk_crud_prompts_route.gen.ts index 8247a88c66297..820d27dca30ce 100644 --- a/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/prompts/bulk_crud_prompts_route.gen.ts +++ b/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/prompts/bulk_crud_prompts_route.gen.ts @@ -137,13 +137,17 @@ export const PromptUpdateProps = z.object({ consumer: z.string().optional(), }); -export type PerformBulkActionRequestBody = z.infer; -export const PerformBulkActionRequestBody = z.object({ +export type PerformPromptsBulkActionRequestBody = z.infer< + typeof PerformPromptsBulkActionRequestBody +>; +export const PerformPromptsBulkActionRequestBody = z.object({ delete: BulkActionBase.optional(), create: z.array(PromptCreateProps).optional(), update: z.array(PromptUpdateProps).optional(), }); -export type PerformBulkActionRequestBodyInput = z.input; +export type PerformPromptsBulkActionRequestBodyInput = z.input< + typeof PerformPromptsBulkActionRequestBody +>; -export type PerformBulkActionResponse = z.infer; -export const PerformBulkActionResponse = PromptsBulkCrudActionResponse; +export type PerformPromptsBulkActionResponse = z.infer; +export const PerformPromptsBulkActionResponse = PromptsBulkCrudActionResponse; diff --git a/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/prompts/bulk_crud_prompts_route.schema.yaml b/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/prompts/bulk_crud_prompts_route.schema.yaml index ad0550e6d3d6f..24fa425a22ed0 100644 --- a/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/prompts/bulk_crud_prompts_route.schema.yaml +++ b/x-pack/packages/kbn-elastic-assistant-common/impl/schemas/prompts/bulk_crud_prompts_route.schema.yaml @@ -7,7 +7,7 @@ paths: post: x-codegen-enabled: true x-labels: [ess, serverless] - operationId: PerformBulkAction + operationId: PerformPromptsBulkAction summary: Applies a bulk action to multiple prompts description: The bulk action is applied to all prompts that match the filter or to the list of prompts by their IDs. tags: diff --git a/x-pack/packages/kbn-elastic-assistant/impl/assistant/api/anonymization_fields/bulk_update_anonymization_fields.ts b/x-pack/packages/kbn-elastic-assistant/impl/assistant/api/anonymization_fields/bulk_update_anonymization_fields.ts index 9745e7ce38662..b91682e20abe7 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/assistant/api/anonymization_fields/bulk_update_anonymization_fields.ts +++ b/x-pack/packages/kbn-elastic-assistant/impl/assistant/api/anonymization_fields/bulk_update_anonymization_fields.ts @@ -12,17 +12,17 @@ import { API_VERSIONS, } from '@kbn/elastic-assistant-common'; import { - PerformBulkActionRequestBody, - PerformBulkActionResponse, + PerformAnonymizationFieldsBulkActionRequestBody, + PerformAnonymizationFieldsBulkActionResponse, } from '@kbn/elastic-assistant-common/impl/schemas/anonymization_fields/bulk_crud_anonymization_fields_route.gen'; export const bulkUpdateAnonymizationFields = async ( http: HttpSetup, - anonymizationFieldsActions: PerformBulkActionRequestBody, + anonymizationFieldsActions: PerformAnonymizationFieldsBulkActionRequestBody, toasts?: IToasts ) => { try { - const result = await http.fetch( + const result = await http.fetch( ELASTIC_AI_ASSISTANT_ANONYMIZATION_FIELDS_URL_BULK_ACTION, { method: 'POST', diff --git a/x-pack/packages/kbn-elastic-assistant/impl/assistant/api/prompts/bulk_update_prompts.ts b/x-pack/packages/kbn-elastic-assistant/impl/assistant/api/prompts/bulk_update_prompts.ts index 9b024716ea0da..0223eac11210b 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/assistant/api/prompts/bulk_update_prompts.ts +++ b/x-pack/packages/kbn-elastic-assistant/impl/assistant/api/prompts/bulk_update_prompts.ts @@ -12,17 +12,17 @@ import { API_VERSIONS, } from '@kbn/elastic-assistant-common'; import { - PerformBulkActionRequestBody, - PerformBulkActionResponse, + PerformPromptsBulkActionRequestBody, + PerformPromptsBulkActionResponse, } from '@kbn/elastic-assistant-common/impl/schemas/prompts/bulk_crud_prompts_route.gen'; export const bulkUpdatePrompts = async ( http: HttpSetup, - prompts: PerformBulkActionRequestBody, + prompts: PerformPromptsBulkActionRequestBody, toasts?: IToasts ) => { try { - const result = await http.fetch( + const result = await http.fetch( ELASTIC_AI_ASSISTANT_PROMPTS_URL_BULK_ACTION, { method: 'POST', diff --git a/x-pack/packages/kbn-elastic-assistant/impl/assistant/prompt_editor/system_prompt/system_prompt_modal/system_prompt_editor.tsx b/x-pack/packages/kbn-elastic-assistant/impl/assistant/prompt_editor/system_prompt/system_prompt_modal/system_prompt_editor.tsx index be072790bf7fc..2036b1114b79c 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/assistant/prompt_editor/system_prompt/system_prompt_modal/system_prompt_editor.tsx +++ b/x-pack/packages/kbn-elastic-assistant/impl/assistant/prompt_editor/system_prompt/system_prompt_modal/system_prompt_editor.tsx @@ -20,7 +20,7 @@ import { keyBy } from 'lodash/fp'; import { css } from '@emotion/react'; import { PromptResponse, - PerformBulkActionRequestBody as PromptsPerformBulkActionRequestBody, + PerformPromptsBulkActionRequestBody as PromptsPerformBulkActionRequestBody, } from '@kbn/elastic-assistant-common/impl/schemas/prompts/bulk_crud_prompts_route.gen'; import { ApiConfig } from '@kbn/elastic-assistant-common'; import { AIConnector } from '../../../../connectorland/connector_selector'; diff --git a/x-pack/packages/kbn-elastic-assistant/impl/assistant/prompt_editor/system_prompt/system_prompt_modal/types.ts b/x-pack/packages/kbn-elastic-assistant/impl/assistant/prompt_editor/system_prompt/system_prompt_modal/types.ts index e92961cb1763f..0ea97ea8fed2e 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/assistant/prompt_editor/system_prompt/system_prompt_modal/types.ts +++ b/x-pack/packages/kbn-elastic-assistant/impl/assistant/prompt_editor/system_prompt/system_prompt_modal/types.ts @@ -6,7 +6,7 @@ */ import { PromptResponse, - PerformBulkActionRequestBody as PromptsPerformBulkActionRequestBody, + PerformPromptsBulkActionRequestBody as PromptsPerformBulkActionRequestBody, } from '@kbn/elastic-assistant-common/impl/schemas/prompts/bulk_crud_prompts_route.gen'; import { AIConnector } from '../../../../connectorland/connector_selector'; import { Conversation } from '../../../../..'; diff --git a/x-pack/packages/kbn-elastic-assistant/impl/assistant/prompt_editor/system_prompt/system_prompt_modal/use_system_prompt_editor.tsx b/x-pack/packages/kbn-elastic-assistant/impl/assistant/prompt_editor/system_prompt/system_prompt_modal/use_system_prompt_editor.tsx index 72e193142e998..090925b7b8ca3 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/assistant/prompt_editor/system_prompt/system_prompt_modal/use_system_prompt_editor.tsx +++ b/x-pack/packages/kbn-elastic-assistant/impl/assistant/prompt_editor/system_prompt/system_prompt_modal/use_system_prompt_editor.tsx @@ -7,7 +7,7 @@ import { PromptResponse, - PerformBulkActionRequestBody as PromptsPerformBulkActionRequestBody, + PerformPromptsBulkActionRequestBody as PromptsPerformBulkActionRequestBody, } from '@kbn/elastic-assistant-common/impl/schemas/prompts/bulk_crud_prompts_route.gen'; import { useCallback } from 'react'; import { useAssistantContext } from '../../../../..'; diff --git a/x-pack/packages/kbn-elastic-assistant/impl/assistant/quick_prompts/quick_prompt_settings/quick_prompt_editor.tsx b/x-pack/packages/kbn-elastic-assistant/impl/assistant/quick_prompts/quick_prompt_settings/quick_prompt_editor.tsx index 01ffe00d11100..9a4010e32d09d 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/assistant/quick_prompts/quick_prompt_settings/quick_prompt_editor.tsx +++ b/x-pack/packages/kbn-elastic-assistant/impl/assistant/quick_prompts/quick_prompt_settings/quick_prompt_editor.tsx @@ -12,7 +12,7 @@ import { EuiSetColorMethod } from '@elastic/eui/src/services/color_picker/color_ import { css } from '@emotion/react'; import { PromptResponse, - PerformBulkActionRequestBody as PromptsPerformBulkActionRequestBody, + PerformPromptsBulkActionRequestBody as PromptsPerformBulkActionRequestBody, } from '@kbn/elastic-assistant-common/impl/schemas/prompts/bulk_crud_prompts_route.gen'; import { PromptContextTemplate } from '../../../..'; import * as i18n from './translations'; diff --git a/x-pack/packages/kbn-elastic-assistant/impl/assistant/quick_prompts/quick_prompt_settings/quick_prompt_settings.tsx b/x-pack/packages/kbn-elastic-assistant/impl/assistant/quick_prompts/quick_prompt_settings/quick_prompt_settings.tsx index 61496c64fd73a..450f4be181290 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/assistant/quick_prompts/quick_prompt_settings/quick_prompt_settings.tsx +++ b/x-pack/packages/kbn-elastic-assistant/impl/assistant/quick_prompts/quick_prompt_settings/quick_prompt_settings.tsx @@ -10,7 +10,7 @@ import { EuiTitle, EuiText, EuiHorizontalRule, EuiSpacer } from '@elastic/eui'; import { PromptResponse, - PerformBulkActionRequestBody as PromptsPerformBulkActionRequestBody, + PerformPromptsBulkActionRequestBody as PromptsPerformBulkActionRequestBody, } from '@kbn/elastic-assistant-common/impl/schemas/prompts/bulk_crud_prompts_route.gen'; import * as i18n from './translations'; import { QuickPromptSettingsEditor } from './quick_prompt_editor'; diff --git a/x-pack/packages/kbn-elastic-assistant/impl/assistant/quick_prompts/quick_prompt_settings/use_quick_prompt_editor.tsx b/x-pack/packages/kbn-elastic-assistant/impl/assistant/quick_prompts/quick_prompt_settings/use_quick_prompt_editor.tsx index d96c4fca716d1..9e48b227451a1 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/assistant/quick_prompts/quick_prompt_settings/use_quick_prompt_editor.tsx +++ b/x-pack/packages/kbn-elastic-assistant/impl/assistant/quick_prompts/quick_prompt_settings/use_quick_prompt_editor.tsx @@ -8,7 +8,7 @@ import { PromptResponse, PromptTypeEnum, - PerformBulkActionRequestBody as PromptsPerformBulkActionRequestBody, + PerformPromptsBulkActionRequestBody as PromptsPerformBulkActionRequestBody, } from '@kbn/elastic-assistant-common/impl/schemas/prompts/bulk_crud_prompts_route.gen'; import { useCallback } from 'react'; import { useAssistantContext } from '../../../..'; diff --git a/x-pack/packages/kbn-elastic-assistant/impl/assistant/settings/use_settings_updater/use_settings_updater.tsx b/x-pack/packages/kbn-elastic-assistant/impl/assistant/settings/use_settings_updater/use_settings_updater.tsx index 3d326acb66a06..9786663a28b94 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/assistant/settings/use_settings_updater/use_settings_updater.tsx +++ b/x-pack/packages/kbn-elastic-assistant/impl/assistant/settings/use_settings_updater/use_settings_updater.tsx @@ -7,9 +7,9 @@ import React, { useCallback, useEffect, useState } from 'react'; import { FindAnonymizationFieldsResponse } from '@kbn/elastic-assistant-common/impl/schemas/anonymization_fields/find_anonymization_fields_route.gen'; -import { PerformBulkActionRequestBody } from '@kbn/elastic-assistant-common/impl/schemas/anonymization_fields/bulk_crud_anonymization_fields_route.gen'; +import { PerformAnonymizationFieldsBulkActionRequestBody } from '@kbn/elastic-assistant-common/impl/schemas/anonymization_fields/bulk_crud_anonymization_fields_route.gen'; import { - PerformBulkActionRequestBody as PromptsPerformBulkActionRequestBody, + PerformPromptsBulkActionRequestBody as PromptsPerformBulkActionRequestBody, PromptResponse, PromptTypeEnum, } from '@kbn/elastic-assistant-common/impl/schemas/prompts/bulk_crud_prompts_route.gen'; @@ -50,9 +50,9 @@ interface UseSettingsUpdater { setConversationsSettingsBulkActions: React.Dispatch< React.SetStateAction >; - anonymizationFieldsBulkActions: PerformBulkActionRequestBody; + anonymizationFieldsBulkActions: PerformAnonymizationFieldsBulkActionRequestBody; setAnonymizationFieldsBulkActions: React.Dispatch< - React.SetStateAction + React.SetStateAction >; promptsBulkActions: PromptsPerformBulkActionRequestBody; setPromptsBulkActions: React.Dispatch>; @@ -99,7 +99,7 @@ export const useSettingsUpdater = ( ); // Anonymization const [anonymizationFieldsBulkActions, setAnonymizationFieldsBulkActions] = - useState({}); + useState({}); // Prompts const [promptsBulkActions, setPromptsBulkActions] = useState( {} diff --git a/x-pack/packages/kbn-elastic-assistant/impl/data_anonymization/settings/anonymization_settings/index.tsx b/x-pack/packages/kbn-elastic-assistant/impl/data_anonymization/settings/anonymization_settings/index.tsx index c371c9498dc2f..77d9a3602d849 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/data_anonymization/settings/anonymization_settings/index.tsx +++ b/x-pack/packages/kbn-elastic-assistant/impl/data_anonymization/settings/anonymization_settings/index.tsx @@ -9,7 +9,7 @@ import { EuiFlexGroup, EuiHorizontalRule, EuiSpacer, EuiText, EuiTitle } from '@ import React from 'react'; import { FindAnonymizationFieldsResponse } from '@kbn/elastic-assistant-common/impl/schemas/anonymization_fields/find_anonymization_fields_route.gen'; -import { PerformBulkActionRequestBody } from '@kbn/elastic-assistant-common/impl/schemas/anonymization_fields/bulk_crud_anonymization_fields_route.gen'; +import { PerformAnonymizationFieldsBulkActionRequestBody } from '@kbn/elastic-assistant-common/impl/schemas/anonymization_fields/bulk_crud_anonymization_fields_route.gen'; import { Stats } from '../../../data_anonymization_editor/stats'; import { ContextEditor } from '../../../data_anonymization_editor/context_editor'; import * as i18n from './translations'; @@ -18,9 +18,9 @@ import { useAnonymizationListUpdate } from './use_anonymization_list_update'; export interface Props { defaultPageSize?: number; anonymizationFields: FindAnonymizationFieldsResponse; - anonymizationFieldsBulkActions: PerformBulkActionRequestBody; + anonymizationFieldsBulkActions: PerformAnonymizationFieldsBulkActionRequestBody; setAnonymizationFieldsBulkActions: React.Dispatch< - React.SetStateAction + React.SetStateAction >; setUpdatedAnonymizationData: React.Dispatch< React.SetStateAction diff --git a/x-pack/packages/kbn-elastic-assistant/impl/data_anonymization/settings/anonymization_settings/use_anonymization_list_update.tsx b/x-pack/packages/kbn-elastic-assistant/impl/data_anonymization/settings/anonymization_settings/use_anonymization_list_update.tsx index 643a2ca8d7c39..e6b405f162d05 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/data_anonymization/settings/anonymization_settings/use_anonymization_list_update.tsx +++ b/x-pack/packages/kbn-elastic-assistant/impl/data_anonymization/settings/anonymization_settings/use_anonymization_list_update.tsx @@ -7,15 +7,15 @@ import { useCallback } from 'react'; import { FindAnonymizationFieldsResponse } from '@kbn/elastic-assistant-common/impl/schemas/anonymization_fields/find_anonymization_fields_route.gen'; -import { PerformBulkActionRequestBody } from '@kbn/elastic-assistant-common/impl/schemas/anonymization_fields/bulk_crud_anonymization_fields_route.gen'; +import { PerformAnonymizationFieldsBulkActionRequestBody } from '@kbn/elastic-assistant-common/impl/schemas/anonymization_fields/bulk_crud_anonymization_fields_route.gen'; import { BatchUpdateListItem } from '../../../data_anonymization_editor/context_editor/types'; interface Props { anonymizationFields: FindAnonymizationFieldsResponse; - anonymizationFieldsBulkActions: PerformBulkActionRequestBody; + anonymizationFieldsBulkActions: PerformAnonymizationFieldsBulkActionRequestBody; setAnonymizationFieldsBulkActions: React.Dispatch< - React.SetStateAction + React.SetStateAction >; setUpdatedAnonymizationData: React.Dispatch< React.SetStateAction diff --git a/x-pack/packages/kbn-elastic-assistant/impl/data_anonymization_editor/context_editor_modal/index.tsx b/x-pack/packages/kbn-elastic-assistant/impl/data_anonymization_editor/context_editor_modal/index.tsx index e689bc564329d..652f6fd89b315 100644 --- a/x-pack/packages/kbn-elastic-assistant/impl/data_anonymization_editor/context_editor_modal/index.tsx +++ b/x-pack/packages/kbn-elastic-assistant/impl/data_anonymization_editor/context_editor_modal/index.tsx @@ -28,7 +28,7 @@ import { css } from '@emotion/react'; import { euiThemeVars } from '@kbn/ui-theme'; import { AnonymizationFieldResponse, - PerformBulkActionRequestBody, + PerformAnonymizationFieldsBulkActionRequestBody, } from '@kbn/elastic-assistant-common/impl/schemas/anonymization_fields/bulk_crud_anonymization_fields_route.gen'; import { find, uniqBy } from 'lodash'; import { ContextEditor } from '../context_editor'; @@ -57,7 +57,7 @@ const SelectedPromptContextEditorModalComponent = ({ onClose, onSave, promptCont const [contextUpdates, setContextUpdates] = React.useState([]); const [selectedPromptContext, setSelectedPromptContext] = React.useState(promptContext); const [anonymizationFieldsBulkActions, setAnonymizationFieldsBulkActions] = - useState({ + useState({ create: [], update: [], delete: {}, @@ -94,7 +94,7 @@ const SelectedPromptContextEditorModalComponent = ({ onClose, onSave, promptCont setContextUpdates((prev) => [...prev, ...updates]); setAnonymizationFieldsBulkActions((prev) => { - return updates.reduce( + return updates.reduce( (acc, item) => { const persistedField = find(anonymizationFields.data, ['field', item.field]) as | AnonymizationFieldResponse diff --git a/x-pack/plugins/elastic_assistant/server/__mocks__/anonymization_fields_schema.mock.ts b/x-pack/plugins/elastic_assistant/server/__mocks__/anonymization_fields_schema.mock.ts index e7fd791a209b3..73d47d96be492 100644 --- a/x-pack/plugins/elastic_assistant/server/__mocks__/anonymization_fields_schema.mock.ts +++ b/x-pack/plugins/elastic_assistant/server/__mocks__/anonymization_fields_schema.mock.ts @@ -10,7 +10,7 @@ import { AnonymizationFieldCreateProps, AnonymizationFieldResponse, AnonymizationFieldUpdateProps, - PerformBulkActionRequestBody, + PerformAnonymizationFieldsBulkActionRequestBody, } from '@kbn/elastic-assistant-common/impl/schemas/anonymization_fields/bulk_crud_anonymization_fields_route.gen'; import { EsAnonymizationFieldsSchema } from '../ai_assistant_data_clients/anonymization_fields/types'; @@ -95,10 +95,11 @@ export const getQueryAnonymizationFieldParams = ( }; }; -export const getPerformBulkActionSchemaMock = (): PerformBulkActionRequestBody => ({ - create: [getQueryAnonymizationFieldParams(false) as AnonymizationFieldCreateProps], - delete: { - ids: ['99403909-ca9b-49ba-9d7a-7e5320e68d05'], - }, - update: [getQueryAnonymizationFieldParams(true) as AnonymizationFieldUpdateProps], -}); +export const getPerformBulkActionSchemaMock = + (): PerformAnonymizationFieldsBulkActionRequestBody => ({ + create: [getQueryAnonymizationFieldParams(false) as AnonymizationFieldCreateProps], + delete: { + ids: ['99403909-ca9b-49ba-9d7a-7e5320e68d05'], + }, + update: [getQueryAnonymizationFieldParams(true) as AnonymizationFieldUpdateProps], + }); diff --git a/x-pack/plugins/elastic_assistant/server/__mocks__/prompts_schema.mock.ts b/x-pack/plugins/elastic_assistant/server/__mocks__/prompts_schema.mock.ts index adbe299c33993..4939a6608e618 100644 --- a/x-pack/plugins/elastic_assistant/server/__mocks__/prompts_schema.mock.ts +++ b/x-pack/plugins/elastic_assistant/server/__mocks__/prompts_schema.mock.ts @@ -8,7 +8,7 @@ import { estypes } from '@elastic/elasticsearch'; import { EsPromptsSchema } from '../ai_assistant_data_clients/prompts/types'; import { - PerformBulkActionRequestBody, + PerformPromptsBulkActionRequestBody, PromptCreateProps, PromptResponse, PromptUpdateProps, @@ -123,7 +123,7 @@ export const getQueryPromptParams = (isUpdate?: boolean): PromptCreateProps | Pr }; }; -export const getPerformBulkActionSchemaMock = (): PerformBulkActionRequestBody => ({ +export const getPerformBulkActionSchemaMock = (): PerformPromptsBulkActionRequestBody => ({ create: [getQueryPromptParams(false) as PromptCreateProps], delete: { ids: ['99403909-ca9b-49ba-9d7a-7e5320e68d05'], diff --git a/x-pack/plugins/elastic_assistant/server/routes/anonymization_fields/bulk_actions_route.ts b/x-pack/plugins/elastic_assistant/server/routes/anonymization_fields/bulk_actions_route.ts index f7b87b49dd2a7..5464756739c08 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/anonymization_fields/bulk_actions_route.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/anonymization_fields/bulk_actions_route.ts @@ -20,8 +20,8 @@ import { AnonymizationFieldsBulkCrudActionResponse, AnonymizationFieldsBulkCrudActionResults, BulkCrudActionSummary, - PerformBulkActionRequestBody, - PerformBulkActionResponse, + PerformAnonymizationFieldsBulkActionRequestBody, + PerformAnonymizationFieldsBulkActionResponse, } from '@kbn/elastic-assistant-common/impl/schemas/anonymization_fields/bulk_crud_anonymization_fields_route.gen'; import { buildRouteValidationWithZod } from '@kbn/elastic-assistant-common/impl/schemas/common'; import { ANONYMIZATION_FIELDS_TABLE_MAX_PAGE_SIZE } from '../../../common/constants'; @@ -132,11 +132,15 @@ export const bulkActionAnonymizationFieldsRoute = ( version: API_VERSIONS.public.v1, validate: { request: { - body: buildRouteValidationWithZod(PerformBulkActionRequestBody), + body: buildRouteValidationWithZod(PerformAnonymizationFieldsBulkActionRequestBody), }, }, }, - async (context, request, response): Promise> => { + async ( + context, + request, + response + ): Promise> => { const { body } = request; const assistantResponse = buildResponse(response); diff --git a/x-pack/plugins/elastic_assistant/server/routes/prompts/bulk_actions_route.ts b/x-pack/plugins/elastic_assistant/server/routes/prompts/bulk_actions_route.ts index c2713f28088d8..44a949cd22eeb 100644 --- a/x-pack/plugins/elastic_assistant/server/routes/prompts/bulk_actions_route.ts +++ b/x-pack/plugins/elastic_assistant/server/routes/prompts/bulk_actions_route.ts @@ -20,8 +20,8 @@ import { PromptsBulkCrudActionResponse, PromptsBulkCrudActionResults, BulkCrudActionSummary, - PerformBulkActionRequestBody, - PerformBulkActionResponse, + PerformPromptsBulkActionRequestBody, + PerformPromptsBulkActionResponse, } from '@kbn/elastic-assistant-common/impl/schemas/prompts/bulk_crud_prompts_route.gen'; import { buildRouteValidationWithZod } from '@kbn/elastic-assistant-common/impl/schemas/common'; import { PROMPTS_TABLE_MAX_PAGE_SIZE } from '../../../common/constants'; @@ -126,11 +126,15 @@ export const bulkPromptsRoute = (router: ElasticAssistantPluginRouter, logger: L version: API_VERSIONS.public.v1, validate: { request: { - body: buildRouteValidationWithZod(PerformBulkActionRequestBody), + body: buildRouteValidationWithZod(PerformPromptsBulkActionRequestBody), }, }, }, - async (context, request, response): Promise> => { + async ( + context, + request, + response + ): Promise> => { const { body } = request; const assistantResponse = buildResponse(response); diff --git a/x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.gen.ts b/x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.gen.ts index c10013361e42b..ed47d67becc3d 100644 --- a/x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.gen.ts +++ b/x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.gen.ts @@ -305,17 +305,19 @@ export const BulkEditRules = BulkActionBase.merge( }) ); -export type PerformBulkActionRequestQuery = z.infer; -export const PerformBulkActionRequestQuery = z.object({ +export type PerformRulesBulkActionRequestQuery = z.infer; +export const PerformRulesBulkActionRequestQuery = z.object({ /** * Enables dry run mode for the request call. */ dry_run: BooleanFromString.optional(), }); -export type PerformBulkActionRequestQueryInput = z.input; +export type PerformRulesBulkActionRequestQueryInput = z.input< + typeof PerformRulesBulkActionRequestQuery +>; -export type PerformBulkActionRequestBody = z.infer; -export const PerformBulkActionRequestBody = z.union([ +export type PerformRulesBulkActionRequestBody = z.infer; +export const PerformRulesBulkActionRequestBody = z.union([ BulkDeleteRules, BulkDisableRules, BulkEnableRules, @@ -324,10 +326,12 @@ export const PerformBulkActionRequestBody = z.union([ BulkManualRuleRun, BulkEditRules, ]); -export type PerformBulkActionRequestBodyInput = z.input; +export type PerformRulesBulkActionRequestBodyInput = z.input< + typeof PerformRulesBulkActionRequestBody +>; -export type PerformBulkActionResponse = z.infer; -export const PerformBulkActionResponse = z.union([ +export type PerformRulesBulkActionResponse = z.infer; +export const PerformRulesBulkActionResponse = z.union([ BulkEditActionResponse, BulkExportActionResponse, ]); diff --git a/x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.mock.ts b/x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.mock.ts index 0a7cd906dc4bb..37471efb0a958 100644 --- a/x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.mock.ts +++ b/x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.mock.ts @@ -5,16 +5,16 @@ * 2.0. */ -import type { PerformBulkActionRequestBody } from './bulk_actions_route.gen'; +import type { PerformRulesBulkActionRequestBody } from './bulk_actions_route.gen'; import { BulkActionEditTypeEnum, BulkActionTypeEnum } from './bulk_actions_route.gen'; -export const getBulkDisableRuleActionSchemaMock = (): PerformBulkActionRequestBody => ({ +export const getBulkDisableRuleActionSchemaMock = (): PerformRulesBulkActionRequestBody => ({ query: '', ids: undefined, action: BulkActionTypeEnum.disable, }); -export const getPerformBulkActionEditSchemaMock = (): PerformBulkActionRequestBody => ({ +export const getPerformBulkActionEditSchemaMock = (): PerformRulesBulkActionRequestBody => ({ query: '', ids: undefined, action: BulkActionTypeEnum.edit, diff --git a/x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.schema.yaml b/x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.schema.yaml index b58560ecd4e36..f3c0180c83d4d 100644 --- a/x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.schema.yaml +++ b/x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.schema.yaml @@ -7,7 +7,7 @@ paths: post: x-labels: [ess, serverless] x-codegen-enabled: true - operationId: PerformBulkAction + operationId: PerformRulesBulkAction summary: Apply a bulk action to detection rules description: Apply a bulk action, such as bulk edit, duplicate, or delete, to multiple detection rules. The bulk action is applied to all rules that match the query or to the rules listed by their IDs. tags: diff --git a/x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.test.ts b/x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.test.ts index 3c33eb6c103e7..8529d286905a0 100644 --- a/x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.test.ts +++ b/x-pack/plugins/security_solution/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.test.ts @@ -9,28 +9,28 @@ import { expectParseError, expectParseSuccess, stringifyZodError } from '@kbn/zo import { BulkActionEditTypeEnum, BulkActionTypeEnum, - PerformBulkActionRequestBody, + PerformRulesBulkActionRequestBody, } from './bulk_actions_route.gen'; describe('Perform bulk action request schema', () => { describe('cases common to every bulk action', () => { // missing query means it will request for all rules test('valid request: missing query', () => { - const payload: PerformBulkActionRequestBody = { + const payload: PerformRulesBulkActionRequestBody = { query: undefined, action: BulkActionTypeEnum.enable, }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual(payload); }); test('invalid request: missing action', () => { - const payload: Omit = { + const payload: Omit = { query: 'name: test', }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseError(result); expect(stringifyZodError(result.error)).toMatchInlineSnapshot( @@ -39,10 +39,10 @@ describe('Perform bulk action request schema', () => { }); test('invalid request: unknown action', () => { - const payload: Omit & { action: 'unknown' } = { + const payload: Omit & { action: 'unknown' } = { action: 'unknown', }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseError(result); expect(stringifyZodError(result.error)).toMatchInlineSnapshot( @@ -56,7 +56,7 @@ describe('Perform bulk action request schema', () => { action: BulkActionTypeEnum.enable, mock: ['id'], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual({ @@ -70,7 +70,7 @@ describe('Perform bulk action request schema', () => { ids: 'mock', action: BulkActionTypeEnum.enable, }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseError(result); expect(stringifyZodError(result.error)).toMatchInlineSnapshot( @@ -81,11 +81,11 @@ describe('Perform bulk action request schema', () => { describe('bulk enable', () => { test('valid request', () => { - const payload: PerformBulkActionRequestBody = { + const payload: PerformRulesBulkActionRequestBody = { query: 'name: test', action: BulkActionTypeEnum.enable, }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual(payload); }); @@ -93,11 +93,11 @@ describe('Perform bulk action request schema', () => { describe('bulk disable', () => { test('valid request', () => { - const payload: PerformBulkActionRequestBody = { + const payload: PerformRulesBulkActionRequestBody = { query: 'name: test', action: BulkActionTypeEnum.disable, }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual(payload); }); @@ -105,11 +105,11 @@ describe('Perform bulk action request schema', () => { describe('bulk export', () => { test('valid request', () => { - const payload: PerformBulkActionRequestBody = { + const payload: PerformRulesBulkActionRequestBody = { query: 'name: test', action: BulkActionTypeEnum.export, }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual(payload); }); @@ -117,11 +117,11 @@ describe('Perform bulk action request schema', () => { describe('bulk delete', () => { test('valid request', () => { - const payload: PerformBulkActionRequestBody = { + const payload: PerformRulesBulkActionRequestBody = { query: 'name: test', action: BulkActionTypeEnum.delete, }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual(payload); }); @@ -129,7 +129,7 @@ describe('Perform bulk action request schema', () => { describe('bulk duplicate', () => { test('valid request', () => { - const payload: PerformBulkActionRequestBody = { + const payload: PerformRulesBulkActionRequestBody = { query: 'name: test', action: BulkActionTypeEnum.duplicate, [BulkActionTypeEnum.duplicate]: { @@ -137,7 +137,7 @@ describe('Perform bulk action request schema', () => { include_expired_exceptions: false, }, }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual(payload); }); @@ -150,7 +150,7 @@ describe('Perform bulk action request schema', () => { action: BulkActionTypeEnum.run, }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseError(result); expect(stringifyZodError(result.error)).toMatchInlineSnapshot( @@ -159,7 +159,7 @@ describe('Perform bulk action request schema', () => { }); test('valid request', () => { - const payload: PerformBulkActionRequestBody = { + const payload: PerformRulesBulkActionRequestBody = { query: 'name: test', action: BulkActionTypeEnum.run, [BulkActionTypeEnum.run]: { @@ -167,7 +167,7 @@ describe('Perform bulk action request schema', () => { end_date: new Date().toISOString(), }, }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual(payload); }); @@ -181,7 +181,7 @@ describe('Perform bulk action request schema', () => { action: BulkActionTypeEnum.edit, }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseError(result); expect(stringifyZodError(result.error)).toMatchInlineSnapshot( @@ -196,7 +196,7 @@ describe('Perform bulk action request schema', () => { [BulkActionTypeEnum.edit]: { type: BulkActionEditTypeEnum.set_tags, value: ['test-tag'] }, }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseError(result); expect(stringifyZodError(result.error)).toMatchInlineSnapshot( @@ -213,7 +213,7 @@ describe('Perform bulk action request schema', () => { [BulkActionTypeEnum.edit]: [{ type: BulkActionEditTypeEnum.set_tags, value: 'test-tag' }], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseError(result); expect(stringifyZodError(result.error)).toMatchInlineSnapshot( @@ -230,7 +230,7 @@ describe('Perform bulk action request schema', () => { ], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual(payload); @@ -245,7 +245,7 @@ describe('Perform bulk action request schema', () => { ], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual(payload); @@ -260,7 +260,7 @@ describe('Perform bulk action request schema', () => { ], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual(payload); @@ -275,7 +275,7 @@ describe('Perform bulk action request schema', () => { [BulkActionTypeEnum.edit]: [{ type: BulkActionEditTypeEnum.set_tags, value: 'logs-*' }], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseError(result); expect(stringifyZodError(result.error)).toMatchInlineSnapshot( @@ -284,7 +284,7 @@ describe('Perform bulk action request schema', () => { }); test('valid request: set_index_patterns edit action', () => { - const payload: PerformBulkActionRequestBody = { + const payload: PerformRulesBulkActionRequestBody = { query: 'name: test', action: BulkActionTypeEnum.edit, [BulkActionTypeEnum.edit]: [ @@ -292,14 +292,14 @@ describe('Perform bulk action request schema', () => { ], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual(payload); }); test('valid request: add_index_patterns edit action', () => { - const payload: PerformBulkActionRequestBody = { + const payload: PerformRulesBulkActionRequestBody = { query: 'name: test', action: BulkActionTypeEnum.edit, [BulkActionTypeEnum.edit]: [ @@ -307,14 +307,14 @@ describe('Perform bulk action request schema', () => { ], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual(payload); }); test('valid request: delete_index_patterns edit action', () => { - const payload: PerformBulkActionRequestBody = { + const payload: PerformRulesBulkActionRequestBody = { query: 'name: test', action: BulkActionTypeEnum.edit, [BulkActionTypeEnum.edit]: [ @@ -322,7 +322,7 @@ describe('Perform bulk action request schema', () => { ], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual(payload); @@ -331,7 +331,7 @@ describe('Perform bulk action request schema', () => { describe('investigation_fields', () => { test('valid request: set_investigation_fields edit action', () => { - const payload: PerformBulkActionRequestBody = { + const payload: PerformRulesBulkActionRequestBody = { query: 'name: test', action: BulkActionTypeEnum.edit, [BulkActionTypeEnum.edit]: [ @@ -342,14 +342,14 @@ describe('Perform bulk action request schema', () => { ], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual(payload); }); test('valid request: add_investigation_fields edit action', () => { - const payload: PerformBulkActionRequestBody = { + const payload: PerformRulesBulkActionRequestBody = { query: 'name: test', action: BulkActionTypeEnum.edit, [BulkActionTypeEnum.edit]: [ @@ -360,14 +360,14 @@ describe('Perform bulk action request schema', () => { ], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual(payload); }); test('valid request: delete_investigation_fields edit action', () => { - const payload: PerformBulkActionRequestBody = { + const payload: PerformRulesBulkActionRequestBody = { query: 'name: test', action: BulkActionTypeEnum.edit, [BulkActionTypeEnum.edit]: [ @@ -378,7 +378,7 @@ describe('Perform bulk action request schema', () => { ], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual(payload); @@ -393,7 +393,7 @@ describe('Perform bulk action request schema', () => { [BulkActionTypeEnum.edit]: [{ type: BulkActionEditTypeEnum.set_timeline, value: [] }], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseError(result); expect(stringifyZodError(result.error)).toMatchInlineSnapshot( @@ -415,7 +415,7 @@ describe('Perform bulk action request schema', () => { ], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseError(result); expect(stringifyZodError(result.error)).toMatchInlineSnapshot( @@ -424,7 +424,7 @@ describe('Perform bulk action request schema', () => { }); test('valid request: set_timeline edit action', () => { - const payload: PerformBulkActionRequestBody = { + const payload: PerformRulesBulkActionRequestBody = { query: 'name: test', action: BulkActionTypeEnum.edit, [BulkActionTypeEnum.edit]: [ @@ -438,7 +438,7 @@ describe('Perform bulk action request schema', () => { ], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual(payload); @@ -453,7 +453,7 @@ describe('Perform bulk action request schema', () => { [BulkActionTypeEnum.edit]: [{ type: BulkActionEditTypeEnum.set_schedule, value: [] }], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseError(result); expect(stringifyZodError(result.error)).toMatchInlineSnapshot( @@ -474,9 +474,9 @@ describe('Perform bulk action request schema', () => { }, }, ], - } as PerformBulkActionRequestBody; + } as PerformRulesBulkActionRequestBody; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseError(result); expect(stringifyZodError(result.error)).toMatchInlineSnapshot( @@ -496,9 +496,9 @@ describe('Perform bulk action request schema', () => { }, }, ], - } as PerformBulkActionRequestBody; + } as PerformRulesBulkActionRequestBody; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseError(result); expect(stringifyZodError(result.error)).toMatchInlineSnapshot( @@ -518,9 +518,9 @@ describe('Perform bulk action request schema', () => { }, }, ], - } as PerformBulkActionRequestBody; + } as PerformRulesBulkActionRequestBody; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseError(result); expect(stringifyZodError(result.error)).toMatchInlineSnapshot( @@ -529,7 +529,7 @@ describe('Perform bulk action request schema', () => { }); test('valid request: set_schedule edit action', () => { - const payload: PerformBulkActionRequestBody = { + const payload: PerformRulesBulkActionRequestBody = { query: 'name: test', action: BulkActionTypeEnum.edit, [BulkActionTypeEnum.edit]: [ @@ -541,9 +541,9 @@ describe('Perform bulk action request schema', () => { }, }, ], - } as PerformBulkActionRequestBody; + } as PerformRulesBulkActionRequestBody; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual(payload); @@ -558,7 +558,7 @@ describe('Perform bulk action request schema', () => { [BulkActionTypeEnum.edit]: [{ type: BulkActionEditTypeEnum.add_rule_actions, value: [] }], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseError(result); expect(stringifyZodError(result.error)).toMatchInlineSnapshot( @@ -580,7 +580,7 @@ describe('Perform bulk action request schema', () => { ], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseError(result); expect(stringifyZodError(result.error)).toMatchInlineSnapshot( @@ -614,7 +614,7 @@ describe('Perform bulk action request schema', () => { ], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseError(result); expect(stringifyZodError(result.error)).toMatchInlineSnapshot( `"edit.0.value.actions.0: Unrecognized key(s) in object: 'action_type_id'"` @@ -622,7 +622,7 @@ describe('Perform bulk action request schema', () => { }); test('valid request: add_rule_actions edit action', () => { - const payload: PerformBulkActionRequestBody = { + const payload: PerformRulesBulkActionRequestBody = { query: 'name: test', action: BulkActionTypeEnum.edit, [BulkActionTypeEnum.edit]: [ @@ -646,14 +646,14 @@ describe('Perform bulk action request schema', () => { ], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual(payload); }); test('valid request: set_rule_actions edit action', () => { - const payload: PerformBulkActionRequestBody = { + const payload: PerformRulesBulkActionRequestBody = { query: 'name: test', action: BulkActionTypeEnum.edit, [BulkActionTypeEnum.edit]: [ @@ -679,7 +679,7 @@ describe('Perform bulk action request schema', () => { ], }; - const result = PerformBulkActionRequestBody.safeParse(payload); + const result = PerformRulesBulkActionRequestBody.safeParse(payload); expectParseSuccess(result); expect(result.data).toEqual(payload); diff --git a/x-pack/plugins/security_solution/docs/openapi/ess/security_solution_detections_api_2023_10_31.bundled.schema.yaml b/x-pack/plugins/security_solution/docs/openapi/ess/security_solution_detections_api_2023_10_31.bundled.schema.yaml index c9bb81ede9be3..56f73783667ef 100644 --- a/x-pack/plugins/security_solution/docs/openapi/ess/security_solution_detections_api_2023_10_31.bundled.schema.yaml +++ b/x-pack/plugins/security_solution/docs/openapi/ess/security_solution_detections_api_2023_10_31.bundled.schema.yaml @@ -317,7 +317,7 @@ paths: Apply a bulk action, such as bulk edit, duplicate, or delete, to multiple detection rules. The bulk action is applied to all rules that match the query or to the rules listed by their IDs. - operationId: PerformBulkAction + operationId: PerformRulesBulkAction parameters: - description: Enables dry run mode for the request call. in: query diff --git a/x-pack/plugins/security_solution/docs/openapi/serverless/security_solution_detections_api_2023_10_31.bundled.schema.yaml b/x-pack/plugins/security_solution/docs/openapi/serverless/security_solution_detections_api_2023_10_31.bundled.schema.yaml index 6a8f72d45d46c..e3a294c9f92a5 100644 --- a/x-pack/plugins/security_solution/docs/openapi/serverless/security_solution_detections_api_2023_10_31.bundled.schema.yaml +++ b/x-pack/plugins/security_solution/docs/openapi/serverless/security_solution_detections_api_2023_10_31.bundled.schema.yaml @@ -186,7 +186,7 @@ paths: Apply a bulk action, such as bulk edit, duplicate, or delete, to multiple detection rules. The bulk action is applied to all rules that match the query or to the rules listed by their IDs. - operationId: PerformBulkAction + operationId: PerformRulesBulkAction parameters: - description: Enables dry run mode for the request call. in: query diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/api.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/api.ts index 3513c9a21aa7b..4254b58234400 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/api.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/api.ts @@ -362,7 +362,7 @@ export type BulkAction = | DuplicateBulkAction | ManualRuleRunBulkAction; -export interface PerformBulkActionProps { +export interface PerformRulesBulkActionProps { bulkAction: BulkAction; dryRun?: boolean; } @@ -378,7 +378,7 @@ export interface PerformBulkActionProps { export async function performBulkAction({ bulkAction, dryRun = false, -}: PerformBulkActionProps): Promise { +}: PerformRulesBulkActionProps): Promise { const params = { action: bulkAction.type, query: bulkAction.query, diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/hooks/use_bulk_action_mutation.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/hooks/use_bulk_action_mutation.ts index 9e54e41f1b091..7d8f42adad31b 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/hooks/use_bulk_action_mutation.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/hooks/use_bulk_action_mutation.ts @@ -8,7 +8,11 @@ import type { UseMutationOptions } from '@tanstack/react-query'; import { useMutation } from '@tanstack/react-query'; import type { IHttpFetchError } from '@kbn/core/public'; import { BulkActionTypeEnum } from '../../../../../common/api/detection_engine/rule_management'; -import type { BulkActionErrorResponse, BulkActionResponse, PerformBulkActionProps } from '../api'; +import type { + BulkActionErrorResponse, + BulkActionResponse, + PerformRulesBulkActionProps, +} from '../api'; import { performBulkAction } from '../api'; import { DETECTION_ENGINE_RULES_BULK_ACTION } from '../../../../../common/constants'; import { useInvalidateFindRulesQuery, useUpdateRulesCache } from './use_find_rules_query'; @@ -25,7 +29,7 @@ export const useBulkActionMutation = ( options?: UseMutationOptions< BulkActionResponse, IHttpFetchError, - PerformBulkActionProps + PerformRulesBulkActionProps > ) => { const invalidateFindRulesQuery = useInvalidateFindRulesQuery(); @@ -42,8 +46,8 @@ export const useBulkActionMutation = ( return useMutation< BulkActionResponse, IHttpFetchError, - PerformBulkActionProps - >((bulkActionProps: PerformBulkActionProps) => performBulkAction(bulkActionProps), { + PerformRulesBulkActionProps + >((bulkActionProps: PerformRulesBulkActionProps) => performBulkAction(bulkActionProps), { ...options, mutationKey: BULK_ACTION_MUTATION_KEY, onSettled: (...args) => { diff --git a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/bulk_actions/route.ts b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/bulk_actions/route.ts index 3d2df63919ce7..7ac96312b793d 100644 --- a/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/bulk_actions/route.ts +++ b/x-pack/plugins/security_solution/server/lib/detection_engine/rule_management/api/rules/bulk_actions/route.ts @@ -10,11 +10,11 @@ import { AbortError } from '@kbn/kibana-utils-plugin/common'; import { transformError } from '@kbn/securitysolution-es-utils'; import { buildRouteValidationWithZod } from '@kbn/zod-helpers'; import type { ConfigType } from '../../../../../../config'; -import type { PerformBulkActionResponse } from '../../../../../../../common/api/detection_engine/rule_management'; +import type { PerformRulesBulkActionResponse } from '../../../../../../../common/api/detection_engine/rule_management'; import { BulkActionTypeEnum, - PerformBulkActionRequestBody, - PerformBulkActionRequestQuery, + PerformRulesBulkActionRequestBody, + PerformRulesBulkActionRequestQuery, } from '../../../../../../../common/api/detection_engine/rule_management'; import { DETECTION_ENGINE_RULES_BULK_ACTION, @@ -68,13 +68,17 @@ export const performBulkActionRoute = ( version: '2023-10-31', validate: { request: { - body: buildRouteValidationWithZod(PerformBulkActionRequestBody), - query: buildRouteValidationWithZod(PerformBulkActionRequestQuery), + body: buildRouteValidationWithZod(PerformRulesBulkActionRequestBody), + query: buildRouteValidationWithZod(PerformRulesBulkActionRequestQuery), }, }, }, - async (context, request, response): Promise> => { + async ( + context, + request, + response + ): Promise> => { const { body } = request; const siemResponse = buildSiemResponse(response); diff --git a/x-pack/test/api_integration/services/security_solution_api.gen.ts b/x-pack/test/api_integration/services/security_solution_api.gen.ts index ef706d2aca2cd..dd2b9eaab6a0b 100644 --- a/x-pack/test/api_integration/services/security_solution_api.gen.ts +++ b/x-pack/test/api_integration/services/security_solution_api.gen.ts @@ -95,8 +95,8 @@ import { InstallPrepackedTimelinesRequestBodyInput } from '@kbn/security-solutio import { PatchRuleRequestBodyInput } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/crud/patch_rule/patch_rule_route.gen'; import { PatchTimelineRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/patch_timelines/patch_timeline_route.gen'; import { - PerformBulkActionRequestQueryInput, - PerformBulkActionRequestBodyInput, + PerformRulesBulkActionRequestQueryInput, + PerformRulesBulkActionRequestBodyInput, } from '@kbn/security-solution-plugin/common/api/detection_engine/rule_management/bulk_actions/bulk_actions_route.gen'; import { PersistFavoriteRouteRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/persist_favorite/persist_favorite_route.gen'; import { PersistNoteRouteRequestBodyInput } from '@kbn/security-solution-plugin/common/api/timeline/persist_note/persist_note_route.gen'; @@ -797,7 +797,7 @@ finalize it. /** * Apply a bulk action, such as bulk edit, duplicate, or delete, to multiple detection rules. The bulk action is applied to all rules that match the query or to the rules listed by their IDs. */ - performBulkAction(props: PerformBulkActionProps) { + performRulesBulkAction(props: PerformRulesBulkActionProps) { return supertest .post('/api/detection_engine/rules/_bulk_action') .set('kbn-xsrf', 'true') @@ -1204,9 +1204,9 @@ export interface PatchRuleProps { export interface PatchTimelineProps { body: PatchTimelineRequestBodyInput; } -export interface PerformBulkActionProps { - query: PerformBulkActionRequestQueryInput; - body: PerformBulkActionRequestBodyInput; +export interface PerformRulesBulkActionProps { + query: PerformRulesBulkActionRequestQueryInput; + body: PerformRulesBulkActionRequestBodyInput; } export interface PersistFavoriteRouteProps { body: PersistFavoriteRouteRequestBodyInput; diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/rules_management/rule_bulk_actions/trial_license_complete_tier/perform_bulk_action.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/rules_management/rule_bulk_actions/trial_license_complete_tier/perform_bulk_action.ts index ec558f7f39098..43afebc55decd 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/rules_management/rule_bulk_actions/trial_license_complete_tier/perform_bulk_action.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/rules_management/rule_bulk_actions/trial_license_complete_tier/perform_bulk_action.ts @@ -152,7 +152,7 @@ export default ({ getService }: FtrProviderContext): void => { await securitySolutionApi.createRule({ body: mockRule }); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: {}, body: { action: BulkActionTypeEnum.export, @@ -1165,7 +1165,7 @@ export default ({ getService }: FtrProviderContext): void => { await createRule(supertest, log, getSimpleRule(ruleId)); const { body: bulkEditResponse } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: {}, body: { query: '', @@ -1208,7 +1208,7 @@ export default ({ getService }: FtrProviderContext): void => { }); const { body: bulkEditResponse } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: {}, body: { query: '', @@ -1251,7 +1251,7 @@ export default ({ getService }: FtrProviderContext): void => { }); const { body: bulkEditResponse } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: {}, body: { query: '', @@ -1327,7 +1327,7 @@ export default ({ getService }: FtrProviderContext): void => { }); const { body: bulkEditResponse } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: {}, body: { query: '', @@ -2431,7 +2431,7 @@ export default ({ getService }: FtrProviderContext): void => { const startDate = endDate.clone().subtract(1, 'h'); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: {}, body: { query: '', @@ -2479,7 +2479,7 @@ export default ({ getService }: FtrProviderContext): void => { const startDate = endDate.clone().subtract(1, 'h'); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: {}, body: { ids: [createdRule1.id, createdRule2.id], @@ -2521,7 +2521,7 @@ export default ({ getService }: FtrProviderContext): void => { const startDate = endDate.clone(); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: {}, body: { ids: [createdRule1.id, createdRule2.id], @@ -2562,7 +2562,7 @@ export default ({ getService }: FtrProviderContext): void => { const startDate = moment().add(1, 'd'); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: {}, body: { ids: [createdRule1.id, createdRule2.id], @@ -2601,7 +2601,7 @@ export default ({ getService }: FtrProviderContext): void => { const startDate = moment().subtract(1, 'd'); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: {}, body: { ids: [createdRule1.id, createdRule2.id], @@ -2643,7 +2643,7 @@ export default ({ getService }: FtrProviderContext): void => { const startDate = moment().subtract(MAX_MANUAL_RULE_RUN_LOOKBACK_WINDOW_DAYS + 1, 'd'); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: {}, body: { ids: [createdRule1.id, createdRule2.id], @@ -2678,7 +2678,7 @@ export default ({ getService }: FtrProviderContext): void => { const startDate = endDate.clone().subtract(1, 'h'); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: {}, body: { ids: [createdRule1.id, 'rule-2'], @@ -2736,7 +2736,7 @@ export default ({ getService }: FtrProviderContext): void => { const startDate = endDate.clone().subtract(1, 'h'); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: {}, body: { ids: [createdRule1.id, createdRule2.id], diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/rules_management/rule_bulk_actions/trial_license_complete_tier/perform_bulk_action_dry_run.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/rules_management/rule_bulk_actions/trial_license_complete_tier/perform_bulk_action_dry_run.ts index 34681be8f2bf5..3a82c28dc944b 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/rules_management/rule_bulk_actions/trial_license_complete_tier/perform_bulk_action_dry_run.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/rules_management/rule_bulk_actions/trial_license_complete_tier/perform_bulk_action_dry_run.ts @@ -44,7 +44,7 @@ export default ({ getService }: FtrProviderContext): void => { await createRule(supertest, log, getSimpleRule()); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: { dry_run: true }, body: { action: BulkActionTypeEnum.export }, }) @@ -62,7 +62,7 @@ export default ({ getService }: FtrProviderContext): void => { await createRule(supertest, log, testRule); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: { dry_run: true }, body: { action: BulkActionTypeEnum.delete }, }) @@ -86,7 +86,7 @@ export default ({ getService }: FtrProviderContext): void => { await createRule(supertest, log, getSimpleRule(ruleId)); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: { dry_run: true }, body: { action: BulkActionTypeEnum.enable }, }) @@ -113,7 +113,7 @@ export default ({ getService }: FtrProviderContext): void => { await createRule(supertest, log, getSimpleRule(ruleId, true)); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: { dry_run: true }, body: { action: BulkActionTypeEnum.disable }, }) @@ -141,7 +141,7 @@ export default ({ getService }: FtrProviderContext): void => { await createRule(supertest, log, ruleToDuplicate); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: { dry_run: true }, body: { action: BulkActionTypeEnum.disable }, }) @@ -171,7 +171,7 @@ export default ({ getService }: FtrProviderContext): void => { await createRule(supertest, log, { ...getSimpleRule(ruleId), tags }); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: { dry_run: true }, body: { action: BulkActionTypeEnum.edit, @@ -210,7 +210,7 @@ export default ({ getService }: FtrProviderContext): void => { const immutableRule = findBody.data[0]; const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: { dry_run: true }, body: { ids: [immutableRule.id], @@ -256,7 +256,7 @@ export default ({ getService }: FtrProviderContext): void => { const mlRule = await createRule(supertest, log, getSimpleMlRule()); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: { dry_run: true }, body: { ids: [mlRule.id], @@ -323,7 +323,7 @@ export default ({ getService }: FtrProviderContext): void => { const startDate = endDate.clone().subtract(1, 'h'); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: { dry_run: true }, body: { ids: [createdRule1.id, createdRule2.id], @@ -362,7 +362,7 @@ export default ({ getService }: FtrProviderContext): void => { const startDate = endDate.clone().subtract(1, 'h'); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: { dry_run: true }, body: { ids: [createdRule1.id, 'rule-2'], @@ -420,7 +420,7 @@ export default ({ getService }: FtrProviderContext): void => { const startDate = endDate.clone().subtract(1, 'h'); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ query: { dry_run: true }, body: { ids: [createdRule1.id, createdRule2.id], diff --git a/x-pack/test/security_solution_api_integration/test_suites/detections_response/rules_management/rule_bulk_actions/trial_license_complete_tier/perform_bulk_action_ess.ts b/x-pack/test/security_solution_api_integration/test_suites/detections_response/rules_management/rule_bulk_actions/trial_license_complete_tier/perform_bulk_action_ess.ts index c1bdae1ed9061..3e3eb594cc0bc 100644 --- a/x-pack/test/security_solution_api_integration/test_suites/detections_response/rules_management/rule_bulk_actions/trial_license_complete_tier/perform_bulk_action_ess.ts +++ b/x-pack/test/security_solution_api_integration/test_suites/detections_response/rules_management/rule_bulk_actions/trial_license_complete_tier/perform_bulk_action_ess.ts @@ -75,7 +75,7 @@ export default ({ getService }: FtrProviderContext): void => { expect(sidecarActionsResults.hits.hits[0]?._source?.references[0].id).to.eql(rule1.id); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ body: { query: '', action: BulkActionTypeEnum.delete }, query: {}, }) @@ -117,7 +117,7 @@ export default ({ getService }: FtrProviderContext): void => { expect(sidecarActionsResults.hits.hits[0]?._source?.references[0].id).to.eql(rule1.id); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ body: { query: '', action: BulkActionTypeEnum.enable }, query: {}, }) @@ -177,7 +177,7 @@ export default ({ getService }: FtrProviderContext): void => { expect(sidecarActionsResults.hits.hits[0]?._source?.references[0].id).to.eql(rule1.id); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ body: { query: '', action: BulkActionTypeEnum.disable }, query: {}, }) @@ -237,7 +237,7 @@ export default ({ getService }: FtrProviderContext): void => { ); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ body: { query: '', action: BulkActionTypeEnum.duplicate, @@ -281,7 +281,7 @@ export default ({ getService }: FtrProviderContext): void => { await createRule(supertest, log, getCustomQueryRuleParams()); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ body: { query: '', action: BulkActionTypeEnum.duplicate, @@ -303,7 +303,7 @@ export default ({ getService }: FtrProviderContext): void => { const esqlRule = await createRule(supertest, log, getCreateEsqlRulesSchemaMock()); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ body: { ids: [esqlRule.id], action: BulkActionTypeEnum.edit, @@ -357,7 +357,7 @@ export default ({ getService }: FtrProviderContext): void => { ruleToDuplicate.id ); - const { body: setTagsBody } = await securitySolutionApi.performBulkAction({ + const { body: setTagsBody } = await securitySolutionApi.performRulesBulkAction({ body: { query: '', action: BulkActionTypeEnum.edit, @@ -440,7 +440,7 @@ export default ({ getService }: FtrProviderContext): void => { ); const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ body: { ids: [createdRule.id], action: BulkActionTypeEnum.edit, @@ -516,7 +516,7 @@ export default ({ getService }: FtrProviderContext): void => { it('should export rules with legacy investigation_fields and transform legacy field in response', async () => { const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ body: { query: '', action: BulkActionTypeEnum.export }, query: {}, }) @@ -585,7 +585,7 @@ export default ({ getService }: FtrProviderContext): void => { it('should delete rules with investigation fields and transform legacy field in response', async () => { const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ body: { query: '', action: BulkActionTypeEnum.delete }, query: {}, }) @@ -626,7 +626,7 @@ export default ({ getService }: FtrProviderContext): void => { it('should enable rules with legacy investigation fields and transform legacy field in response', async () => { const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ body: { query: '', action: BulkActionTypeEnum.enable }, query: {}, }) @@ -697,7 +697,10 @@ export default ({ getService }: FtrProviderContext): void => { it('should disable rules with legacy investigation fields and transform legacy field in response', async () => { const { body } = await securitySolutionApi - .performBulkAction({ body: { query: '', action: BulkActionTypeEnum.disable }, query: {} }) + .performRulesBulkAction({ + body: { query: '', action: BulkActionTypeEnum.disable }, + query: {}, + }) .expect(200); expect(body.attributes.summary).to.eql({ failed: 0, skipped: 0, succeeded: 3, total: 3 }); @@ -768,7 +771,7 @@ export default ({ getService }: FtrProviderContext): void => { it('should duplicate rules with legacy investigation fields and transform field in response', async () => { const { body } = await securitySolutionApi - .performBulkAction({ + .performRulesBulkAction({ body: { query: '', action: BulkActionTypeEnum.duplicate, @@ -887,7 +890,7 @@ export default ({ getService }: FtrProviderContext): void => { }); it('should edit rules with legacy investigation fields', async () => { - const { body } = await securitySolutionApi.performBulkAction({ + const { body } = await securitySolutionApi.performRulesBulkAction({ body: { query: '', action: BulkActionTypeEnum.edit,