Skip to content

Commit

Permalink
[Alerting] Rename alertTypeRegistry to ruleTypeRegistry according to …
Browse files Browse the repository at this point in the history
…the new terminology. (elastic#106519)

* [Alerting] Renamed Alerting framework AlertsClient to RulesClient according to the new terminology.

* fixed path

* fixed type checks

* fixed type checks

* [Alerting] Rename alertTypeRegistry to ruleTypeRegistry.

* Apply suggestions from code review

Co-authored-by: ymao1 <[email protected]>

* fixed type checks

* fixed tests

* fixed merge issues

* fixed merge issues

* fixed tests

* fixed tests

* fixed functional tests

Co-authored-by: ymao1 <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
3 people authored and vadimkibana committed Aug 8, 2021
1 parent a9b93df commit 7aa9a60
Show file tree
Hide file tree
Showing 77 changed files with 496 additions and 496 deletions.
4 changes: 2 additions & 2 deletions api_docs/alerting.json
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@
"description": [],
"signature": [
"() => Set<",
"RegistryAlertType",
"RegistryRuleType",
">"
],
"source": {
Expand Down Expand Up @@ -1330,7 +1330,7 @@
"description": [],
"signature": [
"() => Set<",
"RegistryAlertType",
"RegistryRuleType",
">"
],
"source": {
Expand Down
16 changes: 8 additions & 8 deletions api_docs/triggers_actions_ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -2187,10 +2187,10 @@
},
{
"parentPluginId": "triggersActionsUi",
"id": "def-public.TriggersAndActionsUiServices.alertTypeRegistry",
"id": "def-public.TriggersAndActionsUiServices.ruleTypeRegistry",
"type": "Object",
"tags": [],
"label": "alertTypeRegistry",
"label": "ruleTypeRegistry",
"description": [],
"signature": [
"{ get: (id: string) => ",
Expand Down Expand Up @@ -2535,10 +2535,10 @@
},
{
"parentPluginId": "triggersActionsUi",
"id": "def-public.AlertTypeRegistryContract",
"id": "def-public.RuleTypeRegistryContract",
"type": "Type",
"tags": [],
"label": "AlertTypeRegistryContract",
"label": "RuleTypeRegistryContract",
"description": [],
"signature": [
"{ get: (id: string) => ",
Expand Down Expand Up @@ -3623,10 +3623,10 @@
},
{
"parentPluginId": "triggersActionsUi",
"id": "def-public.TriggersAndActionsUIPublicPluginSetup.alertTypeRegistry",
"id": "def-public.TriggersAndActionsUIPublicPluginSetup.ruleTypeRegistry",
"type": "Object",
"tags": [],
"label": "alertTypeRegistry",
"label": "ruleTypeRegistry",
"description": [],
"signature": [
"TypeRegistry",
Expand Down Expand Up @@ -3684,10 +3684,10 @@
},
{
"parentPluginId": "triggersActionsUi",
"id": "def-public.TriggersAndActionsUIPublicPluginStart.alertTypeRegistry",
"id": "def-public.TriggersAndActionsUIPublicPluginStart.ruleTypeRegistry",
"type": "Object",
"tags": [],
"label": "alertTypeRegistry",
"label": "ruleTypeRegistry",
"description": [],
"signature": [
"TypeRegistry",
Expand Down
4 changes: 2 additions & 2 deletions x-pack/examples/alerting_example/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ export class AlertingExamplePlugin implements Plugin<Setup, Start, AlertingExamp
},
});

triggersActionsUi.alertTypeRegistry.register(getAlwaysFiringAlertType());
triggersActionsUi.alertTypeRegistry.register(getPeopleInSpaceAlertType());
triggersActionsUi.ruleTypeRegistry.register(getAlwaysFiringAlertType());
triggersActionsUi.ruleTypeRegistry.register(getPeopleInSpaceAlertType());

registerNavigation(alerting);

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

import { Request } from '@hapi/hapi';
import { alertTypeRegistryMock } from './alert_type_registry.mock';
import { ruleTypeRegistryMock } from './rule_type_registry.mock';
import { KibanaRequest } from '../../../../src/core/server';
import { savedObjectsClientMock } from '../../../../src/core/server/mocks';
import { securityMock } from '../../security/server/mocks';
Expand All @@ -27,7 +27,7 @@ const securityPluginSetup = securityMock.createSetup();
const securityPluginStart = securityMock.createStart();

const alertingAuthorizationClientFactoryParams: jest.Mocked<AlertingAuthorizationClientFactoryOpts> = {
alertTypeRegistry: alertTypeRegistryMock.create(),
ruleTypeRegistry: ruleTypeRegistryMock.create(),
getSpace: jest.fn(),
features,
};
Expand Down Expand Up @@ -69,7 +69,7 @@ test('creates an alerting authorization client with proper constructor arguments
expect(AlertingAuthorization).toHaveBeenCalledWith({
request,
authorization: securityPluginStart.authz,
alertTypeRegistry: alertingAuthorizationClientFactoryParams.alertTypeRegistry,
ruleTypeRegistry: alertingAuthorizationClientFactoryParams.ruleTypeRegistry,
features: alertingAuthorizationClientFactoryParams.features,
auditLogger: expect.any(AlertingAuthorizationAuditLogger),
getSpace: expect.any(Function),
Expand All @@ -96,7 +96,7 @@ test('creates an alerting authorization client with proper constructor arguments
expect(AlertingAuthorization).toHaveBeenCalledWith({
request,
authorization: securityPluginStart.authz,
alertTypeRegistry: alertingAuthorizationClientFactoryParams.alertTypeRegistry,
ruleTypeRegistry: alertingAuthorizationClientFactoryParams.ruleTypeRegistry,
features: alertingAuthorizationClientFactoryParams.features,
auditLogger: expect.any(AlertingAuthorizationAuditLogger),
getSpace: expect.any(Function),
Expand All @@ -118,7 +118,7 @@ test('creates an alerting authorization client with proper constructor arguments
const { AlertingAuthorization } = jest.requireMock('./authorization/alerting_authorization');
expect(AlertingAuthorization).toHaveBeenCalledWith({
request,
alertTypeRegistry: alertingAuthorizationClientFactoryParams.alertTypeRegistry,
ruleTypeRegistry: alertingAuthorizationClientFactoryParams.ruleTypeRegistry,
features: alertingAuthorizationClientFactoryParams.features,
auditLogger: expect.any(AlertingAuthorizationAuditLogger),
getSpace: expect.any(Function),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

import { KibanaRequest } from 'src/core/server';
import { ALERTS_FEATURE_ID } from '../common';
import { AlertTypeRegistry } from './types';
import { RuleTypeRegistry } from './types';
import { SecurityPluginSetup, SecurityPluginStart } from '../../security/server';
import { PluginStartContract as FeaturesPluginStart } from '../../features/server';
import { AlertingAuthorization } from './authorization/alerting_authorization';
import { AlertingAuthorizationAuditLogger } from './authorization/audit_logger';
import { Space } from '../../spaces/server';

export interface AlertingAuthorizationClientFactoryOpts {
alertTypeRegistry: AlertTypeRegistry;
ruleTypeRegistry: RuleTypeRegistry;
securityPluginSetup?: SecurityPluginSetup;
securityPluginStart?: SecurityPluginStart;
getSpace: (request: KibanaRequest) => Promise<Space | undefined>;
Expand All @@ -24,7 +24,7 @@ export interface AlertingAuthorizationClientFactoryOpts {

export class AlertingAuthorizationClientFactory {
private isInitialized = false;
private alertTypeRegistry!: AlertTypeRegistry;
private ruleTypeRegistry!: RuleTypeRegistry;
private securityPluginStart?: SecurityPluginStart;
private securityPluginSetup?: SecurityPluginSetup;
private features!: FeaturesPluginStart;
Expand All @@ -36,7 +36,7 @@ export class AlertingAuthorizationClientFactory {
}
this.isInitialized = true;
this.getSpace = options.getSpace;
this.alertTypeRegistry = options.alertTypeRegistry;
this.ruleTypeRegistry = options.ruleTypeRegistry;
this.securityPluginSetup = options.securityPluginSetup;
this.securityPluginStart = options.securityPluginStart;
this.features = options.features;
Expand All @@ -48,7 +48,7 @@ export class AlertingAuthorizationClientFactory {
authorization: securityPluginStart?.authz,
request,
getSpace: this.getSpace,
alertTypeRegistry: this.alertTypeRegistry,
ruleTypeRegistry: this.ruleTypeRegistry,
features: features!,
auditLogger: new AlertingAuthorizationAuditLogger(
securityPluginSetup?.audit.getLogger(ALERTS_FEATURE_ID)
Expand Down
Loading

0 comments on commit 7aa9a60

Please sign in to comment.