AutoscalingMetricSpec.fromJson constructor

AutoscalingMetricSpec.fromJson(
  1. Object? j
)

Implementation

factory AutoscalingMetricSpec.fromJson(Object? j) {
  final json = j as Map<String, Object?>;
  return AutoscalingMetricSpec(
    metricName: switch (json['metricName']) {
      null => '',
      Object $1 => decodeString($1),
    },
    target: switch (json['target']) {
      null => 0,
      Object $1 => decodeInt($1),
    },
    monitoredResourceLabels: switch (json['monitoredResourceLabels']) {
      null => {},
      Map<String, Object?> $1 => {
        for (final e in $1.entries)
          decodeString(e.key): decodeString(e.value),
      },
      _ => throw const FormatException(
        '"monitoredResourceLabels" is not an object',
      ),
    },
  );
}