1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { snakeCase } from "lodash";
6 import { AxiosInstance } from "axios";
7 import { TrashableResource } from "models/resource";
8 import { CommonResourceService } from "services/common-service/common-resource-service";
9 import { ApiActions } from "services/api/api-actions";
11 export class TrashableResourceService<T extends TrashableResource> extends CommonResourceService<T> {
12 constructor(serverApi: AxiosInstance, resourceType: string, actions: ApiActions, readOnlyFields: string[] = []) {
13 super(serverApi, resourceType, actions, readOnlyFields);
16 trash(uuid: string): Promise<T> {
17 return CommonResourceService.defaultResponse(this.serverApi.post(this.resourceType + `/${uuid}/trash`), this.actions);
20 untrash(uuid: string): Promise<T> {
22 ensure_unique_name: true,
24 return CommonResourceService.defaultResponse(
25 this.serverApi.post(this.resourceType + `/${uuid}/untrash`, {
26 params: CommonResourceService.mapKeys(snakeCase)(params),