import '../../internal/json_utils.dart'; import 'network_subnet.dart'; /// Detailed network data from `GET /libpod/networks/{name}/json`. final class NetworkDetails { /// Creates network details. const NetworkDetails({ required this.id, required this.name, required this.driver, required this.networkInterface, required this.internal, required this.ipv6Enabled, required this.dnsEnabled, required this.createdAt, required this.labels, required this.options, required this.subnets, required this.raw, }); /// Network ID. final String id; /// Network name. final String name; /// Driver name. final String driver; /// Host interface name. final String networkInterface; /// Internal-only flag. final bool internal; /// IPv6-enabled flag. final bool ipv6Enabled; /// DNS-enabled flag. final bool dnsEnabled; /// Creation timestamp. final DateTime? createdAt; /// Labels. final Map labels; /// Driver options. final Map options; /// Subnet definitions. final List subnets; /// Raw payload. final Map raw; /// Builds [NetworkDetails] from JSON. factory NetworkDetails.fromJson(Map json) { return NetworkDetails( id: asString(json['id']) ?? asString(json['Id']) ?? '', name: asString(json['name']) ?? asString(json['Name']) ?? '', driver: asString(json['driver']) ?? asString(json['Driver']) ?? '', networkInterface: asString(json['network_interface']) ?? asString(json['NetworkInterface']) ?? '', internal: asBool(json['internal']) ?? false, ipv6Enabled: asBool(json['ipv6_enabled']) ?? false, dnsEnabled: asBool(json['dns_enabled']) ?? false, createdAt: DateTime.tryParse(asString(json['created']) ?? ''), labels: asStringMap(json['labels']), options: asStringMap(json['options']), subnets: asJsonList( json['subnets'], ).map(asJsonMap).map(NetworkSubnet.fromJson).toList(growable: false), raw: json, ); } }