public static TimeSeriesDescription GetTimeSeriesDescription(this IAquariusClient client, string identifier) { var locationIdentifier = TimeSeriesIdentifierParser.ParseLocationIdentifier(identifier); var response = client.Publish.Get(new TimeSeriesDescriptionServiceRequest { LocationIdentifier = client.FindLocationDescription(locationIdentifier).Identifier }); var caseInsensitiveMatches = response .TimeSeriesDescriptions .Where(t => t.Identifier.Equals(identifier, StringComparison.InvariantCultureIgnoreCase)) .ToList(); if (!caseInsensitiveMatches.Any()) { throw new ExpectedException($"Can't find '{identifier}' at location '{locationIdentifier}'"); } if (caseInsensitiveMatches.Count == 1) { return(caseInsensitiveMatches.Single()); } var exactMatch = caseInsensitiveMatches .FirstOrDefault(t => t.Identifier == identifier); if (exactMatch != null) { return(exactMatch); } throw new ExpectedException($"{caseInsensitiveMatches.Count} ambiguous matches for '{identifier}': {string.Join(", ", caseInsensitiveMatches.Select(t => t.Identifier))}"); }
public void CreateMissingTimeSeries(string timeSeriesIdentifier) { var locationIdentifier = TimeSeriesIdentifierParser.ParseLocationIdentifier(timeSeriesIdentifier); var location = GetOrCreateLocation(locationIdentifier); GetOrCreateTimeSeries(location, timeSeriesIdentifier); }
public static TimeSeriesDescription GetTimeSeriesDescription(this IAquariusClient client, string identifier) { var location = TimeSeriesIdentifierParser.ParseLocationIdentifier(identifier); var response = client.Publish.Get(new TimeSeriesDescriptionServiceRequest { LocationIdentifier = location }); var timeSeriesDescription = response.TimeSeriesDescriptions.FirstOrDefault(t => t.Identifier == identifier); if (timeSeriesDescription == null) { throw new ExpectedException($"Can't find '{identifier}' at location '{location}'"); } return(timeSeriesDescription); }