toJson method

Map<String, Object> toJson()

Converts a HorizontalPodAutoscalerSpec instance to JSON data.

Implementation

Map<String, Object> toJson() {
  final jsonData = <String, Object>{};

  final tempBehavior = behavior;
  final tempMaxReplicas = maxReplicas;
  final tempMetrics = metrics;
  final tempMinReplicas = minReplicas;
  final tempScaleTargetRef = scaleTargetRef;

  if (tempBehavior != null) {
    jsonData['behavior'] = tempBehavior.toJson();
  }

  jsonData['maxReplicas'] = tempMaxReplicas;

  if (tempMetrics != null) {
    jsonData['metrics'] =
        tempMetrics.map((e) => e.toJson()).toList(growable: false);
  }

  if (tempMinReplicas != null) {
    jsonData['minReplicas'] = tempMinReplicas;
  }

  jsonData['scaleTargetRef'] = tempScaleTargetRef.toJson();

  return jsonData;
}