1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { ApiClientAuthorization } from '~/models/api-client-authorization';
7 export interface Resource {
11 modifiedByClientUuid: string;
12 modifiedByUserUuid: string;
19 export interface TrashableResource extends Resource {
25 export enum ResourceKind {
26 API_CLIENT_AUTHORIZATION = "arvados#apiClientAuthorization",
27 COLLECTION = "arvados#collection",
28 CONTAINER = "arvados#container",
29 CONTAINER_REQUEST = "arvados#containerRequest",
30 GROUP = "arvados#group",
31 LINK = "arvados#link",
33 NODE = "arvados#node",
34 PROCESS = "arvados#containerRequest",
35 PROJECT = "arvados#group",
36 REPOSITORY = "arvados#repository",
37 SSH_KEY = "arvados#authorizedKeys",
38 KEEP_SERVICE = "arvados#keepService",
39 USER = "arvados#user",
40 VIRTUAL_MACHINE = "arvados#virtualMachine",
41 WORKFLOW = "arvados#workflow",
45 export enum ResourceObjectType {
46 API_CLIENT_AUTHORIZATION = 'gj3su',
49 CONTAINER_REQUEST = 'xvhdp',
55 VIRTUAL_MACHINE = '2x53u',
58 KEEP_SERVICE = 'bi6l4',
62 export const RESOURCE_UUID_PATTERN = '.{5}-.{5}-.{15}';
63 export const RESOURCE_UUID_REGEX = new RegExp(RESOURCE_UUID_PATTERN);
65 export const isResourceUuid = (uuid: string) =>
66 RESOURCE_UUID_REGEX.test(uuid);
68 export const extractUuidObjectType = (uuid: string) => {
69 const match = RESOURCE_UUID_REGEX.exec(uuid);
71 ? match[0].split('-')[1]
75 export const extractUuidKind = (uuid: string = '') => {
76 const objectType = extractUuidObjectType(uuid);
78 case ResourceObjectType.USER:
79 return ResourceKind.USER;
80 case ResourceObjectType.GROUP:
81 return ResourceKind.GROUP;
82 case ResourceObjectType.COLLECTION:
83 return ResourceKind.COLLECTION;
84 case ResourceObjectType.CONTAINER_REQUEST:
85 return ResourceKind.CONTAINER_REQUEST;
86 case ResourceObjectType.CONTAINER:
87 return ResourceKind.CONTAINER;
88 case ResourceObjectType.LOG:
89 return ResourceKind.LOG;
90 case ResourceObjectType.WORKFLOW:
91 return ResourceKind.WORKFLOW;
92 case ResourceObjectType.VIRTUAL_MACHINE:
93 return ResourceKind.VIRTUAL_MACHINE;
94 case ResourceObjectType.REPOSITORY:
95 return ResourceKind.REPOSITORY;
96 case ResourceObjectType.SSH_KEY:
97 return ResourceKind.SSH_KEY;
98 case ResourceObjectType.KEEP_SERVICE:
99 return ResourceKind.KEEP_SERVICE;
100 case ResourceObjectType.NODE:
101 return ResourceKind.NODE;
102 case ResourceObjectType.API_CLIENT_AUTHORIZATION:
103 return ResourceKind.API_CLIENT_AUTHORIZATION;
104 case ResourceObjectType.LINK:
105 return ResourceKind.LINK;