toJson method
Converts a NetworkPolicySpec instance to JSON data.
Implementation
Map<String, Object> toJson() {
final jsonData = <String, Object>{};
final tempEgress = egress;
final tempIngress = ingress;
final tempPodSelector = podSelector;
final tempPolicyTypes = policyTypes;
if (tempEgress != null) {
jsonData['egress'] =
tempEgress.map((e) => e.toJson()).toList(growable: false);
}
if (tempIngress != null) {
jsonData['ingress'] =
tempIngress.map((e) => e.toJson()).toList(growable: false);
}
jsonData['podSelector'] = tempPodSelector.toJson();
if (tempPolicyTypes != null) {
jsonData['policyTypes'] = tempPolicyTypes;
}
return jsonData;
}