NetworkPolicySpec.fromJson constructor
Creates a NetworkPolicySpec from JSON data.
Implementation
factory NetworkPolicySpec.fromJson(Map<String, dynamic> json) {
final tempEgressJson = json['egress'];
final tempIngressJson = json['ingress'];
final tempPodSelectorJson = json['podSelector'];
final tempPolicyTypesJson = json['policyTypes'];
final List<NetworkPolicyEgressRule>? tempEgress = tempEgressJson != null
? List<dynamic>.from(tempEgressJson)
.map(
(e) => NetworkPolicyEgressRule.fromJson(
Map<String, dynamic>.from(e),
),
)
.toList()
: null;
final List<NetworkPolicyIngressRule>? tempIngress = tempIngressJson != null
? List<dynamic>.from(tempIngressJson)
.map(
(e) => NetworkPolicyIngressRule.fromJson(
Map<String, dynamic>.from(e),
),
)
.toList()
: null;
final LabelSelector tempPodSelector =
LabelSelector.fromJson(tempPodSelectorJson);
final List<String>? tempPolicyTypes = tempPolicyTypesJson != null
? List<String>.from(tempPolicyTypesJson)
: null;
return NetworkPolicySpec(
egress: tempEgress,
ingress: tempIngress,
podSelector: tempPodSelector,
policyTypes: tempPolicyTypes,
);
}