Skip to content

Commit

Permalink
Moves new SO definitions into corresponding folders
Browse files Browse the repository at this point in the history
This way our top-level file still acts as the index, but these are
more/less unconnected if/when we split these out into separate
applications.
  • Loading branch information
rylnd committed Apr 20, 2020
1 parent 3470076 commit 0808144
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 76 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SavedObjectsType } from '../../../../../../../src/core/server';

export const ruleActionsSavedObjectType = 'siem-detection-engine-rule-actions';

export const ruleActionsSavedObjectMappings = {
Expand Down Expand Up @@ -37,3 +39,10 @@ export const ruleActionsSavedObjectMappings = {
},
},
};

export const type: SavedObjectsType = {
name: ruleActionsSavedObjectType,
hidden: false,
namespaceType: 'single',
mappings: ruleActionsSavedObjectMappings,
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SavedObjectsType } from '../../../../../../../src/core/server';

export const ruleStatusSavedObjectType = 'siem-detection-engine-rule-status';

export const ruleStatusSavedObjectMappings = {
Expand Down Expand Up @@ -43,3 +45,10 @@ export const ruleStatusSavedObjectMappings = {
},
},
};

export const type: SavedObjectsType = {
name: ruleStatusSavedObjectType,
hidden: false,
namespaceType: 'single',
mappings: ruleStatusSavedObjectMappings,
};
9 changes: 9 additions & 0 deletions x-pack/plugins/siem/server/lib/note/saved_object_mappings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SavedObjectsType } from '../../../../../../src/core/server';

export const noteSavedObjectType = 'siem-ui-timeline-note';

export const noteSavedObjectMappings = {
Expand Down Expand Up @@ -31,3 +33,10 @@ export const noteSavedObjectMappings = {
},
},
};

export const type: SavedObjectsType = {
name: noteSavedObjectType,
hidden: false,
namespaceType: 'single',
mappings: noteSavedObjectMappings,
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SavedObjectsType } from '../../../../../../src/core/server';

export const pinnedEventSavedObjectType = 'siem-ui-timeline-pinned-event';

export const pinnedEventSavedObjectMappings = {
Expand All @@ -28,3 +30,10 @@ export const pinnedEventSavedObjectMappings = {
},
},
};

export const type: SavedObjectsType = {
name: pinnedEventSavedObjectType,
hidden: false,
namespaceType: 'single',
mappings: pinnedEventSavedObjectMappings,
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/

import { SavedObjectsType } from '../../../../../../src/core/server';

export const timelineSavedObjectType = 'siem-ui-timeline';

export const timelineSavedObjectMappings = {
Expand Down Expand Up @@ -266,3 +268,10 @@ export const timelineSavedObjectMappings = {
},
},
};

export const type: SavedObjectsType = {
name: timelineSavedObjectType,
hidden: false,
namespaceType: 'single',
mappings: timelineSavedObjectMappings,
};
21 changes: 3 additions & 18 deletions x-pack/plugins/siem/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,7 @@ import { signalRulesAlertType } from './lib/detection_engine/signals/signal_rule
import { rulesNotificationAlertType } from './lib/detection_engine/notifications/rules_notification_alert_type';
import { isNotificationAlertExecutor } from './lib/detection_engine/notifications/types';
import { hasListsFeature, listsEnvFeatureFlagName } from './lib/detection_engine/feature_flags';
import {
noteSavedObjectType,
pinnedEventSavedObjectType,
timelineSavedObjectType,
ruleStatusSavedObjectType,
ruleActionsSavedObjectType,
initSavedObjects,
} from './saved_objects';
import { initSavedObjects, savedObjectTypes } from './saved_objects';
import { SiemClientFactory } from './client';
import { createConfig$, ConfigType } from './config';

Expand Down Expand Up @@ -128,15 +121,11 @@ export class Plugin {
'alert',
'action',
'action_task_params',
noteSavedObjectType,
pinnedEventSavedObjectType,
timelineSavedObjectType,
ruleStatusSavedObjectType,
ruleActionsSavedObjectType,
'cases',
'cases-comments',
'cases-configure',
'cases-user-actions',
...savedObjectTypes,
],
read: ['config'],
},
Expand All @@ -159,15 +148,11 @@ export class Plugin {
all: ['alert', 'action', 'action_task_params'],
read: [
'config',
noteSavedObjectType,
pinnedEventSavedObjectType,
timelineSavedObjectType,
ruleStatusSavedObjectType,
ruleActionsSavedObjectType,
'cases',
'cases-comments',
'cases-configure',
'cases-user-actions',
...savedObjectTypes,
],
},
ui: [
Expand Down
67 changes: 9 additions & 58 deletions x-pack/plugins/siem/server/saved_objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,65 +6,16 @@

import { CoreSetup } from '../../../../src/core/server';

import { noteSavedObjectType, noteSavedObjectMappings } from './lib/note/saved_object_mappings';
import {
pinnedEventSavedObjectType,
pinnedEventSavedObjectMappings,
} from './lib/pinned_event/saved_object_mappings';
import {
timelineSavedObjectType,
timelineSavedObjectMappings,
} from './lib/timeline/saved_object_mappings';
import {
ruleStatusSavedObjectType,
ruleStatusSavedObjectMappings,
} from './lib/detection_engine/rules/saved_object_mappings';
import {
ruleActionsSavedObjectMappings,
ruleActionsSavedObjectType,
} from './lib/detection_engine/rule_actions/saved_object_mappings';
import { type as noteType } from './lib/note/saved_object_mappings';
import { type as pinnedEventType } from './lib/pinned_event/saved_object_mappings';
import { type as timelineType } from './lib/timeline/saved_object_mappings';
import { type as ruleStatusType } from './lib/detection_engine/rules/saved_object_mappings';
import { type as ruleActionsType } from './lib/detection_engine/rule_actions/saved_object_mappings';

export {
noteSavedObjectType,
pinnedEventSavedObjectType,
ruleStatusSavedObjectType,
ruleActionsSavedObjectType,
timelineSavedObjectType,
};

export const initSavedObjects = (savedObjects: CoreSetup['savedObjects']) => {
savedObjects.registerType({
name: pinnedEventSavedObjectType,
hidden: false,
namespaceType: 'single',
mappings: pinnedEventSavedObjectMappings,
});
const types = [noteType, pinnedEventType, ruleActionsType, ruleStatusType, timelineType];

savedObjects.registerType({
name: noteSavedObjectType,
hidden: false,
namespaceType: 'single',
mappings: noteSavedObjectMappings,
});
export const savedObjectTypes = types.map(type => type.name);

savedObjects.registerType({
name: ruleStatusSavedObjectType,
hidden: false,
namespaceType: 'single',
mappings: ruleStatusSavedObjectMappings,
});

savedObjects.registerType({
name: ruleActionsSavedObjectType,
hidden: false,
namespaceType: 'single',
mappings: ruleActionsSavedObjectMappings,
});

savedObjects.registerType({
name: timelineSavedObjectType,
hidden: false,
namespaceType: 'single',
mappings: timelineSavedObjectMappings,
});
export const initSavedObjects = (savedObjects: CoreSetup['savedObjects']) => {
types.forEach(type => savedObjects.registerType(type));
};

0 comments on commit 0808144

Please sign in to comment.