19988: Refactor getOrder into data explorer middleware when no order prefixes are...
[arvados.git] / src / models / group.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import {
6     ResourceKind,
7     ResourceWithProperties,
8     RESOURCE_UUID_REGEX,
9     ResourceObjectType,
10     TrashableResource
11 } from "./resource";
12
13 export interface GroupResource extends TrashableResource, ResourceWithProperties {
14     kind: ResourceKind.GROUP;
15     name: string;
16     groupClass: GroupClass | null;
17     description: string;
18     writableBy: string[];
19     ensure_unique_name: boolean;
20 }
21
22 export enum GroupClass {
23     PROJECT = 'project',
24     FILTER  = 'filter',
25     ROLE  = 'role',
26 }
27
28 export enum BuiltinGroups {
29     ALL = 'fffffffffffffff',
30     ANON = 'anonymouspublic',
31     SYSTEM = '000000000000000',
32 }
33
34 export const getBuiltinGroupUuid = (cluster: string, groupName: BuiltinGroups): string => {
35     return cluster ? `${cluster}-${ResourceObjectType.GROUP}-${groupName}` : "";
36 };
37
38 export const isBuiltinGroup = (uuid: string) => {
39     const match = RESOURCE_UUID_REGEX.exec(uuid);
40     const parts = match ? match[0].split('-') : [];
41     return parts.length === 3 && parts[1] === ResourceObjectType.GROUP && Object.values<string>(BuiltinGroups).includes(parts[2]);
42 };