PodAffinity.fromJson constructor

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

Creates a PodAffinity from JSON data.

Implementation

factory PodAffinity.fromJson(Map<String, dynamic> json) {
  final tempPreferredDuringSchedulingIgnoredDuringExecutionJson =
      json['preferredDuringSchedulingIgnoredDuringExecution'];
  final tempRequiredDuringSchedulingIgnoredDuringExecutionJson =
      json['requiredDuringSchedulingIgnoredDuringExecution'];

  final List<WeightedPodAffinityTerm>?
      tempPreferredDuringSchedulingIgnoredDuringExecution =
      tempPreferredDuringSchedulingIgnoredDuringExecutionJson != null
          ? List<dynamic>.from(
                  tempPreferredDuringSchedulingIgnoredDuringExecutionJson)
              .map(
                (e) => WeightedPodAffinityTerm.fromJson(
                  Map<String, dynamic>.from(e),
                ),
              )
              .toList()
          : null;

  final List<PodAffinityTerm>?
      tempRequiredDuringSchedulingIgnoredDuringExecution =
      tempRequiredDuringSchedulingIgnoredDuringExecutionJson != null
          ? List<dynamic>.from(
                  tempRequiredDuringSchedulingIgnoredDuringExecutionJson)
              .map(
                (e) => PodAffinityTerm.fromJson(
                  Map<String, dynamic>.from(e),
                ),
              )
              .toList()
          : null;

  return PodAffinity(
    preferredDuringSchedulingIgnoredDuringExecution:
        tempPreferredDuringSchedulingIgnoredDuringExecution,
    requiredDuringSchedulingIgnoredDuringExecution:
        tempRequiredDuringSchedulingIgnoredDuringExecution,
  );
}