private void DeserializeMetrics(YamlMappingNode node, MetricDefinitionV1 metricDefinition, IErrorReporter errorReporter) { if (metricDefinition.ResourceType == null) { return; } var resourceTypeNode = node.Children["resourceType"]; if (metricDefinition.ResourceType == ResourceType.NotSpecified) { errorReporter.ReportError(resourceTypeNode, "'resourceType' must not be set to 'NotSpecified'."); return; } if (node.Children.TryGetValue(ResourcesTag, out var metricsNode)) { var resourceDeserializer = _azureResourceDeserializerFactory.GetDeserializerFor(metricDefinition.ResourceType.Value); if (resourceDeserializer != null) { metricDefinition.Resources = resourceDeserializer.Deserialize((YamlSequenceNode)metricsNode, errorReporter); } else { errorReporter.ReportError(resourceTypeNode, $"Could not find a deserializer for resource type '{metricDefinition.ResourceType}'."); } } else { errorReporter.ReportError(node, "'resources' is a required field but was not found."); } }
private void DeserializeMetrics(YamlMappingNode node, MetricDefinitionV1 metricDefinition) { if (metricDefinition.ResourceType != null && metricDefinition.ResourceType != ResourceType.NotSpecified && node.Children.TryGetValue(ResourcesTag, out var metricsNode)) { var resourceDeserializer = _azureResourceDeserializerFactory.GetDeserializerFor(metricDefinition.ResourceType.Value); metricDefinition.Resources = resourceDeserializer.Deserialize((YamlSequenceNode)metricsNode); } }
private void DeserializeMetrics(YamlMappingNode node, MetricDefinitionV1 metricDefinition, IErrorReporter errorReporter) { if (metricDefinition.ResourceType == null) { return; } var resourceTypeNode = node.Children["resourceType"]; if (metricDefinition.ResourceType == ResourceType.NotSpecified) { errorReporter.ReportError(resourceTypeNode, "'resourceType' must not be set to 'NotSpecified'."); return; } if (node.Children.TryGetValue(ResourceCollectionsTag, out var resourceCollectionNode)) { metricDefinition.ResourceCollections = _azureResourceCollectionDeserializer.Deserialize((YamlSequenceNode)resourceCollectionNode, errorReporter); } if (node.Children.TryGetValue(ResourcesTag, out var metricsNode)) { var resourceDeserializer = _azureResourceDeserializerFactory.GetDeserializerFor(metricDefinition.ResourceType.Value); if (resourceDeserializer != null) { metricDefinition.Resources = resourceDeserializer.Deserialize((YamlSequenceNode)metricsNode, errorReporter); } else { errorReporter.ReportError(resourceTypeNode, $"Could not find a deserializer for resource type '{metricDefinition.ResourceType}'."); } } if ((metricDefinition.Resources == null || !metricDefinition.Resources.Any()) && (metricDefinition.ResourceCollections == null || !metricDefinition.ResourceCollections.Any())) { errorReporter.ReportError(node, "Either 'resources' or 'resourceCollections' must be specified."); } }