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 API_CLIENT_AUTHORIZATION = "arvados#apiClientAuthorization",
25 COLLECTION = "arvados#collection",
26 CONTAINER = "arvados#container",
27 CONTAINER_REQUEST = "arvados#containerRequest",
28 GROUP = "arvados#group",
29 LINK = "arvados#link",
31 NODE = "arvados#node",
32 PROCESS = "arvados#containerRequest",
33 PROJECT = "arvados#group",
34 REPOSITORY = "arvados#repository",
35 SSH_KEY = "arvados#authorizedKeys",
36 KEEP_SERVICE = "arvados#keepService",
37 USER = "arvados#user",
38 VIRTUAL_MACHINE = "arvados#virtualMachine",
39 WORKFLOW = "arvados#workflow",
43 export enum ResourceObjectType {
44 API_CLIENT_AUTHORIZATION = 'gj3su',
47 CONTAINER_REQUEST = 'xvhdp',
53 VIRTUAL_MACHINE = '2x53u',
56 KEEP_SERVICE = 'bi6l4',
60 export const RESOURCE_UUID_PATTERN = '.{5}-.{5}-.{15}';
61 export const RESOURCE_UUID_REGEX = new RegExp(RESOURCE_UUID_PATTERN);
63 export const isResourceUuid = (uuid: string) =>
64 RESOURCE_UUID_REGEX.test(uuid);
66 export const extractUuidObjectType = (uuid: string) => {
67 const match = RESOURCE_UUID_REGEX.exec(uuid);
69 ? match[0].split('-')[1]
73 export const extractUuidKind = (uuid: string = '') => {
74 const objectType = extractUuidObjectType(uuid);
76 case ResourceObjectType.USER:
77 return ResourceKind.USER;
78 case ResourceObjectType.GROUP:
79 return ResourceKind.GROUP;
80 case ResourceObjectType.COLLECTION:
81 return ResourceKind.COLLECTION;
82 case ResourceObjectType.CONTAINER_REQUEST:
83 return ResourceKind.CONTAINER_REQUEST;
84 case ResourceObjectType.CONTAINER:
85 return ResourceKind.CONTAINER;
86 case ResourceObjectType.LOG:
87 return ResourceKind.LOG;
88 case ResourceObjectType.WORKFLOW:
89 return ResourceKind.WORKFLOW;
90 case ResourceObjectType.VIRTUAL_MACHINE:
91 return ResourceKind.VIRTUAL_MACHINE;
92 case ResourceObjectType.REPOSITORY:
93 return ResourceKind.REPOSITORY;
94 case ResourceObjectType.SSH_KEY:
95 return ResourceKind.SSH_KEY;
96 case ResourceObjectType.KEEP_SERVICE:
97 return ResourceKind.KEEP_SERVICE;
98 case ResourceObjectType.NODE:
99 return ResourceKind.NODE;
100 case ResourceObjectType.API_CLIENT_AUTHORIZATION:
101 return ResourceKind.API_CLIENT_AUTHORIZATION;
102 case ResourceObjectType.LINK:
103 return ResourceKind.LINK;