1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { CancelToken } from 'axios';
6 import { snakeCase, camelCase } from "lodash";
7 import { CommonResourceService } from 'services/common-service/common-resource-service';
11 } from 'services/common-service/common-service';
12 import { AxiosInstance, AxiosRequestConfig } from 'axios';
13 import { CollectionResource } from 'models/collection';
14 import { ProjectResource } from 'models/project';
15 import { ProcessResource } from 'models/process';
16 import { WorkflowResource } from 'models/workflow';
17 import { TrashableResourceService } from 'services/common-service/trashable-resource-service';
18 import { ApiActions } from 'services/api/api-actions';
19 import { GroupResource } from 'models/group';
20 import { Session } from 'models/session';
22 export interface ContentsArguments {
28 includeTrash?: boolean;
29 excludeHomeProject?: boolean;
32 export interface SharedArguments extends ListArguments {
36 export type GroupContentsResource =
42 export class GroupsService<
43 T extends GroupResource = GroupResource
44 > extends TrashableResourceService<T> {
45 constructor(serverApi: AxiosInstance, actions: ApiActions) {
46 super(serverApi, 'groups', actions);
49 async contents(uuid: string, args: ContentsArguments = {}, session?: Session, cancelToken?: CancelToken): Promise<ListResults<GroupContentsResource>> {
50 const { filters, order, ...other } = args;
53 filters: filters ? `[${filters}]` : undefined,
54 order: order ? order : undefined
56 const pathUrl = uuid ? `/${uuid}/contents` : '/contents';
57 const cfg: AxiosRequestConfig = {
58 params: CommonResourceService.mapKeys(snakeCase)(params),
62 cfg.baseURL = session.baseUrl;
63 cfg.headers = { Authorization: 'Bearer ' + session.token };
67 cfg.cancelToken = cancelToken;
70 const response = await CommonResourceService.defaultResponse(
71 this.serverApi.get(this.resourceType + pathUrl, cfg),
77 ...TrashableResourceService.mapKeys(camelCase)(response),
78 clusterId: session && session.clusterId,
83 params: SharedArguments = {}
84 ): Promise<ListResults<GroupContentsResource>> {
85 return CommonResourceService.defaultResponse(
86 this.serverApi.get(this.resourceType + '/shared', { params }),
92 export enum GroupContentsResourcePrefix {
93 COLLECTION = 'collections',
95 PROCESS = 'container_requests',
96 WORKFLOW = 'workflows',