15088: Saves account link data in session storage and logs out
[arvados.git] / src / services / container-request-service / container-request-service.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { snakeCase } from 'lodash';
6 import { CommonResourceService } from "~/services/common-service/common-resource-service";
7 import { AxiosInstance } from "axios";
8 import { ContainerRequestResource } from '~/models/container-request';
9 import { ApiActions } from "~/services/api/api-actions";
10
11 export class ContainerRequestService extends CommonResourceService<ContainerRequestResource> {
12     constructor(serverApi: AxiosInstance, actions: ApiActions) {
13         super(serverApi, "container_requests", actions);
14     }
15
16     create(data?: Partial<ContainerRequestResource>) {
17         if (data) {
18             const { mounts } = data;
19             if (mounts) {
20                 const mappedData = {
21                     ...CommonResourceService.mapKeys(snakeCase)(data),
22                     mounts,
23                 };
24                 return CommonResourceService
25                     .defaultResponse(
26                         this.serverApi.post<ContainerRequestResource>(this.resourceType, mappedData),
27                         this.actions);
28             }
29         }
30         return CommonResourceService
31             .defaultResponse(
32                 this.serverApi
33                     .post<ContainerRequestResource>(this.resourceType, data && CommonResourceService.mapKeys(snakeCase)(data)),
34                 this.actions);
35     }
36 }