Exemple #1
0
        public async Task <IActionResult> Metric(string type, string source)
        {
            Metrics metricType;

            try
            {
                metricType = type.ToEnum <Metrics>();
            }
            catch (System.Exception)
            {
                return(BadRequest("Bad type. Needs to be one of Metrics type."));
            }

            var metrics = await _metricService.GetMetricsAsync(metricType, source);

            if (metrics.Count() == 0)
            {
                return(NotFound());
            }

            var metric = metrics.First();

            if (!_auth.IsAuthenticated() && !metric.Public)
            {
                return(Unauthorized());
            }

            return(new BadgeResult(
                       _badge.GetMetricHealthBadge(
                           metric.Source, (Metrics)metric.Type, (AutoLabels)metric.AutoLabel.Id
                           )
                       ));
        }