diff --git a/x-pack/plugins/security/server/authorization/actions/actions.ts b/x-pack/plugins/security/server/authorization/actions/actions.ts index 23d07f73f04be..619bcfe44e75b 100644 --- a/x-pack/plugins/security/server/authorization/actions/actions.ts +++ b/x-pack/plugins/security/server/authorization/actions/actions.ts @@ -6,6 +6,7 @@ */ import { AlertingActions } from './alerting'; +import { AlertsActions } from './alerts'; import { ApiActions } from './api'; import { AppActions } from './app'; import { SavedObjectActions } from './saved_object'; @@ -21,6 +22,8 @@ export class Actions { public readonly app = new AppActions(this.versionNumber); + public readonly alerts = new AlertsActions(this.versionNumber); + public readonly login = 'login:'; public readonly savedObject = new SavedObjectActions(this.versionNumber); diff --git a/x-pack/plugins/security/server/authorization/actions/alerts.ts b/x-pack/plugins/security/server/authorization/actions/alerts.ts new file mode 100644 index 0000000000000..a8e3375f7fa3e --- /dev/null +++ b/x-pack/plugins/security/server/authorization/actions/alerts.ts @@ -0,0 +1,32 @@ +/* + * 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 { isString } from 'lodash'; + +export class AlertsActions { + private readonly prefix: string; + + constructor(versionNumber: string) { + this.prefix = `alerts:${versionNumber}:`; + } + + public get(spaceId: string, owner: string, operation: string): string { + if (!spaceId || !isString(spaceId)) { + throw new Error('"spaceId" is required and must be a string'); + } + + if (!operation || !isString(operation)) { + throw new Error('"operation" is required and must be a string'); + } + + if (!owner || !isString(owner)) { + throw new Error('"owner" is required and must be a string'); + } + + return `${this.prefix}${spaceId}/${owner}/${operation}`; + } +}