Restore height to process log code snippet
[arvados-workbench2.git] / src / services / common-service / trashable-resource-service.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as _ from "lodash";
6 import { AxiosInstance } from "axios";
7 import { TrashableResource } from "src/models/resource";
8 import { CommonResourceService } from "~/services/common-service/common-resource-service";
9
10 export class TrashableResourceService<T extends TrashableResource> extends CommonResourceService<T> {
11
12     constructor(serverApi: AxiosInstance, resourceType: string) {
13         super(serverApi, resourceType);
14     }
15
16     trash(uuid: string): Promise<T> {
17         return this.serverApi
18             .post(this.resourceType + `${uuid}/trash`)
19             .then(CommonResourceService.mapResponseKeys);
20     }
21
22     untrash(uuid: string): Promise<T> {
23         const params = {
24             ensure_unique_name: true
25         };
26         return this.serverApi
27             .post(this.resourceType + `${uuid}/untrash`, {
28                 params: CommonResourceService.mapKeys(_.snakeCase)(params)
29             })
30             .then(CommonResourceService.mapResponseKeys);
31     }
32 }