forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathelasticsearch_feature.ts
86 lines (75 loc) · 2.22 KB
/
elasticsearch_feature.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/*
* 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 { RecursiveReadonly } from '@kbn/utility-types';
import { FeatureElasticsearchPrivileges } from './feature_elasticsearch_privileges';
/**
* Interface for registering an Elasticsearch feature.
* Feature registration allows plugins to hide their applications based
* on configured cluster or index privileges.
*/
export interface ElasticsearchFeatureConfig {
/**
* Unique identifier for this feature.
* This identifier is also used when generating UI Capabilities.
*
* @see UICapabilities
*/
id: string;
/**
* Management sections associated with this feature.
*
* @example
* ```ts
* // Enables access to the "Advanced Settings" management page within the Kibana section
* management: {
* kibana: ['settings']
* }
* ```
*/
management?: {
[sectionId: string]: string[];
};
/**
* If this feature includes a catalogue entry, you can specify them here to control visibility based on the current space.
*
*/
catalogue?: string[];
/**
* Feature privilege definition. Specify one or more privileges which grant access to this feature.
* Users must satisfy all privileges in at least one of the defined sets of privileges in order to be granted access.
*
* @example
* ```ts
* [{
* requiredClusterPrivileges: ['monitor'],
* requiredIndexPrivileges: {
* ['metricbeat-*']: ['read', 'view_index_metadata']
* }
* }]
* ```
* @see FeatureElasticsearchPrivileges
*/
privileges: FeatureElasticsearchPrivileges[];
}
export class ElasticsearchFeature {
constructor(protected readonly config: RecursiveReadonly<ElasticsearchFeatureConfig>) {}
public get id() {
return this.config.id;
}
public get catalogue() {
return this.config.catalogue;
}
public get management() {
return this.config.management;
}
public get privileges() {
return this.config.privileges;
}
public toRaw() {
return { ...this.config } as ElasticsearchFeatureConfig;
}
}