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

Index mapping poc - leverage saved object type #257

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -186,18 +186,18 @@ function defaultMapping(): IndexMapping {
},
},
},
workspaces: {
type: 'keyword',
},
permissions: {
properties: {
read: principals,
write: principals,
management: principals,
library_read: principals,
library_write: principals,
},
},
// workspaces: {
// type: 'keyword',
// },
// permissions: {
// properties: {
// read: principals,
// write: principals,
// management: principals,
// library_read: principals,
// library_write: principals,
// },
// },
},
};
}
Expand Down
4 changes: 2 additions & 2 deletions src/core/server/saved_objects/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
*/

import { SavedObjectsClient } from './service/saved_objects_client';
import { SavedObjectsTypeMappingDefinition } from './mappings';
import { SavedObjectsFieldMapping, SavedObjectsTypeMappingDefinition } from './mappings';
import { SavedObjectMigrationMap } from './migrations';

export {
Expand Down Expand Up @@ -246,7 +246,7 @@ export interface SavedObjectsType {
/**
* The {@link SavedObjectsTypeMappingDefinition | mapping definition} for the type.
*/
mappings: SavedObjectsTypeMappingDefinition;
mappings: SavedObjectsTypeMappingDefinition | SavedObjectsFieldMapping;
/**
* An optional map of {@link SavedObjectMigrationFn | migrations} to be used to migrate the type.
*/
Expand Down
3 changes: 3 additions & 0 deletions src/plugins/workspace/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import { registerPermissionCheckRoutes } from './permission_control/routes';
import { ConfigSchema } from '../config';
import { cleanWorkspaceId, getWorkspaceIdFromUrl } from '../../../core/server/utils';
import { permission, workspaces } from './saved_objects/workspace';

export class WorkspacePlugin implements Plugin<{}, {}> {
private readonly logger: Logger;
Expand Down Expand Up @@ -59,6 +60,8 @@ export class WorkspacePlugin implements Plugin<{}, {}> {
config.permission.enabled === undefined ? true : config.permission.enabled;

this.client = new WorkspaceClientWithSavedObject(core, this.logger);
core.savedObjects.registerType(permission);
core.savedObjects.registerType(workspaces);

await this.client.setup(core);

Expand Down
50 changes: 49 additions & 1 deletion src/plugins/workspace/server/saved_objects/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { SavedObjectsType, WORKSPACE_TYPE } from '../../../../core/server';
import {
SavedObjectsFieldMapping,
SavedObjectsType,
WORKSPACE_TYPE,
} from '../../../../core/server';

export const workspace: SavedObjectsType = {
name: WORKSPACE_TYPE,
Expand Down Expand Up @@ -42,3 +46,47 @@ export const workspace: SavedObjectsType = {
},
},
};

const principals: SavedObjectsFieldMapping = {
properties: {
users: {
type: 'keyword',
},
groups: {
type: 'keyword',
},
},
};
export const permission: SavedObjectsType = {
name: 'permission',
namespaceType: 'agnostic',
/**
* Disable operation by using saved objects APIs on workspace metadata
*/
hidden: true,
/**
* workspace won't appear in management page.
*/
mappings: {
dynamic: false,
properties: {
read: principals,
write: principals,
management: principals,
library_read: principals,
library_write: principals,
},
},
};

export const workspaces: SavedObjectsType = {
name: 'workspaces',
namespaceType: 'agnostic',
/**
* Disable operation by using saved objects APIs on workspace metadata
*/
hidden: true,
mappings: {
type: 'keyword',
},
};
Loading