Update machine-api for modified api schema (#3572)

update to new machine-api format
This commit is contained in:
Paul Tagliamonte
2024-08-28 15:15:37 -04:00
committed by GitHub
parent 5e8227ead8
commit 1162ff3b03
7 changed files with 197 additions and 2880 deletions

View File

@ -1,15 +1,16 @@
import { isDesktop } from './isDesktop'
import { components } from './machine-api'
export type MachinesListing = {
[key: string]: components['schemas']['Machine']
}
export type MachinesListing = Array<
components['schemas']['MachineInfoResponse']
>
export class MachineManager {
private _isDesktop: boolean = isDesktop()
private _machines: MachinesListing = {}
private _machines: MachinesListing = []
private _machineApiIp: string | null = null
private _currentMachine: components['schemas']['Machine'] | null = null
private _currentMachine: components['schemas']['MachineInfoResponse'] | null =
null
constructor() {
if (!this._isDesktop) {
@ -44,7 +45,7 @@ export class MachineManager {
}
machineCount(): number {
return Object.keys(this._machines).length
return this._machines.length
}
get machineApiIp(): string | null {
@ -64,11 +65,13 @@ export class MachineManager {
return 'Machine API server was discovered, but no machines are available'
}
get currentMachine(): components['schemas']['Machine'] | null {
get currentMachine(): components['schemas']['MachineInfoResponse'] | null {
return this._currentMachine
}
set currentMachine(machine: components['schemas']['Machine'] | null) {
set currentMachine(
machine: components['schemas']['MachineInfoResponse'] | null
) {
this._currentMachine = machine
}