MetricDescriptor.fromJson constructor
MetricDescriptor.fromJson(
- Object? j
Implementation
factory MetricDescriptor.fromJson(Object? j) {
final json = j as Map<String, Object?>;
return MetricDescriptor(
name: switch (json['name']) {
null => '',
Object $1 => decodeString($1),
},
type: switch (json['type']) {
null => '',
Object $1 => decodeString($1),
},
labels: switch (json['labels']) {
null => [],
List<Object?> $1 => [for (final i in $1) LabelDescriptor.fromJson(i)],
_ => throw const FormatException('"labels" is not a list'),
},
metricKind: switch (json['metricKind']) {
null => MetricDescriptor_MetricKind.$default,
Object $1 => MetricDescriptor_MetricKind.fromJson($1),
},
valueType: switch (json['valueType']) {
null => MetricDescriptor_ValueType.$default,
Object $1 => MetricDescriptor_ValueType.fromJson($1),
},
unit: switch (json['unit']) {
null => '',
Object $1 => decodeString($1),
},
description: switch (json['description']) {
null => '',
Object $1 => decodeString($1),
},
displayName: switch (json['displayName']) {
null => '',
Object $1 => decodeString($1),
},
metadata: switch (json['metadata']) {
null => null,
Object $1 => MetricDescriptor_MetricDescriptorMetadata.fromJson($1),
},
launchStage: switch (json['launchStage']) {
null => LaunchStage.$default,
Object $1 => LaunchStage.fromJson($1),
},
monitoredResourceTypes: switch (json['monitoredResourceTypes']) {
null => [],
List<Object?> $1 => [for (final i in $1) decodeString(i)],
_ => throw const FormatException(
'"monitoredResourceTypes" is not a list',
),
},
);
}