HorizontalPodAutoscalerSpec.fromJson constructor

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

Creates a HorizontalPodAutoscalerSpec from JSON data.

Implementation

factory HorizontalPodAutoscalerSpec.fromJson(Map<String, dynamic> json) {
  final tempBehaviorJson = json['behavior'];
  final tempMaxReplicasJson = json['maxReplicas'];
  final tempMetricsJson = json['metrics'];
  final tempMinReplicasJson = json['minReplicas'];
  final tempScaleTargetRefJson = json['scaleTargetRef'];

  final HorizontalPodAutoscalerBehavior? tempBehavior =
      tempBehaviorJson != null
          ? HorizontalPodAutoscalerBehavior.fromJson(tempBehaviorJson)
          : null;
  final int tempMaxReplicas = tempMaxReplicasJson;

  final List<MetricSpec>? tempMetrics = tempMetricsJson != null
      ? List<dynamic>.from(tempMetricsJson)
          .map(
            (e) => MetricSpec.fromJson(
              Map<String, dynamic>.from(e),
            ),
          )
          .toList()
      : null;

  final int? tempMinReplicas = tempMinReplicasJson;
  final CrossVersionObjectReference tempScaleTargetRef =
      CrossVersionObjectReference.fromJson(tempScaleTargetRefJson);

  return HorizontalPodAutoscalerSpec(
    behavior: tempBehavior,
    maxReplicas: tempMaxReplicas,
    metrics: tempMetrics,
    minReplicas: tempMinReplicas,
    scaleTargetRef: tempScaleTargetRef,
  );
}