public async Task <Response <MetricsResponse> > GetLogAnalyticsMetricsAsync(string subscriptionId, string resourceGroupName, string profileName, IEnumerable <LogMetric> metrics, DateTimeOffset dateTimeBegin, DateTimeOffset dateTimeEnd, LogMetricsGranularity granularity, IEnumerable <string> customDomains, IEnumerable <string> protocols, IEnumerable <LogMetricsGroupBy> groupBy = null, IEnumerable <string> continents = null, IEnumerable <string> countryOrRegions = null, CancellationToken cancellationToken = default) { Argument.AssertNotNullOrEmpty(subscriptionId, nameof(subscriptionId)); Argument.AssertNotNullOrEmpty(resourceGroupName, nameof(resourceGroupName)); Argument.AssertNotNullOrEmpty(profileName, nameof(profileName)); Argument.AssertNotNull(metrics, nameof(metrics)); Argument.AssertNotNull(customDomains, nameof(customDomains)); Argument.AssertNotNull(protocols, nameof(protocols)); using var message = CreateGetLogAnalyticsMetricsRequest(subscriptionId, resourceGroupName, profileName, metrics, dateTimeBegin, dateTimeEnd, granularity, customDomains, protocols, groupBy, continents, countryOrRegions); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { case 200: { MetricsResponse value = default; using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); value = MetricsResponse.DeserializeMetricsResponse(document.RootElement); return(Response.FromValue(value, message.Response)); }
internal HttpMessage CreateGetLogAnalyticsMetricsRequest(string subscriptionId, string resourceGroupName, string profileName, IEnumerable <LogMetric> metrics, DateTimeOffset dateTimeBegin, DateTimeOffset dateTimeEnd, LogMetricsGranularity granularity, IEnumerable <string> customDomains, IEnumerable <string> protocols, IEnumerable <LogMetricsGroupBy> groupBy, IEnumerable <string> continents, IEnumerable <string> countryOrRegions) { var message = _pipeline.CreateMessage(); var request = message.Request; request.Method = RequestMethod.Get; var uri = new RawRequestUriBuilder(); uri.Reset(_endpoint); uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/resourceGroups/", false); uri.AppendPath(resourceGroupName, true); uri.AppendPath("/providers/Microsoft.Cdn/profiles/", false); uri.AppendPath(profileName, true); uri.AppendPath("/getLogAnalyticsMetrics", false); uri.AppendQuery("api-version", _apiVersion, true); foreach (var param in metrics) { uri.AppendQuery("metrics", param.ToString(), true); } uri.AppendQuery("dateTimeBegin", dateTimeBegin, "O", true); uri.AppendQuery("dateTimeEnd", dateTimeEnd, "O", true); uri.AppendQuery("granularity", granularity.ToString(), true); if (groupBy != null) { foreach (var param0 in groupBy) { uri.AppendQuery("groupBy", param0.ToString(), true); } } if (continents != null) { foreach (var param0 in continents) { uri.AppendQuery("continents", param0, true); } } if (countryOrRegions != null) { foreach (var param0 in countryOrRegions) { uri.AppendQuery("countryOrRegions", param0, true); } } foreach (var param1 in customDomains) { uri.AppendQuery("customDomains", param1, true); } foreach (var param2 in protocols) { uri.AppendQuery("protocols", param2, true); } request.Uri = uri; request.Headers.Add("Accept", "application/json"); _userAgent.Apply(message); return(message); }
/// <summary> /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider" /// /> and <see cref="ignoreCase" /> /// </summary> /// <param name="sourceValue">the <see cref="System.Object"/> to convert from</param> /// <param name="destinationType">the <see cref="System.Type" /> to convert to</param> /// <param name="formatProvider">not used by this TypeConverter.</param> /// <param name="ignoreCase">when set to <c>true</c>, will ignore the case when converting.</param> /// <returns> /// an instance of <see cref="LogMetricsGranularity" />, or <c>null</c> if there is no suitable conversion. /// </returns> public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => LogMetricsGranularity.CreateFrom(sourceValue);