Merge branch '19421-restore-old-redirect-key' into main. Closes #19421
[arvados.git] / src / services / virtual-machines-service / virtual-machines-service.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { AxiosInstance } from "axios";
6 import { CommonResourceService } from "services/common-service/common-resource-service";
7 import { VirtualMachineLogins, VirtualMachinesResource } from 'models/virtual-machines';
8 import { ApiActions } from 'services/api/api-actions';
9
10 export class VirtualMachinesService extends CommonResourceService<VirtualMachinesResource> {
11     constructor(serverApi: AxiosInstance, actions: ApiActions) {
12         super(serverApi, "virtual_machines", actions);
13     }
14
15     getRequestedDate(): string {
16         return localStorage.getItem('requestedDate') || '';
17     }
18
19     saveRequestedDate(date: string) {
20         localStorage.setItem('requestedDate', date);
21     }
22
23     logins(uuid: string): Promise<VirtualMachineLogins> {
24         return CommonResourceService.defaultResponse(
25             this.serverApi
26                 .get(`virtual_machines/${uuid}/logins`),
27             this.actions
28         );
29     }
30
31     getAllLogins(): Promise<VirtualMachineLogins> {
32         return CommonResourceService.defaultResponse(
33             this.serverApi
34                 .get('virtual_machines/get_all_logins'),
35             this.actions
36         );
37     }
38 }