NetworkPolicyIngressRule.fromJson constructor

NetworkPolicyIngressRule.fromJson(
  1. Map<String, dynamic> json
)

Creates a NetworkPolicyIngressRule from JSON data.

Implementation

factory NetworkPolicyIngressRule.fromJson(Map<String, dynamic> json) {
  final tempFromJson = json['from'];
  final tempPortsJson = json['ports'];

  final List<NetworkPolicyPeer>? tempFrom = tempFromJson != null
      ? List<dynamic>.from(tempFromJson)
          .map(
            (e) => NetworkPolicyPeer.fromJson(
              Map<String, dynamic>.from(e),
            ),
          )
          .toList()
      : null;

  final List<NetworkPolicyPort>? tempPorts = tempPortsJson != null
      ? List<dynamic>.from(tempPortsJson)
          .map(
            (e) => NetworkPolicyPort.fromJson(
              Map<String, dynamic>.from(e),
            ),
          )
          .toList()
      : null;

  return NetworkPolicyIngressRule(
    from: tempFrom,
    ports: tempPorts,
  );
}