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 USER = "arvados#user",
32 WORKFLOW = "arvados#workflow",
36 export enum ResourceObjectType {
39 CONTAINER_REQUEST = 'xvhdp',
46 export const RESOURCE_UUID_PATTERN = '.{5}-.{5}-.{15}';
47 export const RESOURCE_UUID_REGEX = new RegExp(RESOURCE_UUID_PATTERN);
49 export const isResourceUuid = (uuid: string) =>
50 RESOURCE_UUID_REGEX.test(uuid);
52 export const extractUuidObjectType = (uuid: string) => {
53 const match = RESOURCE_UUID_REGEX.exec(uuid);
55 ? match[0].split('-')[1]
59 export const extractUuidKind = (uuid: string = '') => {
60 const objectType = extractUuidObjectType(uuid);
62 case ResourceObjectType.USER:
63 return ResourceKind.USER;
64 case ResourceObjectType.GROUP:
65 return ResourceKind.GROUP;
66 case ResourceObjectType.COLLECTION:
67 return ResourceKind.COLLECTION;
68 case ResourceObjectType.CONTAINER_REQUEST:
69 return ResourceKind.CONTAINER_REQUEST;
70 case ResourceObjectType.CONTAINER:
71 return ResourceKind.CONTAINER;
72 case ResourceObjectType.LOG:
73 return ResourceKind.LOG;
74 case ResourceObjectType.WORKFLOW:
75 return ResourceKind.WORKFLOW;