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 NODE = "arvados#node",
30 PROCESS = "arvados#containerRequest",
31 PROJECT = "arvados#group",
32 REPOSITORY = "arvados#repository",
33 SSH_KEY = "arvados#authorizedKeys",
34 KEEP_SERVICE = "arvados#keepService",
35 USER = "arvados#user",
36 VIRTUAL_MACHINE = "arvados#virtualMachine",
37 WORKFLOW = "arvados#workflow",
41 export enum ResourceObjectType {
44 CONTAINER_REQUEST = 'xvhdp',
49 VIRTUAL_MACHINE = '2x53u',
52 KEEP_SERVICE = 'bi6l4',
56 export const RESOURCE_UUID_PATTERN = '.{5}-.{5}-.{15}';
57 export const RESOURCE_UUID_REGEX = new RegExp(RESOURCE_UUID_PATTERN);
59 export const isResourceUuid = (uuid: string) =>
60 RESOURCE_UUID_REGEX.test(uuid);
62 export const extractUuidObjectType = (uuid: string) => {
63 const match = RESOURCE_UUID_REGEX.exec(uuid);
65 ? match[0].split('-')[1]
69 export const extractUuidKind = (uuid: string = '') => {
70 const objectType = extractUuidObjectType(uuid);
72 case ResourceObjectType.USER:
73 return ResourceKind.USER;
74 case ResourceObjectType.GROUP:
75 return ResourceKind.GROUP;
76 case ResourceObjectType.COLLECTION:
77 return ResourceKind.COLLECTION;
78 case ResourceObjectType.CONTAINER_REQUEST:
79 return ResourceKind.CONTAINER_REQUEST;
80 case ResourceObjectType.CONTAINER:
81 return ResourceKind.CONTAINER;
82 case ResourceObjectType.LOG:
83 return ResourceKind.LOG;
84 case ResourceObjectType.WORKFLOW:
85 return ResourceKind.WORKFLOW;
86 case ResourceObjectType.VIRTUAL_MACHINE:
87 return ResourceKind.VIRTUAL_MACHINE;
88 case ResourceObjectType.REPOSITORY:
89 return ResourceKind.REPOSITORY;
90 case ResourceObjectType.SSH_KEY:
91 return ResourceKind.SSH_KEY;
92 case ResourceObjectType.KEEP_SERVICE:
93 return ResourceKind.KEEP_SERVICE;
94 case ResourceObjectType.NODE:
95 return ResourceKind.NODE;