forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Rules migration] Add
install
and install all
migration rules end…
…points (elastic#11283) (elastic#202026) ## Summary [Internal link](elastic/security-team#10820) to the feature details With these changes we two new routes: * `/internal/siem_migrations/rules/install`: allows to install a specific set of migration rules * `/internal/siem_migrations/rules/install_translated`: allows to install all translated rules in specified migration Also we connect these two new API calls with the "Install" button within the "migration rules" table and the "Install translated rules" button on the "SIEM migration rules" page. ### Screenshots https://github.com/user-attachments/assets/29390d07-eab5-4157-8958-1e3f8459db09 --------- Co-authored-by: kibanamachine <[email protected]> Co-authored-by: Sergi Massaneda <[email protected]>
- Loading branch information
1 parent
8d2e28a
commit 07fbb92
Showing
36 changed files
with
1,361 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
...lution/public/siem_migrations/rules/api/hooks/use_install_all_migration_rules_mutation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import type { UseMutationOptions } from '@tanstack/react-query'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import type { InstallTranslatedMigrationRulesResponse } from '../../../../../common/siem_migrations/model/api/rules/rule_migration.gen'; | ||
import { SIEM_RULE_MIGRATION_INSTALL_TRANSLATED_PATH } from '../../../../../common/siem_migrations/constants'; | ||
import { installTranslatedMigrationRules } from '../api'; | ||
import { useInvalidateGetMigrationRulesQuery } from './use_get_migration_rules_query'; | ||
|
||
export const INSTALL_ALL_MIGRATION_RULES_MUTATION_KEY = [ | ||
'POST', | ||
SIEM_RULE_MIGRATION_INSTALL_TRANSLATED_PATH, | ||
]; | ||
|
||
export const useInstallAllMigrationRulesMutation = ( | ||
migrationId: string, | ||
options?: UseMutationOptions<InstallTranslatedMigrationRulesResponse, Error> | ||
) => { | ||
const invalidateGetRuleMigrationsQuery = useInvalidateGetMigrationRulesQuery(migrationId); | ||
|
||
return useMutation<InstallTranslatedMigrationRulesResponse, Error>( | ||
() => installTranslatedMigrationRules({ migrationId }), | ||
{ | ||
...options, | ||
mutationKey: INSTALL_ALL_MIGRATION_RULES_MUTATION_KEY, | ||
onSettled: (...args) => { | ||
invalidateGetRuleMigrationsQuery(); | ||
|
||
if (options?.onSettled) { | ||
options.onSettled(...args); | ||
} | ||
}, | ||
} | ||
); | ||
}; |
36 changes: 36 additions & 0 deletions
36
...y_solution/public/siem_migrations/rules/api/hooks/use_install_migration_rules_mutation.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import type { UseMutationOptions } from '@tanstack/react-query'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import type { InstallMigrationRulesResponse } from '../../../../../common/siem_migrations/model/api/rules/rule_migration.gen'; | ||
import { SIEM_RULE_MIGRATION_INSTALL_PATH } from '../../../../../common/siem_migrations/constants'; | ||
import { installMigrationRules } from '../api'; | ||
import { useInvalidateGetMigrationRulesQuery } from './use_get_migration_rules_query'; | ||
|
||
export const INSTALL_MIGRATION_RULES_MUTATION_KEY = ['POST', SIEM_RULE_MIGRATION_INSTALL_PATH]; | ||
|
||
export const useInstallMigrationRulesMutation = ( | ||
migrationId: string, | ||
options?: UseMutationOptions<InstallMigrationRulesResponse, Error, string[]> | ||
) => { | ||
const invalidateGetRuleMigrationsQuery = useInvalidateGetMigrationRulesQuery(migrationId); | ||
|
||
return useMutation<InstallMigrationRulesResponse, Error, string[]>( | ||
(ids: string[]) => installMigrationRules({ migrationId, ids }), | ||
{ | ||
...options, | ||
mutationKey: INSTALL_MIGRATION_RULES_MUTATION_KEY, | ||
onSettled: (...args) => { | ||
invalidateGetRuleMigrationsQuery(); | ||
|
||
if (options?.onSettled) { | ||
options.onSettled(...args); | ||
} | ||
}, | ||
} | ||
); | ||
}; |
Oops, something went wrong.