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",
30 NODE = "arvados#node",
31 PROCESS = "arvados#containerRequest",
32 PROJECT = "arvados#group",
33 REPOSITORY = "arvados#repository",
34 SSH_KEY = "arvados#authorizedKeys",
35 KEEP_SERVICE = "arvados#keepService",
36 USER = "arvados#user",
37 VIRTUAL_MACHINE = "arvados#virtualMachine",
38 WORKFLOW = "arvados#workflow",
42 export enum ResourceObjectType {
43 API_CLIENT_AUTHORIZATION = 'gj3su',
46 CONTAINER_REQUEST = 'xvhdp',
51 VIRTUAL_MACHINE = '2x53u',
54 KEEP_SERVICE = 'bi6l4',
58 export const RESOURCE_UUID_PATTERN = '.{5}-.{5}-.{15}';
59 export const RESOURCE_UUID_REGEX = new RegExp(RESOURCE_UUID_PATTERN);
61 export const isResourceUuid = (uuid: string) =>
62 RESOURCE_UUID_REGEX.test(uuid);
64 export const extractUuidObjectType = (uuid: string) => {
65 const match = RESOURCE_UUID_REGEX.exec(uuid);
67 ? match[0].split('-')[1]
71 export const extractUuidKind = (uuid: string = '') => {
72 const objectType = extractUuidObjectType(uuid);
74 case ResourceObjectType.USER:
75 return ResourceKind.USER;
76 case ResourceObjectType.GROUP:
77 return ResourceKind.GROUP;
78 case ResourceObjectType.COLLECTION:
79 return ResourceKind.COLLECTION;
80 case ResourceObjectType.CONTAINER_REQUEST:
81 return ResourceKind.CONTAINER_REQUEST;
82 case ResourceObjectType.CONTAINER:
83 return ResourceKind.CONTAINER;
84 case ResourceObjectType.LOG:
85 return ResourceKind.LOG;
86 case ResourceObjectType.WORKFLOW:
87 return ResourceKind.WORKFLOW;
88 case ResourceObjectType.VIRTUAL_MACHINE:
89 return ResourceKind.VIRTUAL_MACHINE;
90 case ResourceObjectType.REPOSITORY:
91 return ResourceKind.REPOSITORY;
92 case ResourceObjectType.SSH_KEY:
93 return ResourceKind.SSH_KEY;
94 case ResourceObjectType.KEEP_SERVICE:
95 return ResourceKind.KEEP_SERVICE;
96 case ResourceObjectType.NODE:
97 return ResourceKind.NODE;
98 case ResourceObjectType.API_CLIENT_AUTHORIZATION:
99 return ResourceKind.API_CLIENT_AUTHORIZATION;