AutoscalingPolicy.fromJson constructor

AutoscalingPolicy.fromJson(
  1. Object? j
)

Implementation

factory AutoscalingPolicy.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return AutoscalingPolicy(
    coolDownPeriodSec: switch (json['coolDownPeriodSec']) {
      null => null,
      Object $1 => decodeInt($1),
    },
    cpuUtilization: switch (json['cpuUtilization']) {
      null => null,
      Object $1 => AutoscalingPolicyCpuUtilization.fromJson($1),
    },
    customMetricUtilizations: switch (json['customMetricUtilizations']) {
      null => [],
      List<Object?> $1 => [
        for (final i in $1)
          AutoscalingPolicyCustomMetricUtilization.fromJson(i),
      ],
      _ => throw const FormatException(
        '"customMetricUtilizations" is not a list',
      ),
    },
    loadBalancingUtilization: switch (json['loadBalancingUtilization']) {
      null => null,
      Object $1 => AutoscalingPolicyLoadBalancingUtilization.fromJson($1),
    },
    maxNumReplicas: switch (json['maxNumReplicas']) {
      null => null,
      Object $1 => decodeInt($1),
    },
    minNumReplicas: switch (json['minNumReplicas']) {
      null => null,
      Object $1 => decodeInt($1),
    },
    mode: switch (json['mode']) {
      null => null,
      Object $1 => decodeString($1),
    },
    scaleInControl: switch (json['scaleInControl']) {
      null => null,
      Object $1 => AutoscalingPolicyScaleInControl.fromJson($1),
    },
    scalingSchedules: switch (json['scalingSchedules']) {
      null => {},
      Map<String, Object?> $1 => {
        for (final e in $1.entries)
          decodeString(e.key): AutoscalingPolicyScalingSchedule.fromJson(
            e.value,
          ),
      },
      _ => throw const FormatException('"scalingSchedules" is not an object'),
    },
    stabilizationPeriodSec: switch (json['stabilizationPeriodSec']) {
      null => null,
      Object $1 => decodeInt($1),
    },
  );
}