1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { snakeCase, camelCase } from "lodash";
6 import { CommonResourceService } from 'services/common-service/common-resource-service';
7 import { ListResults, ListArguments } from 'services/common-service/common-service';
8 import { AxiosInstance, AxiosRequestConfig } from "axios";
9 import { CollectionResource } from "models/collection";
10 import { ProjectResource } from "models/project";
11 import { ProcessResource } from "models/process";
12 import { WorkflowResource } from "models/workflow";
13 import { TrashableResourceService } from "services/common-service/trashable-resource-service";
14 import { ApiActions } from "services/api/api-actions";
15 import { GroupResource } from "models/group";
16 import { Session } from "models/session";
18 export interface ContentsArguments {
24 includeTrash?: boolean;
25 excludeHomeProject?: boolean;
28 export interface SharedArguments extends ListArguments {
32 export type GroupContentsResource =
38 export class GroupsService<T extends GroupResource = GroupResource> extends TrashableResourceService<T> {
40 constructor(serverApi: AxiosInstance, actions: ApiActions) {
41 super(serverApi, "groups", actions);
44 async contents(uuid: string, args: ContentsArguments = {}, session?: Session): Promise<ListResults<GroupContentsResource>> {
45 const { filters, order, ...other } = args;
48 filters: filters ? `[${filters}]` : undefined,
49 order: order ? order : undefined
51 const pathUrl = uuid ? `/${uuid}/contents` : '/contents';
53 const cfg: AxiosRequestConfig = { params: CommonResourceService.mapKeys(snakeCase)(params) };
55 cfg.baseURL = session.baseUrl;
56 cfg.headers = { 'Authorization': 'Bearer ' + session.token };
59 const response = await CommonResourceService.defaultResponse(
60 this.serverApi.get(this.resourceType + pathUrl, cfg), this.actions, false
63 return { ...TrashableResourceService.mapKeys(camelCase)(response), clusterId: session && session.clusterId };
66 shared(params: SharedArguments = {}): Promise<ListResults<GroupContentsResource>> {
67 return CommonResourceService.defaultResponse(
69 .get(this.resourceType + '/shared', { params }),
75 export enum GroupContentsResourcePrefix {
76 COLLECTION = "collections",
78 PROCESS = "container_requests",
79 WORKFLOW = "workflows"