Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed alerting API endpoints urls, bodies and params to follow Kibana STYLEGUIDE #66838

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c84afcc
Changed alerting API endpoints urls, bodies and params to follow Kiba…
YulNaumenko May 16, 2020
2df78f4
Merge remote-tracking branch 'upstream/master' into alerting-change-u…
YulNaumenko May 26, 2020
529875e
Changed alerting REST API to keep the pattern 'alerts/alert/{id}'
YulNaumenko May 26, 2020
c016a6d
Merge branch 'master' into alerting-change-urls-to-kibana-styleguide
elasticmachine May 26, 2020
a247e1e
fixed tests
YulNaumenko May 27, 2020
d2fec71
Merge branch 'alerting-change-urls-to-kibana-styleguide' of github.co…
YulNaumenko May 27, 2020
618e90e
fixed tests
YulNaumenko May 27, 2020
edd6a1a
Merge remote-tracking branch 'upstream/master' into alerting-change-u…
YulNaumenko May 27, 2020
7676025
Fixed jest tests
YulNaumenko May 27, 2020
5bacd42
Renamed plugin from alerting to alerts
YulNaumenko May 27, 2020
62c6642
Merge remote-tracking branch 'upstream/master' into alerting-change-u…
YulNaumenko May 27, 2020
7a26f49
fixed tests
YulNaumenko May 28, 2020
40e2bb0
fixed tests
YulNaumenko May 28, 2020
b396db5
Fixed alert type check error
YulNaumenko May 28, 2020
ee17ee3
Merge remote-tracking branch 'upstream/master' into alerting-change-u…
YulNaumenko May 28, 2020
ea75836
Fixed find api
YulNaumenko May 28, 2020
1f47537
fixed type checks
YulNaumenko May 29, 2020
f486629
Merge remote-tracking branch 'upstream/master' into alerting-change-u…
YulNaumenko Jun 1, 2020
668fd32
fixed tests security issues
YulNaumenko Jun 1, 2020
7dec745
Fixed view in app
YulNaumenko Jun 1, 2020
ef62641
Merge remote-tracking branch 'upstream/master' into alerting-change-u…
YulNaumenko Jun 1, 2020
07945b4
-
YulNaumenko Jun 1, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@
/x-pack/plugins/telemetry_collection_xpack/ @elastic/pulse

# Kibana Alerting Services
/x-pack/plugins/alerting/ @elastic/kibana-alerting-services
/x-pack/plugins/alerts/ @elastic/kibana-alerting-services
/x-pack/plugins/actions/ @elastic/kibana-alerting-services
/x-pack/plugins/event_log/ @elastic/kibana-alerting-services
/x-pack/plugins/task_manager/ @elastic/kibana-alerting-services
Expand Down
2 changes: 1 addition & 1 deletion examples/alerting_example/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
"kibanaVersion": "kibana",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we also change the directory name alerting_example to alerts_example. I'd suggest opening a separate issue for that, 307 files already now, this one isn't critical

"server": true,
"ui": true,
"requiredPlugins": ["triggers_actions_ui", "charts", "data", "alerting", "actions"],
"requiredPlugins": ["triggers_actions_ui", "charts", "data", "alerts", "actions"],
"optionalPlugins": []
}
8 changes: 4 additions & 4 deletions examples/alerting_example/public/alert_types/astros.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ import {
import { i18n } from '@kbn/i18n';
import { flatten } from 'lodash';
import { ALERTING_EXAMPLE_APP_ID, Craft, Operator } from '../../common/constants';
import { SanitizedAlert } from '../../../../x-pack/plugins/alerting/common';
import { PluginSetupContract as AlertingSetup } from '../../../../x-pack/plugins/alerting/public';
import { SanitizedAlert } from '../../../../x-pack/plugins/alerts/common';
import { PluginSetupContract as AlertingSetup } from '../../../../x-pack/plugins/alerts/public';
import { AlertTypeModel } from '../../../../x-pack/plugins/triggers_actions_ui/public';

export function registerNavigation(alerting: AlertingSetup) {
alerting.registerNavigation(
export function registerNavigation(alerts: AlertingSetup) {
alerts.registerNavigation(
ALERTING_EXAMPLE_APP_ID,
'example.people-in-space',
(alert: SanitizedAlert) => `/astros/${alert.id}`
Expand Down
10 changes: 5 additions & 5 deletions examples/alerting_example/public/alert_types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@

import { registerNavigation as registerPeopleInSpaceNavigation } from './astros';
import { ALERTING_EXAMPLE_APP_ID } from '../../common/constants';
import { SanitizedAlert } from '../../../../x-pack/plugins/alerting/common';
import { PluginSetupContract as AlertingSetup } from '../../../../x-pack/plugins/alerting/public';
import { SanitizedAlert } from '../../../../x-pack/plugins/alerts/common';
import { PluginSetupContract as AlertingSetup } from '../../../../x-pack/plugins/alerts/public';

export function registerNavigation(alerting: AlertingSetup) {
export function registerNavigation(alerts: AlertingSetup) {
// register default navigation
alerting.registerDefaultNavigation(
alerts.registerDefaultNavigation(
ALERTING_EXAMPLE_APP_ID,
(alert: SanitizedAlert) => `/alert/${alert.id}`
);

registerPeopleInSpaceNavigation(alerting);
registerPeopleInSpaceNavigation(alerts);
}
2 changes: 1 addition & 1 deletion examples/alerting_example/public/components/view_alert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import {
Alert,
AlertTaskState,
BASE_ALERT_API_PATH,
} from '../../../../x-pack/plugins/alerting/common';
} from '../../../../x-pack/plugins/alerts/common';
import { ALERTING_EXAMPLE_APP_ID } from '../../common/constants';

type Props = RouteComponentProps & {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ import {
Alert,
AlertTaskState,
BASE_ALERT_API_PATH,
} from '../../../../x-pack/plugins/alerting/common';
} from '../../../../x-pack/plugins/alerts/common';
import { ALERTING_EXAMPLE_APP_ID } from '../../common/constants';

type Props = RouteComponentProps & {
Expand Down
10 changes: 5 additions & 5 deletions examples/alerting_example/public/plugin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import { Plugin, CoreSetup, AppMountParameters } from 'kibana/public';
import { PluginSetupContract as AlertingSetup } from '../../../x-pack/plugins/alerting/public';
import { PluginSetupContract as AlertingSetup } from '../../../x-pack/plugins/alerts/public';
import { ChartsPluginStart } from '../../../src/plugins/charts/public';
import { TriggersAndActionsUIPublicPluginSetup } from '../../../x-pack/plugins/triggers_actions_ui/public';
import { DataPublicPluginStart } from '../../../src/plugins/data/public';
Expand All @@ -30,12 +30,12 @@ export type Setup = void;
export type Start = void;

export interface AlertingExamplePublicSetupDeps {
alerting: AlertingSetup;
alerts: AlertingSetup;
triggers_actions_ui: TriggersAndActionsUIPublicPluginSetup;
}

export interface AlertingExamplePublicStartDeps {
alerting: AlertingSetup;
alerts: AlertingSetup;
triggers_actions_ui: TriggersAndActionsUIPublicPluginSetup;
charts: ChartsPluginStart;
data: DataPublicPluginStart;
Expand All @@ -44,7 +44,7 @@ export interface AlertingExamplePublicStartDeps {
export class AlertingExamplePlugin implements Plugin<Setup, Start, AlertingExamplePublicSetupDeps> {
public setup(
core: CoreSetup<AlertingExamplePublicStartDeps, Start>,
{ alerting, triggers_actions_ui }: AlertingExamplePublicSetupDeps
{ alerts, triggers_actions_ui }: AlertingExamplePublicSetupDeps
) {
core.application.register({
id: 'AlertingExample',
Expand All @@ -59,7 +59,7 @@ export class AlertingExamplePlugin implements Plugin<Setup, Start, AlertingExamp
triggers_actions_ui.alertTypeRegistry.register(getAlwaysFiringAlertType());
triggers_actions_ui.alertTypeRegistry.register(getPeopleInSpaceAlertType());

registerNavigation(alerting);
registerNavigation(alerts);
}

public start() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import uuid from 'uuid';
import { range } from 'lodash';
import { AlertType } from '../../../../x-pack/plugins/alerting/server';
import { AlertType } from '../../../../x-pack/plugins/alerts/server';
import { DEFAULT_INSTANCES_TO_GENERATE, ALERTING_EXAMPLE_APP_ID } from '../../common/constants';

export const alertType: AlertType = {
Expand Down
2 changes: 1 addition & 1 deletion examples/alerting_example/server/alert_types/astros.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

import axios from 'axios';
import { AlertType } from '../../../../x-pack/plugins/alerting/server';
import { AlertType } from '../../../../x-pack/plugins/alerts/server';
import { Operator, Craft, ALERTING_EXAMPLE_APP_ID } from '../../common/constants';

interface PeopleInSpace {
Expand Down
10 changes: 5 additions & 5 deletions examples/alerting_example/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,20 @@
*/

import { Plugin, CoreSetup } from 'kibana/server';
import { PluginSetupContract as AlertingSetup } from '../../../x-pack/plugins/alerting/server';
import { PluginSetupContract as AlertingSetup } from '../../../x-pack/plugins/alerts/server';

import { alertType as alwaysFiringAlert } from './alert_types/always_firing';
import { alertType as peopleInSpaceAlert } from './alert_types/astros';

// this plugin's dependendencies
export interface AlertingExampleDeps {
alerting: AlertingSetup;
alerts: AlertingSetup;
}

export class AlertingExamplePlugin implements Plugin<void, void, AlertingExampleDeps> {
public setup(core: CoreSetup, { alerting }: AlertingExampleDeps) {
alerting.registerType(alwaysFiringAlert);
alerting.registerType(peopleInSpaceAlert);
public setup(core: CoreSetup, { alerts }: AlertingExampleDeps) {
alerts.registerType(alwaysFiringAlert);
alerts.registerType(peopleInSpaceAlert);
}

public start() {}
Expand Down
2 changes: 1 addition & 1 deletion rfcs/text/0003_handler_interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ application.registerApp({
});

// Alerting
alerting.registerType({
alerts.registerType({
id: 'myAlert',
async execute(context, params, state) {
const indexPatterns = await context.core.savedObjects.find('indexPattern');
Expand Down
2 changes: 1 addition & 1 deletion x-pack/.i18nrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"xpack.actions": "plugins/actions",
"xpack.advancedUiActions": "plugins/advanced_ui_actions",
"xpack.uiActionsEnhanced": "examples/ui_actions_enhanced_examples",
"xpack.alerting": "plugins/alerting",
"xpack.alerts": "plugins/alerts",
"xpack.alertingBuiltins": "plugins/alerting_builtins",
"xpack.apm": ["legacy/plugins/apm", "plugins/apm"],
"xpack.beatsManagement": ["legacy/plugins/beats_management", "plugins/beats_management"],
Expand Down
2 changes: 1 addition & 1 deletion x-pack/legacy/plugins/monitoring/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { KIBANA_ALERTING_ENABLED } from '../../../plugins/monitoring/common/cons
*/
const deps = ['kibana', 'elasticsearch', 'xpack_main'];
if (KIBANA_ALERTING_ENABLED) {
deps.push(...['alerting', 'actions']);
deps.push(...['alerts', 'actions']);
}
export const monitoring = (kibana: any) => {
return new kibana.Plugin({
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/actions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Table of Contents
- [Executor](#executor)
- [Example](#example)
- [RESTful API](#restful-api)
- [`POST /api/action`: Create action](#post-apiaction-create-action)
- [`POST /api/actions/action`: Create action](#post-apiaction-create-action)
- [`DELETE /api/actions/action/{id}`: Delete action](#delete-apiactionid-delete-action)
- [`GET /api/actions`: Get all actions](#get-apiactiongetall-get-all-actions)
- [`GET /api/actions/action/{id}`: Get action](#get-apiactionid-get-action)
Expand Down Expand Up @@ -163,7 +163,7 @@ The built-in email action type provides a good example of creating an action typ

Using an action type requires an action to be created that will contain and encrypt configuration for a given action type. See below for CRUD operations using the API.

### `POST /api/action`: Create action
### `POST /api/actions/action`: Create action

Payload:

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/alerting_builtins/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# alerting_builtins plugin
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as with the alerting example, we probably want this renamed as well, to alerts_builtins, but it's not critical ATM - I don't think anything should be referencing this plugin anyway


This plugin provides alertTypes shipped with Kibana for use with the
[the alerting plugin](../alerting/README.md). When enabled, it will register
[the alerts plugin](../alerts/README.md). When enabled, it will register
the built-in alertTypes with the alerting plugin, register associated HTTP
routes, etc.

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/alerting_builtins/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"server": true,
"version": "8.0.0",
"kibanaVersion": "kibana",
"requiredPlugins": ["alerting"],
"requiredPlugins": ["alerts"],
"configPath": ["xpack", "alerting_builtins"],
"ui": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { register as registerIndexThreshold } from './index_threshold';
interface RegisterBuiltInAlertTypesParams {
service: Service;
router: IRouter;
alerting: AlertingSetup;
alerts: AlertingSetup;
baseRoute: string;
}

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

import { i18n } from '@kbn/i18n';
import { Params } from './alert_type_params';
import { AlertExecutorOptions } from '../../../../alerting/server';
import { AlertExecutorOptions } from '../../../../alerts/server';

// alert type context provided to actions

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ export function getService() {
interface RegisterParams {
service: Service;
router: IRouter;
alerting: AlertingSetup;
alerts: AlertingSetup;
baseRoute: string;
}

export function register(params: RegisterParams) {
const { service, router, alerting, baseRoute } = params;
const { service, router, alerts, baseRoute } = params;

alerting.registerType(getAlertType(service));
alerts.registerType(getAlertType(service));

const baseBuiltInRoute = `${baseRoute}/index_threshold`;
registerRoutes({ service, router, baseRoute: baseBuiltInRoute });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { i18n } from '@kbn/i18n';
import { times } from 'lodash';
import { parseDuration } from '../../../../../alerting/server';
import { parseDuration } from '../../../../../alerts/server';
import { MAX_INTERVALS } from '../index';

// dates as numbers are epoch millis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import { i18n } from '@kbn/i18n';
import { schema, TypeOf } from '@kbn/config-schema';

import { parseDuration } from '../../../../../alerting/server';
import { parseDuration } from '../../../../../alerts/server';
import { MAX_INTERVALS } from '../index';
import { CoreQueryParamsSchemaProperties, validateCoreQueryBody } from './core_query_types';
import {
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/alerting_builtins/server/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { AlertingBuiltinsPlugin } from './plugin';
import { coreMock } from '../../../../src/core/server/mocks';
import { alertsMock } from '../../../plugins/alerting/server/mocks';
import { alertsMock } from '../../alerts/server/mocks';

describe('AlertingBuiltins Plugin', () => {
describe('setup()', () => {
Expand All @@ -22,7 +22,7 @@ describe('AlertingBuiltins Plugin', () => {

it('should register built-in alert types', async () => {
const alertingSetup = alertsMock.createSetup();
await plugin.setup(coreSetup, { alerting: alertingSetup });
await plugin.setup(coreSetup, { alerts: alertingSetup });

expect(alertingSetup.registerType).toHaveBeenCalledTimes(1);

Expand All @@ -44,7 +44,7 @@ describe('AlertingBuiltins Plugin', () => {

it('should return a service in the expected shape', async () => {
const alertingSetup = alertsMock.createSetup();
const service = await plugin.setup(coreSetup, { alerting: alertingSetup });
const service = await plugin.setup(coreSetup, { alerts: alertingSetup });

expect(typeof service.indexThreshold.timeSeriesQuery).toBe('function');
});
Expand Down
4 changes: 2 additions & 2 deletions x-pack/plugins/alerting_builtins/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export class AlertingBuiltinsPlugin implements Plugin<IService, IService> {
};
}

public async setup(core: CoreSetup, { alerting }: AlertingBuiltinsDeps): Promise<IService> {
public async setup(core: CoreSetup, { alerts }: AlertingBuiltinsDeps): Promise<IService> {
registerBuiltInAlertTypes({
service: this.service,
router: core.http.createRouter(),
alerting,
alerts,
baseRoute: '/api/alerting_builtins',
});
return this.service;
Expand Down
6 changes: 3 additions & 3 deletions x-pack/plugins/alerting_builtins/server/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { Logger, ScopedClusterClient } from '../../../../src/core/server';
import { PluginSetupContract as AlertingSetup } from '../../alerting/server';
import { PluginSetupContract as AlertingSetup } from '../../alerts/server';
import { getService as getServiceIndexThreshold } from './alert_types/index_threshold';

export { Logger, IRouter } from '../../../../src/core/server';
Expand All @@ -14,11 +14,11 @@ export {
PluginSetupContract as AlertingSetup,
AlertType,
AlertExecutorOptions,
} from '../../alerting/server';
} from '../../alerts/server';

// this plugin's dependendencies
export interface AlertingBuiltinsDeps {
alerting: AlertingSetup;
alerts: AlertingSetup;
}

// external service exposed through plugin setup/start
Expand Down
Loading