HorizontalPodAutoscalerStatus.fromJson constructor

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

Creates a HorizontalPodAutoscalerStatus from JSON data.

Implementation

factory HorizontalPodAutoscalerStatus.fromJson(Map<String, dynamic> json) {
  final tempConditionsJson = json['conditions'];
  final tempCurrentMetricsJson = json['currentMetrics'];
  final tempCurrentReplicasJson = json['currentReplicas'];
  final tempDesiredReplicasJson = json['desiredReplicas'];
  final tempLastScaleTimeJson = json['lastScaleTime'];
  final tempObservedGenerationJson = json['observedGeneration'];

  final List<HorizontalPodAutoscalerCondition>? tempConditions =
      tempConditionsJson != null
          ? List<dynamic>.from(tempConditionsJson)
              .map(
                (e) => HorizontalPodAutoscalerCondition.fromJson(
                  Map<String, dynamic>.from(e),
                ),
              )
              .toList()
          : null;

  final List<MetricStatus>? tempCurrentMetrics =
      tempCurrentMetricsJson != null
          ? List<dynamic>.from(tempCurrentMetricsJson)
              .map(
                (e) => MetricStatus.fromJson(
                  Map<String, dynamic>.from(e),
                ),
              )
              .toList()
          : null;

  final int? tempCurrentReplicas = tempCurrentReplicasJson;
  final int tempDesiredReplicas = tempDesiredReplicasJson;
  final DateTime? tempLastScaleTime = tempLastScaleTimeJson != null
      ? DateTime.tryParse(tempLastScaleTimeJson)
      : null;
  final int? tempObservedGeneration = tempObservedGenerationJson;

  return HorizontalPodAutoscalerStatus(
    conditions: tempConditions,
    currentMetrics: tempCurrentMetrics,
    currentReplicas: tempCurrentReplicas,
    desiredReplicas: tempDesiredReplicas,
    lastScaleTime: tempLastScaleTime,
    observedGeneration: tempObservedGeneration,
  );
}