toJson method
Converts a MetricSpec instance to JSON data.
Implementation
Map<String, Object> toJson() {
final jsonData = <String, Object>{};
if (containerResource != null) {
jsonData['containerResource'] = containerResource!.toJson();
}
if (external != null) {
jsonData['external'] = external!.toJson();
}
if (object != null) {
jsonData['object'] = object!.toJson();
}
if (pods != null) {
jsonData['pods'] = pods!.toJson();
}
if (resource != null) {
jsonData['resource'] = resource!.toJson();
}
jsonData['type'] = type;
return jsonData;
}