import 'dart:convert'; class DhcpModel { int loadStatus = 0; DhcpData? data; DhcpModel({ required this.loadStatus, this.data, }); } class DhcpData { List networkInterfaces; DhcpStatus dhcpStatus; DhcpData({ required this.networkInterfaces, required this.dhcpStatus, }); } NetworkInterface networkInterfaceFromJson(String str) => NetworkInterface.fromJson(json.decode(str)); String networkInterfaceToJson(NetworkInterface data) => json.encode(data.toJson()); class NetworkInterface { String name; String hardwareAddress; List flags; String gatewayIp; List ipv4Addresses; List ipv6Addresses; NetworkInterface({ required this.name, required this.hardwareAddress, required this.flags, required this.gatewayIp, required this.ipv4Addresses, required this.ipv6Addresses, }); factory NetworkInterface.fromJson(Map json) => NetworkInterface( name: json["name"], hardwareAddress: json["hardware_address"], flags: json["flags"] != null ? json["flags"].split("|") : [], gatewayIp: json["gateway_ip"], ipv4Addresses: json["ipv4_addresses"] != null ? List.from(json["ipv4_addresses"].map((x) => x)) : [], ipv6Addresses: json["ipv6_addresses"] != null ? List.from(json["ipv6_addresses"].map((x) => x)) : [], ); Map toJson() => { "name": name, "hardware_address": hardwareAddress, "flags": flags, "gateway_ip": gatewayIp, "ipv4_addresses": List.from(ipv4Addresses.map((x) => x)), "ipv6_addresses": List.from(ipv6Addresses.map((x) => x)), }; } DhcpStatus dhcpStatusFromJson(String str) => DhcpStatus.fromJson(json.decode(str)); String dhcpStatusToJson(DhcpStatus data) => json.encode(data.toJson()); class DhcpStatus { String interfaceName; IpVersion v4; IpVersion v6; List leases; List staticLeases; bool enabled; DhcpStatus({ required this.interfaceName, required this.v4, required this.v6, required this.leases, required this.staticLeases, required this.enabled, }); factory DhcpStatus.fromJson(Map json) => DhcpStatus( interfaceName: json["interface_name"], v4: IpVersion.fromJson(json["v4"]), v6: IpVersion.fromJson(json["v6"]), leases: List.from(json["leases"].map((x) => Lease.fromJson(x))), staticLeases: List.from(json["static_leases"].map((x) => Lease.fromJson(x))), enabled: json["enabled"], ); Map toJson() => { "interface_name": interfaceName, "v4": v4.toJson(), "v6": v6.toJson(), "leases": List.from(leases.map((x) => x)), "static_leases": List.from(staticLeases.map((x) => x)), "enabled": enabled, }; } class IpVersion { String? gatewayIp; String? subnetMask; String rangeStart; String? rangeEnd; int leaseDuration; IpVersion({ this.gatewayIp, this.subnetMask, required this.rangeStart, this.rangeEnd, required this.leaseDuration, }); factory IpVersion.fromJson(Map json) => IpVersion( gatewayIp: json["gateway_ip"], subnetMask: json["subnet_mask"], rangeStart: json["range_start"], rangeEnd: json["range_end"], leaseDuration: json["lease_duration"], ); Map toJson() => { "gateway_ip": gatewayIp, "subnet_mask": subnetMask, "range_start": rangeStart, "range_end": rangeEnd, "lease_duration": leaseDuration, }; } class Lease { final String mac; final String hostname; final String ip; Lease({ required this.mac, required this.hostname, required this.ip, }); factory Lease.fromJson(Map json) => Lease( mac: json["mac"], hostname: json["hostname"], ip: json["ip"], ); Map toJson() => { "mac": mac, "hostname": hostname, "ip": ip, }; }