Can list and delete networks
This commit is contained in:
virtweb_frontend/src
50
virtweb_frontend/src/api/NetworksApi.ts
Normal file
50
virtweb_frontend/src/api/NetworksApi.ts
Normal file
@ -0,0 +1,50 @@
|
||||
import { APIClient } from "./ApiClient";
|
||||
|
||||
export interface IpConfig {
|
||||
bridge_address: string;
|
||||
prefix: number;
|
||||
dhcp_range?: [string, string];
|
||||
}
|
||||
|
||||
export interface NetworkInfo {
|
||||
name: string;
|
||||
uuid: string;
|
||||
title?: string;
|
||||
description?: string;
|
||||
forward_mode: "NAT" | "Isolated";
|
||||
device?: string;
|
||||
dns_server?: string;
|
||||
domain?: string;
|
||||
ip_v4?: IpConfig;
|
||||
ip_v6?: IpConfig;
|
||||
}
|
||||
|
||||
export function NetworkURL(n: NetworkInfo, edit: boolean = false): string {
|
||||
return `/net/${n.uuid}${edit ? "/edit" : ""}`;
|
||||
}
|
||||
|
||||
export class NetworkApi {
|
||||
/**
|
||||
* Get the entire list of networks
|
||||
*/
|
||||
static async GetList(): Promise<NetworkInfo[]> {
|
||||
return (
|
||||
await APIClient.exec({
|
||||
method: "GET",
|
||||
uri: "/network/list",
|
||||
})
|
||||
).data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a network
|
||||
*/
|
||||
static async Delete(n: NetworkInfo): Promise<NetworkInfo[]> {
|
||||
return (
|
||||
await APIClient.exec({
|
||||
method: "DELETE",
|
||||
uri: `/network/${n.uuid}`,
|
||||
})
|
||||
).data;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user