public async Task <CustomEntityTags> GetTagsAsync(EntitySelector entitySelector, Timeframe from = null, Timeframe to = null, CancellationToken cancellationToken = default) { var queryParamValues = new Dictionary <string, object>(); if (entitySelector is not null) { queryParamValues.Add(nameof(entitySelector), entitySelector.ToString()); } if (from is not null) { queryParamValues.Add(nameof(from), from.ToString()); } if (to is not null) { queryParamValues.Add(nameof(to), to.ToString()); } var response = await GetCustomTagsUrl() .SetQueryParams(queryParamValues) .GetJsonIfNotEmptyAsync(new CustomEntityTags(), cancellationToken) .ConfigureAwait(false); return(response); }
public async Task <ProblemsDto> GetProblemsV2Async(IEnumerable <WithOrWithout <ProblemFields> > fields = null, string nextPageKey = null, int?pageSize = null, Timeframe from = null, Timeframe to = null, ProblemSelector problemSelector = null, EntitySelector entitySelector = null, IEnumerable <AscendingOrDescending <ProblemSorts> > sort = null, CancellationToken cancellationToken = default) { var queryParamValues = new Dictionary <string, object> { [nameof(fields)] = string.Join(",", (fields ?? Enumerable.Empty <WithOrWithout <ProblemFields> >()) .Distinct() .Select(x => $"+{x.ToString().ToCamelCase()}")), [nameof(nextPageKey)] = nextPageKey, [nameof(pageSize)] = pageSize, [nameof(from)] = from?.ToString(), [nameof(to)] = to?.ToString(), [nameof(problemSelector)] = problemSelector?.ToString(), [nameof(entitySelector)] = entitySelector?.ToString(), [nameof(sort)] = string.Join(",", sort ?? Enumerable.Empty <AscendingOrDescending <ProblemSorts> >()) .Distinct() .Select(x => x.ToString().ToCamelCase()) }; var response = await GetProblemsV2Url() .SetQueryParams(queryParamValues) .GetJsonWithErrorCheckingAsync <ProblemsDto>(cancellationToken) .ConfigureAwait(false); return(response); }
public async Task <AddedEntityTags> AssignTagsAsync(EntitySelector entitySelector, AddEntityTags body, CancellationToken cancellationToken = default) { var response = await GetCustomTagsUrl() .SetQueryParam(nameof(entitySelector), entitySelector.ToString()) .PostJsonAsync(body, cancellationToken) .ReceiveJsonWithErrorChecking <AddedEntityTags>() .ConfigureAwait(false); return(response); }
public void ConvertToString() { var entitySelector = new EntitySelector { HealthState = HealthStates.Unhealthy }; string s = entitySelector.ToString(); Assert.NotNull(s); Assert.Equal("healthState(\"UNHEALTHY\")", s); }
public async Task <MetricData> GetMetricDataPointsV2Async(MetricResultFormats?resultFormat = null, string nextPageKey = null, int?pageSize = null, IEnumerable <string> metricSelector = null, string resolution = null, Timeframe from = null, Timeframe to = null, EntitySelector entitySelector = null, CancellationToken cancellationToken = default) { var queryParamValues = new Dictionary <string, object>(); if (nextPageKey is not null) { queryParamValues[nameof(nextPageKey)] = nextPageKey; } if (pageSize is not null) { queryParamValues[nameof(pageSize)] = pageSize; } if (metricSelector is not null) { queryParamValues[nameof(metricSelector)] = string.Join(",", metricSelector); } if (resolution is not null) { queryParamValues[nameof(resolution)] = resolution; } if (from is not null) { queryParamValues[nameof(from)] = from.ToString(); } if (to is not null) { queryParamValues[nameof(to)] = to.ToString(); } if (entitySelector is not null) { queryParamValues[nameof(entitySelector)] = entitySelector.ToString(); } var response = await GetMetricsV2Url() .WithHeader("Accept", s_metricResultFormatsConverter.ConvertToString(resultFormat ?? MetricResultFormats.ApplicationJson)) .SetQueryParams(queryParamValues) .GetJsonWithErrorCheckingAsync <MetricData>(cancellationToken) .ConfigureAwait(false); return(response); }
public async Task <EntitiesList> GetMonitoredEntitiesV2Async(string nextPageKey = null, int?pageSize = null, EntitySelector entitySelector = null, Timeframe from = null, Timeframe to = null, IEnumerable <WithOrWithout <string> > fields = null, CancellationToken cancellationToken = default) { var queryParamValues = new Dictionary <string, object>(); if (nextPageKey is not null) { queryParamValues[nameof(nextPageKey)] = nextPageKey; } if (pageSize is not null) { queryParamValues[nameof(pageSize)] = pageSize; } if (entitySelector is not null) { queryParamValues[nameof(entitySelector)] = entitySelector.ToString(); } if (from is not null) { queryParamValues[nameof(from)] = from.ToString(); } if (to is not null) { queryParamValues[nameof(to)] = to.ToString(); } if (fields is not null) { queryParamValues[nameof(fields)] = string.Join(",", fields .Distinct() .Select(x => $"+{x.ToString().ToCamelCase()}")).WithPrefixAndParentheses("fields="); } var response = await GetMonitoredEntitiesV2Url() .SetQueryParams(queryParamValues) .GetJsonIfNotEmptyAsync(new EntitiesList(), cancellationToken) .ConfigureAwait(false); return(response); }
public async Task <DeletedEntityTags> DeleteTagAsync(EntitySelector entitySelector, string key, string value = null, bool?deleteAllWithKey = null, CancellationToken cancellationToken = default) { var queryParamValues = new Dictionary <string, object> { [nameof(entitySelector)] = entitySelector.ToString(), [nameof(key)] = key, [nameof(value)] = value, [nameof(deleteAllWithKey)] = deleteAllWithKey }; var response = await GetCustomTagsUrl() .SetQueryParams(queryParamValues) .DeleteAsync(cancellationToken) .ReceiveJsonWithErrorChecking <DeletedEntityTags>() .ConfigureAwait(false); return(response); }