1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 export interface Resource {
9 modifiedByClientUuid: string;
10 modifiedByUserUuid: string;
17 export interface TrashableResource extends Resource {
23 export enum ResourceKind {
24 COLLECTION = "arvados#collection",
25 CONTAINER = "arvados#container",
26 CONTAINER_REQUEST = "arvados#containerRequest",
27 GROUP = "arvados#group",
29 PROCESS = "arvados#containerRequest",
30 PROJECT = "arvados#group",
31 REPOSITORY = "arvados#repository",
32 SSH_KEY = "arvados#authorizedKeys",
33 KEEP_SERVICE = "arvados#keepService",
34 USER = "arvados#user",
35 VIRTUAL_MACHINE = "arvados#virtualMachine",
36 WORKFLOW = "arvados#workflow",
40 export enum ResourceObjectType {
43 CONTAINER_REQUEST = 'xvhdp',
48 VIRTUAL_MACHINE = '2x53u',
51 KEEP_SERVICE = 'bi6l4'
54 export const RESOURCE_UUID_PATTERN = '.{5}-.{5}-.{15}';
55 export const RESOURCE_UUID_REGEX = new RegExp(RESOURCE_UUID_PATTERN);
57 export const isResourceUuid = (uuid: string) =>
58 RESOURCE_UUID_REGEX.test(uuid);
60 export const extractUuidObjectType = (uuid: string) => {
61 const match = RESOURCE_UUID_REGEX.exec(uuid);
63 ? match[0].split('-')[1]
67 export const extractUuidKind = (uuid: string = '') => {
68 const objectType = extractUuidObjectType(uuid);
70 case ResourceObjectType.USER:
71 return ResourceKind.USER;
72 case ResourceObjectType.GROUP:
73 return ResourceKind.GROUP;
74 case ResourceObjectType.COLLECTION:
75 return ResourceKind.COLLECTION;
76 case ResourceObjectType.CONTAINER_REQUEST:
77 return ResourceKind.CONTAINER_REQUEST;
78 case ResourceObjectType.CONTAINER:
79 return ResourceKind.CONTAINER;
80 case ResourceObjectType.LOG:
81 return ResourceKind.LOG;
82 case ResourceObjectType.WORKFLOW:
83 return ResourceKind.WORKFLOW;
84 case ResourceObjectType.VIRTUAL_MACHINE:
85 return ResourceKind.VIRTUAL_MACHINE;
86 case ResourceObjectType.REPOSITORY:
87 return ResourceKind.REPOSITORY;
88 case ResourceObjectType.SSH_KEY:
89 return ResourceKind.SSH_KEY;
90 case ResourceObjectType.KEEP_SERVICE:
91 return ResourceKind.KEEP_SERVICE;