From f2c56e59e60cd1a42d2d6f5aa14e1c0dbff48db6 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Fri, 1 Sep 2023 16:05:14 -0700 Subject: [PATCH 01/36] wip --- .../src/Generated/MetricsBatchRestClient.cs | 227 +++++++ ...ditionalInfoErrorResponse.Serialization.cs | 33 + .../Models/AdditionalInfoErrorResponse.cs | 29 + ...nalInfoErrorResponseError.Serialization.cs | 55 ++ .../AdditionalInfoErrorResponseError.cs | 49 ++ ...seErrorAdditionalInfoItem.Serialization.cs | 39 ++ ...nfoErrorResponseErrorAdditionalInfoItem.cs | 32 + .../MetricResultsResponse.Serialization.cs | 43 ++ .../Generated/Models/MetricResultsResponse.cs | 32 + ...ResultsResponseValuesItem.Serialization.cs | 80 +++ .../Models/MetricResultsResponseValuesItem.cs | 68 +++ ...eryBatchLocalizableString.Serialization.cs | 39 ++ .../Models/QueryBatchLocalizableString.cs | 40 ++ .../QueryBatchMetadataValue.Serialization.cs | 43 ++ .../Models/QueryBatchMetadataValue.cs | 32 + .../Models/QueryBatchMetric.Serialization.cs | 81 +++ .../src/Generated/Models/QueryBatchMetric.cs | 80 +++ .../QueryBatchMetricUnit.Serialization.cs | 50 ++ .../Generated/Models/QueryBatchMetricUnit.cs | 40 ++ .../QueryBatchMetricValue.Serialization.cs | 84 +++ .../Generated/Models/QueryBatchMetricValue.cs | 52 ++ ...eryBatchTimeSeriesElement.Serialization.cs | 58 ++ .../Models/QueryBatchTimeSeriesElement.cs | 37 ++ .../Models/ResourceIdList.Serialization.cs | 36 ++ .../src/Generated/Models/ResourceIdList.cs | 25 + .../src/Generated/MonitorQueryModelFactory.cs | 88 +++ .../Azure.Monitor.Query/src/autorest.md | 1 + .../Azure.Monitor.Query/src/metricBatch.json | 562 ++++++++++++++++++ 28 files changed, 2035 insertions(+) create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/MetricsBatchRestClient.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponse.Serialization.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponse.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponseError.Serialization.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponseError.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponseErrorAdditionalInfoItem.Serialization.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponseErrorAdditionalInfoItem.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponse.Serialization.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponse.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.Serialization.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchLocalizableString.Serialization.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchLocalizableString.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetadataValue.Serialization.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetadataValue.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetric.Serialization.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetric.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetricUnit.Serialization.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetricUnit.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetricValue.Serialization.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetricValue.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchTimeSeriesElement.Serialization.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchTimeSeriesElement.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.Serialization.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/metricBatch.json diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/MetricsBatchRestClient.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/MetricsBatchRestClient.cs new file mode 100644 index 000000000000..4f9968e3a3fb --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/MetricsBatchRestClient.cs @@ -0,0 +1,227 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.Monitor.Query.Models; + +namespace Azure.Monitor.Query +{ + internal partial class MetricsBatchRestClient + { + private readonly HttpPipeline _pipeline; + private readonly Uri _endpoint; + + /// The ClientDiagnostics is used to provide tracing support for the client library. + internal ClientDiagnostics ClientDiagnostics { get; } + + /// Initializes a new instance of MetricsBatchRestClient. + /// The handler for diagnostic messaging in the client. + /// The HTTP pipeline for sending and receiving REST requests and responses. + /// The regional endpoint to use, for example https://eastus.metrics.monitor.azure.com. The region should match the region of the requested resources. For global resources, the region should be 'global'. + /// , or is null. + public MetricsBatchRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline pipeline, Uri endpoint) + { + ClientDiagnostics = clientDiagnostics ?? throw new ArgumentNullException(nameof(clientDiagnostics)); + _pipeline = pipeline ?? throw new ArgumentNullException(nameof(pipeline)); + _endpoint = endpoint ?? throw new ArgumentNullException(nameof(endpoint)); + } + + internal HttpMessage CreateBatchRequest(string subscriptionId, string metricnamespace, IEnumerable metricnames, ResourceIdList resourceIds, string starttime, string endtime, TimeSpan? interval, string aggregation, int? top, string orderby, string filter) + { + var message = _pipeline.CreateMessage(); + var request = message.Request; + request.Method = RequestMethod.Post; + var uri = new RawRequestUriBuilder(); + uri.Reset(_endpoint); + uri.AppendPath("/subscriptions/", false); + uri.AppendPath(subscriptionId, true); + uri.AppendPath("/metrics:getBatch", false); + if (starttime != null) + { + uri.AppendQuery("starttime", starttime, true); + } + if (endtime != null) + { + uri.AppendQuery("endtime", endtime, true); + } + if (interval != null) + { + uri.AppendQuery("interval", interval.Value, "P", true); + } + uri.AppendQuery("metricnamespace", metricnamespace, true); + if (metricnames != null && Optional.IsCollectionDefined(metricnames)) + { + uri.AppendQueryDelimited("metricnames", metricnames, ",", true); + } + if (aggregation != null) + { + uri.AppendQuery("aggregation", aggregation, true); + } + if (top != null) + { + uri.AppendQuery("top", top.Value, true); + } + if (orderby != null) + { + uri.AppendQuery("orderby", orderby, true); + } + if (filter != null) + { + uri.AppendQuery("filter", filter, true); + } + uri.AppendQuery("api-version", "2023-05-01-preview", true); + request.Uri = uri; + request.Headers.Add("Accept", "application/json"); + request.Headers.Add("Content-Type", "application/json"); + var content = new Utf8JsonRequestContent(); + content.JsonWriter.WriteObjectValue(resourceIds); + request.Content = content; + return message; + } + + /// Lists the metric values for multiple resources. + /// The subscription identifier for the resources in this batch. + /// Metric namespace that contains the requested metric names. + /// The names of the metrics (comma separated) to retrieve. + /// The comma separated list of resource IDs to query metrics for. + /// + /// The start time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. If you have specified the endtime parameter, then this parameter is required. + /// If only starttime is specified, then endtime defaults to the current time. + /// If no time interval is specified, the default is 1 hour. + /// + /// The end time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. + /// + /// The interval (i.e. timegrain) of the query. + /// *Examples: PT15M, PT1H, P1D* + /// + /// + /// The list of aggregation types (comma separated) to retrieve. + /// *Examples: average, minimum, maximum* + /// + /// + /// The maximum number of records to retrieve per resource ID in the request. + /// Valid only if filter is specified. + /// Defaults to 10. + /// + /// + /// The aggregation to use for sorting results and the direction of the sort. + /// Only one order can be specified. + /// *Examples: sum asc* + /// + /// The filter is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. + /// The cancellation token to use. + /// , , or is null. + public async Task> BatchAsync(string subscriptionId, string metricnamespace, IEnumerable metricnames, ResourceIdList resourceIds, string starttime = null, string endtime = null, TimeSpan? interval = null, string aggregation = null, int? top = null, string orderby = null, string filter = null, CancellationToken cancellationToken = default) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (metricnamespace == null) + { + throw new ArgumentNullException(nameof(metricnamespace)); + } + if (metricnames == null) + { + throw new ArgumentNullException(nameof(metricnames)); + } + if (resourceIds == null) + { + throw new ArgumentNullException(nameof(resourceIds)); + } + + using var message = CreateBatchRequest(subscriptionId, metricnamespace, metricnames, resourceIds, starttime, endtime, interval, aggregation, top, orderby, filter); + await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); + switch (message.Response.Status) + { + case 200: + { + MetricResultsResponse value = default; + using var document = await JsonDocument.ParseAsync(message.Response.ContentStream, default, cancellationToken).ConfigureAwait(false); + value = MetricResultsResponse.DeserializeMetricResultsResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + + /// Lists the metric values for multiple resources. + /// The subscription identifier for the resources in this batch. + /// Metric namespace that contains the requested metric names. + /// The names of the metrics (comma separated) to retrieve. + /// The comma separated list of resource IDs to query metrics for. + /// + /// The start time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. If you have specified the endtime parameter, then this parameter is required. + /// If only starttime is specified, then endtime defaults to the current time. + /// If no time interval is specified, the default is 1 hour. + /// + /// The end time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. + /// + /// The interval (i.e. timegrain) of the query. + /// *Examples: PT15M, PT1H, P1D* + /// + /// + /// The list of aggregation types (comma separated) to retrieve. + /// *Examples: average, minimum, maximum* + /// + /// + /// The maximum number of records to retrieve per resource ID in the request. + /// Valid only if filter is specified. + /// Defaults to 10. + /// + /// + /// The aggregation to use for sorting results and the direction of the sort. + /// Only one order can be specified. + /// *Examples: sum asc* + /// + /// The filter is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. + /// The cancellation token to use. + /// , , or is null. + public Response Batch(string subscriptionId, string metricnamespace, IEnumerable metricnames, ResourceIdList resourceIds, string starttime = null, string endtime = null, TimeSpan? interval = null, string aggregation = null, int? top = null, string orderby = null, string filter = null, CancellationToken cancellationToken = default) + { + if (subscriptionId == null) + { + throw new ArgumentNullException(nameof(subscriptionId)); + } + if (metricnamespace == null) + { + throw new ArgumentNullException(nameof(metricnamespace)); + } + if (metricnames == null) + { + throw new ArgumentNullException(nameof(metricnames)); + } + if (resourceIds == null) + { + throw new ArgumentNullException(nameof(resourceIds)); + } + + using var message = CreateBatchRequest(subscriptionId, metricnamespace, metricnames, resourceIds, starttime, endtime, interval, aggregation, top, orderby, filter); + _pipeline.Send(message, cancellationToken); + switch (message.Response.Status) + { + case 200: + { + MetricResultsResponse value = default; + using var document = JsonDocument.Parse(message.Response.ContentStream); + value = MetricResultsResponse.DeserializeMetricResultsResponse(document.RootElement); + return Response.FromValue(value, message.Response); + } + default: + throw new RequestFailedException(message.Response); + } + } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponse.Serialization.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponse.Serialization.cs new file mode 100644 index 000000000000..7ba720e24ad3 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponse.Serialization.cs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + internal partial class AdditionalInfoErrorResponse + { + internal static AdditionalInfoErrorResponse DeserializeAdditionalInfoErrorResponse(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + AdditionalInfoErrorResponseError error = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("error"u8)) + { + error = AdditionalInfoErrorResponseError.DeserializeAdditionalInfoErrorResponseError(property.Value); + continue; + } + } + return new AdditionalInfoErrorResponse(error); + } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponse.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponse.cs new file mode 100644 index 000000000000..c88e253b8bf2 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponse.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + /// The response to a metrics query that results in a bad request, with optional additional information. + internal partial class AdditionalInfoErrorResponse + { + /// Initializes a new instance of AdditionalInfoErrorResponse. + /// Top level error object that contains all relevant information. + /// is null. + internal AdditionalInfoErrorResponse(AdditionalInfoErrorResponseError error) + { + Argument.AssertNotNull(error, nameof(error)); + + Error = error; + } + + /// Top level error object that contains all relevant information. + public AdditionalInfoErrorResponseError Error { get; } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponseError.Serialization.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponseError.Serialization.cs new file mode 100644 index 000000000000..6fbb6ffd3697 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponseError.Serialization.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + internal partial class AdditionalInfoErrorResponseError + { + internal static AdditionalInfoErrorResponseError DeserializeAdditionalInfoErrorResponseError(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> additionalInfo = default; + string code = default; + string message = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("additionalInfo"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(AdditionalInfoErrorResponseErrorAdditionalInfoItem.DeserializeAdditionalInfoErrorResponseErrorAdditionalInfoItem(item)); + } + additionalInfo = array; + continue; + } + if (property.NameEquals("code"u8)) + { + code = property.Value.GetString(); + continue; + } + if (property.NameEquals("message"u8)) + { + message = property.Value.GetString(); + continue; + } + } + return new AdditionalInfoErrorResponseError(Optional.ToList(additionalInfo), code, message); + } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponseError.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponseError.cs new file mode 100644 index 000000000000..9a9e3b59cea4 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponseError.cs @@ -0,0 +1,49 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + /// Top level error object that contains all relevant information. + internal partial class AdditionalInfoErrorResponseError + { + /// Initializes a new instance of AdditionalInfoErrorResponseError. + /// Error code. + /// Error message indicating why the operation failed. + /// or is null. + internal AdditionalInfoErrorResponseError(string code, string message) + { + Argument.AssertNotNull(code, nameof(code)); + Argument.AssertNotNull(message, nameof(message)); + + AdditionalInfo = new ChangeTrackingList(); + Code = code; + Message = message; + } + + /// Initializes a new instance of AdditionalInfoErrorResponseError. + /// Additional information about the error. + /// Error code. + /// Error message indicating why the operation failed. + internal AdditionalInfoErrorResponseError(IReadOnlyList additionalInfo, string code, string message) + { + AdditionalInfo = additionalInfo; + Code = code; + Message = message; + } + + /// Additional information about the error. + public IReadOnlyList AdditionalInfo { get; } + /// Error code. + public string Code { get; } + /// Error message indicating why the operation failed. + public string Message { get; } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponseErrorAdditionalInfoItem.Serialization.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponseErrorAdditionalInfoItem.Serialization.cs new file mode 100644 index 000000000000..7b5f218f7af4 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponseErrorAdditionalInfoItem.Serialization.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + internal partial class AdditionalInfoErrorResponseErrorAdditionalInfoItem + { + internal static AdditionalInfoErrorResponseErrorAdditionalInfoItem DeserializeAdditionalInfoErrorResponseErrorAdditionalInfoItem(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional type = default; + Optional info = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("info"u8)) + { + info = property.Value.GetString(); + continue; + } + } + return new AdditionalInfoErrorResponseErrorAdditionalInfoItem(type.Value, info.Value); + } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponseErrorAdditionalInfoItem.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponseErrorAdditionalInfoItem.cs new file mode 100644 index 000000000000..eda896e6ff82 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponseErrorAdditionalInfoItem.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.Monitor.Query.Models +{ + /// The AdditionalInfoErrorResponseErrorAdditionalInfoItem. + internal partial class AdditionalInfoErrorResponseErrorAdditionalInfoItem + { + /// Initializes a new instance of AdditionalInfoErrorResponseErrorAdditionalInfoItem. + internal AdditionalInfoErrorResponseErrorAdditionalInfoItem() + { + } + + /// Initializes a new instance of AdditionalInfoErrorResponseErrorAdditionalInfoItem. + /// The type of the info property (e.g. string). + /// Additional information related to the error. + internal AdditionalInfoErrorResponseErrorAdditionalInfoItem(string type, string info) + { + Type = type; + Info = info; + } + + /// The type of the info property (e.g. string). + public string Type { get; } + /// Additional information related to the error. + public string Info { get; } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponse.Serialization.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponse.Serialization.cs new file mode 100644 index 000000000000..cac5dbf5e6b7 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponse.Serialization.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + public partial class MetricResultsResponse + { + internal static MetricResultsResponse DeserializeMetricResultsResponse(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> values = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("values"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(MetricResultsResponseValuesItem.DeserializeMetricResultsResponseValuesItem(item)); + } + values = array; + continue; + } + } + return new MetricResultsResponse(Optional.ToList(values)); + } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponse.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponse.cs new file mode 100644 index 000000000000..f9b129a01dbf --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponse.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + /// The metrics result for a resource. + public partial class MetricResultsResponse + { + /// Initializes a new instance of MetricResultsResponse. + internal MetricResultsResponse() + { + Values = new ChangeTrackingList(); + } + + /// Initializes a new instance of MetricResultsResponse. + /// The collection of metric data responses per resource, per metric. + internal MetricResultsResponse(IReadOnlyList values) + { + Values = values; + } + + /// The collection of metric data responses per resource, per metric. + public IReadOnlyList Values { get; } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.Serialization.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.Serialization.cs new file mode 100644 index 000000000000..de68768b0929 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.Serialization.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + public partial class MetricResultsResponseValuesItem + { + internal static MetricResultsResponseValuesItem DeserializeMetricResultsResponseValuesItem(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string starttime = default; + string endtime = default; + Optional interval = default; + Optional @namespace = default; + Optional resourceregion = default; + Optional resourceid = default; + IReadOnlyList value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("starttime"u8)) + { + starttime = property.Value.GetString(); + continue; + } + if (property.NameEquals("endtime"u8)) + { + endtime = property.Value.GetString(); + continue; + } + if (property.NameEquals("interval"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + interval = property.Value.GetTimeSpan("P"); + continue; + } + if (property.NameEquals("namespace"u8)) + { + @namespace = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceregion"u8)) + { + resourceregion = property.Value.GetString(); + continue; + } + if (property.NameEquals("resourceid"u8)) + { + resourceid = property.Value.GetString(); + continue; + } + if (property.NameEquals("value"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(QueryBatchMetric.DeserializeQueryBatchMetric(item)); + } + value = array; + continue; + } + } + return new MetricResultsResponseValuesItem(starttime, endtime, Optional.ToNullable(interval), @namespace.Value, resourceregion.Value, resourceid.Value, value); + } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.cs new file mode 100644 index 000000000000..fa77cd65b910 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + /// The MetricResultsResponseValuesItem. + public partial class MetricResultsResponseValuesItem + { + /// Initializes a new instance of MetricResultsResponseValuesItem. + /// The start time, in datetime format, for which the data was retrieved. + /// The end time, in datetime format, for which the data was retrieved. + /// The value of the collection. + /// , or is null. + internal MetricResultsResponseValuesItem(string starttime, string endtime, IEnumerable value) + { + Argument.AssertNotNull(starttime, nameof(starttime)); + Argument.AssertNotNull(endtime, nameof(endtime)); + Argument.AssertNotNull(value, nameof(value)); + + Starttime = starttime; + Endtime = endtime; + Value = value.ToList(); + } + + /// Initializes a new instance of MetricResultsResponseValuesItem. + /// The start time, in datetime format, for which the data was retrieved. + /// The end time, in datetime format, for which the data was retrieved. + /// The interval (window size) for which the metric data was returned in. Follows the IS8601/RFC3339 duration format (e.g. 'P1D' for 1 day). This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. + /// The namespace of the metrics been queried. + /// The region of the resource been queried for metrics. + /// The resource that has been queried for metrics. + /// The value of the collection. + internal MetricResultsResponseValuesItem(string starttime, string endtime, TimeSpan? interval, string @namespace, string resourceregion, string resourceid, IReadOnlyList value) + { + Starttime = starttime; + Endtime = endtime; + Interval = interval; + Namespace = @namespace; + Resourceregion = resourceregion; + Resourceid = resourceid; + Value = value; + } + + /// The start time, in datetime format, for which the data was retrieved. + public string Starttime { get; } + /// The end time, in datetime format, for which the data was retrieved. + public string Endtime { get; } + /// The interval (window size) for which the metric data was returned in. Follows the IS8601/RFC3339 duration format (e.g. 'P1D' for 1 day). This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. + public TimeSpan? Interval { get; } + /// The namespace of the metrics been queried. + public string Namespace { get; } + /// The region of the resource been queried for metrics. + public string Resourceregion { get; } + /// The resource that has been queried for metrics. + public string Resourceid { get; } + /// The value of the collection. + public IReadOnlyList Value { get; } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchLocalizableString.Serialization.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchLocalizableString.Serialization.cs new file mode 100644 index 000000000000..ec5865be531c --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchLocalizableString.Serialization.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + public partial class QueryBatchLocalizableString + { + internal static QueryBatchLocalizableString DeserializeQueryBatchLocalizableString(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string value = default; + Optional localizedValue = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("value"u8)) + { + value = property.Value.GetString(); + continue; + } + if (property.NameEquals("localizedValue"u8)) + { + localizedValue = property.Value.GetString(); + continue; + } + } + return new QueryBatchLocalizableString(value, localizedValue.Value); + } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchLocalizableString.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchLocalizableString.cs new file mode 100644 index 000000000000..ea2db1594e6b --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchLocalizableString.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + /// The localizable string class. + public partial class QueryBatchLocalizableString + { + /// Initializes a new instance of QueryBatchLocalizableString. + /// The invariant value. + /// is null. + internal QueryBatchLocalizableString(string value) + { + Argument.AssertNotNull(value, nameof(value)); + + Value = value; + } + + /// Initializes a new instance of QueryBatchLocalizableString. + /// The invariant value. + /// The display name. + internal QueryBatchLocalizableString(string value, string localizedValue) + { + Value = value; + LocalizedValue = localizedValue; + } + + /// The invariant value. + public string Value { get; } + /// The display name. + public string LocalizedValue { get; } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetadataValue.Serialization.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetadataValue.Serialization.cs new file mode 100644 index 000000000000..257ba6da9b85 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetadataValue.Serialization.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + public partial class QueryBatchMetadataValue + { + internal static QueryBatchMetadataValue DeserializeQueryBatchMetadataValue(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional name = default; + Optional value = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("name"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + name = QueryBatchLocalizableString.DeserializeQueryBatchLocalizableString(property.Value); + continue; + } + if (property.NameEquals("value"u8)) + { + value = property.Value.GetString(); + continue; + } + } + return new QueryBatchMetadataValue(name.Value, value.Value); + } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetadataValue.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetadataValue.cs new file mode 100644 index 000000000000..d61fd87d4cc8 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetadataValue.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.Monitor.Query.Models +{ + /// Represents a metric metadata value. + public partial class QueryBatchMetadataValue + { + /// Initializes a new instance of QueryBatchMetadataValue. + internal QueryBatchMetadataValue() + { + } + + /// Initializes a new instance of QueryBatchMetadataValue. + /// The name of the metadata. + /// The value of the metadata. + internal QueryBatchMetadataValue(QueryBatchLocalizableString name, string value) + { + Name = name; + Value = value; + } + + /// The name of the metadata. + public QueryBatchLocalizableString Name { get; } + /// The value of the metadata. + public string Value { get; } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetric.Serialization.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetric.Serialization.cs new file mode 100644 index 000000000000..99e7839d2bf6 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetric.Serialization.cs @@ -0,0 +1,81 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + public partial class QueryBatchMetric + { + internal static QueryBatchMetric DeserializeQueryBatchMetric(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + string id = default; + QueryBatchLocalizableString name = default; + string displayDescription = default; + string type = default; + QueryBatchMetricUnit unit = default; + IReadOnlyList timeseries = default; + Optional errorCode = default; + Optional errorMessage = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("id"u8)) + { + id = property.Value.GetString(); + continue; + } + if (property.NameEquals("name"u8)) + { + name = QueryBatchLocalizableString.DeserializeQueryBatchLocalizableString(property.Value); + continue; + } + if (property.NameEquals("displayDescription"u8)) + { + displayDescription = property.Value.GetString(); + continue; + } + if (property.NameEquals("type"u8)) + { + type = property.Value.GetString(); + continue; + } + if (property.NameEquals("unit"u8)) + { + unit = property.Value.GetString().ToQueryBatchMetricUnit(); + continue; + } + if (property.NameEquals("timeseries"u8)) + { + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(QueryBatchTimeSeriesElement.DeserializeQueryBatchTimeSeriesElement(item)); + } + timeseries = array; + continue; + } + if (property.NameEquals("errorCode"u8)) + { + errorCode = property.Value.GetString(); + continue; + } + if (property.NameEquals("errorMessage"u8)) + { + errorMessage = property.Value.GetString(); + continue; + } + } + return new QueryBatchMetric(id, name, displayDescription, type, unit, timeseries, errorCode.Value, errorMessage.Value); + } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetric.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetric.cs new file mode 100644 index 000000000000..b9749f23b2fa --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetric.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Collections.Generic; +using System.Linq; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + /// The result data of a query. + public partial class QueryBatchMetric + { + /// Initializes a new instance of QueryBatchMetric. + /// The metric Id. + /// The name and the display name of the metric, i.e. it is localizable string. + /// Description of this metric. + /// The resource type of the metric resource. + /// The unit of the metric. + /// The time series returned when a data query is performed. + /// , , , or is null. + internal QueryBatchMetric(string id, QueryBatchLocalizableString name, string displayDescription, string type, QueryBatchMetricUnit unit, IEnumerable timeseries) + { + Argument.AssertNotNull(id, nameof(id)); + Argument.AssertNotNull(name, nameof(name)); + Argument.AssertNotNull(displayDescription, nameof(displayDescription)); + Argument.AssertNotNull(type, nameof(type)); + Argument.AssertNotNull(timeseries, nameof(timeseries)); + + Id = id; + Name = name; + DisplayDescription = displayDescription; + Type = type; + Unit = unit; + Timeseries = timeseries.ToList(); + } + + /// Initializes a new instance of QueryBatchMetric. + /// The metric Id. + /// The name and the display name of the metric, i.e. it is localizable string. + /// Description of this metric. + /// The resource type of the metric resource. + /// The unit of the metric. + /// The time series returned when a data query is performed. + /// 'Success' or the error details on query failures for this metric. + /// Error message encountered querying this specific metric. + internal QueryBatchMetric(string id, QueryBatchLocalizableString name, string displayDescription, string type, QueryBatchMetricUnit unit, IReadOnlyList timeseries, string errorCode, string errorMessage) + { + Id = id; + Name = name; + DisplayDescription = displayDescription; + Type = type; + Unit = unit; + Timeseries = timeseries; + ErrorCode = errorCode; + ErrorMessage = errorMessage; + } + + /// The metric Id. + public string Id { get; } + /// The name and the display name of the metric, i.e. it is localizable string. + public QueryBatchLocalizableString Name { get; } + /// Description of this metric. + public string DisplayDescription { get; } + /// The resource type of the metric resource. + public string Type { get; } + /// The unit of the metric. + public QueryBatchMetricUnit Unit { get; } + /// The time series returned when a data query is performed. + public IReadOnlyList Timeseries { get; } + /// 'Success' or the error details on query failures for this metric. + public string ErrorCode { get; } + /// Error message encountered querying this specific metric. + public string ErrorMessage { get; } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetricUnit.Serialization.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetricUnit.Serialization.cs new file mode 100644 index 000000000000..be5c87bb0d61 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetricUnit.Serialization.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.Monitor.Query.Models +{ + internal static partial class QueryBatchMetricUnitExtensions + { + public static string ToSerialString(this QueryBatchMetricUnit value) => value switch + { + QueryBatchMetricUnit.Count => "Count", + QueryBatchMetricUnit.Bytes => "Bytes", + QueryBatchMetricUnit.Seconds => "Seconds", + QueryBatchMetricUnit.CountPerSecond => "CountPerSecond", + QueryBatchMetricUnit.BytesPerSecond => "BytesPerSecond", + QueryBatchMetricUnit.Percent => "Percent", + QueryBatchMetricUnit.MilliSeconds => "MilliSeconds", + QueryBatchMetricUnit.ByteSeconds => "ByteSeconds", + QueryBatchMetricUnit.Unspecified => "Unspecified", + QueryBatchMetricUnit.Cores => "Cores", + QueryBatchMetricUnit.MilliCores => "MilliCores", + QueryBatchMetricUnit.NanoCores => "NanoCores", + QueryBatchMetricUnit.BitsPerSecond => "BitsPerSecond", + _ => throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown QueryBatchMetricUnit value.") + }; + + public static QueryBatchMetricUnit ToQueryBatchMetricUnit(this string value) + { + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Count")) return QueryBatchMetricUnit.Count; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Bytes")) return QueryBatchMetricUnit.Bytes; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Seconds")) return QueryBatchMetricUnit.Seconds; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "CountPerSecond")) return QueryBatchMetricUnit.CountPerSecond; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "BytesPerSecond")) return QueryBatchMetricUnit.BytesPerSecond; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Percent")) return QueryBatchMetricUnit.Percent; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "MilliSeconds")) return QueryBatchMetricUnit.MilliSeconds; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "ByteSeconds")) return QueryBatchMetricUnit.ByteSeconds; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Unspecified")) return QueryBatchMetricUnit.Unspecified; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "Cores")) return QueryBatchMetricUnit.Cores; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "MilliCores")) return QueryBatchMetricUnit.MilliCores; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "NanoCores")) return QueryBatchMetricUnit.NanoCores; + if (StringComparer.OrdinalIgnoreCase.Equals(value, "BitsPerSecond")) return QueryBatchMetricUnit.BitsPerSecond; + throw new ArgumentOutOfRangeException(nameof(value), value, "Unknown QueryBatchMetricUnit value."); + } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetricUnit.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetricUnit.cs new file mode 100644 index 000000000000..dbf5f5240d09 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetricUnit.cs @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +namespace Azure.Monitor.Query.Models +{ + /// The unit of the metric. + public enum QueryBatchMetricUnit + { + /// Unit of raw quantity. + Count, + /// Unit of memory in bytes. + Bytes, + /// Unit of time in seconds. + Seconds, + /// Rate unit of raw quantity per second. + CountPerSecond, + /// Rate unit of memory in bytes per second. + BytesPerSecond, + /// Percentage unit. + Percent, + /// Unit of time in 1/1000th of a second. + MilliSeconds, + /// Unit of data transfer or storage. It is the size of the data in bytes multiplied by the time it takes to transfer or store the data in seconds. + ByteSeconds, + /// No specified unit. + Unspecified, + /// Unit of processing power. + Cores, + /// Unit of processing power in 1/1000th of a CPU core. + MilliCores, + /// Unit of processing power in one billionth of a CPU core. + NanoCores, + /// Rate unit of binary digits per second. + BitsPerSecond + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetricValue.Serialization.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetricValue.Serialization.cs new file mode 100644 index 000000000000..9fe6b5755e78 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetricValue.Serialization.cs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + public partial class QueryBatchMetricValue + { + internal static QueryBatchMetricValue DeserializeQueryBatchMetricValue(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + DateTimeOffset timeStamp = default; + Optional average = default; + Optional minimum = default; + Optional maximum = default; + Optional total = default; + Optional count = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("timeStamp"u8)) + { + timeStamp = property.Value.GetDateTimeOffset("O"); + continue; + } + if (property.NameEquals("average"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + average = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("minimum"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + minimum = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("maximum"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + maximum = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("total"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + total = property.Value.GetDouble(); + continue; + } + if (property.NameEquals("count"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + count = property.Value.GetDouble(); + continue; + } + } + return new QueryBatchMetricValue(timeStamp, Optional.ToNullable(average), Optional.ToNullable(minimum), Optional.ToNullable(maximum), Optional.ToNullable(total), Optional.ToNullable(count)); + } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetricValue.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetricValue.cs new file mode 100644 index 000000000000..4f2d798ab131 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchMetricValue.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System; + +namespace Azure.Monitor.Query.Models +{ + /// Represents a metric value. + public partial class QueryBatchMetricValue + { + /// Initializes a new instance of QueryBatchMetricValue. + /// The timestamp for the metric value in ISO 8601 format. + internal QueryBatchMetricValue(DateTimeOffset timeStamp) + { + TimeStamp = timeStamp; + } + + /// Initializes a new instance of QueryBatchMetricValue. + /// The timestamp for the metric value in ISO 8601 format. + /// The average value in the time range. + /// The least value in the time range. + /// The greatest value in the time range. + /// The sum of all of the values in the time range. + /// The number of samples in the time range. Can be used to determine the number of values that contributed to the average value. + internal QueryBatchMetricValue(DateTimeOffset timeStamp, double? average, double? minimum, double? maximum, double? total, double? count) + { + TimeStamp = timeStamp; + Average = average; + Minimum = minimum; + Maximum = maximum; + Total = total; + Count = count; + } + + /// The timestamp for the metric value in ISO 8601 format. + public DateTimeOffset TimeStamp { get; } + /// The average value in the time range. + public double? Average { get; } + /// The least value in the time range. + public double? Minimum { get; } + /// The greatest value in the time range. + public double? Maximum { get; } + /// The sum of all of the values in the time range. + public double? Total { get; } + /// The number of samples in the time range. Can be used to determine the number of values that contributed to the average value. + public double? Count { get; } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchTimeSeriesElement.Serialization.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchTimeSeriesElement.Serialization.cs new file mode 100644 index 000000000000..38f5770feae5 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchTimeSeriesElement.Serialization.cs @@ -0,0 +1,58 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using System.Text.Json; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + public partial class QueryBatchTimeSeriesElement + { + internal static QueryBatchTimeSeriesElement DeserializeQueryBatchTimeSeriesElement(JsonElement element) + { + if (element.ValueKind == JsonValueKind.Null) + { + return null; + } + Optional> metadatavalues = default; + Optional> data = default; + foreach (var property in element.EnumerateObject()) + { + if (property.NameEquals("metadatavalues"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(QueryBatchMetadataValue.DeserializeQueryBatchMetadataValue(item)); + } + metadatavalues = array; + continue; + } + if (property.NameEquals("data"u8)) + { + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + List array = new List(); + foreach (var item in property.Value.EnumerateArray()) + { + array.Add(QueryBatchMetricValue.DeserializeQueryBatchMetricValue(item)); + } + data = array; + continue; + } + } + return new QueryBatchTimeSeriesElement(Optional.ToList(metadatavalues), Optional.ToList(data)); + } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchTimeSeriesElement.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchTimeSeriesElement.cs new file mode 100644 index 000000000000..8c1578b83bbd --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/QueryBatchTimeSeriesElement.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + /// A time series result type. The discriminator value is always TimeSeries in this case. + public partial class QueryBatchTimeSeriesElement + { + /// Initializes a new instance of QueryBatchTimeSeriesElement. + internal QueryBatchTimeSeriesElement() + { + Metadatavalues = new ChangeTrackingList(); + Data = new ChangeTrackingList(); + } + + /// Initializes a new instance of QueryBatchTimeSeriesElement. + /// The metadata values returned if filter was specified in the call. + /// An array of data points representing the metric values. This is only returned if a result type of data is specified. + internal QueryBatchTimeSeriesElement(IReadOnlyList metadatavalues, IReadOnlyList data) + { + Metadatavalues = metadatavalues; + Data = data; + } + + /// The metadata values returned if filter was specified in the call. + public IReadOnlyList Metadatavalues { get; } + /// An array of data points representing the metric values. This is only returned if a result type of data is specified. + public IReadOnlyList Data { get; } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.Serialization.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.Serialization.cs new file mode 100644 index 000000000000..ccbf1841cde1 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.Serialization.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Text.Json; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + public partial class ResourceIdList : IUtf8JsonSerializable + { + void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) + { + writer.WriteStartObject(); + if (Optional.IsCollectionDefined(Resourceids)) + { + writer.WritePropertyName("resourceids"u8); + writer.WriteStartArray(); + foreach (var item in Resourceids) + { + if (item == null) + { + writer.WriteNullValue(); + continue; + } + writer.WriteStringValue(item); + } + writer.WriteEndArray(); + } + writer.WriteEndObject(); + } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.cs new file mode 100644 index 000000000000..92540028cbe7 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + /// The comma separated list of resource IDs to query metrics for. + public partial class ResourceIdList + { + /// Initializes a new instance of ResourceIdList. + public ResourceIdList() + { + Resourceids = new ChangeTrackingList(); + } + + /// The list of resource IDs to query metrics for. + public IList Resourceids { get; } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/MonitorQueryModelFactory.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/MonitorQueryModelFactory.cs index 15e6f27bd309..ed78eec94f65 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/Generated/MonitorQueryModelFactory.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/MonitorQueryModelFactory.cs @@ -6,6 +6,8 @@ #nullable disable using System; +using System.Collections.Generic; +using System.Linq; namespace Azure.Monitor.Query.Models { @@ -35,5 +37,91 @@ public static MetricAvailability MetricAvailability(TimeSpan? granularity = null { return new MetricAvailability(granularity, retention); } + + /// Initializes a new instance of MetricResultsResponse. + /// The collection of metric data responses per resource, per metric. + /// A new instance for mocking. + public static MetricResultsResponse MetricResultsResponse(IEnumerable values = null) + { + values ??= new List(); + + return new MetricResultsResponse(values?.ToList()); + } + + /// Initializes a new instance of MetricResultsResponseValuesItem. + /// The start time, in datetime format, for which the data was retrieved. + /// The end time, in datetime format, for which the data was retrieved. + /// The interval (window size) for which the metric data was returned in. Follows the IS8601/RFC3339 duration format (e.g. 'P1D' for 1 day). This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. + /// The namespace of the metrics been queried. + /// The region of the resource been queried for metrics. + /// The resource that has been queried for metrics. + /// The value of the collection. + /// A new instance for mocking. + public static MetricResultsResponseValuesItem MetricResultsResponseValuesItem(string starttime = null, string endtime = null, TimeSpan? interval = null, string @namespace = null, string resourceregion = null, string resourceid = null, IEnumerable value = null) + { + value ??= new List(); + + return new MetricResultsResponseValuesItem(starttime, endtime, interval, @namespace, resourceregion, resourceid, value?.ToList()); + } + + /// Initializes a new instance of QueryBatchMetric. + /// The metric Id. + /// The name and the display name of the metric, i.e. it is localizable string. + /// Description of this metric. + /// The resource type of the metric resource. + /// The unit of the metric. + /// The time series returned when a data query is performed. + /// 'Success' or the error details on query failures for this metric. + /// Error message encountered querying this specific metric. + /// A new instance for mocking. + public static QueryBatchMetric QueryBatchMetric(string id = null, QueryBatchLocalizableString name = null, string displayDescription = null, string type = null, QueryBatchMetricUnit unit = default, IEnumerable timeseries = null, string errorCode = null, string errorMessage = null) + { + timeseries ??= new List(); + + return new QueryBatchMetric(id, name, displayDescription, type, unit, timeseries?.ToList(), errorCode, errorMessage); + } + + /// Initializes a new instance of QueryBatchLocalizableString. + /// The invariant value. + /// The display name. + /// A new instance for mocking. + public static QueryBatchLocalizableString QueryBatchLocalizableString(string value = null, string localizedValue = null) + { + return new QueryBatchLocalizableString(value, localizedValue); + } + + /// Initializes a new instance of QueryBatchTimeSeriesElement. + /// The metadata values returned if filter was specified in the call. + /// An array of data points representing the metric values. This is only returned if a result type of data is specified. + /// A new instance for mocking. + public static QueryBatchTimeSeriesElement QueryBatchTimeSeriesElement(IEnumerable metadatavalues = null, IEnumerable data = null) + { + metadatavalues ??= new List(); + data ??= new List(); + + return new QueryBatchTimeSeriesElement(metadatavalues?.ToList(), data?.ToList()); + } + + /// Initializes a new instance of QueryBatchMetadataValue. + /// The name of the metadata. + /// The value of the metadata. + /// A new instance for mocking. + public static QueryBatchMetadataValue QueryBatchMetadataValue(QueryBatchLocalizableString name = null, string value = null) + { + return new QueryBatchMetadataValue(name, value); + } + + /// Initializes a new instance of QueryBatchMetricValue. + /// The timestamp for the metric value in ISO 8601 format. + /// The average value in the time range. + /// The least value in the time range. + /// The greatest value in the time range. + /// The sum of all of the values in the time range. + /// The number of samples in the time range. Can be used to determine the number of values that contributed to the average value. + /// A new instance for mocking. + public static QueryBatchMetricValue QueryBatchMetricValue(DateTimeOffset timeStamp = default, double? average = null, double? minimum = null, double? maximum = null, double? total = null, double? count = null) + { + return new QueryBatchMetricValue(timeStamp, average, minimum, maximum, total, count); + } } } diff --git a/sdk/monitor/Azure.Monitor.Query/src/autorest.md b/sdk/monitor/Azure.Monitor.Query/src/autorest.md index f1d5a5310824..9c96da747fc9 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/autorest.md +++ b/sdk/monitor/Azure.Monitor.Query/src/autorest.md @@ -9,6 +9,7 @@ input-file: - https://github.com/Azure/azure-rest-api-specs/blob/fc3c409825d6a31ba909a88ea34dcc13165edc9c/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/metricDefinitions_API.json - https://github.com/Azure/azure-rest-api-specs/blob/fc3c409825d6a31ba909a88ea34dcc13165edc9c/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/metrics_API.json - https://github.com/Azure/azure-rest-api-specs/blob/fc3c409825d6a31ba909a88ea34dcc13165edc9c/specification/monitor/resource-manager/Microsoft.Insights/preview/2017-12-01-preview/metricNamespaces_API.json + - metricBatch.json generation1-convenience-client: true modelerfour: lenient-model-deduplication: true diff --git a/sdk/monitor/Azure.Monitor.Query/src/metricBatch.json b/sdk/monitor/Azure.Monitor.Query/src/metricBatch.json new file mode 100644 index 000000000000..25926dfa767f --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/metricBatch.json @@ -0,0 +1,562 @@ +{ + "swagger": "2.0", + "info": { + "title": "Azure Monitor Metric Batch", + "version": "2023-05-01-preview" + }, + "securityDefinitions": { + "AADToken": { + "type": "oauth2", + "tokenUrl": "https://login.microsoftonline.com/common/oauth2/v2.0/token", + "flow": "application", + "description": "Azure Active Directory OAuth2 Authentication", + "scopes": { + "https://metrics.monitor.azure.com/.default": "https://metrics.monitor.azure.com/.default" + } + } + }, + "security": [ + { + "AADToken": [ + "https://metrics.monitor.azure.com/.default" + ] + } + ], + "x-ms-parameterized-host": { + "hostTemplate": "{endpoint}", + "useSchemePrefix": false, + "positionInOperation": "first", + "parameters": [ + { + "name": "endpoint", + "description": "The regional endpoint to use, for example https://eastus.metrics.monitor.azure.com. The region should match the region of the requested resources. For global resources, the region should be 'global'.", + "required": true, + "type": "string", + "in": "path", + "x-ms-skip-url-encoding": true, + "x-ms-parameter-location": "client", + "format": "url" + } + ] + }, + "consumes": [ + "application/json" + ], + "produces": [ + "application/json" + ], + "paths": { + "/subscriptions/{subscriptionId}/metrics:getBatch": { + "post": { + "tags": [ + "Metrics" + ], + "operationId": "MetricsBatch_Batch", + "description": "Lists the metric values for multiple resources.", + "parameters": [ + { + "$ref": "#/parameters/SubscriptionIdParameter" + }, + { + "$ref": "#/parameters/StartTimeParameter" + }, + { + "$ref": "#/parameters/EndTimeParameter" + }, + { + "$ref": "#/parameters/IntervalParameter" + }, + { + "$ref": "#/parameters/MetricNamespaceParameter" + }, + { + "$ref": "#/parameters/MetricNamesParameter" + }, + { + "$ref": "#/parameters/AggregationsParameter" + }, + { + "$ref": "#/parameters/TopParameter" + }, + { + "$ref": "#/parameters/OrderByParameter" + }, + { + "$ref": "#/parameters/FilterParameter" + }, + { + "$ref": "#/parameters/ApiVersionParameter" + }, + { + "$ref": "#/parameters/ResourceIdList" + } + ], + "responses": { + "200": { + "description": "The response to a metrics query.", + "schema": { + "$ref": "#/definitions/MetricResultsResponse" + } + }, + "default": { + "description": "Describes the format of Error response.", + "headers": { + "x-ms-error-code": { + "type": "string", + "description": "Error code for specific error that occurred." + } + }, + "schema": { + "$ref": "#/definitions/AdditionalInfoErrorResponse" + } + } + }, + "x-ms-examples": { + "Query Storage Metrics": { + "$ref": "./examples/MetricBatchExample.json" + } + } + } + } + }, + "parameters": { + "ResourceIdList": { + "name": "resourceIds", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/ResourceIdList" + }, + "description": "The comma separated list of resource IDs to query metrics for." + }, + "SubscriptionIdParameter": { + "name": "subscriptionId", + "in": "path", + "required": true, + "type": "string", + "description": "The subscription identifier for the resources in this batch.", + "x-ms-parameter-location": "method" + }, + "StartTimeParameter": { + "name": "starttime", + "in": "query", + "required": false, + "type": "string", + "description": "The start time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. If you have specified the endtime parameter, then this parameter is required.\nIf only starttime is specified, then endtime defaults to the current time.\nIf no time interval is specified, the default is 1 hour.", + "x-ms-parameter-location": "method" + }, + "EndTimeParameter": { + "name": "endtime", + "in": "query", + "required": false, + "type": "string", + "description": "The end time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'.", + "x-ms-parameter-location": "method" + }, + "IntervalParameter": { + "name": "interval", + "in": "query", + "required": false, + "type": "string", + "format": "duration", + "default": "PT1M", + "description": "The interval (i.e. timegrain) of the query.\n*Examples: PT15M, PT1H, P1D*", + "x-ms-parameter-location": "method" + }, + "MetricNamespaceParameter": { + "name": "metricnamespace", + "in": "query", + "required": true, + "type": "string", + "description": "Metric namespace that contains the requested metric names.", + "x-ms-parameter-location": "method" + }, + "MetricNamesParameter": { + "name": "metricnames", + "in": "query", + "required": true, + "type": "array", + "items": { + "type": "string" + }, + "collectionFormat": "csv", + "description": "The names of the metrics (comma separated) to retrieve.", + "x-ms-parameter-location": "method" + }, + "AggregationsParameter": { + "name": "aggregation", + "in": "query", + "required": false, + "type": "string", + "description": "The list of aggregation types (comma separated) to retrieve.\n*Examples: average, minimum, maximum*", + "x-ms-parameter-location": "method" + }, + "TopParameter": { + "name": "top", + "in": "query", + "required": false, + "type": "integer", + "format": "int32", + "description": "The maximum number of records to retrieve per resource ID in the request.\nValid only if filter is specified.\nDefaults to 10.", + "x-ms-parameter-location": "method" + }, + "OrderByParameter": { + "name": "orderby", + "in": "query", + "required": false, + "type": "string", + "description": "The aggregation to use for sorting results and the direction of the sort.\nOnly one order can be specified.\n*Examples: sum asc*", + "x-ms-parameter-location": "method" + }, + "FilterParameter": { + "name": "filter", + "in": "query", + "required": false, + "type": "string", + "description": "The filter is used to reduce the set of metric data returned.
Example:
Metric contains metadata A, B and C.
- Return all time series of C where A = a1 and B = b1 or b2
**filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**
- Invalid variant:
**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**
This is invalid because the logical or operator cannot separate two different metadata names.
- Return all time series where A = a1, B = b1 and C = c1:
**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**
- Return all time series where A = a1
**filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**.", + "x-ms-parameter-location": "method" + }, + "ApiVersionParameter": { + "name": "api-version", + "in": "query", + "required": true, + "type": "string", + "description": "Client Api Version.", + "x-ms-parameter-location": "client" + } + }, + "definitions": { + "ResourceIdList": { + "description": "The comma separated list of resource IDs to query metrics for.", + "type": "object", + "properties": { + "resourceids": { + "description": "The list of resource IDs to query metrics for.", + "type": "array", + "items": { + "type": "string", + "format": "arm-id" + } + } + }, + "example": { + "resourceids": [ + "/subscriptions/123456728-abcd-1234-abcd-123456789abc/resourceGroups/TestGroup/providers/Microsoft.Storage/storageAccounts/TestStorage1", + "/subscriptions/123456728-abcd-1234-abcd-123456789abc/resourceGroups/TestGroup/providers/Microsoft.Storage/storageAccounts/TestStorage2" + ] + } + }, + "AdditionalInfoErrorResponse": { + "description": "The response to a metrics query that results in a bad request, with optional additional information.", + "type": "object", + "properties": { + "error": { + "description": "Top level error object that contains all relevant information.", + "type": "object", + "properties": { + "additionalInfo": { + "description": "Additional information about the error", + "type": "array", + "items": { + "type": "object", + "properties": { + "type": { + "description": "The type of the info property (e.g. string).", + "type": "string" + }, + "info": { + "description": "Additional information related to the error.", + "type": "string" + } + } + } + }, + "code": { + "description": "Error code", + "type": "string" + }, + "message": { + "description": "Error message indicating why the operation failed.", + "type": "string" + } + }, + "required": [ + "code", + "message" + ] + } + }, + "required": [ + "error" + ] + }, + "MetricResultsResponse": { + "description": "The metrics result for a resource.", + "type": "object", + "properties": { + "values": { + "description": "The collection of metric data responses per resource, per metric.", + "type": "array", + "items": { + "type": "object", + "properties": { + "starttime": { + "type": "string", + "description": "The start time, in datetime format, for which the data was retrieved." + }, + "endtime": { + "type": "string", + "description": "The end time, in datetime format, for which the data was retrieved." + }, + "interval": { + "type": "string", + "format": "duration", + "description": "The interval (window size) for which the metric data was returned in. Follows the IS8601/RFC3339 duration format (e.g. 'P1D' for 1 day). This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made." + }, + "namespace": { + "type": "string", + "description": "The namespace of the metrics been queried" + }, + "resourceregion": { + "type": "string", + "description": "The region of the resource been queried for metrics." + }, + "resourceid": { + "type": "string", + "description": "The resource that has been queried for metrics." + }, + "value": { + "type": "array", + "items": { + "$ref": "#/definitions/QueryBatchMetric" + }, + "description": "The value of the collection." + } + }, + "required": [ + "starttime", + "endtime", + "value" + ] + } + } + } + }, + "QueryBatchLocalizableString": { + "type": "object", + "required": [ + "value" + ], + "properties": { + "value": { + "type": "string", + "description": "The invariant value." + }, + "localizedValue": { + "type": "string", + "description": "The display name." + } + }, + "description": "The localizable string class." + }, + "QueryBatchMetricUnit": { + "type": "string", + "description": "The unit of the metric.", + "enum": [ + "Count", + "Bytes", + "Seconds", + "CountPerSecond", + "BytesPerSecond", + "Percent", + "MilliSeconds", + "ByteSeconds", + "Unspecified", + "Cores", + "MilliCores", + "NanoCores", + "BitsPerSecond" + ], + "x-ms-enum": { + "name": "QueryBatchMetricUnit", + "modelAsString": false, + "values": [ + { + "value": "Count", + "description": "Unit of raw quantity." + }, + { + "value": "Bytes", + "description": "Unit of memory in bytes." + }, + { + "value": "Seconds", + "description": "Unit of time in seconds." + }, + { + "value": "CountPerSecond", + "description": "Rate unit of raw quantity per second." + }, + { + "value": "BytesPerSecond", + "description": "Rate unit of memory in bytes per second." + }, + { + "value": "Percent", + "description": "Percentage unit." + }, + { + "value": "MilliSeconds", + "description": "Unit of time in 1/1000th of a second." + }, + { + "value": "ByteSeconds", + "description": "Unit of data transfer or storage. It is the size of the data in bytes multiplied by the time it takes to transfer or store the data in seconds." + }, + { + "value": "Unspecified", + "description": "No specified unit." + }, + { + "value": "Cores", + "description": "Unit of processing power." + }, + { + "value": "MilliCores", + "description": "Unit of processing power in 1/1000th of a CPU core." + }, + { + "value": "NanoCores", + "description": "Unit of processing power in one billionth of a CPU core." + }, + { + "value": "BitsPerSecond", + "description": "Rate unit of binary digits per second." + } + ] + } + }, + "QueryBatchMetricValue": { + "type": "object", + "required": [ + "timeStamp" + ], + "properties": { + "timeStamp": { + "type": "string", + "format": "date-time", + "description": "The timestamp for the metric value in ISO 8601 format." + }, + "average": { + "type": "number", + "format": "double", + "description": "The average value in the time range." + }, + "minimum": { + "type": "number", + "format": "double", + "description": "The least value in the time range." + }, + "maximum": { + "type": "number", + "format": "double", + "description": "The greatest value in the time range." + }, + "total": { + "type": "number", + "format": "double", + "description": "The sum of all of the values in the time range." + }, + "count": { + "type": "number", + "format": "double", + "description": "The number of samples in the time range. Can be used to determine the number of values that contributed to the average value." + } + }, + "description": "Represents a metric value." + }, + "QueryBatchMetadataValue": { + "type": "object", + "properties": { + "name": { + "$ref": "#/definitions/QueryBatchLocalizableString", + "description": "The name of the metadata." + }, + "value": { + "type": "string", + "description": "The value of the metadata." + } + }, + "description": "Represents a metric metadata value." + }, + "QueryBatchMetric": { + "type": "object", + "properties": { + "id": { + "type": "string", + "description": "The metric Id." + }, + "name": { + "$ref": "#/definitions/QueryBatchLocalizableString", + "description": "The name and the display name of the metric, i.e. it is localizable string." + }, + "displayDescription": { + "type": "string", + "description": "Description of this metric" + }, + "type": { + "type": "string", + "description": "The resource type of the metric resource." + }, + "unit": { + "$ref": "#/definitions/QueryBatchMetricUnit", + "description": "The unit of the metric." + }, + "timeseries": { + "type": "array", + "items": { + "$ref": "#/definitions/QueryBatchTimeSeriesElement" + }, + "description": "The time series returned when a data query is performed." + }, + "errorCode": { + "type": "string", + "description": "'Success' or the error details on query failures for this metric." + }, + "errorMessage": { + "type": "string", + "description": "Error message encountered querying this specific metric." + } + }, + "required": [ + "id", + "name", + "displayDescription", + "type", + "unit", + "timeseries" + ], + "description": "The result data of a query." + }, + "QueryBatchTimeSeriesElement": { + "type": "object", + "properties": { + "metadatavalues": { + "type": "array", + "items": { + "$ref": "#/definitions/QueryBatchMetadataValue" + }, + "description": "The metadata values returned if filter was specified in the call." + }, + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/QueryBatchMetricValue" + }, + "description": "An array of data points representing the metric values. This is only returned if a result type of data is specified." + } + }, + "description": "A time series result type. The discriminator value is always TimeSeries in this case." + } + } +} From 75afbb1bfde74e2789d18e1707ca2a681540d9ea Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Thu, 7 Sep 2023 14:45:10 -0700 Subject: [PATCH 02/36] wip --- sdk/core/Azure.Core/api/Azure.Core.net472.cs | 1239 +++++++++++++++++ .../src/MetricsBatchQueryClient.cs | 155 +++ 2 files changed, 1394 insertions(+) create mode 100644 sdk/core/Azure.Core/api/Azure.Core.net472.cs create mode 100644 sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs diff --git a/sdk/core/Azure.Core/api/Azure.Core.net472.cs b/sdk/core/Azure.Core/api/Azure.Core.net472.cs new file mode 100644 index 000000000000..9aaf09bb355c --- /dev/null +++ b/sdk/core/Azure.Core/api/Azure.Core.net472.cs @@ -0,0 +1,1239 @@ +namespace Azure +{ + public abstract partial class AsyncPageable : System.Collections.Generic.IAsyncEnumerable where T : notnull + { + protected AsyncPageable() { } + protected AsyncPageable(System.Threading.CancellationToken cancellationToken) { } + protected virtual System.Threading.CancellationToken CancellationToken { get { throw null; } } + public abstract System.Collections.Generic.IAsyncEnumerable> AsPages(string? continuationToken = null, int? pageSizeHint = default(int?)); + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object? obj) { throw null; } + public static Azure.AsyncPageable FromPages(System.Collections.Generic.IEnumerable> pages) { throw null; } + public virtual System.Collections.Generic.IAsyncEnumerator GetAsyncEnumerator(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override string? ToString() { throw null; } + } + public static partial class AzureCoreExtensions + { + public static dynamic ToDynamicFromJson(this System.BinaryData utf8Json) { throw null; } + public static dynamic ToDynamicFromJson(this System.BinaryData utf8Json, Azure.Core.Serialization.JsonPropertyNames propertyNameFormat, string dateTimeFormat = "o") { throw null; } + public static System.Threading.Tasks.ValueTask ToObjectAsync(this System.BinaryData data, Azure.Core.Serialization.ObjectSerializer serializer, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public static object? ToObjectFromJson(this System.BinaryData data) { throw null; } + public static T? ToObject(this System.BinaryData data, Azure.Core.Serialization.ObjectSerializer serializer, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class AzureKeyCredential + { + public AzureKeyCredential(string key) { } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public string Key { get { throw null; } } + public void Update(string key) { } + } + public partial class AzureNamedKeyCredential + { + public AzureNamedKeyCredential(string name, string key) { } + public string Name { get { throw null; } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public void Deconstruct(out string name, out string key) { throw null; } + public void Update(string name, string key) { } + } + public partial class AzureSasCredential + { + public AzureSasCredential(string signature) { } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public string Signature { get { throw null; } } + public void Update(string signature) { } + } + [System.FlagsAttribute] + public enum ErrorOptions + { + Default = 0, + NoThrow = 1, + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ETag : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public static readonly Azure.ETag All; + public ETag(string etag) { throw null; } + public bool Equals(Azure.ETag other) { throw null; } + public override bool Equals(object? obj) { throw null; } + public bool Equals(string? other) { throw null; } + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.ETag left, Azure.ETag right) { throw null; } + public static bool operator !=(Azure.ETag left, Azure.ETag right) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override string ToString() { throw null; } + public string ToString(string format) { throw null; } + } + public partial class HttpAuthorization + { + public HttpAuthorization(string scheme, string parameter) { } + public string Parameter { get { throw null; } } + public string Scheme { get { throw null; } } + public override string ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct HttpRange : System.IEquatable + { + private readonly int _dummyPrimitive; + public HttpRange(long offset = (long)0, long? length = default(long?)) { throw null; } + public long? Length { get { throw null; } } + public long Offset { get { throw null; } } + public bool Equals(Azure.HttpRange other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object? obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.HttpRange left, Azure.HttpRange right) { throw null; } + public static bool operator !=(Azure.HttpRange left, Azure.HttpRange right) { throw null; } + public override string ToString() { throw null; } + } + public partial class JsonPatchDocument + { + public JsonPatchDocument() { } + public JsonPatchDocument(Azure.Core.Serialization.ObjectSerializer serializer) { } + public JsonPatchDocument(System.ReadOnlyMemory rawDocument) { } + public JsonPatchDocument(System.ReadOnlyMemory rawDocument, Azure.Core.Serialization.ObjectSerializer serializer) { } + public void AppendAddRaw(string path, string rawJsonValue) { } + public void AppendAdd(string path, T value) { } + public void AppendCopy(string from, string path) { } + public void AppendMove(string from, string path) { } + public void AppendRemove(string path) { } + public void AppendReplaceRaw(string path, string rawJsonValue) { } + public void AppendReplace(string path, T value) { } + public void AppendTestRaw(string path, string rawJsonValue) { } + public void AppendTest(string path, T value) { } + public System.ReadOnlyMemory ToBytes() { throw null; } + public override string ToString() { throw null; } + } + public partial class MatchConditions + { + public MatchConditions() { } + public Azure.ETag? IfMatch { get { throw null; } set { } } + public Azure.ETag? IfNoneMatch { get { throw null; } set { } } + } + public abstract partial class NullableResponse + { + protected NullableResponse() { } + public abstract bool HasValue { get; } + public abstract T? Value { get; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object? obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public abstract Azure.Response GetRawResponse(); + public override string ToString() { throw null; } + } + public abstract partial class Operation + { + protected Operation() { } + public abstract bool HasCompleted { get; } + public abstract string Id { get; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object? obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public abstract Azure.Response GetRawResponse(); + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override string? ToString() { throw null; } + public abstract Azure.Response UpdateStatus(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract System.Threading.Tasks.ValueTask UpdateStatusAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public virtual Azure.Response WaitForCompletionResponse(Azure.Core.DelayStrategy delayStrategy, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response WaitForCompletionResponse(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response WaitForCompletionResponse(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(Azure.Core.DelayStrategy delayStrategy, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public abstract partial class Operation : Azure.Operation where T : notnull + { + protected Operation() { } + public abstract bool HasValue { get; } + public abstract T Value { get; } + public virtual Azure.Response WaitForCompletion(Azure.Core.DelayStrategy delayStrategy, System.Threading.CancellationToken cancellationToken) { throw null; } + public virtual Azure.Response WaitForCompletion(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response WaitForCompletion(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken) { throw null; } + public virtual System.Threading.Tasks.ValueTask> WaitForCompletionAsync(Azure.Core.DelayStrategy delayStrategy, System.Threading.CancellationToken cancellationToken) { throw null; } + public virtual System.Threading.Tasks.ValueTask> WaitForCompletionAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.ValueTask> WaitForCompletionAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override System.Threading.Tasks.ValueTask WaitForCompletionResponseAsync(System.TimeSpan pollingInterval, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public abstract partial class PageableOperation : Azure.Operation> where T : notnull + { + protected PageableOperation() { } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override Azure.AsyncPageable Value { get { throw null; } } + public abstract Azure.Pageable GetValues(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + public abstract Azure.AsyncPageable GetValuesAsync(System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + } + public abstract partial class Pageable : System.Collections.Generic.IEnumerable, System.Collections.IEnumerable where T : notnull + { + protected Pageable() { } + protected Pageable(System.Threading.CancellationToken cancellationToken) { } + protected virtual System.Threading.CancellationToken CancellationToken { get { throw null; } } + public abstract System.Collections.Generic.IEnumerable> AsPages(string? continuationToken = null, int? pageSizeHint = default(int?)); + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object? obj) { throw null; } + public static Azure.Pageable FromPages(System.Collections.Generic.IEnumerable> pages) { throw null; } + public virtual System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override string? ToString() { throw null; } + } + public abstract partial class Page + { + protected Page() { } + public abstract string? ContinuationToken { get; } + public abstract System.Collections.Generic.IReadOnlyList Values { get; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object? obj) { throw null; } + public static Azure.Page FromValues(System.Collections.Generic.IReadOnlyList values, string? continuationToken, Azure.Response response) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public abstract Azure.Response GetRawResponse(); + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override string? ToString() { throw null; } + } + public partial class RequestConditions : Azure.MatchConditions + { + public RequestConditions() { } + public System.DateTimeOffset? IfModifiedSince { get { throw null; } set { } } + public System.DateTimeOffset? IfUnmodifiedSince { get { throw null; } set { } } + } + public partial class RequestContext + { + public RequestContext() { } + public System.Threading.CancellationToken CancellationToken { get { throw null; } set { } } + public Azure.ErrorOptions ErrorOptions { get { throw null; } set { } } + public void AddClassifier(Azure.Core.ResponseClassificationHandler classifier) { } + public void AddClassifier(int statusCode, bool isError) { } + public void AddPolicy(Azure.Core.Pipeline.HttpPipelinePolicy policy, Azure.Core.HttpPipelinePosition position) { } + public static implicit operator Azure.RequestContext (Azure.ErrorOptions options) { throw null; } + } + public partial class RequestFailedException : System.Exception, System.Runtime.Serialization.ISerializable + { + public RequestFailedException(Azure.Response response) { } + public RequestFailedException(Azure.Response response, System.Exception? innerException) { } + public RequestFailedException(Azure.Response response, System.Exception? innerException, Azure.Core.RequestFailedDetailsParser? detailsParser) { } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public RequestFailedException(int status, string message) { } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public RequestFailedException(int status, string message, System.Exception? innerException) { } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public RequestFailedException(int status, string message, string? errorCode, System.Exception? innerException) { } + protected RequestFailedException(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } + public RequestFailedException(string message) { } + public RequestFailedException(string message, System.Exception? innerException) { } + public string? ErrorCode { get { throw null; } } + public int Status { get { throw null; } } + public override void GetObjectData(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context) { } + public Azure.Response? GetRawResponse() { throw null; } + } + public abstract partial class Response : System.IDisposable + { + protected Response() { } + public abstract string ClientRequestId { get; set; } + public virtual System.BinaryData Content { get { throw null; } } + public abstract System.IO.Stream? ContentStream { get; set; } + public virtual Azure.Core.ResponseHeaders Headers { get { throw null; } } + public virtual bool IsError { get { throw null; } } + public abstract string ReasonPhrase { get; } + public abstract int Status { get; } + protected internal abstract bool ContainsHeader(string name); + public abstract void Dispose(); + protected internal abstract System.Collections.Generic.IEnumerable EnumerateHeaders(); + public static Azure.Response FromValue(T value, Azure.Response response) { throw null; } + public override string ToString() { throw null; } + protected internal abstract bool TryGetHeader(string name, out string? value); + protected internal abstract bool TryGetHeaderValues(string name, out System.Collections.Generic.IEnumerable? values); + } + public sealed partial class ResponseError + { + public ResponseError(string? code, string? message) { } + public string? Code { get { throw null; } } + public string? Message { get { throw null; } } + public override string ToString() { throw null; } + } + public abstract partial class Response : Azure.NullableResponse + { + protected Response() { } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool HasValue { get { throw null; } } + public override T Value { get { throw null; } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object? obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static implicit operator T (Azure.Response response) { throw null; } + } + public partial class SyncAsyncEventArgs : System.EventArgs + { + public SyncAsyncEventArgs(bool isRunningSynchronously, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { } + public System.Threading.CancellationToken CancellationToken { get { throw null; } } + public bool IsRunningSynchronously { get { throw null; } } + } + public enum WaitUntil + { + Completed = 0, + Started = 1, + } +} +namespace Azure.Core +{ + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public partial struct AccessToken + { + private object _dummy; + private int _dummyPrimitive; + public AccessToken(string accessToken, System.DateTimeOffset expiresOn) { throw null; } + public System.DateTimeOffset ExpiresOn { get { throw null; } } + public string Token { get { throw null; } } + public override bool Equals(object? obj) { throw null; } + public override int GetHashCode() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct AzureLocation : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public AzureLocation(string location) { throw null; } + public AzureLocation(string name, string displayName) { throw null; } + public static Azure.Core.AzureLocation AustraliaCentral { get { throw null; } } + public static Azure.Core.AzureLocation AustraliaCentral2 { get { throw null; } } + public static Azure.Core.AzureLocation AustraliaEast { get { throw null; } } + public static Azure.Core.AzureLocation AustraliaSoutheast { get { throw null; } } + public static Azure.Core.AzureLocation BrazilSouth { get { throw null; } } + public static Azure.Core.AzureLocation BrazilSoutheast { get { throw null; } } + public static Azure.Core.AzureLocation CanadaCentral { get { throw null; } } + public static Azure.Core.AzureLocation CanadaEast { get { throw null; } } + public static Azure.Core.AzureLocation CentralIndia { get { throw null; } } + public static Azure.Core.AzureLocation CentralUS { get { throw null; } } + public static Azure.Core.AzureLocation ChinaEast { get { throw null; } } + public static Azure.Core.AzureLocation ChinaEast2 { get { throw null; } } + public static Azure.Core.AzureLocation ChinaNorth { get { throw null; } } + public static Azure.Core.AzureLocation ChinaNorth2 { get { throw null; } } + public string? DisplayName { get { throw null; } } + public static Azure.Core.AzureLocation EastAsia { get { throw null; } } + public static Azure.Core.AzureLocation EastUS { get { throw null; } } + public static Azure.Core.AzureLocation EastUS2 { get { throw null; } } + public static Azure.Core.AzureLocation FranceCentral { get { throw null; } } + public static Azure.Core.AzureLocation FranceSouth { get { throw null; } } + public static Azure.Core.AzureLocation GermanyCentral { get { throw null; } } + public static Azure.Core.AzureLocation GermanyNorth { get { throw null; } } + public static Azure.Core.AzureLocation GermanyNorthEast { get { throw null; } } + public static Azure.Core.AzureLocation GermanyWestCentral { get { throw null; } } + public static Azure.Core.AzureLocation JapanEast { get { throw null; } } + public static Azure.Core.AzureLocation JapanWest { get { throw null; } } + public static Azure.Core.AzureLocation KoreaCentral { get { throw null; } } + public static Azure.Core.AzureLocation KoreaSouth { get { throw null; } } + public string Name { get { throw null; } } + public static Azure.Core.AzureLocation NorthCentralUS { get { throw null; } } + public static Azure.Core.AzureLocation NorthEurope { get { throw null; } } + public static Azure.Core.AzureLocation NorwayEast { get { throw null; } } + public static Azure.Core.AzureLocation NorwayWest { get { throw null; } } + public static Azure.Core.AzureLocation QatarCentral { get { throw null; } } + public static Azure.Core.AzureLocation SouthAfricaNorth { get { throw null; } } + public static Azure.Core.AzureLocation SouthAfricaWest { get { throw null; } } + public static Azure.Core.AzureLocation SouthCentralUS { get { throw null; } } + public static Azure.Core.AzureLocation SoutheastAsia { get { throw null; } } + public static Azure.Core.AzureLocation SouthIndia { get { throw null; } } + public static Azure.Core.AzureLocation SwedenCentral { get { throw null; } } + public static Azure.Core.AzureLocation SwitzerlandNorth { get { throw null; } } + public static Azure.Core.AzureLocation SwitzerlandWest { get { throw null; } } + public static Azure.Core.AzureLocation UAECentral { get { throw null; } } + public static Azure.Core.AzureLocation UAENorth { get { throw null; } } + public static Azure.Core.AzureLocation UKSouth { get { throw null; } } + public static Azure.Core.AzureLocation UKWest { get { throw null; } } + public static Azure.Core.AzureLocation USDoDCentral { get { throw null; } } + public static Azure.Core.AzureLocation USDoDEast { get { throw null; } } + public static Azure.Core.AzureLocation USGovArizona { get { throw null; } } + public static Azure.Core.AzureLocation USGovIowa { get { throw null; } } + public static Azure.Core.AzureLocation USGovTexas { get { throw null; } } + public static Azure.Core.AzureLocation USGovVirginia { get { throw null; } } + public static Azure.Core.AzureLocation WestCentralUS { get { throw null; } } + public static Azure.Core.AzureLocation WestEurope { get { throw null; } } + public static Azure.Core.AzureLocation WestIndia { get { throw null; } } + public static Azure.Core.AzureLocation WestUS { get { throw null; } } + public static Azure.Core.AzureLocation WestUS2 { get { throw null; } } + public static Azure.Core.AzureLocation WestUS3 { get { throw null; } } + public bool Equals(Azure.Core.AzureLocation other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object? obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.Core.AzureLocation left, Azure.Core.AzureLocation right) { throw null; } + public static implicit operator string (Azure.Core.AzureLocation location) { throw null; } + public static implicit operator Azure.Core.AzureLocation (string location) { throw null; } + public static bool operator !=(Azure.Core.AzureLocation left, Azure.Core.AzureLocation right) { throw null; } + public override string ToString() { throw null; } + } + public abstract partial class ClientOptions + { + protected ClientOptions() { } + protected ClientOptions(Azure.Core.DiagnosticsOptions? diagnostics) { } + public static Azure.Core.ClientOptions Default { get { throw null; } } + public Azure.Core.DiagnosticsOptions Diagnostics { get { throw null; } } + public Azure.Core.RetryOptions Retry { get { throw null; } } + public Azure.Core.Pipeline.HttpPipelinePolicy? RetryPolicy { get { throw null; } set { } } + public Azure.Core.Pipeline.HttpPipelineTransport Transport { get { throw null; } set { } } + public void AddPolicy(Azure.Core.Pipeline.HttpPipelinePolicy policy, Azure.Core.HttpPipelinePosition position) { } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object? obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override string? ToString() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ContentType : System.IEquatable, System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ContentType(string contentType) { throw null; } + public static Azure.Core.ContentType ApplicationJson { get { throw null; } } + public static Azure.Core.ContentType ApplicationOctetStream { get { throw null; } } + public static Azure.Core.ContentType TextPlain { get { throw null; } } + public bool Equals(Azure.Core.ContentType other) { throw null; } + public override bool Equals(object? obj) { throw null; } + public bool Equals(string? other) { throw null; } + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.Core.ContentType left, Azure.Core.ContentType right) { throw null; } + public static implicit operator Azure.Core.ContentType (string contentType) { throw null; } + public static bool operator !=(Azure.Core.ContentType left, Azure.Core.ContentType right) { throw null; } + public override string ToString() { throw null; } + } + public abstract partial class DelayStrategy + { + protected DelayStrategy(System.TimeSpan? maxDelay = default(System.TimeSpan?), double jitterFactor = 0.2) { } + public static Azure.Core.DelayStrategy CreateExponentialDelayStrategy(System.TimeSpan? initialDelay = default(System.TimeSpan?), System.TimeSpan? maxDelay = default(System.TimeSpan?)) { throw null; } + public static Azure.Core.DelayStrategy CreateFixedDelayStrategy(System.TimeSpan? delay = default(System.TimeSpan?)) { throw null; } + public System.TimeSpan GetNextDelay(Azure.Response? response, int retryNumber) { throw null; } + protected abstract System.TimeSpan GetNextDelayCore(Azure.Response? response, int retryNumber); + protected static System.TimeSpan Max(System.TimeSpan val1, System.TimeSpan val2) { throw null; } + protected static System.TimeSpan Min(System.TimeSpan val1, System.TimeSpan val2) { throw null; } + } + public static partial class DelegatedTokenCredential + { + public static Azure.Core.TokenCredential Create(System.Func getToken) { throw null; } + public static Azure.Core.TokenCredential Create(System.Func getToken, System.Func> getTokenAsync) { throw null; } + } + public partial class DiagnosticsOptions + { + protected internal DiagnosticsOptions() { } + public string? ApplicationId { get { throw null; } set { } } + public static string? DefaultApplicationId { get { throw null; } set { } } + public bool IsDistributedTracingEnabled { get { throw null; } set { } } + public bool IsLoggingContentEnabled { get { throw null; } set { } } + public bool IsLoggingEnabled { get { throw null; } set { } } + public bool IsTelemetryEnabled { get { throw null; } set { } } + public int LoggedContentSizeLimit { get { throw null; } set { } } + public System.Collections.Generic.IList LoggedHeaderNames { get { throw null; } } + public System.Collections.Generic.IList LoggedQueryParameters { get { throw null; } } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct HttpHeader : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public HttpHeader(string name, string value) { throw null; } + public string Name { get { throw null; } } + public string Value { get { throw null; } } + public bool Equals(Azure.Core.HttpHeader other) { throw null; } + public override bool Equals(object? obj) { throw null; } + public override int GetHashCode() { throw null; } + public override string ToString() { throw null; } + public static partial class Common + { + public static readonly Azure.Core.HttpHeader FormUrlEncodedContentType; + public static readonly Azure.Core.HttpHeader JsonAccept; + public static readonly Azure.Core.HttpHeader JsonContentType; + public static readonly Azure.Core.HttpHeader OctetStreamContentType; + } + public static partial class Names + { + public static string Accept { get { throw null; } } + public static string Authorization { get { throw null; } } + public static string ContentDisposition { get { throw null; } } + public static string ContentLength { get { throw null; } } + public static string ContentType { get { throw null; } } + public static string Date { get { throw null; } } + public static string ETag { get { throw null; } } + public static string Host { get { throw null; } } + public static string IfMatch { get { throw null; } } + public static string IfModifiedSince { get { throw null; } } + public static string IfNoneMatch { get { throw null; } } + public static string IfUnmodifiedSince { get { throw null; } } + public static string Prefer { get { throw null; } } + public static string Range { get { throw null; } } + public static string Referer { get { throw null; } } + public static string UserAgent { get { throw null; } } + public static string WwwAuthenticate { get { throw null; } } + public static string XMsDate { get { throw null; } } + public static string XMsRange { get { throw null; } } + public static string XMsRequestId { get { throw null; } } + } + } + public sealed partial class HttpMessage : System.IDisposable + { + public HttpMessage(Azure.Core.Request request, Azure.Core.ResponseClassifier responseClassifier) { } + public bool BufferResponse { get { throw null; } set { } } + public System.Threading.CancellationToken CancellationToken { get { throw null; } } + public bool HasResponse { get { throw null; } } + public System.TimeSpan? NetworkTimeout { get { throw null; } set { } } + public Azure.Core.MessageProcessingContext ProcessingContext { get { throw null; } } + public Azure.Core.Request Request { get { throw null; } } + public Azure.Response Response { get { throw null; } set { } } + public Azure.Core.ResponseClassifier ResponseClassifier { get { throw null; } set { } } + public void Dispose() { } + public System.IO.Stream? ExtractResponseContent() { throw null; } + public void SetProperty(string name, object value) { } + public void SetProperty(System.Type type, object value) { } + public bool TryGetProperty(string name, out object? value) { throw null; } + public bool TryGetProperty(System.Type type, out object? value) { throw null; } + } + public enum HttpPipelinePosition + { + PerCall = 0, + PerRetry = 1, + BeforeTransport = 2, + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct MessageProcessingContext + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public int RetryNumber { get { throw null; } set { } } + public System.DateTimeOffset StartTime { get { throw null; } } + } + public static partial class MultipartResponse + { + public static Azure.Response[] Parse(Azure.Response response, bool expectCrLf, System.Threading.CancellationToken cancellationToken) { throw null; } + public static System.Threading.Tasks.Task ParseAsync(Azure.Response response, bool expectCrLf, System.Threading.CancellationToken cancellationToken) { throw null; } + } + public abstract partial class Request : System.IDisposable + { + protected Request() { } + public abstract string ClientRequestId { get; set; } + public virtual Azure.Core.RequestContent? Content { get { throw null; } set { } } + public Azure.Core.RequestHeaders Headers { get { throw null; } } + public virtual Azure.Core.RequestMethod Method { get { throw null; } set { } } + public virtual Azure.Core.RequestUriBuilder Uri { get { throw null; } set { } } + protected internal abstract void AddHeader(string name, string value); + protected internal abstract bool ContainsHeader(string name); + public abstract void Dispose(); + protected internal abstract System.Collections.Generic.IEnumerable EnumerateHeaders(); + protected internal abstract bool RemoveHeader(string name); + protected internal virtual void SetHeader(string name, string value) { } + protected internal abstract bool TryGetHeader(string name, out string? value); + protected internal abstract bool TryGetHeaderValues(string name, out System.Collections.Generic.IEnumerable? values); + } + public abstract partial class RequestContent : System.IDisposable + { + protected RequestContent() { } + public static Azure.Core.RequestContent Create(Azure.Core.Serialization.DynamicData content) { throw null; } + public static Azure.Core.RequestContent Create(Azure.Core.Serialization.IModelJsonSerializable model, Azure.Core.Serialization.ModelSerializerOptions? options = null) { throw null; } + public static Azure.Core.RequestContent Create(Azure.Core.Serialization.IModelSerializable model, Azure.Core.Serialization.ModelSerializerOptions? options = null) { throw null; } + public static Azure.Core.RequestContent Create(System.BinaryData content) { throw null; } + public static Azure.Core.RequestContent Create(System.Buffers.ReadOnlySequence bytes) { throw null; } + public static Azure.Core.RequestContent Create(byte[] bytes) { throw null; } + public static Azure.Core.RequestContent Create(byte[] bytes, int index, int length) { throw null; } + public static Azure.Core.RequestContent Create(System.IO.Stream stream) { throw null; } + public static Azure.Core.RequestContent Create(object serializable) { throw null; } + public static Azure.Core.RequestContent Create(object serializable, Azure.Core.Serialization.JsonPropertyNames propertyNameFormat, string dateTimeFormat = "o") { throw null; } + public static Azure.Core.RequestContent Create(object serializable, Azure.Core.Serialization.ObjectSerializer? serializer) { throw null; } + public static Azure.Core.RequestContent Create(System.ReadOnlyMemory bytes) { throw null; } + public static Azure.Core.RequestContent Create(string content) { throw null; } + public abstract void Dispose(); + public static implicit operator Azure.Core.RequestContent (Azure.Core.Serialization.DynamicData content) { throw null; } + public static implicit operator Azure.Core.RequestContent (System.BinaryData content) { throw null; } + public static implicit operator Azure.Core.RequestContent (string content) { throw null; } + public abstract bool TryComputeLength(out long length); + public abstract void WriteTo(System.IO.Stream stream, System.Threading.CancellationToken cancellation); + public abstract System.Threading.Tasks.Task WriteToAsync(System.IO.Stream stream, System.Threading.CancellationToken cancellation); + } + public abstract partial class RequestFailedDetailsParser + { + protected RequestFailedDetailsParser() { } + public abstract bool TryParse(Azure.Response response, out Azure.ResponseError? error, out System.Collections.Generic.IDictionary? data); + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct RequestHeaders : System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public void Add(Azure.Core.HttpHeader header) { } + public void Add(string name, string value) { } + public bool Contains(string name) { throw null; } + public System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } + public bool Remove(string name) { throw null; } + public void SetValue(string name, string value) { } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + public bool TryGetValue(string name, out string? value) { throw null; } + public bool TryGetValues(string name, out System.Collections.Generic.IEnumerable? values) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct RequestMethod : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public RequestMethod(string method) { throw null; } + public static Azure.Core.RequestMethod Delete { get { throw null; } } + public static Azure.Core.RequestMethod Get { get { throw null; } } + public static Azure.Core.RequestMethod Head { get { throw null; } } + public string Method { get { throw null; } } + public static Azure.Core.RequestMethod Options { get { throw null; } } + public static Azure.Core.RequestMethod Patch { get { throw null; } } + public static Azure.Core.RequestMethod Post { get { throw null; } } + public static Azure.Core.RequestMethod Put { get { throw null; } } + public static Azure.Core.RequestMethod Trace { get { throw null; } } + public bool Equals(Azure.Core.RequestMethod other) { throw null; } + public override bool Equals(object? obj) { throw null; } + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.Core.RequestMethod left, Azure.Core.RequestMethod right) { throw null; } + public static bool operator !=(Azure.Core.RequestMethod left, Azure.Core.RequestMethod right) { throw null; } + public static Azure.Core.RequestMethod Parse(string method) { throw null; } + public override string ToString() { throw null; } + } + public partial class RequestUriBuilder + { + public RequestUriBuilder() { } + protected bool HasPath { get { throw null; } } + protected bool HasQuery { get { throw null; } } + public string? Host { get { throw null; } set { } } + public string Path { get { throw null; } set { } } + public string PathAndQuery { get { throw null; } } + public int Port { get { throw null; } set { } } + public string Query { get { throw null; } set { } } + public string? Scheme { get { throw null; } set { } } + public void AppendPath(System.ReadOnlySpan value, bool escape) { } + public void AppendPath(string value) { } + public void AppendPath(string value, bool escape) { } + public void AppendQuery(System.ReadOnlySpan name, System.ReadOnlySpan value, bool escapeValue) { } + public void AppendQuery(string name, string value) { } + public void AppendQuery(string name, string value, bool escapeValue) { } + public void Reset(System.Uri value) { } + public override string ToString() { throw null; } + public System.Uri ToUri() { throw null; } + } + public sealed partial class ResourceIdentifier : System.IComparable, System.IEquatable + { + public static readonly Azure.Core.ResourceIdentifier Root; + public ResourceIdentifier(string resourceId) { } + public Azure.Core.AzureLocation? Location { get { throw null; } } + public string Name { get { throw null; } } + public Azure.Core.ResourceIdentifier? Parent { get { throw null; } } + public string? Provider { get { throw null; } } + public string? ResourceGroupName { get { throw null; } } + public Azure.Core.ResourceType ResourceType { get { throw null; } } + public string? SubscriptionId { get { throw null; } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public Azure.Core.ResourceIdentifier AppendChildResource(string childResourceType, string childResourceName) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public Azure.Core.ResourceIdentifier AppendProviderResource(string providerNamespace, string resourceType, string resourceName) { throw null; } + public int CompareTo(Azure.Core.ResourceIdentifier? other) { throw null; } + public bool Equals(Azure.Core.ResourceIdentifier? other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object? obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.Core.ResourceIdentifier left, Azure.Core.ResourceIdentifier right) { throw null; } + public static bool operator >(Azure.Core.ResourceIdentifier left, Azure.Core.ResourceIdentifier right) { throw null; } + public static bool operator >=(Azure.Core.ResourceIdentifier left, Azure.Core.ResourceIdentifier right) { throw null; } + public static implicit operator string (Azure.Core.ResourceIdentifier id) { throw null; } + public static bool operator !=(Azure.Core.ResourceIdentifier left, Azure.Core.ResourceIdentifier right) { throw null; } + public static bool operator <(Azure.Core.ResourceIdentifier left, Azure.Core.ResourceIdentifier right) { throw null; } + public static bool operator <=(Azure.Core.ResourceIdentifier left, Azure.Core.ResourceIdentifier right) { throw null; } + public static Azure.Core.ResourceIdentifier Parse(string input) { throw null; } + public override string ToString() { throw null; } + public static bool TryParse(string input, out Azure.Core.ResourceIdentifier? result) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ResourceType : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public ResourceType(string resourceType) { throw null; } + public string Namespace { get { throw null; } } + public string Type { get { throw null; } } + public bool Equals(Azure.Core.ResourceType other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object? other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public string GetLastType() { throw null; } + public static bool operator ==(Azure.Core.ResourceType left, Azure.Core.ResourceType right) { throw null; } + public static implicit operator string (Azure.Core.ResourceType resourceType) { throw null; } + public static implicit operator Azure.Core.ResourceType (string resourceType) { throw null; } + public static bool operator !=(Azure.Core.ResourceType left, Azure.Core.ResourceType right) { throw null; } + public override string ToString() { throw null; } + } + public abstract partial class ResponseClassificationHandler + { + protected ResponseClassificationHandler() { } + public abstract bool TryClassify(Azure.Core.HttpMessage message, out bool isError); + } + public partial class ResponseClassifier + { + public ResponseClassifier() { } + public virtual bool IsErrorResponse(Azure.Core.HttpMessage message) { throw null; } + public virtual bool IsRetriable(Azure.Core.HttpMessage message, System.Exception exception) { throw null; } + public virtual bool IsRetriableException(System.Exception exception) { throw null; } + public virtual bool IsRetriableResponse(Azure.Core.HttpMessage message) { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ResponseHeaders : System.Collections.Generic.IEnumerable, System.Collections.IEnumerable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public int? ContentLength { get { throw null; } } + public long? ContentLengthLong { get { throw null; } } + public string? ContentType { get { throw null; } } + public System.DateTimeOffset? Date { get { throw null; } } + public Azure.ETag? ETag { get { throw null; } } + public string? RequestId { get { throw null; } } + public bool Contains(string name) { throw null; } + public System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + public bool TryGetValue(string name, out string? value) { throw null; } + public bool TryGetValues(string name, out System.Collections.Generic.IEnumerable? values) { throw null; } + } + public enum RetryMode + { + Fixed = 0, + Exponential = 1, + } + public partial class RetryOptions + { + internal RetryOptions() { } + public System.TimeSpan Delay { get { throw null; } set { } } + public System.TimeSpan MaxDelay { get { throw null; } set { } } + public int MaxRetries { get { throw null; } set { } } + public Azure.Core.RetryMode Mode { get { throw null; } set { } } + public System.TimeSpan NetworkTimeout { get { throw null; } set { } } + } + public partial class StatusCodeClassifier : Azure.Core.ResponseClassifier + { + public StatusCodeClassifier(System.ReadOnlySpan successStatusCodes) { } + public override bool IsErrorResponse(Azure.Core.HttpMessage message) { throw null; } + } + public delegate System.Threading.Tasks.Task SyncAsyncEventHandler(T e) where T : Azure.SyncAsyncEventArgs; + public partial class TelemetryDetails + { + public TelemetryDetails(System.Reflection.Assembly assembly, string? applicationId = null) { } + public string? ApplicationId { get { throw null; } } + public System.Reflection.Assembly Assembly { get { throw null; } } + public void Apply(Azure.Core.HttpMessage message) { } + public override string ToString() { throw null; } + } + public abstract partial class TokenCredential + { + protected TokenCredential() { } + public abstract Azure.Core.AccessToken GetToken(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken); + public abstract System.Threading.Tasks.ValueTask GetTokenAsync(Azure.Core.TokenRequestContext requestContext, System.Threading.CancellationToken cancellationToken); + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct TokenRequestContext + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public TokenRequestContext(string[] scopes, string? parentRequestId) { throw null; } + public TokenRequestContext(string[] scopes, string? parentRequestId, string? claims) { throw null; } + public TokenRequestContext(string[] scopes, string? parentRequestId, string? claims, string? tenantId) { throw null; } + public TokenRequestContext(string[] scopes, string? parentRequestId = null, string? claims = null, string? tenantId = null, bool isCaeEnabled = false) { throw null; } + public string? Claims { get { throw null; } } + public bool IsCaeEnabled { get { throw null; } } + public string? ParentRequestId { get { throw null; } } + public string[] Scopes { get { throw null; } } + public string? TenantId { get { throw null; } } + } +} +namespace Azure.Core.Cryptography +{ + public partial interface IKeyEncryptionKey + { + string KeyId { get; } + byte[] UnwrapKey(string algorithm, System.ReadOnlyMemory encryptedKey, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task UnwrapKeyAsync(string algorithm, System.ReadOnlyMemory encryptedKey, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + byte[] WrapKey(string algorithm, System.ReadOnlyMemory key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task WrapKeyAsync(string algorithm, System.ReadOnlyMemory key, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + } + public partial interface IKeyEncryptionKeyResolver + { + Azure.Core.Cryptography.IKeyEncryptionKey Resolve(string keyId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + System.Threading.Tasks.Task ResolveAsync(string keyId, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)); + } +} +namespace Azure.Core.Diagnostics +{ + public partial class AzureEventSourceListener : System.Diagnostics.Tracing.EventListener + { + public const string TraitName = "AzureEventSource"; + public const string TraitValue = "true"; + public AzureEventSourceListener(System.Action log, System.Diagnostics.Tracing.EventLevel level) { } + public static Azure.Core.Diagnostics.AzureEventSourceListener CreateConsoleLogger(System.Diagnostics.Tracing.EventLevel level = System.Diagnostics.Tracing.EventLevel.Informational) { throw null; } + public static Azure.Core.Diagnostics.AzureEventSourceListener CreateTraceLogger(System.Diagnostics.Tracing.EventLevel level = System.Diagnostics.Tracing.EventLevel.Informational) { throw null; } + protected sealed override void OnEventSourceCreated(System.Diagnostics.Tracing.EventSource eventSource) { } + protected sealed override void OnEventWritten(System.Diagnostics.Tracing.EventWrittenEventArgs eventData) { } + } +} +namespace Azure.Core.Extensions +{ + public partial interface IAzureClientBuilder where TOptions : class + { + } + public partial interface IAzureClientFactoryBuilder + { + Azure.Core.Extensions.IAzureClientBuilder RegisterClientFactory(System.Func clientFactory) where TOptions : class; + } + public partial interface IAzureClientFactoryBuilderWithConfiguration : Azure.Core.Extensions.IAzureClientFactoryBuilder + { + Azure.Core.Extensions.IAzureClientBuilder RegisterClientFactory(TConfiguration configuration) where TOptions : class; + } + public partial interface IAzureClientFactoryBuilderWithCredential + { + Azure.Core.Extensions.IAzureClientBuilder RegisterClientFactory(System.Func clientFactory, bool requiresCredential = true) where TOptions : class; + } +} +namespace Azure.Core.GeoJson +{ + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct GeoArray : System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public int Count { get { throw null; } } + public T this[int index] { get { throw null; } } + public Azure.Core.GeoJson.GeoArray.Enumerator GetEnumerator() { throw null; } + System.Collections.Generic.IEnumerator System.Collections.Generic.IEnumerable.GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public partial struct Enumerator : System.Collections.Generic.IEnumerator, System.Collections.IEnumerator, System.IDisposable + { + private object _dummy; + private int _dummyPrimitive; + public T Current { get { throw null; } } + object System.Collections.IEnumerator.Current { get { throw null; } } + public void Dispose() { } + public bool MoveNext() { throw null; } + public void Reset() { } + } + } + public sealed partial class GeoBoundingBox : System.IEquatable + { + public GeoBoundingBox(double west, double south, double east, double north) { } + public GeoBoundingBox(double west, double south, double east, double north, double? minAltitude, double? maxAltitude) { } + public double East { get { throw null; } } + public double this[int index] { get { throw null; } } + public double? MaxAltitude { get { throw null; } } + public double? MinAltitude { get { throw null; } } + public double North { get { throw null; } } + public double South { get { throw null; } } + public double West { get { throw null; } } + public bool Equals(Azure.Core.GeoJson.GeoBoundingBox? other) { throw null; } + public override bool Equals(object? obj) { throw null; } + public override int GetHashCode() { throw null; } + public override string ToString() { throw null; } + } + public sealed partial class GeoCollection : Azure.Core.GeoJson.GeoObject, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable + { + public GeoCollection(System.Collections.Generic.IEnumerable geometries) { } + public GeoCollection(System.Collections.Generic.IEnumerable geometries, Azure.Core.GeoJson.GeoBoundingBox? boundingBox, System.Collections.Generic.IReadOnlyDictionary customProperties) { } + public int Count { get { throw null; } } + public Azure.Core.GeoJson.GeoObject this[int index] { get { throw null; } } + public override Azure.Core.GeoJson.GeoObjectType Type { get { throw null; } } + public System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public sealed partial class GeoLinearRing + { + public GeoLinearRing(System.Collections.Generic.IEnumerable coordinates) { } + public Azure.Core.GeoJson.GeoArray Coordinates { get { throw null; } } + } + public sealed partial class GeoLineString : Azure.Core.GeoJson.GeoObject + { + public GeoLineString(System.Collections.Generic.IEnumerable coordinates) { } + public GeoLineString(System.Collections.Generic.IEnumerable coordinates, Azure.Core.GeoJson.GeoBoundingBox? boundingBox, System.Collections.Generic.IReadOnlyDictionary customProperties) { } + public Azure.Core.GeoJson.GeoArray Coordinates { get { throw null; } } + public override Azure.Core.GeoJson.GeoObjectType Type { get { throw null; } } + } + public sealed partial class GeoLineStringCollection : Azure.Core.GeoJson.GeoObject, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable + { + public GeoLineStringCollection(System.Collections.Generic.IEnumerable lines) { } + public GeoLineStringCollection(System.Collections.Generic.IEnumerable lines, Azure.Core.GeoJson.GeoBoundingBox? boundingBox, System.Collections.Generic.IReadOnlyDictionary customProperties) { } + public Azure.Core.GeoJson.GeoArray> Coordinates { get { throw null; } } + public int Count { get { throw null; } } + public Azure.Core.GeoJson.GeoLineString this[int index] { get { throw null; } } + public override Azure.Core.GeoJson.GeoObjectType Type { get { throw null; } } + public System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public abstract partial class GeoObject + { + internal GeoObject() { } + public Azure.Core.GeoJson.GeoBoundingBox? BoundingBox { get { throw null; } } + public abstract Azure.Core.GeoJson.GeoObjectType Type { get; } + public static Azure.Core.GeoJson.GeoObject Parse(string json) { throw null; } + public override string ToString() { throw null; } + public bool TryGetCustomProperty(string name, out object? value) { throw null; } + } + public enum GeoObjectType + { + Point = 0, + MultiPoint = 1, + Polygon = 2, + MultiPolygon = 3, + LineString = 4, + MultiLineString = 5, + GeometryCollection = 6, + } + public sealed partial class GeoPoint : Azure.Core.GeoJson.GeoObject + { + public GeoPoint(Azure.Core.GeoJson.GeoPosition position) { } + public GeoPoint(Azure.Core.GeoJson.GeoPosition position, Azure.Core.GeoJson.GeoBoundingBox? boundingBox, System.Collections.Generic.IReadOnlyDictionary customProperties) { } + public GeoPoint(double longitude, double latitude) { } + public GeoPoint(double longitude, double latitude, double? altitude) { } + public Azure.Core.GeoJson.GeoPosition Coordinates { get { throw null; } } + public override Azure.Core.GeoJson.GeoObjectType Type { get { throw null; } } + } + public sealed partial class GeoPointCollection : Azure.Core.GeoJson.GeoObject, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable + { + public GeoPointCollection(System.Collections.Generic.IEnumerable points) { } + public GeoPointCollection(System.Collections.Generic.IEnumerable points, Azure.Core.GeoJson.GeoBoundingBox? boundingBox, System.Collections.Generic.IReadOnlyDictionary customProperties) { } + public Azure.Core.GeoJson.GeoArray Coordinates { get { throw null; } } + public int Count { get { throw null; } } + public Azure.Core.GeoJson.GeoPoint this[int index] { get { throw null; } } + public override Azure.Core.GeoJson.GeoObjectType Type { get { throw null; } } + public System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + public sealed partial class GeoPolygon : Azure.Core.GeoJson.GeoObject + { + public GeoPolygon(System.Collections.Generic.IEnumerable rings) { } + public GeoPolygon(System.Collections.Generic.IEnumerable rings, Azure.Core.GeoJson.GeoBoundingBox? boundingBox, System.Collections.Generic.IReadOnlyDictionary customProperties) { } + public GeoPolygon(System.Collections.Generic.IEnumerable positions) { } + public Azure.Core.GeoJson.GeoArray> Coordinates { get { throw null; } } + public Azure.Core.GeoJson.GeoLinearRing OuterRing { get { throw null; } } + public System.Collections.Generic.IReadOnlyList Rings { get { throw null; } } + public override Azure.Core.GeoJson.GeoObjectType Type { get { throw null; } } + } + public sealed partial class GeoPolygonCollection : Azure.Core.GeoJson.GeoObject, System.Collections.Generic.IEnumerable, System.Collections.Generic.IReadOnlyCollection, System.Collections.Generic.IReadOnlyList, System.Collections.IEnumerable + { + public GeoPolygonCollection(System.Collections.Generic.IEnumerable polygons) { } + public GeoPolygonCollection(System.Collections.Generic.IEnumerable polygons, Azure.Core.GeoJson.GeoBoundingBox? boundingBox, System.Collections.Generic.IReadOnlyDictionary customProperties) { } + public Azure.Core.GeoJson.GeoArray>> Coordinates { get { throw null; } } + public int Count { get { throw null; } } + public Azure.Core.GeoJson.GeoPolygon this[int index] { get { throw null; } } + public override Azure.Core.GeoJson.GeoObjectType Type { get { throw null; } } + public System.Collections.Generic.IEnumerator GetEnumerator() { throw null; } + System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator() { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct GeoPosition : System.IEquatable + { + private readonly int _dummyPrimitive; + public GeoPosition(double longitude, double latitude) { throw null; } + public GeoPosition(double longitude, double latitude, double? altitude) { throw null; } + public double? Altitude { get { throw null; } } + public int Count { get { throw null; } } + public double this[int index] { get { throw null; } } + public double Latitude { get { throw null; } } + public double Longitude { get { throw null; } } + public bool Equals(Azure.Core.GeoJson.GeoPosition other) { throw null; } + public override bool Equals(object? obj) { throw null; } + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.Core.GeoJson.GeoPosition left, Azure.Core.GeoJson.GeoPosition right) { throw null; } + public static bool operator !=(Azure.Core.GeoJson.GeoPosition left, Azure.Core.GeoJson.GeoPosition right) { throw null; } + public override string ToString() { throw null; } + } +} +namespace Azure.Core.Pipeline +{ + public partial class BearerTokenAuthenticationPolicy : Azure.Core.Pipeline.HttpPipelinePolicy + { + public BearerTokenAuthenticationPolicy(Azure.Core.TokenCredential credential, System.Collections.Generic.IEnumerable scopes) { } + public BearerTokenAuthenticationPolicy(Azure.Core.TokenCredential credential, string scope) { } + protected void AuthenticateAndAuthorizeRequest(Azure.Core.HttpMessage message, Azure.Core.TokenRequestContext context) { } + protected System.Threading.Tasks.ValueTask AuthenticateAndAuthorizeRequestAsync(Azure.Core.HttpMessage message, Azure.Core.TokenRequestContext context) { throw null; } + protected virtual void AuthorizeRequest(Azure.Core.HttpMessage message) { } + protected virtual System.Threading.Tasks.ValueTask AuthorizeRequestAsync(Azure.Core.HttpMessage message) { throw null; } + protected virtual bool AuthorizeRequestOnChallenge(Azure.Core.HttpMessage message) { throw null; } + protected virtual System.Threading.Tasks.ValueTask AuthorizeRequestOnChallengeAsync(Azure.Core.HttpMessage message) { throw null; } + public override void Process(Azure.Core.HttpMessage message, System.ReadOnlyMemory pipeline) { } + public override System.Threading.Tasks.ValueTask ProcessAsync(Azure.Core.HttpMessage message, System.ReadOnlyMemory pipeline) { throw null; } + } + public sealed partial class DisposableHttpPipeline : Azure.Core.Pipeline.HttpPipeline, System.IDisposable + { + internal DisposableHttpPipeline() : base (default(Azure.Core.Pipeline.HttpPipelineTransport), default(Azure.Core.Pipeline.HttpPipelinePolicy[]), default(Azure.Core.ResponseClassifier)) { } + public void Dispose() { } + } + public partial class HttpClientTransport : Azure.Core.Pipeline.HttpPipelineTransport, System.IDisposable + { + public static readonly Azure.Core.Pipeline.HttpClientTransport Shared; + public HttpClientTransport() { } + public HttpClientTransport(System.Net.Http.HttpClient client) { } + public HttpClientTransport(System.Net.Http.HttpMessageHandler messageHandler) { } + public sealed override Azure.Core.Request CreateRequest() { throw null; } + public void Dispose() { } + public override void Process(Azure.Core.HttpMessage message) { } + public override System.Threading.Tasks.ValueTask ProcessAsync(Azure.Core.HttpMessage message) { throw null; } + } + public partial class HttpPipeline + { + public HttpPipeline(Azure.Core.Pipeline.HttpPipelineTransport transport, Azure.Core.Pipeline.HttpPipelinePolicy[]? policies = null, Azure.Core.ResponseClassifier? responseClassifier = null) { } + public Azure.Core.ResponseClassifier ResponseClassifier { get { throw null; } } + public static System.IDisposable CreateClientRequestIdScope(string? clientRequestId) { throw null; } + public static System.IDisposable CreateHttpMessagePropertiesScope(System.Collections.Generic.IDictionary messageProperties) { throw null; } + public Azure.Core.HttpMessage CreateMessage() { throw null; } + public Azure.Core.HttpMessage CreateMessage(Azure.RequestContext? context) { throw null; } + public Azure.Core.HttpMessage CreateMessage(Azure.RequestContext? context, Azure.Core.ResponseClassifier? classifier = null) { throw null; } + public Azure.Core.Request CreateRequest() { throw null; } + public void Send(Azure.Core.HttpMessage message, System.Threading.CancellationToken cancellationToken) { } + public System.Threading.Tasks.ValueTask SendAsync(Azure.Core.HttpMessage message, System.Threading.CancellationToken cancellationToken) { throw null; } + public Azure.Response SendRequest(Azure.Core.Request request, System.Threading.CancellationToken cancellationToken) { throw null; } + public System.Threading.Tasks.ValueTask SendRequestAsync(Azure.Core.Request request, System.Threading.CancellationToken cancellationToken) { throw null; } + } + public static partial class HttpPipelineBuilder + { + public static Azure.Core.Pipeline.HttpPipeline Build(Azure.Core.ClientOptions options, params Azure.Core.Pipeline.HttpPipelinePolicy[] perRetryPolicies) { throw null; } + public static Azure.Core.Pipeline.DisposableHttpPipeline Build(Azure.Core.ClientOptions options, Azure.Core.Pipeline.HttpPipelinePolicy[] perCallPolicies, Azure.Core.Pipeline.HttpPipelinePolicy[] perRetryPolicies, Azure.Core.Pipeline.HttpPipelineTransportOptions transportOptions, Azure.Core.ResponseClassifier? responseClassifier) { throw null; } + public static Azure.Core.Pipeline.HttpPipeline Build(Azure.Core.ClientOptions options, Azure.Core.Pipeline.HttpPipelinePolicy[] perCallPolicies, Azure.Core.Pipeline.HttpPipelinePolicy[] perRetryPolicies, Azure.Core.ResponseClassifier? responseClassifier) { throw null; } + public static Azure.Core.Pipeline.HttpPipeline Build(Azure.Core.Pipeline.HttpPipelineOptions options) { throw null; } + public static Azure.Core.Pipeline.DisposableHttpPipeline Build(Azure.Core.Pipeline.HttpPipelineOptions options, Azure.Core.Pipeline.HttpPipelineTransportOptions transportOptions) { throw null; } + } + public partial class HttpPipelineOptions + { + public HttpPipelineOptions(Azure.Core.ClientOptions options) { } + public Azure.Core.ClientOptions ClientOptions { get { throw null; } } + public System.Collections.Generic.IList PerCallPolicies { get { throw null; } } + public System.Collections.Generic.IList PerRetryPolicies { get { throw null; } } + public Azure.Core.RequestFailedDetailsParser RequestFailedDetailsParser { get { throw null; } set { } } + public Azure.Core.ResponseClassifier? ResponseClassifier { get { throw null; } set { } } + } + public abstract partial class HttpPipelinePolicy + { + protected HttpPipelinePolicy() { } + public abstract void Process(Azure.Core.HttpMessage message, System.ReadOnlyMemory pipeline); + public abstract System.Threading.Tasks.ValueTask ProcessAsync(Azure.Core.HttpMessage message, System.ReadOnlyMemory pipeline); + protected static void ProcessNext(Azure.Core.HttpMessage message, System.ReadOnlyMemory pipeline) { } + protected static System.Threading.Tasks.ValueTask ProcessNextAsync(Azure.Core.HttpMessage message, System.ReadOnlyMemory pipeline) { throw null; } + } + public abstract partial class HttpPipelineSynchronousPolicy : Azure.Core.Pipeline.HttpPipelinePolicy + { + protected HttpPipelineSynchronousPolicy() { } + public virtual void OnReceivedResponse(Azure.Core.HttpMessage message) { } + public virtual void OnSendingRequest(Azure.Core.HttpMessage message) { } + public override void Process(Azure.Core.HttpMessage message, System.ReadOnlyMemory pipeline) { } + public override System.Threading.Tasks.ValueTask ProcessAsync(Azure.Core.HttpMessage message, System.ReadOnlyMemory pipeline) { throw null; } + } + public abstract partial class HttpPipelineTransport + { + protected HttpPipelineTransport() { } + public abstract Azure.Core.Request CreateRequest(); + public abstract void Process(Azure.Core.HttpMessage message); + public abstract System.Threading.Tasks.ValueTask ProcessAsync(Azure.Core.HttpMessage message); + } + public partial class HttpPipelineTransportOptions + { + public HttpPipelineTransportOptions() { } + public System.Collections.Generic.IList ClientCertificates { get { throw null; } } + public bool IsClientRedirectEnabled { get { throw null; } set { } } + public System.Func? ServerCertificateCustomValidationCallback { get { throw null; } set { } } + } + public sealed partial class RedirectPolicy : Azure.Core.Pipeline.HttpPipelinePolicy + { + internal RedirectPolicy() { } + public override void Process(Azure.Core.HttpMessage message, System.ReadOnlyMemory pipeline) { } + public override System.Threading.Tasks.ValueTask ProcessAsync(Azure.Core.HttpMessage message, System.ReadOnlyMemory pipeline) { throw null; } + public static void SetAllowAutoRedirect(Azure.Core.HttpMessage message, bool allowAutoRedirect) { } + } + public partial class RetryPolicy : Azure.Core.Pipeline.HttpPipelinePolicy + { + public RetryPolicy(int maxRetries = 3, Azure.Core.DelayStrategy? delayStrategy = null) { } + protected internal virtual void OnRequestSent(Azure.Core.HttpMessage message) { } + protected internal virtual System.Threading.Tasks.ValueTask OnRequestSentAsync(Azure.Core.HttpMessage message) { throw null; } + protected internal virtual void OnSendingRequest(Azure.Core.HttpMessage message) { } + protected internal virtual System.Threading.Tasks.ValueTask OnSendingRequestAsync(Azure.Core.HttpMessage message) { throw null; } + public override void Process(Azure.Core.HttpMessage message, System.ReadOnlyMemory pipeline) { } + public override System.Threading.Tasks.ValueTask ProcessAsync(Azure.Core.HttpMessage message, System.ReadOnlyMemory pipeline) { throw null; } + protected internal virtual bool ShouldRetry(Azure.Core.HttpMessage message, System.Exception? exception) { throw null; } + protected internal virtual System.Threading.Tasks.ValueTask ShouldRetryAsync(Azure.Core.HttpMessage message, System.Exception? exception) { throw null; } + } + public partial class ServerCertificateCustomValidationArgs + { + public ServerCertificateCustomValidationArgs(System.Security.Cryptography.X509Certificates.X509Certificate2? certificate, System.Security.Cryptography.X509Certificates.X509Chain? certificateAuthorityChain, System.Net.Security.SslPolicyErrors sslPolicyErrors) { } + public System.Security.Cryptography.X509Certificates.X509Certificate2? Certificate { get { throw null; } } + public System.Security.Cryptography.X509Certificates.X509Chain? CertificateAuthorityChain { get { throw null; } } + public System.Net.Security.SslPolicyErrors SslPolicyErrors { get { throw null; } } + } +} +namespace Azure.Core.Serialization +{ + [System.AttributeUsageAttribute(System.AttributeTargets.Class)] + public sealed partial class AbstractHierarchyDeserializerAttribute : System.Attribute + { + public AbstractHierarchyDeserializerAttribute(System.Type typeToActivate) { } + public System.Type TypeToActivate { get { throw null; } } + } + [System.Diagnostics.DebuggerDisplayAttribute("{DebuggerDisplay,nq}")] + public sealed partial class DynamicData : System.Dynamic.IDynamicMetaObjectProvider, System.IDisposable + { + internal DynamicData() { } + public void Dispose() { } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object? obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.Core.Serialization.DynamicData? left, object? right) { throw null; } + public static explicit operator System.DateTime (Azure.Core.Serialization.DynamicData value) { throw null; } + public static explicit operator System.DateTimeOffset (Azure.Core.Serialization.DynamicData value) { throw null; } + public static explicit operator System.Guid (Azure.Core.Serialization.DynamicData value) { throw null; } + public static implicit operator bool (Azure.Core.Serialization.DynamicData value) { throw null; } + public static implicit operator byte (Azure.Core.Serialization.DynamicData value) { throw null; } + public static implicit operator decimal (Azure.Core.Serialization.DynamicData value) { throw null; } + public static implicit operator double (Azure.Core.Serialization.DynamicData value) { throw null; } + public static implicit operator short (Azure.Core.Serialization.DynamicData value) { throw null; } + public static implicit operator int (Azure.Core.Serialization.DynamicData value) { throw null; } + public static implicit operator long (Azure.Core.Serialization.DynamicData value) { throw null; } + public static implicit operator sbyte (Azure.Core.Serialization.DynamicData value) { throw null; } + public static implicit operator float (Azure.Core.Serialization.DynamicData value) { throw null; } + public static implicit operator string (Azure.Core.Serialization.DynamicData value) { throw null; } + public static implicit operator ushort (Azure.Core.Serialization.DynamicData value) { throw null; } + public static implicit operator uint (Azure.Core.Serialization.DynamicData value) { throw null; } + public static implicit operator ulong (Azure.Core.Serialization.DynamicData value) { throw null; } + public static bool operator !=(Azure.Core.Serialization.DynamicData? left, object? right) { throw null; } + System.Dynamic.DynamicMetaObject System.Dynamic.IDynamicMetaObjectProvider.GetMetaObject(System.Linq.Expressions.Expression parameter) { throw null; } + public override string ToString() { throw null; } + } + public partial interface IMemberNameConverter + { + string? ConvertMemberName(System.Reflection.MemberInfo member); + } + public partial interface IModelJsonSerializable : Azure.Core.Serialization.IModelSerializable + { + T Deserialize(ref System.Text.Json.Utf8JsonReader reader, Azure.Core.Serialization.ModelSerializerOptions options); + void Serialize(System.Text.Json.Utf8JsonWriter writer, Azure.Core.Serialization.ModelSerializerOptions options); + } + public partial interface IModelSerializable + { + T Deserialize(System.BinaryData data, Azure.Core.Serialization.ModelSerializerOptions options); + System.BinaryData Serialize(Azure.Core.Serialization.ModelSerializerOptions options); + } + public partial class JsonObjectSerializer : Azure.Core.Serialization.ObjectSerializer, Azure.Core.Serialization.IMemberNameConverter + { + public JsonObjectSerializer() { } + public JsonObjectSerializer(System.Text.Json.JsonSerializerOptions options) { } + public static Azure.Core.Serialization.JsonObjectSerializer Default { get { throw null; } } + string? Azure.Core.Serialization.IMemberNameConverter.ConvertMemberName(System.Reflection.MemberInfo member) { throw null; } + public override object? Deserialize(System.IO.Stream stream, System.Type returnType, System.Threading.CancellationToken cancellationToken) { throw null; } + public override System.Threading.Tasks.ValueTask DeserializeAsync(System.IO.Stream stream, System.Type returnType, System.Threading.CancellationToken cancellationToken) { throw null; } + public override void Serialize(System.IO.Stream stream, object? value, System.Type inputType, System.Threading.CancellationToken cancellationToken) { } + public override System.BinaryData Serialize(object? value, System.Type? inputType = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public override System.Threading.Tasks.ValueTask SerializeAsync(System.IO.Stream stream, object? value, System.Type inputType, System.Threading.CancellationToken cancellationToken) { throw null; } + public override System.Threading.Tasks.ValueTask SerializeAsync(object? value, System.Type? inputType = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public enum JsonPropertyNames + { + UseExact = 0, + CamelCase = 1, + } + public partial class ModelJsonConverter : System.Text.Json.Serialization.JsonConverter> + { + public ModelJsonConverter() { } + public ModelJsonConverter(Azure.Core.Serialization.ModelSerializerFormat format) { } + public ModelJsonConverter(Azure.Core.Serialization.ModelSerializerOptions options) { } + public Azure.Core.Serialization.ModelSerializerOptions ModelSerializerOptions { get { throw null; } } + public override bool CanConvert(System.Type typeToConvert) { throw null; } + public override Azure.Core.Serialization.IModelJsonSerializable Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { throw null; } + public override void Write(System.Text.Json.Utf8JsonWriter writer, Azure.Core.Serialization.IModelJsonSerializable value, System.Text.Json.JsonSerializerOptions options) { } + } + public static partial class ModelSerializer + { + public static object Deserialize(System.BinaryData data, System.Type returnType, Azure.Core.Serialization.ModelSerializerFormat format) { throw null; } + public static object Deserialize(System.BinaryData data, System.Type returnType, Azure.Core.Serialization.ModelSerializerOptions? options = null) { throw null; } + public static T Deserialize(System.BinaryData data, Azure.Core.Serialization.ModelSerializerFormat format) where T : Azure.Core.Serialization.IModelSerializable { throw null; } + public static T Deserialize(System.BinaryData data, Azure.Core.Serialization.ModelSerializerOptions? options = null) where T : Azure.Core.Serialization.IModelSerializable { throw null; } + public static System.BinaryData Serialize(object model, Azure.Core.Serialization.ModelSerializerFormat format) { throw null; } + public static System.BinaryData Serialize(object model, Azure.Core.Serialization.ModelSerializerOptions? options = null) { throw null; } + public static System.BinaryData SerializeCore(Azure.Core.Serialization.IModelJsonSerializable model, Azure.Core.Serialization.ModelSerializerOptions options) { throw null; } + public static System.BinaryData Serialize(T model, Azure.Core.Serialization.ModelSerializerFormat format) where T : Azure.Core.Serialization.IModelSerializable { throw null; } + public static System.BinaryData Serialize(T model, Azure.Core.Serialization.ModelSerializerOptions? options = null) where T : Azure.Core.Serialization.IModelSerializable { throw null; } + } + [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] + public readonly partial struct ModelSerializerFormat : System.IEquatable + { + private readonly object _dummy; + private readonly int _dummyPrimitive; + public static readonly Azure.Core.Serialization.ModelSerializerFormat Json; + public static readonly Azure.Core.Serialization.ModelSerializerFormat Wire; + public ModelSerializerFormat(string value) { throw null; } + public bool Equals(Azure.Core.Serialization.ModelSerializerFormat other) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override bool Equals(object obj) { throw null; } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + public override int GetHashCode() { throw null; } + public static bool operator ==(Azure.Core.Serialization.ModelSerializerFormat left, Azure.Core.Serialization.ModelSerializerFormat right) { throw null; } + public static implicit operator Azure.Core.Serialization.ModelSerializerFormat (string value) { throw null; } + public static bool operator !=(Azure.Core.Serialization.ModelSerializerFormat left, Azure.Core.Serialization.ModelSerializerFormat right) { throw null; } + public override string ToString() { throw null; } + } + public partial class ModelSerializerOptions + { + public static readonly Azure.Core.Serialization.ModelSerializerOptions DefaultWireOptions; + public ModelSerializerOptions() { } + public ModelSerializerOptions(Azure.Core.Serialization.ModelSerializerFormat format) { } + public Azure.Core.Serialization.ModelSerializerFormat Format { get { throw null; } } + public System.Func? GenericTypeSerializerCreator { get { throw null; } set { } } + } + public abstract partial class ObjectSerializer + { + protected ObjectSerializer() { } + public abstract object? Deserialize(System.IO.Stream stream, System.Type returnType, System.Threading.CancellationToken cancellationToken); + public abstract System.Threading.Tasks.ValueTask DeserializeAsync(System.IO.Stream stream, System.Type returnType, System.Threading.CancellationToken cancellationToken); + public abstract void Serialize(System.IO.Stream stream, object? value, System.Type inputType, System.Threading.CancellationToken cancellationToken); + public virtual System.BinaryData Serialize(object? value, System.Type? inputType = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public abstract System.Threading.Tasks.ValueTask SerializeAsync(System.IO.Stream stream, object? value, System.Type inputType, System.Threading.CancellationToken cancellationToken); + public virtual System.Threading.Tasks.ValueTask SerializeAsync(object? value, System.Type? inputType = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } +} +namespace Azure.Messaging +{ + public partial class CloudEvent + { + public CloudEvent(string source, string type, System.BinaryData? data, string? dataContentType, Azure.Messaging.CloudEventDataFormat dataFormat = Azure.Messaging.CloudEventDataFormat.Binary) { } + public CloudEvent(string source, string type, object? jsonSerializableData, System.Type? dataSerializationType = null) { } + public System.BinaryData? Data { get { throw null; } set { } } + public string? DataContentType { get { throw null; } set { } } + public string? DataSchema { get { throw null; } set { } } + public System.Collections.Generic.IDictionary ExtensionAttributes { get { throw null; } } + public string Id { get { throw null; } set { } } + public string Source { get { throw null; } set { } } + public string? Subject { get { throw null; } set { } } + public System.DateTimeOffset? Time { get { throw null; } set { } } + public string Type { get { throw null; } set { } } + public static Azure.Messaging.CloudEvent? Parse(System.BinaryData json, bool skipValidation = false) { throw null; } + public static Azure.Messaging.CloudEvent[] ParseMany(System.BinaryData json, bool skipValidation = false) { throw null; } + } + public enum CloudEventDataFormat + { + Binary = 0, + Json = 1, + } + public partial class MessageContent + { + public MessageContent() { } + public virtual Azure.Core.ContentType? ContentType { get { throw null; } set { } } + [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] + protected virtual Azure.Core.ContentType? ContentTypeCore { get { throw null; } set { } } + public virtual System.BinaryData? Data { get { throw null; } set { } } + public virtual bool IsReadOnly { get { throw null; } } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs b/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs new file mode 100644 index 000000000000..65112ed24429 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs @@ -0,0 +1,155 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.Collections.Generic; +using System.Net; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Azure.Core; +using Azure.Core.Pipeline; +using Azure.Monitor.Query.Models; + +namespace Azure.Monitor.Query +{ + /// + /// The allows you to query multiple Azure Monitor Metric services. + /// + public class MetricsBatchQueryClient + { + private static readonly Uri _defaultEndpoint = new Uri("https://management.azure.com"); + + private readonly MetricsBatchRestClient _metricBatchClient; + private readonly ClientDiagnostics _clientDiagnostics; + + /// + /// Initializes a new instance of . Uses the default 'https://management.azure.com' endpoint. + /// + /// var client = new MetricsBatchQueryClient(new DefaultAzureCredential()); + /// + /// + /// The instance to use for authentication. + public MetricsBatchQueryClient(TokenCredential credential) : this(credential, null) + { + } + + /// + /// Initializes a new instance of . Uses the default 'https://management.azure.com' endpoint. + /// + /// The instance to use for authentication. + /// The instance to as client configuration. + public MetricsBatchQueryClient(TokenCredential credential, MetricsQueryClientOptions options) : this(_defaultEndpoint, credential, options) + { + } + + /// + /// Initializes a new instance of . + /// + /// The resource manager service endpoint to use. For example https://management.azure.com/ for public cloud. + /// The instance to use for authentication. + /// The instance to as client configuration. + public MetricsBatchQueryClient(Uri endpoint, TokenCredential credential, MetricsQueryClientOptions options = null) + { + Argument.AssertNotNull(credential, nameof(credential)); + + options ??= new MetricsQueryClientOptions(); + + _clientDiagnostics = new ClientDiagnostics(options); + + var scope = $"{endpoint.AbsoluteUri}/.default"; + Endpoint = endpoint; + + var pipeline = HttpPipelineBuilder.Build(options, + new BearerTokenAuthenticationPolicy(credential, scope)); + + _metricBatchClient = new MetricsBatchRestClient(_clientDiagnostics, pipeline, endpoint); + } + + /// + /// Initializes a new instance of for mocking. + /// + protected MetricsBatchQueryClient() + { + } + + /// + /// Gets the endpoint used by the client. + /// + public Uri Endpoint { get; } + + /// Lists the metric values for multiple resources. + /// The subscription identifier for the resources in this batch. + /// Metric namespace that contains the requested metric names. + /// The names of the metrics (comma separated) to retrieve. + /// The comma separated list of resource IDs to query metrics for. + /// + /// The start time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. If you have specified the endtime parameter, then this parameter is required. + /// If only starttime is specified, then endtime defaults to the current time. + /// If no time interval is specified, the default is 1 hour. + /// + /// The end time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. + /// + /// The interval (i.e. timegrain) of the query. + /// *Examples: PT15M, PT1H, P1D* + /// + /// + /// The list of aggregation types (comma separated) to retrieve. + /// *Examples: average, minimum, maximum* + /// + /// + /// The maximum number of records to retrieve per resource ID in the request. + /// Valid only if filter is specified. + /// Defaults to 10. + /// + /// + /// The aggregation to use for sorting results and the direction of the sort. + /// Only one order can be specified. + /// *Examples: sum asc* + /// + /// The filter is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. + /// The cancellation token to use. + /// , , or is null. + public virtual Response Batch(string subscriptionId, string metricnamespace, IEnumerable metricnames, ResourceIdList resourceIds, string starttime = null, string endtime = null, TimeSpan? interval = null, string aggregation = null, int? top = null, string orderby = null, string filter = null, CancellationToken cancellationToken = default) + { + return _metricBatchClient.Batch(subscriptionId, metricnamespace, metricnames, resourceIds, starttime, endtime, interval, aggregation, top, orderby, filter, cancellationToken); + } + + /// Lists the metric values for multiple resources. + /// The subscription identifier for the resources in this batch. + /// Metric namespace that contains the requested metric names. + /// The names of the metrics (comma separated) to retrieve. + /// The comma separated list of resource IDs to query metrics for. + /// + /// The start time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. If you have specified the endtime parameter, then this parameter is required. + /// If only starttime is specified, then endtime defaults to the current time. + /// If no time interval is specified, the default is 1 hour. + /// + /// The end time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. + /// + /// The interval (i.e. timegrain) of the query. + /// *Examples: PT15M, PT1H, P1D* + /// + /// + /// The list of aggregation types (comma separated) to retrieve. + /// *Examples: average, minimum, maximum* + /// + /// + /// The maximum number of records to retrieve per resource ID in the request. + /// Valid only if filter is specified. + /// Defaults to 10. + /// + /// + /// The aggregation to use for sorting results and the direction of the sort. + /// Only one order can be specified. + /// *Examples: sum asc* + /// + /// The filter is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. + /// The cancellation token to use. + /// , , or is null. + public virtual async Task> BatchAsync(string subscriptionId, string metricnamespace, IEnumerable metricnames, ResourceIdList resourceIds, string starttime = null, string endtime = null, TimeSpan? interval = null, string aggregation = null, int? top = null, string orderby = null, string filter = null, CancellationToken cancellationToken = default) + { + return await _metricBatchClient.BatchAsync(subscriptionId, metricnamespace, metricnames, resourceIds, starttime, endtime, interval, aggregation, top, orderby, filter, cancellationToken).ConfigureAwait(false); + } + } +} From 8dc50995db151744a4a19e1c040a5f051edb87e8 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Tue, 12 Sep 2023 13:44:47 -0700 Subject: [PATCH 03/36] wip --- .../tests/MetricsQueryClientLiveTests.cs | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs index 85fc55edf2ae..7c41e4a1c90d 100644 --- a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs +++ b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs @@ -3,10 +3,13 @@ using System; using System.Collections.Generic; +using System.Configuration; using System.Linq; using System.Threading.Tasks; using Azure.Core.TestFramework; using Azure.Monitor.Query.Models; +using Castle.Components.DictionaryAdapter.Xml; +using Newtonsoft.Json.Linq; using NUnit.Framework; namespace Azure.Monitor.Query.Tests @@ -28,6 +31,15 @@ private MetricsQueryClient CreateClient() )); } + private MetricsBatchQueryClient CreateBatchClient() + { + return InstrumentClient(new MetricsBatchQueryClient( + TestEnvironment.MetricsEndpoint, + TestEnvironment.Credential, + InstrumentClientOptions(new MetricsQueryClientOptions()) + )); + } + [SetUp] public async Task SetUp() { @@ -325,5 +337,39 @@ public async Task CanGetMetricByNameInvalid() Assert.Throws(() => { results.Value.GetMetricByName("Guinness"); }); } + + [RecordedTest] + public void MetricsBatchQuery() + { + MetricsBatchQueryClient client = CreateBatchClient(); + string resourceId = TestEnvironment.ResourceId; + resourceId = resourceId.Substring(resourceId.IndexOf("/subscriptions")); + + try + { + client.GetComponentType(resourceId); + configClient.getConfigurationSetting("foo", "bar"); + } + catch (Exception) + { + // ignore as this is only to generate some metrics + } + + MetricsQueryOptions options = new MetricsQueryOptions(); + options.Granularity = TimeSpan.FromMinutes(10); + options.Size = 10; + options.TimeRange = new QueryTimeRange(TimeSpan.FromDays(1)); + //lic Mono queryBatch(List resourceUris, List metricsNames, String metricsNamespace) + var metricsQueryResults = client.BatchAsync( + TestEnvironment.SubscriptionId, + "microsoft.appconfiguration/configurationstores", + new List { resourceId }, + options).getValue(); + Assert.AreEqual(1, metricsQueryResults.getMetricsQueryResults().size()); + Assert.AreEqual(1, metricsQueryResults.getMetricsQueryResults().get(0).getMetrics().size()); + MetricResult metricResult = metricsQueryResults.getMetricsQueryResults().get(0).getMetrics().get(0); + Assert.AreEqual("HttpIncomingRequestCount", metricResult.Name); + Assert.NotNull(metricResult.TimeSeries); + } } } From 790ef126f9a86a827eaaef3848cb217cf2a92e43 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Tue, 19 Sep 2023 13:18:31 -0700 Subject: [PATCH 04/36] wip --- .../src/MetricsBatchQueryClient.cs | 176 +++++++++++------- .../src/Models/ResourceIdList.cs | 25 +++ 2 files changed, 133 insertions(+), 68 deletions(-) create mode 100644 sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs diff --git a/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs b/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs index 65112ed24429..a88e90cb0152 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Net; +using System.Runtime.InteropServices; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -78,78 +79,117 @@ protected MetricsBatchQueryClient() /// public Uri Endpoint { get; } - /// Lists the metric values for multiple resources. - /// The subscription identifier for the resources in this batch. - /// Metric namespace that contains the requested metric names. - /// The names of the metrics (comma separated) to retrieve. - /// The comma separated list of resource IDs to query metrics for. - /// - /// The start time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. If you have specified the endtime parameter, then this parameter is required. - /// If only starttime is specified, then endtime defaults to the current time. - /// If no time interval is specified, the default is 1 hour. - /// - /// The end time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. - /// - /// The interval (i.e. timegrain) of the query. - /// *Examples: PT15M, PT1H, P1D* - /// - /// - /// The list of aggregation types (comma separated) to retrieve. - /// *Examples: average, minimum, maximum* - /// - /// - /// The maximum number of records to retrieve per resource ID in the request. - /// Valid only if filter is specified. - /// Defaults to 10. - /// - /// - /// The aggregation to use for sorting results and the direction of the sort. - /// Only one order can be specified. - /// *Examples: sum asc* - /// - /// The filter is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. - /// The cancellation token to use. - /// , , or is null. - public virtual Response Batch(string subscriptionId, string metricnamespace, IEnumerable metricnames, ResourceIdList resourceIds, string starttime = null, string endtime = null, TimeSpan? interval = null, string aggregation = null, int? top = null, string orderby = null, string filter = null, CancellationToken cancellationToken = default) + /// + /// pass in a list of resource ids, metric names, and a time range to query metrics for those resources. + /// + /// + /// + /// + /// + /// + /// + public virtual Response Batch(List resourceIds, List metricNames, string metricNamespace, MetricsQueryOptions options = null, CancellationToken cancellationToken = default) { - return _metricBatchClient.Batch(subscriptionId, metricnamespace, metricnames, resourceIds, starttime, endtime, interval, aggregation, top, orderby, filter, cancellationToken); + if (resourceIds.Count == 0) + { + throw new ArgumentException("Resource IDs can not be empty"); + } + + var subscriptionId = GetSubscriptionId(resourceIds[0]); + + string filter = null; + TimeSpan? granularity = null; + string aggregations = null; + string startTime = null; + int? top = null; + string orderBy = null; + string endTime = null; + ResourceIdList resourceIdList = new ResourceIdList(resourceIds); + + if (options != null) + { + startTime = options.TimeRange.Value.Start.ToString(); + endTime = options.TimeRange.Value.End.ToString(); + + top = options.Size; + orderBy = options.OrderBy; + filter = options.Filter; + granularity = options.Granularity; + } + + return _metricBatchClient.Batch( + subscriptionId, + metricNamespace, + metricNames, + resourceIdList, + startTime, + endTime, + granularity, + aggregations, + top, + orderBy, + filter, + cancellationToken); } - /// Lists the metric values for multiple resources. - /// The subscription identifier for the resources in this batch. - /// Metric namespace that contains the requested metric names. - /// The names of the metrics (comma separated) to retrieve. - /// The comma separated list of resource IDs to query metrics for. - /// - /// The start time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. If you have specified the endtime parameter, then this parameter is required. - /// If only starttime is specified, then endtime defaults to the current time. - /// If no time interval is specified, the default is 1 hour. - /// - /// The end time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. - /// - /// The interval (i.e. timegrain) of the query. - /// *Examples: PT15M, PT1H, P1D* - /// - /// - /// The list of aggregation types (comma separated) to retrieve. - /// *Examples: average, minimum, maximum* - /// - /// - /// The maximum number of records to retrieve per resource ID in the request. - /// Valid only if filter is specified. - /// Defaults to 10. - /// - /// - /// The aggregation to use for sorting results and the direction of the sort. - /// Only one order can be specified. - /// *Examples: sum asc* - /// - /// The filter is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. - /// The cancellation token to use. - /// , , or is null. - public virtual async Task> BatchAsync(string subscriptionId, string metricnamespace, IEnumerable metricnames, ResourceIdList resourceIds, string starttime = null, string endtime = null, TimeSpan? interval = null, string aggregation = null, int? top = null, string orderby = null, string filter = null, CancellationToken cancellationToken = default) + private string GetSubscriptionId(string resourceId) { - return await _metricBatchClient.BatchAsync(subscriptionId, metricnamespace, metricnames, resourceIds, starttime, endtime, interval, aggregation, top, orderby, filter, cancellationToken).ConfigureAwait(false); + int startIndex = resourceId.IndexOf("subscriptions/") + 14; + return resourceId.Substring(startIndex, resourceId.IndexOf("/", startIndex) - startIndex); + } + + /// + /// todo + /// + /// + /// + /// + /// + /// + /// + /// + public virtual async Task> BatchAsync(List resourceIds, List metricNames, string metricNamespace, MetricsQueryOptions options = null, CancellationToken cancellationToken = default) + { + if (resourceIds.Count == 0) + { + throw new ArgumentException("Resource IDs can not be empty"); + } + + var subscriptionId = GetSubscriptionId(resourceIds[0]); + + string filter = null; + TimeSpan? granularity = null; + string aggregations = null; + string startTime = null; + int? top = null; + string orderBy = null; + string endTime = null; + ResourceIdList resourceIdList = new ResourceIdList(resourceIds); + + if (options != null) + { + startTime = options.TimeRange.Value.Start.ToString(); + endTime = options.TimeRange.Value.End.ToString(); + + top = options.Size; + orderBy = options.OrderBy; + filter = options.Filter; + granularity = options.Granularity; + } + + return await _metricBatchClient.BatchAsync( + subscriptionId, + metricNamespace, + metricNames, + resourceIdList, + startTime, + endTime, + granularity, + aggregations, + top, + orderBy, + filter, + cancellationToken).ConfigureAwait(false); } } } diff --git a/sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs b/sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs new file mode 100644 index 000000000000..4b3cf23e4926 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs @@ -0,0 +1,25 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// + +#nullable disable + +using System.Collections.Generic; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + /// The comma separated list of resource IDs to query metrics for. + public partial class ResourceIdList + { + /// Initializes a new instance of ResourceIdList. + public ResourceIdList(List resourceIds) + { + for (int i = 0; i < resourceIds.Count; i++) + { + Resourceids.Add(new ResourceIdentifier(resourceIds[i])); + } + } + } +} From e22a188a2ea6223db6c28660092c2b51c6ac3928 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Tue, 19 Sep 2023 18:09:27 -0700 Subject: [PATCH 05/36] wip --- .../src/Generated/Models/ResourceIdList.cs | 4 -- .../tests/MetricsQueryClientLiveTests.cs | 66 +++++++++---------- 2 files changed, 33 insertions(+), 37 deletions(-) diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.cs index 92540028cbe7..0b89190eb8a5 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.cs @@ -1,10 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// - -#nullable disable - using System.Collections.Generic; using Azure.Core; diff --git a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs index 7c41e4a1c90d..77194851c678 100644 --- a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs +++ b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs @@ -338,38 +338,38 @@ public async Task CanGetMetricByNameInvalid() Assert.Throws(() => { results.Value.GetMetricByName("Guinness"); }); } - [RecordedTest] - public void MetricsBatchQuery() - { - MetricsBatchQueryClient client = CreateBatchClient(); - string resourceId = TestEnvironment.ResourceId; - resourceId = resourceId.Substring(resourceId.IndexOf("/subscriptions")); - - try - { - client.GetComponentType(resourceId); - configClient.getConfigurationSetting("foo", "bar"); - } - catch (Exception) - { - // ignore as this is only to generate some metrics - } - - MetricsQueryOptions options = new MetricsQueryOptions(); - options.Granularity = TimeSpan.FromMinutes(10); - options.Size = 10; - options.TimeRange = new QueryTimeRange(TimeSpan.FromDays(1)); - //lic Mono queryBatch(List resourceUris, List metricsNames, String metricsNamespace) - var metricsQueryResults = client.BatchAsync( - TestEnvironment.SubscriptionId, - "microsoft.appconfiguration/configurationstores", - new List { resourceId }, - options).getValue(); - Assert.AreEqual(1, metricsQueryResults.getMetricsQueryResults().size()); - Assert.AreEqual(1, metricsQueryResults.getMetricsQueryResults().get(0).getMetrics().size()); - MetricResult metricResult = metricsQueryResults.getMetricsQueryResults().get(0).getMetrics().get(0); - Assert.AreEqual("HttpIncomingRequestCount", metricResult.Name); - Assert.NotNull(metricResult.TimeSeries); - } + //[RecordedTest] + //public void MetricsBatchQuery() + //{ + // MetricsBatchQueryClient client = CreateBatchClient(); + // string resourceId = TestEnvironment.ResourceId; + // resourceId = resourceId.Substring(resourceId.IndexOf("/subscriptions")); + + // try + // { + // client.GetComponentType(resourceId); + // configClient.getConfigurationSetting("foo", "bar"); + // } + // catch (Exception) + // { + // // ignore as this is only to generate some metrics + // } + + // MetricsQueryOptions options = new MetricsQueryOptions(); + // options.Granularity = TimeSpan.FromMinutes(10); + // options.Size = 10; + // options.TimeRange = new QueryTimeRange(TimeSpan.FromDays(1)); + // //lic Mono queryBatch(List resourceUris, List metricsNames, String metricsNamespace) + // var metricsQueryResults = client.BatchAsync( + // TestEnvironment.SubscriptionId, + // "microsoft.appconfiguration/configurationstores", + // new List { resourceId }, + // options).getValue(); + // Assert.AreEqual(1, metricsQueryResults.getMetricsQueryResults().size()); + // Assert.AreEqual(1, metricsQueryResults.getMetricsQueryResults().get(0).getMetrics().size()); + // MetricResult metricResult = metricsQueryResults.getMetricsQueryResults().get(0).getMetrics().get(0); + // Assert.AreEqual("HttpIncomingRequestCount", metricResult.Name); + // Assert.NotNull(metricResult.TimeSeries); + //} } } From acd1596ee229e41feeb86f380a1c0f5f21c4a584 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Mon, 25 Sep 2023 16:21:04 -0700 Subject: [PATCH 06/36] fix ci --- ...ditionalInfoErrorResponse.Serialization.cs | 1 - .../src/Generated/Models/ResourceIdList.cs | 4 + .../src/Models/ResourceIdList.cs | 1 + .../tests/MetricsQueryClientLiveTests.cs | 76 +++++++++++-------- 4 files changed, 48 insertions(+), 34 deletions(-) diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponse.Serialization.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponse.Serialization.cs index 7ba720e24ad3..9588651d811c 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponse.Serialization.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/AdditionalInfoErrorResponse.Serialization.cs @@ -6,7 +6,6 @@ #nullable disable using System.Text.Json; -using Azure.Core; namespace Azure.Monitor.Query.Models { diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.cs index 0b89190eb8a5..92540028cbe7 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.cs @@ -1,6 +1,10 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +// + +#nullable disable + using System.Collections.Generic; using Azure.Core; diff --git a/sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs b/sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs index 4b3cf23e4926..590e3981d7ed 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs @@ -18,6 +18,7 @@ public ResourceIdList(List resourceIds) { for (int i = 0; i < resourceIds.Count; i++) { + Resourceids = new ChangeTrackingList(); Resourceids.Add(new ResourceIdentifier(resourceIds[i])); } } diff --git a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs index 77194851c678..ab0a7a222487 100644 --- a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs +++ b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs @@ -18,7 +18,7 @@ public class MetricsQueryClientLiveTests : RecordedTestBase queryBatch(List resourceUris, List metricsNames, String metricsNamespace) - // var metricsQueryResults = client.BatchAsync( - // TestEnvironment.SubscriptionId, - // "microsoft.appconfiguration/configurationstores", - // new List { resourceId }, - // options).getValue(); - // Assert.AreEqual(1, metricsQueryResults.getMetricsQueryResults().size()); - // Assert.AreEqual(1, metricsQueryResults.getMetricsQueryResults().get(0).getMetrics().size()); - // MetricResult metricResult = metricsQueryResults.getMetricsQueryResults().get(0).getMetrics().get(0); - // Assert.AreEqual("HttpIncomingRequestCount", metricResult.Name); - // Assert.NotNull(metricResult.TimeSeries); - //} + [Test] + public async Task MetricsBatchQueryAsync() + { + MetricsBatchQueryClient client = CreateBatchClient(); + string resourceId = TestEnvironment.ResourceId; + resourceId = resourceId.Substring(resourceId.IndexOf("/subscriptions")); + + //try + //{ + // client.GetComponentType(resourceId); + // configClient.getConfigurationSetting("foo", "bar"); + //} + //catch (Exception) + //{ + // // ignore as this is only to generate some metrics + //} + + //MetricsQueryOptions options = new MetricsQueryOptions(); + //options.Granularity = TimeSpan.FromMinutes(10); + //options.Size = 10; + //options.TimeRange = new QueryTimeRange(TimeSpan.FromDays(1)); + ////lic Mono queryBatch(List resourceUris, List metricsNames, String metricsNamespace) + //var metricsQueryResults = client.BatchAsync( + // TestEnvironment.SubscriptionId, + // "microsoft.appconfiguration/configurationstores", + // new List { resourceId }, + // options).getValue(); + + Response metricsResultsResponse = await client.BatchAsync( + resourceIds: new List { resourceId }, + metricNames: new List { "HttpIncomingRequestCount" }, + metricNamespace: "microsoft.insights/components").ConfigureAwait(false); + + MetricResultsResponse metricsQueryResults = metricsResultsResponse.Value; + + Assert.AreEqual(1, metricsQueryResults.Values.Count); + //Assert.AreEqual(1, metricsQueryResults.getMetricsQueryResults().get(0).getMetrics().size()); + MetricResultsResponseValuesItem metricResultResponse = metricsQueryResults.Values.ElementAtOrDefault(0); + QueryBatchMetric metric = metricResultResponse.Value.ElementAtOrDefault(0); + Assert.AreEqual("HttpIncomingRequestCount", metric.Name); + Assert.NotNull(metric.Timeseries); + } } } From 85d39178f4d3e9126038df4b60eb7feee52aa008 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Fri, 29 Sep 2023 15:15:17 -0700 Subject: [PATCH 07/36] wip --- .../tests/MonitorIngestionLiveTest.cs | 52 ++++- sdk/monitor/Azure.Monitor.Query/CHANGELOG.md | 2 + .../src/MetricsBatchQueryClient.cs | 187 ++++++++++-------- .../src/MetricsBatchQueryClientOptions.cs | 46 +++++ .../tests/MetricsQueryClientLiveTests.cs | 17 +- .../tests/MonitorQueryTestEnvironment.cs | 1 + sdk/monitor/test-resources.bicep | 1 + 7 files changed, 213 insertions(+), 93 deletions(-) create mode 100644 sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClientOptions.cs diff --git a/sdk/monitor/Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs b/sdk/monitor/Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs index 9c477014c94b..e61eee036ea9 100644 --- a/sdk/monitor/Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs +++ b/sdk/monitor/Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs @@ -4,12 +4,18 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Data; using System.IO; +using System.Net; using System.Threading.Tasks; using Azure.Core; using Azure.Core.Pipeline; using Azure.Core.TestFramework; +using Azure.Monitor.Query.Models; +using Azure.Monitor.Query; +using Microsoft.Identity.Client.Platforms.Features.DesktopOs.Kerberos; using NUnit.Framework; +using System.Linq; namespace Azure.Monitor.Ingestion.Tests { @@ -18,7 +24,7 @@ public class MonitorIngestionLiveTest : RecordedTestBase(TestEnvironment.Ingestion_WorkspaceId, @" + MyTable_CL + | order by TimeGenerated desc + | take 10", + new QueryTimeRange(TimeSpan.FromDays(1))); + + //LogsBatchQuery batch = new(); + //string query = TestEnvironment.TableName + " | Count;"; + //string countQueryId = batch.AddWorkspaceQuery( + // TestEnvironment.Ingestion_WorkspaceId, + // query, + // new QueryTimeRange(TimeSpan.FromDays(1))); + + //Response queryResponse = + // await logsQueryClient.QueryBatchAsync(batch).ConfigureAwait(false); + + //Console.WriteLine("Table entry count: " + + // queryResponse.Value.GetResult(countQueryId).Single()); + } + + private class MyLogEntry + { + public string Name { get; set; } + public decimal? Value { get; set; } + } } } diff --git a/sdk/monitor/Azure.Monitor.Query/CHANGELOG.md b/sdk/monitor/Azure.Monitor.Query/CHANGELOG.md index 6971a073106d..9435aac04040 100644 --- a/sdk/monitor/Azure.Monitor.Query/CHANGELOG.md +++ b/sdk/monitor/Azure.Monitor.Query/CHANGELOG.md @@ -3,6 +3,8 @@ ## 1.3.0-beta.1 (Unreleased) ### Features Added +- Added the `MetricsBatchQueryClient` client to support batch querying of metrics. +- Added `Batch` and `BatchAsync` methods to `MetricsBatchQueryClient` ### Breaking Changes diff --git a/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs b/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs index a88e90cb0152..714e10bb3d9b 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs @@ -3,9 +3,6 @@ using System; using System.Collections.Generic; -using System.Net; -using System.Runtime.InteropServices; -using System.Text.Json; using System.Threading; using System.Threading.Tasks; using Azure.Core; @@ -19,13 +16,13 @@ namespace Azure.Monitor.Query /// public class MetricsBatchQueryClient { - private static readonly Uri _defaultEndpoint = new Uri("https://management.azure.com"); + private static readonly Uri _defaultEndpoint = new Uri("https://metrics.monitor.azure.com/.default"); private readonly MetricsBatchRestClient _metricBatchClient; private readonly ClientDiagnostics _clientDiagnostics; /// - /// Initializes a new instance of . Uses the default 'https://management.azure.com' endpoint. + /// Initializes a new instance of . Uses the default 'https://metrics.monitor.azure.com/.default' endpoint. /// /// var client = new MetricsBatchQueryClient(new DefaultAzureCredential()); /// @@ -36,29 +33,29 @@ public MetricsBatchQueryClient(TokenCredential credential) : this(credential, nu } /// - /// Initializes a new instance of . Uses the default 'https://management.azure.com' endpoint. + /// Initializes a new instance of . Uses the default 'https://metrics.monitor.azure.com/.default' endpoint. /// /// The instance to use for authentication. - /// The instance to as client configuration. - public MetricsBatchQueryClient(TokenCredential credential, MetricsQueryClientOptions options) : this(_defaultEndpoint, credential, options) + /// The instance to as client configuration. + public MetricsBatchQueryClient(TokenCredential credential, MetricsBatchQueryClientOptions options) : this(_defaultEndpoint, credential, options) { } /// /// Initializes a new instance of . /// - /// The resource manager service endpoint to use. For example https://management.azure.com/ for public cloud. + /// The data plane service endpoint to use. For example https://metrics.monitor.azure.com/.default for public cloud. /// The instance to use for authentication. /// The instance to as client configuration. - public MetricsBatchQueryClient(Uri endpoint, TokenCredential credential, MetricsQueryClientOptions options = null) + public MetricsBatchQueryClient(Uri endpoint, TokenCredential credential, MetricsBatchQueryClientOptions options = null) { Argument.AssertNotNull(credential, nameof(credential)); - options ??= new MetricsQueryClientOptions(); + options ??= new MetricsBatchQueryClientOptions(); _clientDiagnostics = new ClientDiagnostics(options); - var scope = $"{endpoint.AbsoluteUri}/.default"; + var scope = "https://metrics.monitor.azure.com/.default"; Endpoint = endpoint; var pipeline = HttpPipelineBuilder.Build(options, @@ -90,46 +87,57 @@ protected MetricsBatchQueryClient() /// public virtual Response Batch(List resourceIds, List metricNames, string metricNamespace, MetricsQueryOptions options = null, CancellationToken cancellationToken = default) { - if (resourceIds.Count == 0) + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(MetricsBatchQueryClient)}.{nameof(Batch)}"); + scope.Start(); + + try { - throw new ArgumentException("Resource IDs can not be empty"); + if (resourceIds.Count == 0) + { + throw new ArgumentException("Resource IDs can not be empty"); + } + + var subscriptionId = GetSubscriptionId(resourceIds[0]); + + string filter = null; + TimeSpan? granularity = null; + string aggregations = null; + string startTime = null; + int? top = null; + string orderBy = null; + string endTime = null; + ResourceIdList resourceIdList = new ResourceIdList(resourceIds); + + if (options != null) + { + startTime = options.TimeRange.Value.Start.ToString(); + endTime = options.TimeRange.Value.End.ToString(); + + top = options.Size; + orderBy = options.OrderBy; + filter = options.Filter; + granularity = options.Granularity; + } + + return _metricBatchClient.Batch( + subscriptionId, + metricNamespace, + metricNames, + resourceIdList, + startTime, + endTime, + granularity, + aggregations, + top, + orderBy, + filter, + cancellationToken); } - - var subscriptionId = GetSubscriptionId(resourceIds[0]); - - string filter = null; - TimeSpan? granularity = null; - string aggregations = null; - string startTime = null; - int? top = null; - string orderBy = null; - string endTime = null; - ResourceIdList resourceIdList = new ResourceIdList(resourceIds); - - if (options != null) + catch (Exception e) { - startTime = options.TimeRange.Value.Start.ToString(); - endTime = options.TimeRange.Value.End.ToString(); - - top = options.Size; - orderBy = options.OrderBy; - filter = options.Filter; - granularity = options.Granularity; + scope.Failed(e); + throw; } - - return _metricBatchClient.Batch( - subscriptionId, - metricNamespace, - metricNames, - resourceIdList, - startTime, - endTime, - granularity, - aggregations, - top, - orderBy, - filter, - cancellationToken); } private string GetSubscriptionId(string resourceId) @@ -150,46 +158,57 @@ private string GetSubscriptionId(string resourceId) /// public virtual async Task> BatchAsync(List resourceIds, List metricNames, string metricNamespace, MetricsQueryOptions options = null, CancellationToken cancellationToken = default) { - if (resourceIds.Count == 0) + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(MetricsBatchQueryClient)}.{nameof(Batch)}"); + scope.Start(); + + try { - throw new ArgumentException("Resource IDs can not be empty"); + if (resourceIds.Count == 0) + { + throw new ArgumentException("Resource IDs can not be empty"); + } + + var subscriptionId = GetSubscriptionId(resourceIds[0]); + + string filter = null; + TimeSpan? granularity = null; + string aggregations = null; + string startTime = null; + int? top = null; + string orderBy = null; + string endTime = null; + ResourceIdList resourceIdList = new ResourceIdList(resourceIds); + + if (options != null) + { + startTime = options.TimeRange.Value.Start.ToString(); + endTime = options.TimeRange.Value.End.ToString(); + + top = options.Size; + orderBy = options.OrderBy; + filter = options.Filter; + granularity = options.Granularity; + } + + return await _metricBatchClient.BatchAsync( + subscriptionId, + metricNamespace, + metricNames, + resourceIdList, + startTime, + endTime, + granularity, + aggregations, + top, + orderBy, + filter, + cancellationToken).ConfigureAwait(false); } - - var subscriptionId = GetSubscriptionId(resourceIds[0]); - - string filter = null; - TimeSpan? granularity = null; - string aggregations = null; - string startTime = null; - int? top = null; - string orderBy = null; - string endTime = null; - ResourceIdList resourceIdList = new ResourceIdList(resourceIds); - - if (options != null) + catch (Exception e) { - startTime = options.TimeRange.Value.Start.ToString(); - endTime = options.TimeRange.Value.End.ToString(); - - top = options.Size; - orderBy = options.OrderBy; - filter = options.Filter; - granularity = options.Granularity; + scope.Failed(e); + throw; } - - return await _metricBatchClient.BatchAsync( - subscriptionId, - metricNamespace, - metricNames, - resourceIdList, - startTime, - endTime, - granularity, - aggregations, - top, - orderBy, - filter, - cancellationToken).ConfigureAwait(false); } } } diff --git a/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClientOptions.cs b/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClientOptions.cs new file mode 100644 index 000000000000..b6b2f8bc5c33 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClientOptions.cs @@ -0,0 +1,46 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using Azure.Core; + +namespace Azure.Monitor.Query +{ + /// + /// Provides the client configuration options for connecting to Azure Monitor Metrics service. + /// + public class MetricsBatchQueryClientOptions: ClientOptions + { + private readonly ServiceVersion _version; + + /// + /// The latest service version supported by this client library. + /// + internal const ServiceVersion LatestVersion = ServiceVersion.V2023_05_01_PREVIEW; + + /// + /// Initializes a new instance of the class. + /// + /// + /// The of the service API used when + /// making requests. + /// + public MetricsBatchQueryClientOptions(ServiceVersion version = LatestVersion) + { + _version = version; + } + + /// + /// The versions of Azure Monitor Metrics service supported by this client + /// library. + /// + public enum ServiceVersion + { +#pragma warning disable CA1707 // Identifiers should not contain underscores + /// + /// Version 2023-05-01-preview of the service. + /// + V2023_05_01_PREVIEW = 1, +#pragma warning restore CA1707 // Identifiers should not contain underscores + } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs index ab0a7a222487..7ae46e04c46f 100644 --- a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs +++ b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs @@ -34,9 +34,9 @@ private MetricsQueryClient CreateClient() private MetricsBatchQueryClient CreateBatchClient() { return InstrumentClient(new MetricsBatchQueryClient( - TestEnvironment.MetricsEndpoint, + new Uri(TestEnvironment.DataplaneEndpoint), TestEnvironment.Credential, - InstrumentClientOptions(new MetricsQueryClientOptions()) + InstrumentClientOptions(new MetricsBatchQueryClientOptions()) )); } @@ -374,12 +374,13 @@ public async Task MetricsBatchQueryAsync() MetricResultsResponse metricsQueryResults = metricsResultsResponse.Value; - Assert.AreEqual(1, metricsQueryResults.Values.Count); - //Assert.AreEqual(1, metricsQueryResults.getMetricsQueryResults().get(0).getMetrics().size()); - MetricResultsResponseValuesItem metricResultResponse = metricsQueryResults.Values.ElementAtOrDefault(0); - QueryBatchMetric metric = metricResultResponse.Value.ElementAtOrDefault(0); - Assert.AreEqual("HttpIncomingRequestCount", metric.Name); - Assert.NotNull(metric.Timeseries); + //Assert.AreEqual(1, metricsQueryResults.Values.Count); + Assert.AreEqual(0, metricsQueryResults.Values.Count); + ////Assert.AreEqual(1, metricsQueryResults.getMetricsQueryResults().get(0).getMetrics().size()); + //MetricResultsResponseValuesItem metricResultResponse = metricsQueryResults.Values.ElementAtOrDefault(0); + //QueryBatchMetric metric = metricResultResponse.Value.ElementAtOrDefault(0); + //Assert.AreEqual("HttpIncomingRequestCount", metric.Name); + //Assert.NotNull(metric.Timeseries); } } } diff --git a/sdk/monitor/Azure.Monitor.Query/tests/MonitorQueryTestEnvironment.cs b/sdk/monitor/Azure.Monitor.Query/tests/MonitorQueryTestEnvironment.cs index a83ade4be07e..3804799e32bc 100644 --- a/sdk/monitor/Azure.Monitor.Query/tests/MonitorQueryTestEnvironment.cs +++ b/sdk/monitor/Azure.Monitor.Query/tests/MonitorQueryTestEnvironment.cs @@ -21,5 +21,6 @@ public class MonitorQueryTestEnvironment : TestEnvironment public string ResourceId => GetRecordedVariable("RESOURCE_ID"); public string WorkspacePrimaryResourceId => GetRecordedVariable("WORKSPACE_PRIMARY_RESOURCE_ID"); public string WorkspaceSecondaryResourceId => GetRecordedVariable("WORKSPACE_SECONDARY_RESOURCE_ID"); + public string DataplaneEndpoint => GetRecordedOptionalVariable("DATAPLANE_ENDPOINT"); } } diff --git a/sdk/monitor/test-resources.bicep b/sdk/monitor/test-resources.bicep index 702c75ab775d..a477af24d1cb 100644 --- a/sdk/monitor/test-resources.bicep +++ b/sdk/monitor/test-resources.bicep @@ -189,3 +189,4 @@ output INGESTION_DATA_COLLECTION_RULE_IMMUTABLE_ID string = dataCollectionRule.p output RESOURCE_ID string = resourceGroup().id output WORKSPACE_PRIMARY_RESOURCE_ID string = primaryWorkspace.id output WORKSPACE_SECONDARY_RESOURCE_ID string = secondaryWorkspace.id +output DATAPLANE_ENDPOINT string = 'https://metrics.monitor.azure.com/.default' From 7b94d420da5d4e9436e06898d16b8296f173777b Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Wed, 4 Oct 2023 13:25:45 -0700 Subject: [PATCH 08/36] wip --- sdk/monitor/Azure.Monitor.Query/CHANGELOG.md | 1 + .../Azure.Monitor.Query/src/QueryAudience.cs | 59 +++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 sdk/monitor/Azure.Monitor.Query/src/QueryAudience.cs diff --git a/sdk/monitor/Azure.Monitor.Query/CHANGELOG.md b/sdk/monitor/Azure.Monitor.Query/CHANGELOG.md index 9435aac04040..503f08ef790c 100644 --- a/sdk/monitor/Azure.Monitor.Query/CHANGELOG.md +++ b/sdk/monitor/Azure.Monitor.Query/CHANGELOG.md @@ -9,6 +9,7 @@ ### Breaking Changes ### Bugs Fixed +- Fix sovereign support for US Gov and China clouds ### Other Changes diff --git a/sdk/monitor/Azure.Monitor.Query/src/QueryAudience.cs b/sdk/monitor/Azure.Monitor.Query/src/QueryAudience.cs new file mode 100644 index 000000000000..35f971dea712 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/QueryAudience.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ComponentModel; +using Azure.Core; + +namespace Azure.Monitor.Ingestion +{ + /// Cloud audiences available for Ingestion. + public readonly partial struct IngestionAudience : IEquatable + { + private readonly string _value; + + /// + /// Initializes a new instance of the object. + /// + /// The Azure Active Directory audience to use when forming authorization scopes.For the Language service, this value corresponds to a URL that identifies the Azure cloud where the resource is located. For more information: . + /// is null. + /// Please use one of the constant members over creating a custom value unless you have special needs for doing so. + public IngestionAudience(string value) + { + Argument.AssertNotNullOrEmpty(value, nameof(value)); + _value = value; + } + + private const string AzureChinaValue = "https://monitor.azure.cn//.default"; + private const string AzureGovernmentValue = "https://monitor.azure.us//.default"; + private const string AzurePublicCloudValue = "https://monitor.azure.com//.default"; + + /// Azure China. + public static IngestionAudience AzureChina { get; } = new IngestionAudience(AzureChinaValue); + + /// Azure Government. + public static IngestionAudience AzureGovernment { get; } = new IngestionAudience(AzureGovernmentValue); + + /// Azure Public Cloud. + public static IngestionAudience AzurePublicCloud { get; } = new IngestionAudience(AzurePublicCloudValue); + + /// Determines if two values are the same. + public static bool operator ==(IngestionAudience left, IngestionAudience right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(IngestionAudience left, IngestionAudience right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator IngestionAudience(string value) => new IngestionAudience(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is IngestionAudience other && Equals(other); + /// + public bool Equals(IngestionAudience other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} From ea13e03f7beb24c386f78aad24d868618d406e36 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Wed, 4 Oct 2023 16:41:19 -0700 Subject: [PATCH 09/36] wip --- ...{QueryAudience.cs => LogsQueryAudience.cs} | 36 +++++------ .../src/LogsQueryClient.cs | 1 - .../src/MetricsQueryAudience.cs | 59 +++++++++++++++++++ 3 files changed, 77 insertions(+), 19 deletions(-) rename sdk/monitor/Azure.Monitor.Query/src/{QueryAudience.cs => LogsQueryAudience.cs} (52%) create mode 100644 sdk/monitor/Azure.Monitor.Query/src/MetricsQueryAudience.cs diff --git a/sdk/monitor/Azure.Monitor.Query/src/QueryAudience.cs b/sdk/monitor/Azure.Monitor.Query/src/LogsQueryAudience.cs similarity index 52% rename from sdk/monitor/Azure.Monitor.Query/src/QueryAudience.cs rename to sdk/monitor/Azure.Monitor.Query/src/LogsQueryAudience.cs index 35f971dea712..7f8e7031df08 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/QueryAudience.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/LogsQueryAudience.cs @@ -5,50 +5,50 @@ using System.ComponentModel; using Azure.Core; -namespace Azure.Monitor.Ingestion +namespace Azure.Monitor.Query { /// Cloud audiences available for Ingestion. - public readonly partial struct IngestionAudience : IEquatable + public readonly partial struct LogsQueryAudience : IEquatable { private readonly string _value; /// - /// Initializes a new instance of the object. + /// Initializes a new instance of the object. /// /// The Azure Active Directory audience to use when forming authorization scopes.For the Language service, this value corresponds to a URL that identifies the Azure cloud where the resource is located. For more information: . /// is null. /// Please use one of the constant members over creating a custom value unless you have special needs for doing so. - public IngestionAudience(string value) + public LogsQueryAudience(string value) { Argument.AssertNotNullOrEmpty(value, nameof(value)); _value = value; } - private const string AzureChinaValue = "https://monitor.azure.cn//.default"; - private const string AzureGovernmentValue = "https://monitor.azure.us//.default"; - private const string AzurePublicCloudValue = "https://monitor.azure.com//.default"; + private const string AzureChinaValue = "https://api.loganalytics.azure.cn"; + private const string AzureGovernmentValue = "https://api.loganalytics.us"; + private const string AzurePublicCloudValue = "https://api.loganalytics.io"; /// Azure China. - public static IngestionAudience AzureChina { get; } = new IngestionAudience(AzureChinaValue); + public static LogsQueryAudience AzureChina { get; } = new LogsQueryAudience(AzureChinaValue); /// Azure Government. - public static IngestionAudience AzureGovernment { get; } = new IngestionAudience(AzureGovernmentValue); + public static LogsQueryAudience AzureGovernment { get; } = new LogsQueryAudience(AzureGovernmentValue); /// Azure Public Cloud. - public static IngestionAudience AzurePublicCloud { get; } = new IngestionAudience(AzurePublicCloudValue); + public static LogsQueryAudience AzurePublicCloud { get; } = new LogsQueryAudience(AzurePublicCloudValue); - /// Determines if two values are the same. - public static bool operator ==(IngestionAudience left, IngestionAudience right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(IngestionAudience left, IngestionAudience right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator IngestionAudience(string value) => new IngestionAudience(value); + /// Determines if two values are the same. + public static bool operator ==(LogsQueryAudience left, LogsQueryAudience right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(LogsQueryAudience left, LogsQueryAudience right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator LogsQueryAudience(string value) => new LogsQueryAudience(value); /// [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is IngestionAudience other && Equals(other); + public override bool Equals(object obj) => obj is LogsQueryAudience other && Equals(other); /// - public bool Equals(IngestionAudience other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + public bool Equals(LogsQueryAudience other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); /// [EditorBrowsable(EditorBrowsableState.Never)] diff --git a/sdk/monitor/Azure.Monitor.Query/src/LogsQueryClient.cs b/sdk/monitor/Azure.Monitor.Query/src/LogsQueryClient.cs index 3fe386d96a62..58ba047fa7de 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/LogsQueryClient.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/LogsQueryClient.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Globalization; -using System.Linq; using System.Text; using System.Text.Json; using System.Threading; diff --git a/sdk/monitor/Azure.Monitor.Query/src/MetricsQueryAudience.cs b/sdk/monitor/Azure.Monitor.Query/src/MetricsQueryAudience.cs new file mode 100644 index 000000000000..0cb083ffcb9a --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/MetricsQueryAudience.cs @@ -0,0 +1,59 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +using System; +using System.ComponentModel; +using Azure.Core; + +namespace Azure.Monitor.Query +{ + /// Cloud audiences available for Ingestion. + public readonly partial struct MetricsQueryAudience : IEquatable + { + private readonly string _value; + + /// + /// Initializes a new instance of the object. + /// + /// The Azure Active Directory audience to use when forming authorization scopes.For the Language service, this value corresponds to a URL that identifies the Azure cloud where the resource is located. For more information: . + /// is null. + /// Please use one of the constant members over creating a custom value unless you have special needs for doing so. + public MetricsQueryAudience(string value) + { + Argument.AssertNotNullOrEmpty(value, nameof(value)); + _value = value; + } + + private const string AzureChinaValue = "https://management.chinacloudapi.cn"; + private const string AzureGovernmentValue = "https://management.usgovcloudapi.net"; + private const string AzurePublicCloudValue = "https://management.azure.com"; + + /// Azure China. + public static MetricsQueryAudience AzureChina { get; } = new MetricsQueryAudience(AzureChinaValue); + + /// Azure Government. + public static MetricsQueryAudience AzureGovernment { get; } = new MetricsQueryAudience(AzureGovernmentValue); + + /// Azure Public Cloud. + public static MetricsQueryAudience AzurePublicCloud { get; } = new MetricsQueryAudience(AzurePublicCloudValue); + + /// Determines if two values are the same. + public static bool operator ==(MetricsQueryAudience left, MetricsQueryAudience right) => left.Equals(right); + /// Determines if two values are not the same. + public static bool operator !=(MetricsQueryAudience left, MetricsQueryAudience right) => !left.Equals(right); + /// Converts a string to a . + public static implicit operator MetricsQueryAudience(string value) => new MetricsQueryAudience(value); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override bool Equals(object obj) => obj is MetricsQueryAudience other && Equals(other); + /// + public bool Equals(MetricsQueryAudience other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); + + /// + [EditorBrowsable(EditorBrowsableState.Never)] + public override int GetHashCode() => _value?.GetHashCode() ?? 0; + /// + public override string ToString() => _value; + } +} From 1d95e85091cf51588e1bceac377cdf374e0ca28b Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Tue, 10 Oct 2023 14:17:30 -0700 Subject: [PATCH 10/36] revert audience --- .../src/LogsQueryAudience.cs | 59 ------------------- .../src/MetricsQueryAudience.cs | 59 ------------------- 2 files changed, 118 deletions(-) delete mode 100644 sdk/monitor/Azure.Monitor.Query/src/LogsQueryAudience.cs delete mode 100644 sdk/monitor/Azure.Monitor.Query/src/MetricsQueryAudience.cs diff --git a/sdk/monitor/Azure.Monitor.Query/src/LogsQueryAudience.cs b/sdk/monitor/Azure.Monitor.Query/src/LogsQueryAudience.cs deleted file mode 100644 index 7f8e7031df08..000000000000 --- a/sdk/monitor/Azure.Monitor.Query/src/LogsQueryAudience.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.ComponentModel; -using Azure.Core; - -namespace Azure.Monitor.Query -{ - /// Cloud audiences available for Ingestion. - public readonly partial struct LogsQueryAudience : IEquatable - { - private readonly string _value; - - /// - /// Initializes a new instance of the object. - /// - /// The Azure Active Directory audience to use when forming authorization scopes.For the Language service, this value corresponds to a URL that identifies the Azure cloud where the resource is located. For more information: . - /// is null. - /// Please use one of the constant members over creating a custom value unless you have special needs for doing so. - public LogsQueryAudience(string value) - { - Argument.AssertNotNullOrEmpty(value, nameof(value)); - _value = value; - } - - private const string AzureChinaValue = "https://api.loganalytics.azure.cn"; - private const string AzureGovernmentValue = "https://api.loganalytics.us"; - private const string AzurePublicCloudValue = "https://api.loganalytics.io"; - - /// Azure China. - public static LogsQueryAudience AzureChina { get; } = new LogsQueryAudience(AzureChinaValue); - - /// Azure Government. - public static LogsQueryAudience AzureGovernment { get; } = new LogsQueryAudience(AzureGovernmentValue); - - /// Azure Public Cloud. - public static LogsQueryAudience AzurePublicCloud { get; } = new LogsQueryAudience(AzurePublicCloudValue); - - /// Determines if two values are the same. - public static bool operator ==(LogsQueryAudience left, LogsQueryAudience right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(LogsQueryAudience left, LogsQueryAudience right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator LogsQueryAudience(string value) => new LogsQueryAudience(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is LogsQueryAudience other && Equals(other); - /// - public bool Equals(LogsQueryAudience other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value?.GetHashCode() ?? 0; - /// - public override string ToString() => _value; - } -} diff --git a/sdk/monitor/Azure.Monitor.Query/src/MetricsQueryAudience.cs b/sdk/monitor/Azure.Monitor.Query/src/MetricsQueryAudience.cs deleted file mode 100644 index 0cb083ffcb9a..000000000000 --- a/sdk/monitor/Azure.Monitor.Query/src/MetricsQueryAudience.cs +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright (c) Microsoft Corporation. All rights reserved. -// Licensed under the MIT License. - -using System; -using System.ComponentModel; -using Azure.Core; - -namespace Azure.Monitor.Query -{ - /// Cloud audiences available for Ingestion. - public readonly partial struct MetricsQueryAudience : IEquatable - { - private readonly string _value; - - /// - /// Initializes a new instance of the object. - /// - /// The Azure Active Directory audience to use when forming authorization scopes.For the Language service, this value corresponds to a URL that identifies the Azure cloud where the resource is located. For more information: . - /// is null. - /// Please use one of the constant members over creating a custom value unless you have special needs for doing so. - public MetricsQueryAudience(string value) - { - Argument.AssertNotNullOrEmpty(value, nameof(value)); - _value = value; - } - - private const string AzureChinaValue = "https://management.chinacloudapi.cn"; - private const string AzureGovernmentValue = "https://management.usgovcloudapi.net"; - private const string AzurePublicCloudValue = "https://management.azure.com"; - - /// Azure China. - public static MetricsQueryAudience AzureChina { get; } = new MetricsQueryAudience(AzureChinaValue); - - /// Azure Government. - public static MetricsQueryAudience AzureGovernment { get; } = new MetricsQueryAudience(AzureGovernmentValue); - - /// Azure Public Cloud. - public static MetricsQueryAudience AzurePublicCloud { get; } = new MetricsQueryAudience(AzurePublicCloudValue); - - /// Determines if two values are the same. - public static bool operator ==(MetricsQueryAudience left, MetricsQueryAudience right) => left.Equals(right); - /// Determines if two values are not the same. - public static bool operator !=(MetricsQueryAudience left, MetricsQueryAudience right) => !left.Equals(right); - /// Converts a string to a . - public static implicit operator MetricsQueryAudience(string value) => new MetricsQueryAudience(value); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override bool Equals(object obj) => obj is MetricsQueryAudience other && Equals(other); - /// - public bool Equals(MetricsQueryAudience other) => string.Equals(_value, other._value, StringComparison.InvariantCultureIgnoreCase); - - /// - [EditorBrowsable(EditorBrowsableState.Never)] - public override int GetHashCode() => _value?.GetHashCode() ?? 0; - /// - public override string ToString() => _value; - } -} From 9bbaf5ff143bb8f5ee5a2727501387e9a1379138 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Tue, 10 Oct 2023 14:17:54 -0700 Subject: [PATCH 11/36] Update CHANGELOG.md --- sdk/monitor/Azure.Monitor.Query/CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/monitor/Azure.Monitor.Query/CHANGELOG.md b/sdk/monitor/Azure.Monitor.Query/CHANGELOG.md index 503f08ef790c..9435aac04040 100644 --- a/sdk/monitor/Azure.Monitor.Query/CHANGELOG.md +++ b/sdk/monitor/Azure.Monitor.Query/CHANGELOG.md @@ -9,7 +9,6 @@ ### Breaking Changes ### Bugs Fixed -- Fix sovereign support for US Gov and China clouds ### Other Changes From db25117da644878f30f0560f8137e8dac60b464a Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Thu, 12 Oct 2023 12:27:21 -0700 Subject: [PATCH 12/36] wip --- .../api/Azure.Monitor.Query.netstandard2.0.cs | 103 ++++++++++++++++++ .../tests/Azure.Monitor.Query.Tests.csproj | 1 + .../tests/MetricsQueryClientLiveTests.cs | 70 ++++++------ .../tests/MonitorQueryTestEnvironment.cs | 3 + sdk/monitor/test-resources.bicep | 23 +++- 5 files changed, 162 insertions(+), 38 deletions(-) diff --git a/sdk/monitor/Azure.Monitor.Query/api/Azure.Monitor.Query.netstandard2.0.cs b/sdk/monitor/Azure.Monitor.Query/api/Azure.Monitor.Query.netstandard2.0.cs index 63441d8215f7..1a24095be733 100644 --- a/sdk/monitor/Azure.Monitor.Query/api/Azure.Monitor.Query.netstandard2.0.cs +++ b/sdk/monitor/Azure.Monitor.Query/api/Azure.Monitor.Query.netstandard2.0.cs @@ -42,6 +42,24 @@ public LogsQueryOptions() { } public bool IncludeVisualization { get { throw null; } set { } } public System.TimeSpan? ServerTimeout { get { throw null; } set { } } } + public partial class MetricsBatchQueryClient + { + protected MetricsBatchQueryClient() { } + public MetricsBatchQueryClient(Azure.Core.TokenCredential credential) { } + public MetricsBatchQueryClient(Azure.Core.TokenCredential credential, Azure.Monitor.Query.MetricsBatchQueryClientOptions options) { } + public MetricsBatchQueryClient(System.Uri endpoint, Azure.Core.TokenCredential credential, Azure.Monitor.Query.MetricsBatchQueryClientOptions options = null) { } + public System.Uri Endpoint { get { throw null; } } + public virtual Azure.Response Batch(System.Collections.Generic.List resourceIds, System.Collections.Generic.List metricNames, string metricNamespace, Azure.Monitor.Query.MetricsQueryOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> BatchAsync(System.Collections.Generic.List resourceIds, System.Collections.Generic.List metricNames, string metricNamespace, Azure.Monitor.Query.MetricsQueryOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + } + public partial class MetricsBatchQueryClientOptions : Azure.Core.ClientOptions + { + public MetricsBatchQueryClientOptions(Azure.Monitor.Query.MetricsBatchQueryClientOptions.ServiceVersion version = Azure.Monitor.Query.MetricsBatchQueryClientOptions.ServiceVersion.V2023_05_01_PREVIEW) { } + public enum ServiceVersion + { + V2023_05_01_PREVIEW = 1, + } + } public partial class MetricsQueryClient { protected MetricsQueryClient() { } @@ -287,6 +305,22 @@ internal MetricResult() { } public System.Collections.Generic.IReadOnlyList TimeSeries { get { throw null; } } public Azure.Monitor.Query.Models.MetricUnit Unit { get { throw null; } } } + public partial class MetricResultsResponse + { + internal MetricResultsResponse() { } + public System.Collections.Generic.IReadOnlyList Values { get { throw null; } } + } + public partial class MetricResultsResponseValuesItem + { + internal MetricResultsResponseValuesItem() { } + public string Endtime { get { throw null; } } + public System.TimeSpan? Interval { get { throw null; } } + public string Namespace { get { throw null; } } + public string Resourceid { get { throw null; } } + public string Resourceregion { get { throw null; } } + public string Starttime { get { throw null; } } + public System.Collections.Generic.IReadOnlyList Value { get { throw null; } } + } public partial class MetricsQueryResult { internal MetricsQueryResult() { } @@ -352,9 +386,78 @@ public static partial class MonitorQueryModelFactory public static Azure.Monitor.Query.Models.LogsTableRow LogsTableRow(System.Collections.Generic.IEnumerable columns, System.Collections.Generic.IEnumerable values) { throw null; } public static Azure.Monitor.Query.Models.MetricAvailability MetricAvailability(System.TimeSpan? granularity = default(System.TimeSpan?), System.TimeSpan? retention = default(System.TimeSpan?)) { throw null; } public static Azure.Monitor.Query.Models.MetricResult MetricResult(string id, string resourceType, string name, Azure.Monitor.Query.Models.MetricUnit unit, System.Collections.Generic.IEnumerable timeSeries) { throw null; } + public static Azure.Monitor.Query.Models.MetricResultsResponse MetricResultsResponse(System.Collections.Generic.IEnumerable values = null) { throw null; } + public static Azure.Monitor.Query.Models.MetricResultsResponseValuesItem MetricResultsResponseValuesItem(string starttime = null, string endtime = null, System.TimeSpan? interval = default(System.TimeSpan?), string @namespace = null, string resourceregion = null, string resourceid = null, System.Collections.Generic.IEnumerable value = null) { throw null; } public static Azure.Monitor.Query.Models.MetricsQueryResult MetricsQueryResult(int? cost, string timespan, System.TimeSpan? granularity, string @namespace, string resourceRegion, System.Collections.Generic.IReadOnlyList metrics) { throw null; } public static Azure.Monitor.Query.Models.MetricTimeSeriesElement MetricTimeSeriesElement(System.Collections.Generic.IReadOnlyDictionary metadataValues, System.Collections.Generic.IEnumerable values) { throw null; } public static Azure.Monitor.Query.Models.MetricValue MetricValue(System.DateTimeOffset timeStamp = default(System.DateTimeOffset), double? average = default(double?), double? minimum = default(double?), double? maximum = default(double?), double? total = default(double?), double? count = default(double?)) { throw null; } + public static Azure.Monitor.Query.Models.QueryBatchLocalizableString QueryBatchLocalizableString(string value = null, string localizedValue = null) { throw null; } + public static Azure.Monitor.Query.Models.QueryBatchMetadataValue QueryBatchMetadataValue(Azure.Monitor.Query.Models.QueryBatchLocalizableString name = null, string value = null) { throw null; } + public static Azure.Monitor.Query.Models.QueryBatchMetric QueryBatchMetric(string id = null, Azure.Monitor.Query.Models.QueryBatchLocalizableString name = null, string displayDescription = null, string type = null, Azure.Monitor.Query.Models.QueryBatchMetricUnit unit = Azure.Monitor.Query.Models.QueryBatchMetricUnit.Count, System.Collections.Generic.IEnumerable timeseries = null, string errorCode = null, string errorMessage = null) { throw null; } + public static Azure.Monitor.Query.Models.QueryBatchMetricValue QueryBatchMetricValue(System.DateTimeOffset timeStamp = default(System.DateTimeOffset), double? average = default(double?), double? minimum = default(double?), double? maximum = default(double?), double? total = default(double?), double? count = default(double?)) { throw null; } + public static Azure.Monitor.Query.Models.QueryBatchTimeSeriesElement QueryBatchTimeSeriesElement(System.Collections.Generic.IEnumerable metadatavalues = null, System.Collections.Generic.IEnumerable data = null) { throw null; } + } + public partial class QueryBatchLocalizableString + { + internal QueryBatchLocalizableString() { } + public string LocalizedValue { get { throw null; } } + public string Value { get { throw null; } } + } + public partial class QueryBatchMetadataValue + { + internal QueryBatchMetadataValue() { } + public Azure.Monitor.Query.Models.QueryBatchLocalizableString Name { get { throw null; } } + public string Value { get { throw null; } } + } + public partial class QueryBatchMetric + { + internal QueryBatchMetric() { } + public string DisplayDescription { get { throw null; } } + public string ErrorCode { get { throw null; } } + public string ErrorMessage { get { throw null; } } + public string Id { get { throw null; } } + public Azure.Monitor.Query.Models.QueryBatchLocalizableString Name { get { throw null; } } + public System.Collections.Generic.IReadOnlyList Timeseries { get { throw null; } } + public string Type { get { throw null; } } + public Azure.Monitor.Query.Models.QueryBatchMetricUnit Unit { get { throw null; } } + } + public enum QueryBatchMetricUnit + { + Count = 0, + Bytes = 1, + Seconds = 2, + CountPerSecond = 3, + BytesPerSecond = 4, + Percent = 5, + MilliSeconds = 6, + ByteSeconds = 7, + Unspecified = 8, + Cores = 9, + MilliCores = 10, + NanoCores = 11, + BitsPerSecond = 12, + } + public partial class QueryBatchMetricValue + { + internal QueryBatchMetricValue() { } + public double? Average { get { throw null; } } + public double? Count { get { throw null; } } + public double? Maximum { get { throw null; } } + public double? Minimum { get { throw null; } } + public System.DateTimeOffset TimeStamp { get { throw null; } } + public double? Total { get { throw null; } } + } + public partial class QueryBatchTimeSeriesElement + { + internal QueryBatchTimeSeriesElement() { } + public System.Collections.Generic.IReadOnlyList Data { get { throw null; } } + public System.Collections.Generic.IReadOnlyList Metadatavalues { get { throw null; } } + } + public partial class ResourceIdList + { + public ResourceIdList() { } + public ResourceIdList(System.Collections.Generic.List resourceIds) { } + public System.Collections.Generic.IList Resourceids { get { throw null; } } } } namespace Microsoft.Extensions.Azure diff --git a/sdk/monitor/Azure.Monitor.Query/tests/Azure.Monitor.Query.Tests.csproj b/sdk/monitor/Azure.Monitor.Query/tests/Azure.Monitor.Query.Tests.csproj index 87c5f58b66cb..e5d839deef2b 100644 --- a/sdk/monitor/Azure.Monitor.Query/tests/Azure.Monitor.Query.Tests.csproj +++ b/sdk/monitor/Azure.Monitor.Query/tests/Azure.Monitor.Query.Tests.csproj @@ -5,6 +5,7 @@ + diff --git a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs index 7ae46e04c46f..7c2187366c16 100644 --- a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs +++ b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs @@ -3,13 +3,10 @@ using System; using System.Collections.Generic; -using System.Configuration; using System.Linq; using System.Threading.Tasks; using Azure.Core.TestFramework; using Azure.Monitor.Query.Models; -using Castle.Components.DictionaryAdapter.Xml; -using Newtonsoft.Json.Linq; using NUnit.Framework; namespace Azure.Monitor.Query.Tests @@ -18,8 +15,9 @@ public class MetricsQueryClientLiveTests : RecordedTestBase(() => { results.Value.GetMetricByName("Guinness"); }); } - //[RecordedTest] + [RecordedTest] [Test] public async Task MetricsBatchQueryAsync() { MetricsBatchQueryClient client = CreateBatchClient(); - string resourceId = TestEnvironment.ResourceId; - resourceId = resourceId.Substring(resourceId.IndexOf("/subscriptions")); - - //try - //{ - // client.GetComponentType(resourceId); - // configClient.getConfigurationSetting("foo", "bar"); - //} - //catch (Exception) - //{ - // // ignore as this is only to generate some metrics - //} - - //MetricsQueryOptions options = new MetricsQueryOptions(); - //options.Granularity = TimeSpan.FromMinutes(10); - //options.Size = 10; - //options.TimeRange = new QueryTimeRange(TimeSpan.FromDays(1)); - ////lic Mono queryBatch(List resourceUris, List metricsNames, String metricsNamespace) - //var metricsQueryResults = client.BatchAsync( - // TestEnvironment.SubscriptionId, - // "microsoft.appconfiguration/configurationstores", - // new List { resourceId }, - // options).getValue(); + + var resourceId = TestEnvironment.StorageAccountId; Response metricsResultsResponse = await client.BatchAsync( resourceIds: new List { resourceId }, - metricNames: new List { "HttpIncomingRequestCount" }, - metricNamespace: "microsoft.insights/components").ConfigureAwait(false); + metricNames: new List { "Ingress" }, + metricNamespace: "Microsoft.Storage/storageAccounts").ConfigureAwait(false); MetricResultsResponse metricsQueryResults = metricsResultsResponse.Value; + Assert.AreEqual(1, metricsQueryResults.Values.Count); + Assert.AreEqual(TestEnvironment.StorageAccountId, metricsQueryResults.Values[0].Resourceid); + Assert.AreEqual("Microsoft.Storage/storageAccounts", metricsQueryResults.Values[0].Namespace); + for (int i = 0; i < metricsQueryResults.Values.Count; i++) + { + foreach (var value in metricsQueryResults.Values[i].Value) + { + for (int j = 0; j < value.Timeseries.Count; j++) + { + Assert.GreaterOrEqual(value.Timeseries[j].Data[i].Total, 0); + } + } + } + } + + [RecordedTest] + public void MetricsBatchInvalid() + { + MetricsBatchQueryClient client = CreateBatchClient(); - //Assert.AreEqual(1, metricsQueryResults.Values.Count); - Assert.AreEqual(0, metricsQueryResults.Values.Count); - ////Assert.AreEqual(1, metricsQueryResults.getMetricsQueryResults().get(0).getMetrics().size()); - //MetricResultsResponseValuesItem metricResultResponse = metricsQueryResults.Values.ElementAtOrDefault(0); - //QueryBatchMetric metric = metricResultResponse.Value.ElementAtOrDefault(0); - //Assert.AreEqual("HttpIncomingRequestCount", metric.Name); - //Assert.NotNull(metric.Timeseries); + Assert.Throws(() => + { + client.Batch( + resourceIds: new List(), + metricNames: new List { "Ingress" }, + metricNamespace: "Microsoft.Storage/storageAccounts"); + }); } } } diff --git a/sdk/monitor/Azure.Monitor.Query/tests/MonitorQueryTestEnvironment.cs b/sdk/monitor/Azure.Monitor.Query/tests/MonitorQueryTestEnvironment.cs index 3804799e32bc..c31e75a3ff99 100644 --- a/sdk/monitor/Azure.Monitor.Query/tests/MonitorQueryTestEnvironment.cs +++ b/sdk/monitor/Azure.Monitor.Query/tests/MonitorQueryTestEnvironment.cs @@ -22,5 +22,8 @@ public class MonitorQueryTestEnvironment : TestEnvironment public string WorkspacePrimaryResourceId => GetRecordedVariable("WORKSPACE_PRIMARY_RESOURCE_ID"); public string WorkspaceSecondaryResourceId => GetRecordedVariable("WORKSPACE_SECONDARY_RESOURCE_ID"); public string DataplaneEndpoint => GetRecordedOptionalVariable("DATAPLANE_ENDPOINT"); + public string ConnectionString => GetRecordedOptionalVariable("CONNECTION_STRING"); + public string StorageAccountId => GetRecordedOptionalVariable("STORAGE_ID"); + public string StorageAccountConnectionString => GetRecordedOptionalVariable("STORAGE_CONNECTION_ID"); } } diff --git a/sdk/monitor/test-resources.bicep b/sdk/monitor/test-resources.bicep index a477af24d1cb..43f97385a521 100644 --- a/sdk/monitor/test-resources.bicep +++ b/sdk/monitor/test-resources.bicep @@ -172,6 +172,24 @@ resource dataCollectionRuleRoleAssignment 'Microsoft.Authorization/roleAssignmen } } +@description('The base resource name.') +param storageAccountName string = 'nibhatistorage' +@description('The base resource name.') +param storageAccountsku string = 'Standard_LRS' + +resource storageAccount 'Microsoft.Storage/storageAccounts@2021-08-01' = { + name: storageAccountName + location: location + sku: { + name: storageAccountsku + } + kind: 'StorageV2' + tags: { + ObjectName: storageAccountName + } + properties: {} +} + output CONNECTION_STRING string = baseName_resource.properties.ConnectionString output APPLICATION_ID string = baseName_resource.properties.AppId output WORKSPACE_ID string = primaryWorkspace.properties.customerId @@ -189,4 +207,7 @@ output INGESTION_DATA_COLLECTION_RULE_IMMUTABLE_ID string = dataCollectionRule.p output RESOURCE_ID string = resourceGroup().id output WORKSPACE_PRIMARY_RESOURCE_ID string = primaryWorkspace.id output WORKSPACE_SECONDARY_RESOURCE_ID string = secondaryWorkspace.id -output DATAPLANE_ENDPOINT string = 'https://metrics.monitor.azure.com/.default' +output DATAPLANE_ENDPOINT string = 'https://${location}.metrics.monitor.azure.com' +output STORAGE_NAME string = storageAccount.name +output STORAGE_ID string = storageAccount.id +output STORAGE_CONNECTION_ID string = 'DefaultEndpointsProtocol=https;AccountName=${storageAccountName};AccountKey=${listKeys(storageAccount.id, storageAccount.apiVersion).keys[0].value};EndpointSuffix=${environment().suffixes.storage}' From d538ee770708a6e0e79625aa04b4b0d1e6c5a0e1 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Thu, 12 Oct 2023 13:14:56 -0700 Subject: [PATCH 13/36] Update MonitorIngestionLiveTest.cs --- .../tests/MonitorIngestionLiveTest.cs | 61 ++----------------- 1 file changed, 6 insertions(+), 55 deletions(-) diff --git a/sdk/monitor/Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs b/sdk/monitor/Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs index 0cee09b68478..178c23ce398f 100644 --- a/sdk/monitor/Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs +++ b/sdk/monitor/Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs @@ -4,18 +4,12 @@ using System; using System.Collections; using System.Collections.Generic; -using System.Data; using System.IO; -using System.Net; using System.Threading.Tasks; using Azure.Core; using Azure.Core.Pipeline; using Azure.Core.TestFramework; -using Azure.Monitor.Query.Models; -using Azure.Monitor.Query; -using Microsoft.Identity.Client.Platforms.Features.DesktopOs.Kerberos; using NUnit.Framework; -using System.Linq; namespace Azure.Monitor.Ingestion.Tests { @@ -24,7 +18,7 @@ public class MonitorIngestionLiveTest : RecordedTestBase GenerateEntries(int numEntries, DateTime recordingNo for (int i = 0; i < numEntries; i++) { entries.Add( - new { + new + { Time = recordingNow, Computer = "Computer" + i.ToString(), AdditionalContext = i @@ -131,10 +126,10 @@ private static List GenerateEntries(int numEntries, DateTime recordingNo [Test] public async Task ValidInputFromArrayAsJsonWithSingleBatchWithGzip() { - LogsIngestionClient client = CreateClient(); + LogsIngestionClient client = CreateClient(); - // Make the request - var response = await client.UploadAsync(TestEnvironment.DCRImmutableId, TestEnvironment.StreamName, GenerateEntries(10, Recording.Now.DateTime)).ConfigureAwait(false); + // Make the request + var response = await client.UploadAsync(TestEnvironment.DCRImmutableId, TestEnvironment.StreamName, GenerateEntries(10, Recording.Now.DateTime)).ConfigureAwait(false); // Check the response Assert.IsNotNull(response); @@ -246,49 +241,5 @@ Task Options_UploadFailed(LogsUploadFailedEventArgs e) return Task.CompletedTask; } } - - //[LiveOnly] - [Test] - public async Task EndToEndTest() - { - LogsIngestionClient client = CreateClient(); - - var data = new[] - { - new MyLogEntry { Name = "Test1", Value = 1 }, - new MyLogEntry { Name = "Test2", Value = 2 } - }; - - Response response = await client.UploadAsync(TestEnvironment.DCRImmutableId, TestEnvironment.StreamName, RequestContent.Create(data)).ConfigureAwait(false); //takes StreamName not tablename - // Check the response - Assert.AreEqual(204, response.Status); - Assert.IsFalse(response.IsError); - - LogsQueryClient logsQueryClient = new(TestEnvironment.Credential); - var queryResult = logsQueryClient.QueryWorkspace(TestEnvironment.Ingestion_WorkspaceId, @" - MyTable_CL - | order by TimeGenerated desc - | take 10", - new QueryTimeRange(TimeSpan.FromDays(1))); - - //LogsBatchQuery batch = new(); - //string query = TestEnvironment.TableName + " | Count;"; - //string countQueryId = batch.AddWorkspaceQuery( - // TestEnvironment.Ingestion_WorkspaceId, - // query, - // new QueryTimeRange(TimeSpan.FromDays(1))); - - //Response queryResponse = - // await logsQueryClient.QueryBatchAsync(batch).ConfigureAwait(false); - - //Console.WriteLine("Table entry count: " + - // queryResponse.Value.GetResult(countQueryId).Single()); - } - - private class MyLogEntry - { - public string Name { get; set; } - public decimal? Value { get; set; } - } } } From b150a9ecf27d59c487f3347a540e2d58351ac9e0 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Thu, 12 Oct 2023 13:17:14 -0700 Subject: [PATCH 14/36] Update MonitorIngestionLiveTest.cs --- .../tests/MonitorIngestionLiveTest.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/sdk/monitor/Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs b/sdk/monitor/Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs index 178c23ce398f..9c477014c94b 100644 --- a/sdk/monitor/Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs +++ b/sdk/monitor/Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs @@ -49,9 +49,6 @@ private LogsIngestionClient CreateClient(HttpPipelinePolicy policy = null) options.AddPolicy(policy, HttpPipelinePosition.PerCall); } var clientOptions = InstrumentClientOptions(options); - // Set audience for testing including sovereign cloud support - clientOptions.Audience = TestEnvironment.GetAudience(); - return InstrumentClient(new LogsIngestionClient(new Uri(TestEnvironment.DCREndpoint), TestEnvironment.Credential, clientOptions)); } @@ -112,8 +109,7 @@ private static List GenerateEntries(int numEntries, DateTime recordingNo for (int i = 0; i < numEntries; i++) { entries.Add( - new - { + new { Time = recordingNow, Computer = "Computer" + i.ToString(), AdditionalContext = i @@ -126,10 +122,10 @@ private static List GenerateEntries(int numEntries, DateTime recordingNo [Test] public async Task ValidInputFromArrayAsJsonWithSingleBatchWithGzip() { - LogsIngestionClient client = CreateClient(); + LogsIngestionClient client = CreateClient(); - // Make the request - var response = await client.UploadAsync(TestEnvironment.DCRImmutableId, TestEnvironment.StreamName, GenerateEntries(10, Recording.Now.DateTime)).ConfigureAwait(false); + // Make the request + var response = await client.UploadAsync(TestEnvironment.DCRImmutableId, TestEnvironment.StreamName, GenerateEntries(10, Recording.Now.DateTime)).ConfigureAwait(false); // Check the response Assert.IsNotNull(response); From 49e698c7c1b2986dfb0646bde554e552e609daa1 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Thu, 12 Oct 2023 13:20:06 -0700 Subject: [PATCH 15/36] Update MonitorIngestionLiveTest.cs --- .../Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sdk/monitor/Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs b/sdk/monitor/Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs index 9c477014c94b..65b8f529ff03 100644 --- a/sdk/monitor/Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs +++ b/sdk/monitor/Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs @@ -49,6 +49,8 @@ private LogsIngestionClient CreateClient(HttpPipelinePolicy policy = null) options.AddPolicy(policy, HttpPipelinePosition.PerCall); } var clientOptions = InstrumentClientOptions(options); + // Set audience for testing including sovereign cloud support + clientOptions.Audience = TestEnvironment.GetAudience(); return InstrumentClient(new LogsIngestionClient(new Uri(TestEnvironment.DCREndpoint), TestEnvironment.Credential, clientOptions)); } From 81d2411b6b66c948ce1d19f8987821d496f2eccb Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Thu, 12 Oct 2023 13:21:15 -0700 Subject: [PATCH 16/36] Update MonitorIngestionLiveTest.cs --- .../Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/monitor/Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs b/sdk/monitor/Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs index 65b8f529ff03..c4014e942613 100644 --- a/sdk/monitor/Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs +++ b/sdk/monitor/Azure.Monitor.Ingestion/tests/MonitorIngestionLiveTest.cs @@ -51,6 +51,7 @@ private LogsIngestionClient CreateClient(HttpPipelinePolicy policy = null) var clientOptions = InstrumentClientOptions(options); // Set audience for testing including sovereign cloud support clientOptions.Audience = TestEnvironment.GetAudience(); + return InstrumentClient(new LogsIngestionClient(new Uri(TestEnvironment.DCREndpoint), TestEnvironment.Credential, clientOptions)); } From 3cdd388405fe43b6450b3d7efd01c91c1cdc2fde Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Thu, 12 Oct 2023 13:35:29 -0700 Subject: [PATCH 17/36] Update MetricsBatchQueryClient.cs --- sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs b/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs index 714e10bb3d9b..9c234dcb9bd1 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs @@ -24,7 +24,7 @@ public class MetricsBatchQueryClient /// /// Initializes a new instance of . Uses the default 'https://metrics.monitor.azure.com/.default' endpoint. /// - /// var client = new MetricsBatchQueryClient(new DefaultAzureCredential()); + /// var client = new MetricsQueryClient(new DefaultAzureCredential()); /// /// /// The instance to use for authentication. From f9413673bb5afd7b965b0ecbef7fd0c9aecefa87 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Thu, 12 Oct 2023 14:02:23 -0700 Subject: [PATCH 18/36] Update Azure.Core.net472.cs --- sdk/core/Azure.Core/api/Azure.Core.net472.cs | 66 -------------------- 1 file changed, 66 deletions(-) diff --git a/sdk/core/Azure.Core/api/Azure.Core.net472.cs b/sdk/core/Azure.Core/api/Azure.Core.net472.cs index 9aaf09bb355c..3f774979daad 100644 --- a/sdk/core/Azure.Core/api/Azure.Core.net472.cs +++ b/sdk/core/Azure.Core/api/Azure.Core.net472.cs @@ -539,8 +539,6 @@ public abstract partial class RequestContent : System.IDisposable { protected RequestContent() { } public static Azure.Core.RequestContent Create(Azure.Core.Serialization.DynamicData content) { throw null; } - public static Azure.Core.RequestContent Create(Azure.Core.Serialization.IModelJsonSerializable model, Azure.Core.Serialization.ModelSerializerOptions? options = null) { throw null; } - public static Azure.Core.RequestContent Create(Azure.Core.Serialization.IModelSerializable model, Azure.Core.Serialization.ModelSerializerOptions? options = null) { throw null; } public static Azure.Core.RequestContent Create(System.BinaryData content) { throw null; } public static Azure.Core.RequestContent Create(System.Buffers.ReadOnlySequence bytes) { throw null; } public static Azure.Core.RequestContent Create(byte[] bytes) { throw null; } @@ -1077,12 +1075,6 @@ public ServerCertificateCustomValidationArgs(System.Security.Cryptography.X509Ce } namespace Azure.Core.Serialization { - [System.AttributeUsageAttribute(System.AttributeTargets.Class)] - public sealed partial class AbstractHierarchyDeserializerAttribute : System.Attribute - { - public AbstractHierarchyDeserializerAttribute(System.Type typeToActivate) { } - public System.Type TypeToActivate { get { throw null; } } - } [System.Diagnostics.DebuggerDisplayAttribute("{DebuggerDisplay,nq}")] public sealed partial class DynamicData : System.Dynamic.IDynamicMetaObjectProvider, System.IDisposable { @@ -1117,16 +1109,6 @@ public partial interface IMemberNameConverter { string? ConvertMemberName(System.Reflection.MemberInfo member); } - public partial interface IModelJsonSerializable : Azure.Core.Serialization.IModelSerializable - { - T Deserialize(ref System.Text.Json.Utf8JsonReader reader, Azure.Core.Serialization.ModelSerializerOptions options); - void Serialize(System.Text.Json.Utf8JsonWriter writer, Azure.Core.Serialization.ModelSerializerOptions options); - } - public partial interface IModelSerializable - { - T Deserialize(System.BinaryData data, Azure.Core.Serialization.ModelSerializerOptions options); - System.BinaryData Serialize(Azure.Core.Serialization.ModelSerializerOptions options); - } public partial class JsonObjectSerializer : Azure.Core.Serialization.ObjectSerializer, Azure.Core.Serialization.IMemberNameConverter { public JsonObjectSerializer() { } @@ -1145,54 +1127,6 @@ public enum JsonPropertyNames UseExact = 0, CamelCase = 1, } - public partial class ModelJsonConverter : System.Text.Json.Serialization.JsonConverter> - { - public ModelJsonConverter() { } - public ModelJsonConverter(Azure.Core.Serialization.ModelSerializerFormat format) { } - public ModelJsonConverter(Azure.Core.Serialization.ModelSerializerOptions options) { } - public Azure.Core.Serialization.ModelSerializerOptions ModelSerializerOptions { get { throw null; } } - public override bool CanConvert(System.Type typeToConvert) { throw null; } - public override Azure.Core.Serialization.IModelJsonSerializable Read(ref System.Text.Json.Utf8JsonReader reader, System.Type typeToConvert, System.Text.Json.JsonSerializerOptions options) { throw null; } - public override void Write(System.Text.Json.Utf8JsonWriter writer, Azure.Core.Serialization.IModelJsonSerializable value, System.Text.Json.JsonSerializerOptions options) { } - } - public static partial class ModelSerializer - { - public static object Deserialize(System.BinaryData data, System.Type returnType, Azure.Core.Serialization.ModelSerializerFormat format) { throw null; } - public static object Deserialize(System.BinaryData data, System.Type returnType, Azure.Core.Serialization.ModelSerializerOptions? options = null) { throw null; } - public static T Deserialize(System.BinaryData data, Azure.Core.Serialization.ModelSerializerFormat format) where T : Azure.Core.Serialization.IModelSerializable { throw null; } - public static T Deserialize(System.BinaryData data, Azure.Core.Serialization.ModelSerializerOptions? options = null) where T : Azure.Core.Serialization.IModelSerializable { throw null; } - public static System.BinaryData Serialize(object model, Azure.Core.Serialization.ModelSerializerFormat format) { throw null; } - public static System.BinaryData Serialize(object model, Azure.Core.Serialization.ModelSerializerOptions? options = null) { throw null; } - public static System.BinaryData SerializeCore(Azure.Core.Serialization.IModelJsonSerializable model, Azure.Core.Serialization.ModelSerializerOptions options) { throw null; } - public static System.BinaryData Serialize(T model, Azure.Core.Serialization.ModelSerializerFormat format) where T : Azure.Core.Serialization.IModelSerializable { throw null; } - public static System.BinaryData Serialize(T model, Azure.Core.Serialization.ModelSerializerOptions? options = null) where T : Azure.Core.Serialization.IModelSerializable { throw null; } - } - [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)] - public readonly partial struct ModelSerializerFormat : System.IEquatable - { - private readonly object _dummy; - private readonly int _dummyPrimitive; - public static readonly Azure.Core.Serialization.ModelSerializerFormat Json; - public static readonly Azure.Core.Serialization.ModelSerializerFormat Wire; - public ModelSerializerFormat(string value) { throw null; } - public bool Equals(Azure.Core.Serialization.ModelSerializerFormat other) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override bool Equals(object obj) { throw null; } - [System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)] - public override int GetHashCode() { throw null; } - public static bool operator ==(Azure.Core.Serialization.ModelSerializerFormat left, Azure.Core.Serialization.ModelSerializerFormat right) { throw null; } - public static implicit operator Azure.Core.Serialization.ModelSerializerFormat (string value) { throw null; } - public static bool operator !=(Azure.Core.Serialization.ModelSerializerFormat left, Azure.Core.Serialization.ModelSerializerFormat right) { throw null; } - public override string ToString() { throw null; } - } - public partial class ModelSerializerOptions - { - public static readonly Azure.Core.Serialization.ModelSerializerOptions DefaultWireOptions; - public ModelSerializerOptions() { } - public ModelSerializerOptions(Azure.Core.Serialization.ModelSerializerFormat format) { } - public Azure.Core.Serialization.ModelSerializerFormat Format { get { throw null; } } - public System.Func? GenericTypeSerializerCreator { get { throw null; } set { } } - } public abstract partial class ObjectSerializer { protected ObjectSerializer() { } From 57af1bb19a9d8b4fa1f06b23601ef2a23ae98664 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Thu, 12 Oct 2023 15:25:17 -0700 Subject: [PATCH 19/36] Update MetricsQueryClientLiveTests.cs --- .../Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs index 7c2187366c16..2b42006e6a12 100644 --- a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs +++ b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs @@ -17,7 +17,6 @@ public class MetricsQueryClientLiveTests : RecordedTestBase Date: Thu, 12 Oct 2023 17:44:23 -0700 Subject: [PATCH 20/36] revert --- .../src/MetricsBatchQueryClient.cs | 18 ++++++++---------- .../tests/Azure.Monitor.Query.Tests.csproj | 1 - .../tests/MonitorQueryTestEnvironment.cs | 2 +- sdk/monitor/test-resources.bicep | 2 +- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs b/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs index 9c234dcb9bd1..3523ebd56651 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs @@ -87,16 +87,15 @@ protected MetricsBatchQueryClient() /// public virtual Response Batch(List resourceIds, List metricNames, string metricNamespace, MetricsQueryOptions options = null, CancellationToken cancellationToken = default) { + if (resourceIds.Count == 0) + { + throw new ArgumentException("Resource IDs can not be empty"); + } using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(MetricsBatchQueryClient)}.{nameof(Batch)}"); scope.Start(); try { - if (resourceIds.Count == 0) - { - throw new ArgumentException("Resource IDs can not be empty"); - } - var subscriptionId = GetSubscriptionId(resourceIds[0]); string filter = null; @@ -158,16 +157,15 @@ private string GetSubscriptionId(string resourceId) /// public virtual async Task> BatchAsync(List resourceIds, List metricNames, string metricNamespace, MetricsQueryOptions options = null, CancellationToken cancellationToken = default) { + if (resourceIds.Count == 0) + { + throw new ArgumentException("Resource IDs can not be empty"); + } using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(MetricsBatchQueryClient)}.{nameof(Batch)}"); scope.Start(); try { - if (resourceIds.Count == 0) - { - throw new ArgumentException("Resource IDs can not be empty"); - } - var subscriptionId = GetSubscriptionId(resourceIds[0]); string filter = null; diff --git a/sdk/monitor/Azure.Monitor.Query/tests/Azure.Monitor.Query.Tests.csproj b/sdk/monitor/Azure.Monitor.Query/tests/Azure.Monitor.Query.Tests.csproj index e5d839deef2b..87c5f58b66cb 100644 --- a/sdk/monitor/Azure.Monitor.Query/tests/Azure.Monitor.Query.Tests.csproj +++ b/sdk/monitor/Azure.Monitor.Query/tests/Azure.Monitor.Query.Tests.csproj @@ -5,7 +5,6 @@ - diff --git a/sdk/monitor/Azure.Monitor.Query/tests/MonitorQueryTestEnvironment.cs b/sdk/monitor/Azure.Monitor.Query/tests/MonitorQueryTestEnvironment.cs index c31e75a3ff99..9e4664811d6c 100644 --- a/sdk/monitor/Azure.Monitor.Query/tests/MonitorQueryTestEnvironment.cs +++ b/sdk/monitor/Azure.Monitor.Query/tests/MonitorQueryTestEnvironment.cs @@ -24,6 +24,6 @@ public class MonitorQueryTestEnvironment : TestEnvironment public string DataplaneEndpoint => GetRecordedOptionalVariable("DATAPLANE_ENDPOINT"); public string ConnectionString => GetRecordedOptionalVariable("CONNECTION_STRING"); public string StorageAccountId => GetRecordedOptionalVariable("STORAGE_ID"); - public string StorageAccountConnectionString => GetRecordedOptionalVariable("STORAGE_CONNECTION_ID"); + public string StorageAccountConnectionString => GetRecordedOptionalVariable("STORAGE_CONNECTION_STRING"); } } diff --git a/sdk/monitor/test-resources.bicep b/sdk/monitor/test-resources.bicep index 43f97385a521..c57145aca693 100644 --- a/sdk/monitor/test-resources.bicep +++ b/sdk/monitor/test-resources.bicep @@ -210,4 +210,4 @@ output WORKSPACE_SECONDARY_RESOURCE_ID string = secondaryWorkspace.id output DATAPLANE_ENDPOINT string = 'https://${location}.metrics.monitor.azure.com' output STORAGE_NAME string = storageAccount.name output STORAGE_ID string = storageAccount.id -output STORAGE_CONNECTION_ID string = 'DefaultEndpointsProtocol=https;AccountName=${storageAccountName};AccountKey=${listKeys(storageAccount.id, storageAccount.apiVersion).keys[0].value};EndpointSuffix=${environment().suffixes.storage}' +output STORAGE_CONNECTION_STRING string = 'DefaultEndpointsProtocol=https;AccountName=${storageAccountName};AccountKey=${listKeys(storageAccount.id, storageAccount.apiVersion).keys[0].value};EndpointSuffix=${environment().suffixes.storage}' From 30c59c1493b08d3c63b3a6fbc2a508740a16b57c Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Thu, 12 Oct 2023 17:53:44 -0700 Subject: [PATCH 21/36] Update ResourceIdList.cs --- sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs b/sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs index 590e3981d7ed..dc6e978f715a 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs @@ -16,9 +16,9 @@ public partial class ResourceIdList /// Initializes a new instance of ResourceIdList. public ResourceIdList(List resourceIds) { + Resourceids = new ChangeTrackingList(); for (int i = 0; i < resourceIds.Count; i++) { - Resourceids = new ChangeTrackingList(); Resourceids.Add(new ResourceIdentifier(resourceIds[i])); } } From f8d73f13cd87b479ed3c611698af14cd117f1837 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Fri, 13 Oct 2023 01:07:24 -0700 Subject: [PATCH 22/36] wip --- .../src/MetricsBatchQueryClient.cs | 121 ++++++++---------- .../tests/MetricsQueryClientLiveTests.cs | 4 +- 2 files changed, 58 insertions(+), 67 deletions(-) diff --git a/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs b/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs index 3523ebd56651..8c308b3ec4fb 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs @@ -96,28 +96,47 @@ public virtual Response Batch(List resourceIds, L try { - var subscriptionId = GetSubscriptionId(resourceIds[0]); - - string filter = null; - TimeSpan? granularity = null; - string aggregations = null; - string startTime = null; - int? top = null; - string orderBy = null; - string endTime = null; - ResourceIdList resourceIdList = new ResourceIdList(resourceIds); - - if (options != null) - { - startTime = options.TimeRange.Value.Start.ToString(); - endTime = options.TimeRange.Value.End.ToString(); - - top = options.Size; - orderBy = options.OrderBy; - filter = options.Filter; - granularity = options.Granularity; - } + return ExecuteBatchAsync(resourceIds, metricNames, metricNamespace, options, isAsync: false, cancellationToken).Result; + } + catch (Exception e) + { + scope.Failed(e); + throw; + } + } + + private string GetSubscriptionId(string resourceId) + { + int startIndex = resourceId.IndexOf("subscriptions/") + 14; + return resourceId.Substring(startIndex, resourceId.IndexOf("/", startIndex) - startIndex); + } + + private async Task> ExecuteBatchAsync(List resourceIds, List metricNames, string metricNamespace, MetricsQueryOptions options = null, bool isAsync = default, CancellationToken cancellationToken = default) + { + var subscriptionId = GetSubscriptionId(resourceIds[0]); + + string filter = null; + TimeSpan? granularity = null; + string aggregations = null; + string startTime = null; + int? top = null; + string orderBy = null; + string endTime = null; + ResourceIdList resourceIdList = new ResourceIdList(resourceIds); + + if (options != null) + { + startTime = options.TimeRange.Value.Start.ToString(); + endTime = options.TimeRange.Value.End.ToString(); + + top = options.Size; + orderBy = options.OrderBy; + filter = options.Filter; + granularity = options.Granularity; + } + if (!isAsync) + { return _metricBatchClient.Batch( subscriptionId, metricNamespace, @@ -132,19 +151,25 @@ public virtual Response Batch(List resourceIds, L filter, cancellationToken); } - catch (Exception e) + + else { - scope.Failed(e); - throw; + return await _metricBatchClient.BatchAsync( + subscriptionId, + metricNamespace, + metricNames, + resourceIdList, + startTime, + endTime, + granularity, + aggregations, + top, + orderBy, + filter, + cancellationToken).ConfigureAwait(false); } } - private string GetSubscriptionId(string resourceId) - { - int startIndex = resourceId.IndexOf("subscriptions/") + 14; - return resourceId.Substring(startIndex, resourceId.IndexOf("/", startIndex) - startIndex); - } - /// /// todo /// @@ -166,41 +191,7 @@ public virtual async Task> BatchAsync(List(() => { results.Value.GetMetricByName("Guinness"); }); } - [RecordedTest] + //[RecordedTest] [Test] public async Task MetricsBatchQueryAsync() { From 1f8ba97133ffb9c7d66cf701f3bfb4a9d7dc0e02 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Fri, 13 Oct 2023 01:19:58 -0700 Subject: [PATCH 23/36] add docs --- sdk/monitor/Azure.Monitor.Query/README.md | 23 +++++++++++++++++ .../tests/MetricsQueryClientSamples.cs | 25 +++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/sdk/monitor/Azure.Monitor.Query/README.md b/sdk/monitor/Azure.Monitor.Query/README.md index 6e567729f215..4760994fc9ad 100644 --- a/sdk/monitor/Azure.Monitor.Query/README.md +++ b/sdk/monitor/Azure.Monitor.Query/README.md @@ -586,6 +586,28 @@ foreach (MetricResult metric in result.Value.Metrics) } ``` +#### Metrics batch query + +A user can also query metrics from multiple resources at once using the `Batch` method of `MetricsBatchQueryClient`. This uses a different API than the `MetricsQueryClient` and requires that a user pass in a regional endpoint when instantiating the client (for example, "https://westus3.metrics.monitor.azure.com"). + +Note, each resource must be in the same region as the endpoint passed in when instantiating the client, and each resource must be in the same Azure subscription. Furthermore, the metric namespace that contains the metrics to be queried must also be passed. A list of metric namespaces can be found [here][metric_namespaces]. + +```C# Snippet:QueryBatchMetrics +string resourceId = + "/subscriptions//resourceGroups//providers//storageAccounts/"; +MetricsBatchQueryClient client = new MetricsBatchQueryClient(new DefaultAzureCredential()); +Response metricsResultsResponse = await client.BatchAsync( + resourceIds: new List { resourceId }, + metricNames: new List { "Ingress" }, + metricNamespace: "Microsoft.Storage/storageAccounts").ConfigureAwait(false); + +MetricResultsResponse metricsQueryResults = metricsResultsResponse.Value; +foreach (var value in metricsQueryResults.Values) +{ + Console.WriteLine(value.Interval); +} +``` + For an inventory of metrics and dimensions available for each Azure resource type, see [Supported metrics with Azure Monitor](https://learn.microsoft.com/azure/azure-monitor/essentials/metrics-supported). #### Register the client with dependency injection @@ -618,6 +640,7 @@ This project has adopted the [Microsoft Open Source Code of Conduct][coc]. For m [msdocs_apiref]: https://learn.microsoft.com/dotnet/api/overview/azure/monitor.query-readme?view=azure-dotnet [package]: https://www.nuget.org/packages/Azure.Monitor.Query [source]: https://github.com/Azure/azure-sdk-for-net/blob/main/sdk/monitor/Azure.Monitor.Query/src +[metric_namespaces]: https://learn.microsoft.com/azure/azure-monitor/reference/supported-metrics/metrics-index#metrics-by-resource-provider [cla]: https://cla.microsoft.com [coc]: https://opensource.microsoft.com/codeofconduct/ diff --git a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientSamples.cs b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientSamples.cs index d50ff7f54e9b..18a2450762be 100644 --- a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientSamples.cs +++ b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientSamples.cs @@ -2,6 +2,7 @@ // Licensed under the MIT License. using System; +using System.Collections.Generic; using System.Threading.Tasks; using Azure.Core.TestFramework; using Azure.Identity; @@ -131,5 +132,29 @@ public async Task QueryMetricsWithSplitting() } #endregion } + + [Test] + public async Task QueryBatchMetrics() + { + #region Snippet:QueryBatchMetrics +#if SNIPPET + string resourceId = + "/subscriptions//resourceGroups//providers//storageAccounts/"; +#else + string resourceId = TestEnvironment.StorageAccountId; +#endif + MetricsBatchQueryClient client = new MetricsBatchQueryClient(new DefaultAzureCredential()); + Response metricsResultsResponse = await client.BatchAsync( + resourceIds: new List { resourceId }, + metricNames: new List { "Ingress" }, + metricNamespace: "Microsoft.Storage/storageAccounts").ConfigureAwait(false); + + MetricResultsResponse metricsQueryResults = metricsResultsResponse.Value; + foreach (var value in metricsQueryResults.Values) + { + Console.WriteLine(value.Interval); + } + #endregion + } } } From 21927cc237f6eb796b8f7fd3f2bcb39cb56cf66c Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Fri, 13 Oct 2023 11:47:06 -0700 Subject: [PATCH 24/36] Update MetricsQueryClientLiveTests.cs --- .../tests/MetricsQueryClientLiveTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs index 59644d7e6aa9..ac824dd643e4 100644 --- a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs +++ b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs @@ -369,12 +369,12 @@ public void MetricsBatchInvalid() { MetricsBatchQueryClient client = CreateBatchClient(); - Assert.Throws(() => + Assert.Throws(async () => { - client.Batch( + await client.BatchAsync( resourceIds: new List(), metricNames: new List { "Ingress" }, - metricNamespace: "Microsoft.Storage/storageAccounts"); + metricNamespace: "Microsoft.Storage/storageAccounts").ConfigureAwait(false); }); } } From 0889bfb8c49b82910277e291da482756acc7f416 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Fri, 13 Oct 2023 13:02:09 -0700 Subject: [PATCH 25/36] Update MetricsQueryClientLiveTests.cs --- .../tests/MetricsQueryClientLiveTests.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs index ac824dd643e4..590b3b38fe45 100644 --- a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs +++ b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs @@ -364,17 +364,18 @@ public async Task MetricsBatchQueryAsync() } } + [SyncOnly] [RecordedTest] public void MetricsBatchInvalid() { MetricsBatchQueryClient client = CreateBatchClient(); - Assert.Throws(async () => + Assert.Throws(()=> { - await client.BatchAsync( + client.Batch( resourceIds: new List(), metricNames: new List { "Ingress" }, - metricNamespace: "Microsoft.Storage/storageAccounts").ConfigureAwait(false); + metricNamespace: "Microsoft.Storage/storageAccounts"); }); } } From 25db226bb1bdc74557427dfe6fdd7235e7d99bd3 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Mon, 16 Oct 2023 12:46:23 -0700 Subject: [PATCH 26/36] Update MetricsQueryClientLiveTests.cs --- .../tests/MetricsQueryClientLiveTests.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs index 590b3b38fe45..972c37f1332d 100644 --- a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs +++ b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs @@ -15,7 +15,7 @@ public class MetricsQueryClientLiveTests : RecordedTestBase(() => { results.Value.GetMetricByName("Guinness"); }); } - //[RecordedTest] - [Test] + [RecordedTest] public async Task MetricsBatchQueryAsync() { MetricsBatchQueryClient client = CreateBatchClient(); From 6737d510d5f90b9273f118244dc3add0b0182ae5 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Mon, 16 Oct 2023 13:34:02 -0700 Subject: [PATCH 27/36] wip --- sdk/monitor/Azure.Monitor.Query/assets.json | 2 +- .../src/MetricsBatchQueryClient.cs | 29 +++++++++---------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/sdk/monitor/Azure.Monitor.Query/assets.json b/sdk/monitor/Azure.Monitor.Query/assets.json index d7d9ca746c6a..92f1da246a86 100644 --- a/sdk/monitor/Azure.Monitor.Query/assets.json +++ b/sdk/monitor/Azure.Monitor.Query/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/monitor/Azure.Monitor.Query", - "Tag": "net/monitor/Azure.Monitor.Query_3b8122268a" + "Tag": "net/monitor/Azure.Monitor.Query_49d15380f8" } diff --git a/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs b/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs index 8c308b3ec4fb..ef92b5413dcb 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs @@ -77,14 +77,14 @@ protected MetricsBatchQueryClient() public Uri Endpoint { get; } /// - /// pass in a list of resource ids, metric names, and a time range to query metrics for those resources. + /// Returns all the Azure Monitor metrics requested for the batch of resources. /// - /// - /// - /// - /// - /// - /// + /// The resource URIs for which the metrics is requested. + /// The names of the metrics to query. + /// The namespace of the metrics to query. + /// The to configure the query. + /// The to use. + /// A time-series metrics result for the requested metric names. public virtual Response Batch(List resourceIds, List metricNames, string metricNamespace, MetricsQueryOptions options = null, CancellationToken cancellationToken = default) { if (resourceIds.Count == 0) @@ -171,15 +171,14 @@ private async Task> ExecuteBatchAsync(List - /// todo + /// Returns all the Azure Monitor metrics requested for the batch of resources. /// - /// - /// - /// - /// - /// - /// - /// + /// The resource URIs for which the metrics is requested. + /// The names of the metrics to query. + /// The namespace of the metrics to query. + /// The to configure the query. + /// The to use. + /// A time-series metrics result for the requested metric names. public virtual async Task> BatchAsync(List resourceIds, List metricNames, string metricNamespace, MetricsQueryOptions options = null, CancellationToken cancellationToken = default) { if (resourceIds.Count == 0) From 5cf2fc1031c05748022b86d6abc1ce15bf0060f9 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Mon, 16 Oct 2023 15:25:50 -0700 Subject: [PATCH 28/36] wip --- sdk/monitor/Azure.Monitor.Query/assets.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/monitor/Azure.Monitor.Query/assets.json b/sdk/monitor/Azure.Monitor.Query/assets.json index 92f1da246a86..4fed871f7f70 100644 --- a/sdk/monitor/Azure.Monitor.Query/assets.json +++ b/sdk/monitor/Azure.Monitor.Query/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/monitor/Azure.Monitor.Query", - "Tag": "net/monitor/Azure.Monitor.Query_49d15380f8" + "Tag": "net/monitor/Azure.Monitor.Query_bf8de1142d" } From ab6c52710f00bc3ba3b1fae3f2e9891c2f0493b4 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Mon, 16 Oct 2023 21:39:17 -0700 Subject: [PATCH 29/36] Update cspell.json --- .vscode/cspell.json | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.vscode/cspell.json b/.vscode/cspell.json index 82357ba23417..4515c5ba1e3d 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -1228,6 +1228,13 @@ "runpath", "Cves" ] + }, + { + "filename": "**/sdk/monitor/**/*.cs", + "words": [ + "resourceId", + "ResourceId" + ] } ], "allowCompoundWords": true From eebfb748446bb8d3b72d7007b35077c3e8fbc499 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Tue, 17 Oct 2023 14:29:11 -0700 Subject: [PATCH 30/36] wip --- sdk/monitor/Azure.Monitor.Query/README.md | 4 +- .../api/Azure.Monitor.Query.netstandard2.0.cs | 18 ++---- .../src/Generated/MetricsBatchRestClient.cs | 60 +++++++++---------- ...ResultsResponseValuesItem.Serialization.cs | 8 +-- .../Models/MetricResultsResponseValuesItem.cs | 29 ++++----- .../Models/ResourceIdList.Serialization.cs | 2 +- .../src/Generated/Models/ResourceIdList.cs | 2 +- .../src/Generated/MonitorQueryModelFactory.cs | 8 +-- .../src/MetricResultsResponseValuesItem.cs | 22 +++++++ .../src/MetricsBatchQueryClient.cs | 50 ++++++---------- .../src/Models/ResourceIdList.cs | 2 +- .../Azure.Monitor.Query/src/metricBatch.json | 8 +-- .../tests/MetricsQueryClientLiveTests.cs | 4 +- .../tests/MetricsQueryClientSamples.cs | 4 +- 14 files changed, 108 insertions(+), 113 deletions(-) create mode 100644 sdk/monitor/Azure.Monitor.Query/src/MetricResultsResponseValuesItem.cs diff --git a/sdk/monitor/Azure.Monitor.Query/README.md b/sdk/monitor/Azure.Monitor.Query/README.md index 4760994fc9ad..237eaf69530c 100644 --- a/sdk/monitor/Azure.Monitor.Query/README.md +++ b/sdk/monitor/Azure.Monitor.Query/README.md @@ -595,8 +595,8 @@ Note, each resource must be in the same region as the endpoint passed in when in ```C# Snippet:QueryBatchMetrics string resourceId = "/subscriptions//resourceGroups//providers//storageAccounts/"; -MetricsBatchQueryClient client = new MetricsBatchQueryClient(new DefaultAzureCredential()); -Response metricsResultsResponse = await client.BatchAsync( +MetricsBatchQueryClient client = new MetricsBatchQueryClient(new Uri("https://metrics.monitor.azure.com/.default"), new DefaultAzureCredential()); +Response metricsResultsResponse = await client.QueryBatchAsync( resourceIds: new List { resourceId }, metricNames: new List { "Ingress" }, metricNamespace: "Microsoft.Storage/storageAccounts").ConfigureAwait(false); diff --git a/sdk/monitor/Azure.Monitor.Query/api/Azure.Monitor.Query.netstandard2.0.cs b/sdk/monitor/Azure.Monitor.Query/api/Azure.Monitor.Query.netstandard2.0.cs index 1a24095be733..9cab8ad83086 100644 --- a/sdk/monitor/Azure.Monitor.Query/api/Azure.Monitor.Query.netstandard2.0.cs +++ b/sdk/monitor/Azure.Monitor.Query/api/Azure.Monitor.Query.netstandard2.0.cs @@ -45,12 +45,10 @@ public LogsQueryOptions() { } public partial class MetricsBatchQueryClient { protected MetricsBatchQueryClient() { } - public MetricsBatchQueryClient(Azure.Core.TokenCredential credential) { } - public MetricsBatchQueryClient(Azure.Core.TokenCredential credential, Azure.Monitor.Query.MetricsBatchQueryClientOptions options) { } public MetricsBatchQueryClient(System.Uri endpoint, Azure.Core.TokenCredential credential, Azure.Monitor.Query.MetricsBatchQueryClientOptions options = null) { } public System.Uri Endpoint { get { throw null; } } - public virtual Azure.Response Batch(System.Collections.Generic.List resourceIds, System.Collections.Generic.List metricNames, string metricNamespace, Azure.Monitor.Query.MetricsQueryOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } - public virtual System.Threading.Tasks.Task> BatchAsync(System.Collections.Generic.List resourceIds, System.Collections.Generic.List metricNames, string metricNamespace, Azure.Monitor.Query.MetricsQueryOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual Azure.Response QueryBatch(System.Collections.Generic.List resourceIds, System.Collections.Generic.List metricNames, string metricNamespace, Azure.Monitor.Query.MetricsQueryOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } + public virtual System.Threading.Tasks.Task> QueryBatchAsync(System.Collections.Generic.List resourceIds, System.Collections.Generic.List metricNames, string metricNamespace, Azure.Monitor.Query.MetricsQueryOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; } } public partial class MetricsBatchQueryClientOptions : Azure.Core.ClientOptions { @@ -313,12 +311,12 @@ internal MetricResultsResponse() { } public partial class MetricResultsResponseValuesItem { internal MetricResultsResponseValuesItem() { } - public string Endtime { get { throw null; } } + public System.DateTimeOffset EndTime { get { throw null; } } public System.TimeSpan? Interval { get { throw null; } } public string Namespace { get { throw null; } } public string Resourceid { get { throw null; } } public string Resourceregion { get { throw null; } } - public string Starttime { get { throw null; } } + public System.DateTimeOffset StartTime { get { throw null; } } public System.Collections.Generic.IReadOnlyList Value { get { throw null; } } } public partial class MetricsQueryResult @@ -387,7 +385,7 @@ public static partial class MonitorQueryModelFactory public static Azure.Monitor.Query.Models.MetricAvailability MetricAvailability(System.TimeSpan? granularity = default(System.TimeSpan?), System.TimeSpan? retention = default(System.TimeSpan?)) { throw null; } public static Azure.Monitor.Query.Models.MetricResult MetricResult(string id, string resourceType, string name, Azure.Monitor.Query.Models.MetricUnit unit, System.Collections.Generic.IEnumerable timeSeries) { throw null; } public static Azure.Monitor.Query.Models.MetricResultsResponse MetricResultsResponse(System.Collections.Generic.IEnumerable values = null) { throw null; } - public static Azure.Monitor.Query.Models.MetricResultsResponseValuesItem MetricResultsResponseValuesItem(string starttime = null, string endtime = null, System.TimeSpan? interval = default(System.TimeSpan?), string @namespace = null, string resourceregion = null, string resourceid = null, System.Collections.Generic.IEnumerable value = null) { throw null; } + public static Azure.Monitor.Query.Models.MetricResultsResponseValuesItem MetricResultsResponseValuesItem(System.DateTimeOffset startTime = default(System.DateTimeOffset), System.DateTimeOffset endTime = default(System.DateTimeOffset), System.TimeSpan? interval = default(System.TimeSpan?), string @namespace = null, string resourceregion = null, string resourceid = null, System.Collections.Generic.IEnumerable value = null) { throw null; } public static Azure.Monitor.Query.Models.MetricsQueryResult MetricsQueryResult(int? cost, string timespan, System.TimeSpan? granularity, string @namespace, string resourceRegion, System.Collections.Generic.IReadOnlyList metrics) { throw null; } public static Azure.Monitor.Query.Models.MetricTimeSeriesElement MetricTimeSeriesElement(System.Collections.Generic.IReadOnlyDictionary metadataValues, System.Collections.Generic.IEnumerable values) { throw null; } public static Azure.Monitor.Query.Models.MetricValue MetricValue(System.DateTimeOffset timeStamp = default(System.DateTimeOffset), double? average = default(double?), double? minimum = default(double?), double? maximum = default(double?), double? total = default(double?), double? count = default(double?)) { throw null; } @@ -453,12 +451,6 @@ internal QueryBatchTimeSeriesElement() { } public System.Collections.Generic.IReadOnlyList Data { get { throw null; } } public System.Collections.Generic.IReadOnlyList Metadatavalues { get { throw null; } } } - public partial class ResourceIdList - { - public ResourceIdList() { } - public ResourceIdList(System.Collections.Generic.List resourceIds) { } - public System.Collections.Generic.IList Resourceids { get { throw null; } } - } } namespace Microsoft.Extensions.Azure { diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/MetricsBatchRestClient.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/MetricsBatchRestClient.cs index 4f9968e3a3fb..156379878406 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/Generated/MetricsBatchRestClient.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/MetricsBatchRestClient.cs @@ -37,7 +37,7 @@ public MetricsBatchRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline _endpoint = endpoint ?? throw new ArgumentNullException(nameof(endpoint)); } - internal HttpMessage CreateBatchRequest(string subscriptionId, string metricnamespace, IEnumerable metricnames, ResourceIdList resourceIds, string starttime, string endtime, TimeSpan? interval, string aggregation, int? top, string orderby, string filter) + internal HttpMessage CreateBatchRequest(string subscriptionId, string metricNamespace, IEnumerable metricNames, ResourceIdList resourceIds, string startTime, string endTime, TimeSpan? interval, string aggregation, int? top, string orderby, string filter) { var message = _pipeline.CreateMessage(); var request = message.Request; @@ -47,22 +47,22 @@ internal HttpMessage CreateBatchRequest(string subscriptionId, string metricname uri.AppendPath("/subscriptions/", false); uri.AppendPath(subscriptionId, true); uri.AppendPath("/metrics:getBatch", false); - if (starttime != null) + if (startTime != null) { - uri.AppendQuery("starttime", starttime, true); + uri.AppendQuery("startTime", startTime, true); } - if (endtime != null) + if (endTime != null) { - uri.AppendQuery("endtime", endtime, true); + uri.AppendQuery("endTime", endTime, true); } if (interval != null) { uri.AppendQuery("interval", interval.Value, "P", true); } - uri.AppendQuery("metricnamespace", metricnamespace, true); - if (metricnames != null && Optional.IsCollectionDefined(metricnames)) + uri.AppendQuery("metricNamespace", metricNamespace, true); + if (metricNames != null && Optional.IsCollectionDefined(metricNames)) { - uri.AppendQueryDelimited("metricnames", metricnames, ",", true); + uri.AppendQueryDelimited("metricNames", metricNames, ",", true); } if (aggregation != null) { @@ -92,15 +92,15 @@ internal HttpMessage CreateBatchRequest(string subscriptionId, string metricname /// Lists the metric values for multiple resources. /// The subscription identifier for the resources in this batch. - /// Metric namespace that contains the requested metric names. - /// The names of the metrics (comma separated) to retrieve. + /// Metric namespace that contains the requested metric names. + /// The names of the metrics (comma separated) to retrieve. /// The comma separated list of resource IDs to query metrics for. - /// + /// /// The start time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. If you have specified the endtime parameter, then this parameter is required. /// If only starttime is specified, then endtime defaults to the current time. /// If no time interval is specified, the default is 1 hour. /// - /// The end time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. + /// The end time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. /// /// The interval (i.e. timegrain) of the query. /// *Examples: PT15M, PT1H, P1D* @@ -121,27 +121,27 @@ internal HttpMessage CreateBatchRequest(string subscriptionId, string metricname /// /// The filter is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. /// The cancellation token to use. - /// , , or is null. - public async Task> BatchAsync(string subscriptionId, string metricnamespace, IEnumerable metricnames, ResourceIdList resourceIds, string starttime = null, string endtime = null, TimeSpan? interval = null, string aggregation = null, int? top = null, string orderby = null, string filter = null, CancellationToken cancellationToken = default) + /// , , or is null. + public async Task> BatchAsync(string subscriptionId, string metricNamespace, IEnumerable metricNames, ResourceIdList resourceIds, string startTime = null, string endTime = null, TimeSpan? interval = null, string aggregation = null, int? top = null, string orderby = null, string filter = null, CancellationToken cancellationToken = default) { if (subscriptionId == null) { throw new ArgumentNullException(nameof(subscriptionId)); } - if (metricnamespace == null) + if (metricNamespace == null) { - throw new ArgumentNullException(nameof(metricnamespace)); + throw new ArgumentNullException(nameof(metricNamespace)); } - if (metricnames == null) + if (metricNames == null) { - throw new ArgumentNullException(nameof(metricnames)); + throw new ArgumentNullException(nameof(metricNames)); } if (resourceIds == null) { throw new ArgumentNullException(nameof(resourceIds)); } - using var message = CreateBatchRequest(subscriptionId, metricnamespace, metricnames, resourceIds, starttime, endtime, interval, aggregation, top, orderby, filter); + using var message = CreateBatchRequest(subscriptionId, metricNamespace, metricNames, resourceIds, startTime, endTime, interval, aggregation, top, orderby, filter); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { @@ -159,15 +159,15 @@ public async Task> BatchAsync(string subscriptio /// Lists the metric values for multiple resources. /// The subscription identifier for the resources in this batch. - /// Metric namespace that contains the requested metric names. - /// The names of the metrics (comma separated) to retrieve. + /// Metric namespace that contains the requested metric names. + /// The names of the metrics (comma separated) to retrieve. /// The comma separated list of resource IDs to query metrics for. - /// + /// /// The start time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. If you have specified the endtime parameter, then this parameter is required. /// If only starttime is specified, then endtime defaults to the current time. /// If no time interval is specified, the default is 1 hour. /// - /// The end time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. + /// The end time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. /// /// The interval (i.e. timegrain) of the query. /// *Examples: PT15M, PT1H, P1D* @@ -188,27 +188,27 @@ public async Task> BatchAsync(string subscriptio /// /// The filter is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. /// The cancellation token to use. - /// , , or is null. - public Response Batch(string subscriptionId, string metricnamespace, IEnumerable metricnames, ResourceIdList resourceIds, string starttime = null, string endtime = null, TimeSpan? interval = null, string aggregation = null, int? top = null, string orderby = null, string filter = null, CancellationToken cancellationToken = default) + /// , , or is null. + public Response Batch(string subscriptionId, string metricNamespace, IEnumerable metricNames, ResourceIdList resourceIds, string startTime = null, string endTime = null, TimeSpan? interval = null, string aggregation = null, int? top = null, string orderby = null, string filter = null, CancellationToken cancellationToken = default) { if (subscriptionId == null) { throw new ArgumentNullException(nameof(subscriptionId)); } - if (metricnamespace == null) + if (metricNamespace == null) { - throw new ArgumentNullException(nameof(metricnamespace)); + throw new ArgumentNullException(nameof(metricNamespace)); } - if (metricnames == null) + if (metricNames == null) { - throw new ArgumentNullException(nameof(metricnames)); + throw new ArgumentNullException(nameof(metricNames)); } if (resourceIds == null) { throw new ArgumentNullException(nameof(resourceIds)); } - using var message = CreateBatchRequest(subscriptionId, metricnamespace, metricnames, resourceIds, starttime, endtime, interval, aggregation, top, orderby, filter); + using var message = CreateBatchRequest(subscriptionId, metricNamespace, metricNames, resourceIds, startTime, endTime, interval, aggregation, top, orderby, filter); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.Serialization.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.Serialization.cs index de68768b0929..da26f96bab9c 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.Serialization.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.Serialization.cs @@ -20,8 +20,8 @@ internal static MetricResultsResponseValuesItem DeserializeMetricResultsResponse { return null; } - string starttime = default; - string endtime = default; + DateTimeOffset starttime = default; + DateTimeOffset endtime = default; Optional interval = default; Optional @namespace = default; Optional resourceregion = default; @@ -31,12 +31,12 @@ internal static MetricResultsResponseValuesItem DeserializeMetricResultsResponse { if (property.NameEquals("starttime"u8)) { - starttime = property.Value.GetString(); + starttime = property.Value.GetDateTimeOffset(null); continue; } if (property.NameEquals("endtime"u8)) { - endtime = property.Value.GetString(); + endtime = property.Value.GetDateTimeOffset(null); continue; } if (property.NameEquals("interval"u8)) diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.cs index fa77cd65b910..5835dbd932de 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.cs @@ -16,44 +16,37 @@ namespace Azure.Monitor.Query.Models public partial class MetricResultsResponseValuesItem { /// Initializes a new instance of MetricResultsResponseValuesItem. - /// The start time, in datetime format, for which the data was retrieved. - /// The end time, in datetime format, for which the data was retrieved. + /// The start time, in datetime format, for which the data was retrieved. + /// The end time, in datetime format, for which the data was retrieved. /// The value of the collection. - /// , or is null. - internal MetricResultsResponseValuesItem(string starttime, string endtime, IEnumerable value) + /// is null. + internal MetricResultsResponseValuesItem(DateTimeOffset startTime, DateTimeOffset endTime, IEnumerable value) { - Argument.AssertNotNull(starttime, nameof(starttime)); - Argument.AssertNotNull(endtime, nameof(endtime)); Argument.AssertNotNull(value, nameof(value)); - Starttime = starttime; - Endtime = endtime; + StartTime = startTime; + EndTime = endTime; Value = value.ToList(); } /// Initializes a new instance of MetricResultsResponseValuesItem. - /// The start time, in datetime format, for which the data was retrieved. - /// The end time, in datetime format, for which the data was retrieved. + /// The start time, in datetime format, for which the data was retrieved. + /// The end time, in datetime format, for which the data was retrieved. /// The interval (window size) for which the metric data was returned in. Follows the IS8601/RFC3339 duration format (e.g. 'P1D' for 1 day). This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. /// The namespace of the metrics been queried. /// The region of the resource been queried for metrics. /// The resource that has been queried for metrics. /// The value of the collection. - internal MetricResultsResponseValuesItem(string starttime, string endtime, TimeSpan? interval, string @namespace, string resourceregion, string resourceid, IReadOnlyList value) + internal MetricResultsResponseValuesItem(DateTimeOffset startTime, DateTimeOffset endTime, TimeSpan? interval, string @namespace, string resourceregion, string resourceid, IReadOnlyList value) { - Starttime = starttime; - Endtime = endtime; + StartTime = startTime; + EndTime = endTime; Interval = interval; Namespace = @namespace; Resourceregion = resourceregion; Resourceid = resourceid; Value = value; } - - /// The start time, in datetime format, for which the data was retrieved. - public string Starttime { get; } - /// The end time, in datetime format, for which the data was retrieved. - public string Endtime { get; } /// The interval (window size) for which the metric data was returned in. Follows the IS8601/RFC3339 duration format (e.g. 'P1D' for 1 day). This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. public TimeSpan? Interval { get; } /// The namespace of the metrics been queried. diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.Serialization.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.Serialization.cs index ccbf1841cde1..af0752eb8195 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.Serialization.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.Serialization.cs @@ -10,7 +10,7 @@ namespace Azure.Monitor.Query.Models { - public partial class ResourceIdList : IUtf8JsonSerializable + internal partial class ResourceIdList : IUtf8JsonSerializable { void IUtf8JsonSerializable.Write(Utf8JsonWriter writer) { diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.cs index 92540028cbe7..561b8f19f88c 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/ResourceIdList.cs @@ -11,7 +11,7 @@ namespace Azure.Monitor.Query.Models { /// The comma separated list of resource IDs to query metrics for. - public partial class ResourceIdList + internal partial class ResourceIdList { /// Initializes a new instance of ResourceIdList. public ResourceIdList() diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/MonitorQueryModelFactory.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/MonitorQueryModelFactory.cs index ed78eec94f65..fa0d3495ab23 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/Generated/MonitorQueryModelFactory.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/MonitorQueryModelFactory.cs @@ -49,19 +49,19 @@ public static MetricResultsResponse MetricResultsResponse(IEnumerable Initializes a new instance of MetricResultsResponseValuesItem. - /// The start time, in datetime format, for which the data was retrieved. - /// The end time, in datetime format, for which the data was retrieved. + /// The start time, in datetime format, for which the data was retrieved. + /// The end time, in datetime format, for which the data was retrieved. /// The interval (window size) for which the metric data was returned in. Follows the IS8601/RFC3339 duration format (e.g. 'P1D' for 1 day). This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. /// The namespace of the metrics been queried. /// The region of the resource been queried for metrics. /// The resource that has been queried for metrics. /// The value of the collection. /// A new instance for mocking. - public static MetricResultsResponseValuesItem MetricResultsResponseValuesItem(string starttime = null, string endtime = null, TimeSpan? interval = null, string @namespace = null, string resourceregion = null, string resourceid = null, IEnumerable value = null) + public static MetricResultsResponseValuesItem MetricResultsResponseValuesItem(DateTimeOffset startTime = default, DateTimeOffset endTime = default, TimeSpan? interval = null, string @namespace = null, string resourceregion = null, string resourceid = null, IEnumerable value = null) { value ??= new List(); - return new MetricResultsResponseValuesItem(starttime, endtime, interval, @namespace, resourceregion, resourceid, value?.ToList()); + return new MetricResultsResponseValuesItem(startTime, endTime, interval, @namespace, resourceregion, resourceid, value?.ToList()); } /// Initializes a new instance of QueryBatchMetric. diff --git a/sdk/monitor/Azure.Monitor.Query/src/MetricResultsResponseValuesItem.cs b/sdk/monitor/Azure.Monitor.Query/src/MetricResultsResponseValuesItem.cs new file mode 100644 index 000000000000..5b59c0203b81 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.Query/src/MetricResultsResponseValuesItem.cs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +#nullable disable + +using System; +using Azure.Core; + +namespace Azure.Monitor.Query.Models +{ + /// The MetricResultsResponseValuesItem. + public partial class MetricResultsResponseValuesItem + { + /// The start time, in datetime format, for which the data was retrieved. + [CodeGenMember("Starttime")] + public DateTimeOffset StartTime { get; } + + /// The end time, in datetime format, for which the data was retrieved. + [CodeGenMember("Endtime")] + public DateTimeOffset EndTime { get; } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs b/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs index ef92b5413dcb..d8e063c7e7e7 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/MetricsBatchQueryClient.cs @@ -16,32 +16,10 @@ namespace Azure.Monitor.Query /// public class MetricsBatchQueryClient { - private static readonly Uri _defaultEndpoint = new Uri("https://metrics.monitor.azure.com/.default"); - private readonly MetricsBatchRestClient _metricBatchClient; private readonly ClientDiagnostics _clientDiagnostics; - /// - /// Initializes a new instance of . Uses the default 'https://metrics.monitor.azure.com/.default' endpoint. - /// - /// var client = new MetricsQueryClient(new DefaultAzureCredential()); - /// - /// - /// The instance to use for authentication. - public MetricsBatchQueryClient(TokenCredential credential) : this(credential, null) - { - } - - /// - /// Initializes a new instance of . Uses the default 'https://metrics.monitor.azure.com/.default' endpoint. - /// - /// The instance to use for authentication. - /// The instance to as client configuration. - public MetricsBatchQueryClient(TokenCredential credential, MetricsBatchQueryClientOptions options) : this(_defaultEndpoint, credential, options) - { - } - - /// + /// /// Initializes a new instance of . /// /// The data plane service endpoint to use. For example https://metrics.monitor.azure.com/.default for public cloud. @@ -85,13 +63,18 @@ protected MetricsBatchQueryClient() /// The to configure the query. /// The to use. /// A time-series metrics result for the requested metric names. - public virtual Response Batch(List resourceIds, List metricNames, string metricNamespace, MetricsQueryOptions options = null, CancellationToken cancellationToken = default) + public virtual Response QueryBatch(List resourceIds, List metricNames, string metricNamespace, MetricsQueryOptions options = null, CancellationToken cancellationToken = default) { - if (resourceIds.Count == 0) + if (resourceIds.Count == 0 || metricNames.Count == 0) + { + throw new ArgumentException("Resource IDs or metricNames can not be empty"); + } + if (metricNamespace == null) { - throw new ArgumentException("Resource IDs can not be empty"); + throw new ArgumentNullException(nameof(metricNamespace)); } - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(MetricsBatchQueryClient)}.{nameof(Batch)}"); + + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(MetricsBatchQueryClient)}.{nameof(QueryBatch)}"); scope.Start(); try @@ -179,13 +162,18 @@ private async Task> ExecuteBatchAsync(ListThe to configure the query. /// The to use. /// A time-series metrics result for the requested metric names. - public virtual async Task> BatchAsync(List resourceIds, List metricNames, string metricNamespace, MetricsQueryOptions options = null, CancellationToken cancellationToken = default) + public virtual async Task> QueryBatchAsync(List resourceIds, List metricNames, string metricNamespace, MetricsQueryOptions options = null, CancellationToken cancellationToken = default) { - if (resourceIds.Count == 0) + if (resourceIds.Count == 0 || metricNames.Count == 0) { - throw new ArgumentException("Resource IDs can not be empty"); + throw new ArgumentException("Resource IDs or metricNames can not be empty"); } - using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(MetricsBatchQueryClient)}.{nameof(Batch)}"); + if (metricNamespace == null) + { + throw new ArgumentNullException(nameof(metricNamespace)); + } + + using DiagnosticScope scope = _clientDiagnostics.CreateScope($"{nameof(MetricsBatchQueryClient)}.{nameof(QueryBatch)}"); scope.Start(); try diff --git a/sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs b/sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs index dc6e978f715a..a0b443e4f2b8 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs @@ -11,7 +11,7 @@ namespace Azure.Monitor.Query.Models { /// The comma separated list of resource IDs to query metrics for. - public partial class ResourceIdList + internal partial class ResourceIdList { /// Initializes a new instance of ResourceIdList. public ResourceIdList(List resourceIds) diff --git a/sdk/monitor/Azure.Monitor.Query/src/metricBatch.json b/sdk/monitor/Azure.Monitor.Query/src/metricBatch.json index 25926dfa767f..bd5dd1707a54 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/metricBatch.json +++ b/sdk/monitor/Azure.Monitor.Query/src/metricBatch.json @@ -138,7 +138,7 @@ "x-ms-parameter-location": "method" }, "StartTimeParameter": { - "name": "starttime", + "name": "startTime", "in": "query", "required": false, "type": "string", @@ -146,7 +146,7 @@ "x-ms-parameter-location": "method" }, "EndTimeParameter": { - "name": "endtime", + "name": "endTime", "in": "query", "required": false, "type": "string", @@ -164,7 +164,7 @@ "x-ms-parameter-location": "method" }, "MetricNamespaceParameter": { - "name": "metricnamespace", + "name": "metricNamespace", "in": "query", "required": true, "type": "string", @@ -172,7 +172,7 @@ "x-ms-parameter-location": "method" }, "MetricNamesParameter": { - "name": "metricnames", + "name": "metricNames", "in": "query", "required": true, "type": "array", diff --git a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs index 972c37f1332d..36d4b45f9864 100644 --- a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs +++ b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs @@ -343,7 +343,7 @@ public async Task MetricsBatchQueryAsync() var resourceId = TestEnvironment.StorageAccountId; - Response metricsResultsResponse = await client.BatchAsync( + Response metricsResultsResponse = await client.QueryBatchAsync( resourceIds: new List { resourceId }, metricNames: new List { "Ingress" }, metricNamespace: "Microsoft.Storage/storageAccounts").ConfigureAwait(false); @@ -372,7 +372,7 @@ public void MetricsBatchInvalid() Assert.Throws(()=> { - client.Batch( + client.QueryBatch( resourceIds: new List(), metricNames: new List { "Ingress" }, metricNamespace: "Microsoft.Storage/storageAccounts"); diff --git a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientSamples.cs b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientSamples.cs index 18a2450762be..c54e244f7d7c 100644 --- a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientSamples.cs +++ b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientSamples.cs @@ -143,8 +143,8 @@ public async Task QueryBatchMetrics() #else string resourceId = TestEnvironment.StorageAccountId; #endif - MetricsBatchQueryClient client = new MetricsBatchQueryClient(new DefaultAzureCredential()); - Response metricsResultsResponse = await client.BatchAsync( + MetricsBatchQueryClient client = new MetricsBatchQueryClient(new Uri("https://metrics.monitor.azure.com/.default"), new DefaultAzureCredential()); + Response metricsResultsResponse = await client.QueryBatchAsync( resourceIds: new List { resourceId }, metricNames: new List { "Ingress" }, metricNamespace: "Microsoft.Storage/storageAccounts").ConfigureAwait(false); From 964b9bf0848d21fc46d347250b32a33608142e67 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Tue, 17 Oct 2023 14:33:36 -0700 Subject: [PATCH 31/36] wip --- .../api/Azure.Monitor.Query.netstandard2.0.cs | 4 ++-- .../MetricResultsResponseValuesItem.Serialization.cs | 8 ++++++-- .../Generated/Models/MetricResultsResponseValuesItem.cs | 8 +++----- .../src/Generated/MonitorQueryModelFactory.cs | 7 ++++--- .../src/MetricResultsResponseValuesItem.cs | 4 ++++ 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/sdk/monitor/Azure.Monitor.Query/api/Azure.Monitor.Query.netstandard2.0.cs b/sdk/monitor/Azure.Monitor.Query/api/Azure.Monitor.Query.netstandard2.0.cs index 9cab8ad83086..b6b36649e6a6 100644 --- a/sdk/monitor/Azure.Monitor.Query/api/Azure.Monitor.Query.netstandard2.0.cs +++ b/sdk/monitor/Azure.Monitor.Query/api/Azure.Monitor.Query.netstandard2.0.cs @@ -314,7 +314,7 @@ internal MetricResultsResponseValuesItem() { } public System.DateTimeOffset EndTime { get { throw null; } } public System.TimeSpan? Interval { get { throw null; } } public string Namespace { get { throw null; } } - public string Resourceid { get { throw null; } } + public Azure.Core.ResourceIdentifier ResourceId { get { throw null; } } public string Resourceregion { get { throw null; } } public System.DateTimeOffset StartTime { get { throw null; } } public System.Collections.Generic.IReadOnlyList Value { get { throw null; } } @@ -385,7 +385,7 @@ public static partial class MonitorQueryModelFactory public static Azure.Monitor.Query.Models.MetricAvailability MetricAvailability(System.TimeSpan? granularity = default(System.TimeSpan?), System.TimeSpan? retention = default(System.TimeSpan?)) { throw null; } public static Azure.Monitor.Query.Models.MetricResult MetricResult(string id, string resourceType, string name, Azure.Monitor.Query.Models.MetricUnit unit, System.Collections.Generic.IEnumerable timeSeries) { throw null; } public static Azure.Monitor.Query.Models.MetricResultsResponse MetricResultsResponse(System.Collections.Generic.IEnumerable values = null) { throw null; } - public static Azure.Monitor.Query.Models.MetricResultsResponseValuesItem MetricResultsResponseValuesItem(System.DateTimeOffset startTime = default(System.DateTimeOffset), System.DateTimeOffset endTime = default(System.DateTimeOffset), System.TimeSpan? interval = default(System.TimeSpan?), string @namespace = null, string resourceregion = null, string resourceid = null, System.Collections.Generic.IEnumerable value = null) { throw null; } + public static Azure.Monitor.Query.Models.MetricResultsResponseValuesItem MetricResultsResponseValuesItem(System.DateTimeOffset startTime = default(System.DateTimeOffset), System.DateTimeOffset endTime = default(System.DateTimeOffset), System.TimeSpan? interval = default(System.TimeSpan?), string @namespace = null, string resourceregion = null, Azure.Core.ResourceIdentifier resourceId = null, System.Collections.Generic.IEnumerable value = null) { throw null; } public static Azure.Monitor.Query.Models.MetricsQueryResult MetricsQueryResult(int? cost, string timespan, System.TimeSpan? granularity, string @namespace, string resourceRegion, System.Collections.Generic.IReadOnlyList metrics) { throw null; } public static Azure.Monitor.Query.Models.MetricTimeSeriesElement MetricTimeSeriesElement(System.Collections.Generic.IReadOnlyDictionary metadataValues, System.Collections.Generic.IEnumerable values) { throw null; } public static Azure.Monitor.Query.Models.MetricValue MetricValue(System.DateTimeOffset timeStamp = default(System.DateTimeOffset), double? average = default(double?), double? minimum = default(double?), double? maximum = default(double?), double? total = default(double?), double? count = default(double?)) { throw null; } diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.Serialization.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.Serialization.cs index da26f96bab9c..3c9133393a85 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.Serialization.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.Serialization.cs @@ -25,7 +25,7 @@ internal static MetricResultsResponseValuesItem DeserializeMetricResultsResponse Optional interval = default; Optional @namespace = default; Optional resourceregion = default; - Optional resourceid = default; + Optional resourceid = default; IReadOnlyList value = default; foreach (var property in element.EnumerateObject()) { @@ -60,7 +60,11 @@ internal static MetricResultsResponseValuesItem DeserializeMetricResultsResponse } if (property.NameEquals("resourceid"u8)) { - resourceid = property.Value.GetString(); + if (property.Value.ValueKind == JsonValueKind.Null) + { + continue; + } + resourceid = new ResourceIdentifier(property.Value.GetString()); continue; } if (property.NameEquals("value"u8)) diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.cs index 5835dbd932de..ffc33cf338c8 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.cs @@ -35,16 +35,16 @@ internal MetricResultsResponseValuesItem(DateTimeOffset startTime, DateTimeOffse /// The interval (window size) for which the metric data was returned in. Follows the IS8601/RFC3339 duration format (e.g. 'P1D' for 1 day). This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. /// The namespace of the metrics been queried. /// The region of the resource been queried for metrics. - /// The resource that has been queried for metrics. + /// The resource that has been queried for metrics. /// The value of the collection. - internal MetricResultsResponseValuesItem(DateTimeOffset startTime, DateTimeOffset endTime, TimeSpan? interval, string @namespace, string resourceregion, string resourceid, IReadOnlyList value) + internal MetricResultsResponseValuesItem(DateTimeOffset startTime, DateTimeOffset endTime, TimeSpan? interval, string @namespace, string resourceregion, ResourceIdentifier resourceId, IReadOnlyList value) { StartTime = startTime; EndTime = endTime; Interval = interval; Namespace = @namespace; Resourceregion = resourceregion; - Resourceid = resourceid; + ResourceId = resourceId; Value = value; } /// The interval (window size) for which the metric data was returned in. Follows the IS8601/RFC3339 duration format (e.g. 'P1D' for 1 day). This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. @@ -53,8 +53,6 @@ internal MetricResultsResponseValuesItem(DateTimeOffset startTime, DateTimeOffse public string Namespace { get; } /// The region of the resource been queried for metrics. public string Resourceregion { get; } - /// The resource that has been queried for metrics. - public string Resourceid { get; } /// The value of the collection. public IReadOnlyList Value { get; } } diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/MonitorQueryModelFactory.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/MonitorQueryModelFactory.cs index fa0d3495ab23..fc8f39ca587a 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/Generated/MonitorQueryModelFactory.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/MonitorQueryModelFactory.cs @@ -8,6 +8,7 @@ using System; using System.Collections.Generic; using System.Linq; +using Azure.Core; namespace Azure.Monitor.Query.Models { @@ -54,14 +55,14 @@ public static MetricResultsResponse MetricResultsResponse(IEnumerable The interval (window size) for which the metric data was returned in. Follows the IS8601/RFC3339 duration format (e.g. 'P1D' for 1 day). This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. /// The namespace of the metrics been queried. /// The region of the resource been queried for metrics. - /// The resource that has been queried for metrics. + /// The resource that has been queried for metrics. /// The value of the collection. /// A new instance for mocking. - public static MetricResultsResponseValuesItem MetricResultsResponseValuesItem(DateTimeOffset startTime = default, DateTimeOffset endTime = default, TimeSpan? interval = null, string @namespace = null, string resourceregion = null, string resourceid = null, IEnumerable value = null) + public static MetricResultsResponseValuesItem MetricResultsResponseValuesItem(DateTimeOffset startTime = default, DateTimeOffset endTime = default, TimeSpan? interval = null, string @namespace = null, string resourceregion = null, ResourceIdentifier resourceId = null, IEnumerable value = null) { value ??= new List(); - return new MetricResultsResponseValuesItem(startTime, endTime, interval, @namespace, resourceregion, resourceid, value?.ToList()); + return new MetricResultsResponseValuesItem(startTime, endTime, interval, @namespace, resourceregion, resourceId, value?.ToList()); } /// Initializes a new instance of QueryBatchMetric. diff --git a/sdk/monitor/Azure.Monitor.Query/src/MetricResultsResponseValuesItem.cs b/sdk/monitor/Azure.Monitor.Query/src/MetricResultsResponseValuesItem.cs index 5b59c0203b81..9f175d6ec660 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/MetricResultsResponseValuesItem.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/MetricResultsResponseValuesItem.cs @@ -18,5 +18,9 @@ public partial class MetricResultsResponseValuesItem /// The end time, in datetime format, for which the data was retrieved. [CodeGenMember("Endtime")] public DateTimeOffset EndTime { get; } + + /// The resource that has been queried for metrics. + [CodeGenMember("Resourceid")] + public ResourceIdentifier ResourceId { get; } } } From 50c0f872dc709b0375c4fb6bc0a655431adf860e Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Tue, 17 Oct 2023 14:56:11 -0700 Subject: [PATCH 32/36] wip --- .vscode/cspell.json | 3 +-- sdk/monitor/Azure.Monitor.Query/CHANGELOG.md | 2 +- .../api/Azure.Monitor.Query.netstandard2.0.cs | 4 ++-- .../Generated/Models/MetricResultsResponseValuesItem.cs | 8 +++----- .../src/Generated/MonitorQueryModelFactory.cs | 6 +++--- .../src/MetricResultsResponseValuesItem.cs | 4 ++++ .../tests/MetricsQueryClientLiveTests.cs | 2 +- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/.vscode/cspell.json b/.vscode/cspell.json index 4515c5ba1e3d..d3445a442d4e 100644 --- a/.vscode/cspell.json +++ b/.vscode/cspell.json @@ -1232,8 +1232,7 @@ { "filename": "**/sdk/monitor/**/*.cs", "words": [ - "resourceId", - "ResourceId" + "resourceid" ] } ], diff --git a/sdk/monitor/Azure.Monitor.Query/CHANGELOG.md b/sdk/monitor/Azure.Monitor.Query/CHANGELOG.md index 9435aac04040..e183fbe6f74b 100644 --- a/sdk/monitor/Azure.Monitor.Query/CHANGELOG.md +++ b/sdk/monitor/Azure.Monitor.Query/CHANGELOG.md @@ -4,7 +4,7 @@ ### Features Added - Added the `MetricsBatchQueryClient` client to support batch querying of metrics. -- Added `Batch` and `BatchAsync` methods to `MetricsBatchQueryClient` +- Added `QueryBatch` and `QueryBatchAsync` methods to `MetricsBatchQueryClient` ### Breaking Changes diff --git a/sdk/monitor/Azure.Monitor.Query/api/Azure.Monitor.Query.netstandard2.0.cs b/sdk/monitor/Azure.Monitor.Query/api/Azure.Monitor.Query.netstandard2.0.cs index b6b36649e6a6..6b27263b166f 100644 --- a/sdk/monitor/Azure.Monitor.Query/api/Azure.Monitor.Query.netstandard2.0.cs +++ b/sdk/monitor/Azure.Monitor.Query/api/Azure.Monitor.Query.netstandard2.0.cs @@ -315,7 +315,7 @@ internal MetricResultsResponseValuesItem() { } public System.TimeSpan? Interval { get { throw null; } } public string Namespace { get { throw null; } } public Azure.Core.ResourceIdentifier ResourceId { get { throw null; } } - public string Resourceregion { get { throw null; } } + public string ResourceRegion { get { throw null; } } public System.DateTimeOffset StartTime { get { throw null; } } public System.Collections.Generic.IReadOnlyList Value { get { throw null; } } } @@ -385,7 +385,7 @@ public static partial class MonitorQueryModelFactory public static Azure.Monitor.Query.Models.MetricAvailability MetricAvailability(System.TimeSpan? granularity = default(System.TimeSpan?), System.TimeSpan? retention = default(System.TimeSpan?)) { throw null; } public static Azure.Monitor.Query.Models.MetricResult MetricResult(string id, string resourceType, string name, Azure.Monitor.Query.Models.MetricUnit unit, System.Collections.Generic.IEnumerable timeSeries) { throw null; } public static Azure.Monitor.Query.Models.MetricResultsResponse MetricResultsResponse(System.Collections.Generic.IEnumerable values = null) { throw null; } - public static Azure.Monitor.Query.Models.MetricResultsResponseValuesItem MetricResultsResponseValuesItem(System.DateTimeOffset startTime = default(System.DateTimeOffset), System.DateTimeOffset endTime = default(System.DateTimeOffset), System.TimeSpan? interval = default(System.TimeSpan?), string @namespace = null, string resourceregion = null, Azure.Core.ResourceIdentifier resourceId = null, System.Collections.Generic.IEnumerable value = null) { throw null; } + public static Azure.Monitor.Query.Models.MetricResultsResponseValuesItem MetricResultsResponseValuesItem(System.DateTimeOffset startTime = default(System.DateTimeOffset), System.DateTimeOffset endTime = default(System.DateTimeOffset), System.TimeSpan? interval = default(System.TimeSpan?), string @namespace = null, string resourceRegion = null, Azure.Core.ResourceIdentifier resourceId = null, System.Collections.Generic.IEnumerable value = null) { throw null; } public static Azure.Monitor.Query.Models.MetricsQueryResult MetricsQueryResult(int? cost, string timespan, System.TimeSpan? granularity, string @namespace, string resourceRegion, System.Collections.Generic.IReadOnlyList metrics) { throw null; } public static Azure.Monitor.Query.Models.MetricTimeSeriesElement MetricTimeSeriesElement(System.Collections.Generic.IReadOnlyDictionary metadataValues, System.Collections.Generic.IEnumerable values) { throw null; } public static Azure.Monitor.Query.Models.MetricValue MetricValue(System.DateTimeOffset timeStamp = default(System.DateTimeOffset), double? average = default(double?), double? minimum = default(double?), double? maximum = default(double?), double? total = default(double?), double? count = default(double?)) { throw null; } diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.cs index ffc33cf338c8..53a10f795ac9 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/Models/MetricResultsResponseValuesItem.cs @@ -34,16 +34,16 @@ internal MetricResultsResponseValuesItem(DateTimeOffset startTime, DateTimeOffse /// The end time, in datetime format, for which the data was retrieved. /// The interval (window size) for which the metric data was returned in. Follows the IS8601/RFC3339 duration format (e.g. 'P1D' for 1 day). This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. /// The namespace of the metrics been queried. - /// The region of the resource been queried for metrics. + /// The region of the resource been queried for metrics. /// The resource that has been queried for metrics. /// The value of the collection. - internal MetricResultsResponseValuesItem(DateTimeOffset startTime, DateTimeOffset endTime, TimeSpan? interval, string @namespace, string resourceregion, ResourceIdentifier resourceId, IReadOnlyList value) + internal MetricResultsResponseValuesItem(DateTimeOffset startTime, DateTimeOffset endTime, TimeSpan? interval, string @namespace, string resourceRegion, ResourceIdentifier resourceId, IReadOnlyList value) { StartTime = startTime; EndTime = endTime; Interval = interval; Namespace = @namespace; - Resourceregion = resourceregion; + ResourceRegion = resourceRegion; ResourceId = resourceId; Value = value; } @@ -51,8 +51,6 @@ internal MetricResultsResponseValuesItem(DateTimeOffset startTime, DateTimeOffse public TimeSpan? Interval { get; } /// The namespace of the metrics been queried. public string Namespace { get; } - /// The region of the resource been queried for metrics. - public string Resourceregion { get; } /// The value of the collection. public IReadOnlyList Value { get; } } diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/MonitorQueryModelFactory.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/MonitorQueryModelFactory.cs index fc8f39ca587a..862c36ac9c28 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/Generated/MonitorQueryModelFactory.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/MonitorQueryModelFactory.cs @@ -54,15 +54,15 @@ public static MetricResultsResponse MetricResultsResponse(IEnumerable The end time, in datetime format, for which the data was retrieved. /// The interval (window size) for which the metric data was returned in. Follows the IS8601/RFC3339 duration format (e.g. 'P1D' for 1 day). This may be adjusted in the future and returned back from what was originally requested. This is not present if a metadata request was made. /// The namespace of the metrics been queried. - /// The region of the resource been queried for metrics. + /// The region of the resource been queried for metrics. /// The resource that has been queried for metrics. /// The value of the collection. /// A new instance for mocking. - public static MetricResultsResponseValuesItem MetricResultsResponseValuesItem(DateTimeOffset startTime = default, DateTimeOffset endTime = default, TimeSpan? interval = null, string @namespace = null, string resourceregion = null, ResourceIdentifier resourceId = null, IEnumerable value = null) + public static MetricResultsResponseValuesItem MetricResultsResponseValuesItem(DateTimeOffset startTime = default, DateTimeOffset endTime = default, TimeSpan? interval = null, string @namespace = null, string resourceRegion = null, ResourceIdentifier resourceId = null, IEnumerable value = null) { value ??= new List(); - return new MetricResultsResponseValuesItem(startTime, endTime, interval, @namespace, resourceregion, resourceId, value?.ToList()); + return new MetricResultsResponseValuesItem(startTime, endTime, interval, @namespace, resourceRegion, resourceId, value?.ToList()); } /// Initializes a new instance of QueryBatchMetric. diff --git a/sdk/monitor/Azure.Monitor.Query/src/MetricResultsResponseValuesItem.cs b/sdk/monitor/Azure.Monitor.Query/src/MetricResultsResponseValuesItem.cs index 9f175d6ec660..27591c21df8d 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/MetricResultsResponseValuesItem.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/MetricResultsResponseValuesItem.cs @@ -22,5 +22,9 @@ public partial class MetricResultsResponseValuesItem /// The resource that has been queried for metrics. [CodeGenMember("Resourceid")] public ResourceIdentifier ResourceId { get; } + + /// The region of the resource been queried for metrics. + [CodeGenMember("Resourceregion")] + public string ResourceRegion { get; } } } diff --git a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs index 36d4b45f9864..b49c8cf40d43 100644 --- a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs +++ b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs @@ -350,7 +350,7 @@ public async Task MetricsBatchQueryAsync() MetricResultsResponse metricsQueryResults = metricsResultsResponse.Value; Assert.AreEqual(1, metricsQueryResults.Values.Count); - Assert.AreEqual(TestEnvironment.StorageAccountId, metricsQueryResults.Values[0].Resourceid); + Assert.AreEqual(TestEnvironment.StorageAccountId, metricsQueryResults.Values[0].ResourceId); Assert.AreEqual("Microsoft.Storage/storageAccounts", metricsQueryResults.Values[0].Namespace); for (int i = 0; i < metricsQueryResults.Values.Count; i++) { From a87a324425579cc92738ceb0d5271476e2e0f97b Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Tue, 17 Oct 2023 15:06:38 -0700 Subject: [PATCH 33/36] wip --- ...e.Monitor.OpenTelemetry.Exporter.net6.0.cs | 24 +++++++++++++++++++ .../MetricResultsResponseValuesItem.cs | 0 .../src/Models/ResourceIdList.cs | 2 -- 3 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/api/Azure.Monitor.OpenTelemetry.Exporter.net6.0.cs rename sdk/monitor/Azure.Monitor.Query/src/{ => Models}/MetricResultsResponseValuesItem.cs (100%) diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/api/Azure.Monitor.OpenTelemetry.Exporter.net6.0.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/api/Azure.Monitor.OpenTelemetry.Exporter.net6.0.cs new file mode 100644 index 000000000000..df4fa7a16050 --- /dev/null +++ b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/api/Azure.Monitor.OpenTelemetry.Exporter.net6.0.cs @@ -0,0 +1,24 @@ +namespace Azure.Monitor.OpenTelemetry.Exporter +{ + public static partial class AzureMonitorExporterExtensions + { + public static OpenTelemetry.Logs.OpenTelemetryLoggerOptions AddAzureMonitorLogExporter(this OpenTelemetry.Logs.OpenTelemetryLoggerOptions loggerOptions, System.Action configure = null, Azure.Core.TokenCredential credential = null) { throw null; } + public static OpenTelemetry.Metrics.MeterProviderBuilder AddAzureMonitorMetricExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure = null, Azure.Core.TokenCredential credential = null, string name = null) { throw null; } + public static OpenTelemetry.Trace.TracerProviderBuilder AddAzureMonitorTraceExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configure = null, Azure.Core.TokenCredential credential = null, string name = null) { throw null; } + } + public partial class AzureMonitorExporterOptions : Azure.Core.ClientOptions + { + public AzureMonitorExporterOptions() { } + public AzureMonitorExporterOptions(Azure.Monitor.OpenTelemetry.Exporter.AzureMonitorExporterOptions.ServiceVersion version = Azure.Monitor.OpenTelemetry.Exporter.AzureMonitorExporterOptions.ServiceVersion.v2_1) { } + public string ConnectionString { get { throw null; } set { } } + public Azure.Core.TokenCredential Credential { get { throw null; } set { } } + public bool DisableOfflineStorage { get { throw null; } set { } } + public float SamplingRatio { get { throw null; } set { } } + public string StorageDirectory { get { throw null; } set { } } + public Azure.Monitor.OpenTelemetry.Exporter.AzureMonitorExporterOptions.ServiceVersion Version { get { throw null; } set { } } + public enum ServiceVersion + { + v2_1 = 1, + } + } +} diff --git a/sdk/monitor/Azure.Monitor.Query/src/MetricResultsResponseValuesItem.cs b/sdk/monitor/Azure.Monitor.Query/src/Models/MetricResultsResponseValuesItem.cs similarity index 100% rename from sdk/monitor/Azure.Monitor.Query/src/MetricResultsResponseValuesItem.cs rename to sdk/monitor/Azure.Monitor.Query/src/Models/MetricResultsResponseValuesItem.cs diff --git a/sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs b/sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs index a0b443e4f2b8..1cc95ac54ab2 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/Models/ResourceIdList.cs @@ -1,8 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. -// - #nullable disable using System.Collections.Generic; From e2ba5fb780aa2b36119b892588b8cd314978ff3b Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Tue, 17 Oct 2023 15:58:28 -0700 Subject: [PATCH 34/36] wip --- sdk/monitor/Azure.Monitor.Query/assets.json | 2 +- .../src/Generated/MetricsBatchRestClient.cs | 44 +++++++++---------- .../Azure.Monitor.Query/src/metricBatch.json | 4 +- .../tests/MetricsQueryClientLiveTests.cs | 2 +- 4 files changed, 26 insertions(+), 26 deletions(-) diff --git a/sdk/monitor/Azure.Monitor.Query/assets.json b/sdk/monitor/Azure.Monitor.Query/assets.json index 4fed871f7f70..34e4dbdcb67d 100644 --- a/sdk/monitor/Azure.Monitor.Query/assets.json +++ b/sdk/monitor/Azure.Monitor.Query/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "net", "TagPrefix": "net/monitor/Azure.Monitor.Query", - "Tag": "net/monitor/Azure.Monitor.Query_bf8de1142d" + "Tag": "net/monitor/Azure.Monitor.Query_cdc38c2347" } diff --git a/sdk/monitor/Azure.Monitor.Query/src/Generated/MetricsBatchRestClient.cs b/sdk/monitor/Azure.Monitor.Query/src/Generated/MetricsBatchRestClient.cs index 156379878406..a032121648e8 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/Generated/MetricsBatchRestClient.cs +++ b/sdk/monitor/Azure.Monitor.Query/src/Generated/MetricsBatchRestClient.cs @@ -37,7 +37,7 @@ public MetricsBatchRestClient(ClientDiagnostics clientDiagnostics, HttpPipeline _endpoint = endpoint ?? throw new ArgumentNullException(nameof(endpoint)); } - internal HttpMessage CreateBatchRequest(string subscriptionId, string metricNamespace, IEnumerable metricNames, ResourceIdList resourceIds, string startTime, string endTime, TimeSpan? interval, string aggregation, int? top, string orderby, string filter) + internal HttpMessage CreateBatchRequest(string subscriptionId, string metricnamespace, IEnumerable metricnames, ResourceIdList resourceIds, string startTime, string endTime, TimeSpan? interval, string aggregation, int? top, string orderby, string filter) { var message = _pipeline.CreateMessage(); var request = message.Request; @@ -59,10 +59,10 @@ internal HttpMessage CreateBatchRequest(string subscriptionId, string metricName { uri.AppendQuery("interval", interval.Value, "P", true); } - uri.AppendQuery("metricNamespace", metricNamespace, true); - if (metricNames != null && Optional.IsCollectionDefined(metricNames)) + uri.AppendQuery("metricnamespace", metricnamespace, true); + if (metricnames != null && Optional.IsCollectionDefined(metricnames)) { - uri.AppendQueryDelimited("metricNames", metricNames, ",", true); + uri.AppendQueryDelimited("metricnames", metricnames, ",", true); } if (aggregation != null) { @@ -92,8 +92,8 @@ internal HttpMessage CreateBatchRequest(string subscriptionId, string metricName /// Lists the metric values for multiple resources. /// The subscription identifier for the resources in this batch. - /// Metric namespace that contains the requested metric names. - /// The names of the metrics (comma separated) to retrieve. + /// Metric namespace that contains the requested metric names. + /// The names of the metrics (comma separated) to retrieve. /// The comma separated list of resource IDs to query metrics for. /// /// The start time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. If you have specified the endtime parameter, then this parameter is required. @@ -121,27 +121,27 @@ internal HttpMessage CreateBatchRequest(string subscriptionId, string metricName /// /// The filter is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. /// The cancellation token to use. - /// , , or is null. - public async Task> BatchAsync(string subscriptionId, string metricNamespace, IEnumerable metricNames, ResourceIdList resourceIds, string startTime = null, string endTime = null, TimeSpan? interval = null, string aggregation = null, int? top = null, string orderby = null, string filter = null, CancellationToken cancellationToken = default) + /// , , or is null. + public async Task> BatchAsync(string subscriptionId, string metricnamespace, IEnumerable metricnames, ResourceIdList resourceIds, string startTime = null, string endTime = null, TimeSpan? interval = null, string aggregation = null, int? top = null, string orderby = null, string filter = null, CancellationToken cancellationToken = default) { if (subscriptionId == null) { throw new ArgumentNullException(nameof(subscriptionId)); } - if (metricNamespace == null) + if (metricnamespace == null) { - throw new ArgumentNullException(nameof(metricNamespace)); + throw new ArgumentNullException(nameof(metricnamespace)); } - if (metricNames == null) + if (metricnames == null) { - throw new ArgumentNullException(nameof(metricNames)); + throw new ArgumentNullException(nameof(metricnames)); } if (resourceIds == null) { throw new ArgumentNullException(nameof(resourceIds)); } - using var message = CreateBatchRequest(subscriptionId, metricNamespace, metricNames, resourceIds, startTime, endTime, interval, aggregation, top, orderby, filter); + using var message = CreateBatchRequest(subscriptionId, metricnamespace, metricnames, resourceIds, startTime, endTime, interval, aggregation, top, orderby, filter); await _pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false); switch (message.Response.Status) { @@ -159,8 +159,8 @@ public async Task> BatchAsync(string subscriptio /// Lists the metric values for multiple resources. /// The subscription identifier for the resources in this batch. - /// Metric namespace that contains the requested metric names. - /// The names of the metrics (comma separated) to retrieve. + /// Metric namespace that contains the requested metric names. + /// The names of the metrics (comma separated) to retrieve. /// The comma separated list of resource IDs to query metrics for. /// /// The start time of the query. It is a string in the format 'yyyy-MM-ddTHH:mm:ss.fffZ'. If you have specified the endtime parameter, then this parameter is required. @@ -188,27 +188,27 @@ public async Task> BatchAsync(string subscriptio /// /// The filter is used to reduce the set of metric data returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series of C where A = a1 and B = b1 or b2<br>**filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq ‘*’**<br>- Invalid variant:<br>**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**filter=A eq ‘a1’ and B eq ‘*’ and C eq ‘*’**. /// The cancellation token to use. - /// , , or is null. - public Response Batch(string subscriptionId, string metricNamespace, IEnumerable metricNames, ResourceIdList resourceIds, string startTime = null, string endTime = null, TimeSpan? interval = null, string aggregation = null, int? top = null, string orderby = null, string filter = null, CancellationToken cancellationToken = default) + /// , , or is null. + public Response Batch(string subscriptionId, string metricnamespace, IEnumerable metricnames, ResourceIdList resourceIds, string startTime = null, string endTime = null, TimeSpan? interval = null, string aggregation = null, int? top = null, string orderby = null, string filter = null, CancellationToken cancellationToken = default) { if (subscriptionId == null) { throw new ArgumentNullException(nameof(subscriptionId)); } - if (metricNamespace == null) + if (metricnamespace == null) { - throw new ArgumentNullException(nameof(metricNamespace)); + throw new ArgumentNullException(nameof(metricnamespace)); } - if (metricNames == null) + if (metricnames == null) { - throw new ArgumentNullException(nameof(metricNames)); + throw new ArgumentNullException(nameof(metricnames)); } if (resourceIds == null) { throw new ArgumentNullException(nameof(resourceIds)); } - using var message = CreateBatchRequest(subscriptionId, metricNamespace, metricNames, resourceIds, startTime, endTime, interval, aggregation, top, orderby, filter); + using var message = CreateBatchRequest(subscriptionId, metricnamespace, metricnames, resourceIds, startTime, endTime, interval, aggregation, top, orderby, filter); _pipeline.Send(message, cancellationToken); switch (message.Response.Status) { diff --git a/sdk/monitor/Azure.Monitor.Query/src/metricBatch.json b/sdk/monitor/Azure.Monitor.Query/src/metricBatch.json index bd5dd1707a54..154bcb62530e 100644 --- a/sdk/monitor/Azure.Monitor.Query/src/metricBatch.json +++ b/sdk/monitor/Azure.Monitor.Query/src/metricBatch.json @@ -164,7 +164,7 @@ "x-ms-parameter-location": "method" }, "MetricNamespaceParameter": { - "name": "metricNamespace", + "name": "metricnamespace", "in": "query", "required": true, "type": "string", @@ -172,7 +172,7 @@ "x-ms-parameter-location": "method" }, "MetricNamesParameter": { - "name": "metricNames", + "name": "metricnames", "in": "query", "required": true, "type": "array", diff --git a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs index b49c8cf40d43..653c09f92a5a 100644 --- a/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs +++ b/sdk/monitor/Azure.Monitor.Query/tests/MetricsQueryClientLiveTests.cs @@ -350,7 +350,7 @@ public async Task MetricsBatchQueryAsync() MetricResultsResponse metricsQueryResults = metricsResultsResponse.Value; Assert.AreEqual(1, metricsQueryResults.Values.Count); - Assert.AreEqual(TestEnvironment.StorageAccountId, metricsQueryResults.Values[0].ResourceId); + Assert.AreEqual(TestEnvironment.StorageAccountId, metricsQueryResults.Values[0].ResourceId.ToString()); Assert.AreEqual("Microsoft.Storage/storageAccounts", metricsQueryResults.Values[0].Namespace); for (int i = 0; i < metricsQueryResults.Values.Count; i++) { From c056b9eeddcf83e78459a3bc6e0cc939ecf0ec09 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Tue, 17 Oct 2023 16:26:00 -0700 Subject: [PATCH 35/36] Delete Azure.Monitor.OpenTelemetry.Exporter.net6.0.cs --- ...e.Monitor.OpenTelemetry.Exporter.net6.0.cs | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/api/Azure.Monitor.OpenTelemetry.Exporter.net6.0.cs diff --git a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/api/Azure.Monitor.OpenTelemetry.Exporter.net6.0.cs b/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/api/Azure.Monitor.OpenTelemetry.Exporter.net6.0.cs deleted file mode 100644 index df4fa7a16050..000000000000 --- a/sdk/monitor/Azure.Monitor.OpenTelemetry.Exporter/api/Azure.Monitor.OpenTelemetry.Exporter.net6.0.cs +++ /dev/null @@ -1,24 +0,0 @@ -namespace Azure.Monitor.OpenTelemetry.Exporter -{ - public static partial class AzureMonitorExporterExtensions - { - public static OpenTelemetry.Logs.OpenTelemetryLoggerOptions AddAzureMonitorLogExporter(this OpenTelemetry.Logs.OpenTelemetryLoggerOptions loggerOptions, System.Action configure = null, Azure.Core.TokenCredential credential = null) { throw null; } - public static OpenTelemetry.Metrics.MeterProviderBuilder AddAzureMonitorMetricExporter(this OpenTelemetry.Metrics.MeterProviderBuilder builder, System.Action configure = null, Azure.Core.TokenCredential credential = null, string name = null) { throw null; } - public static OpenTelemetry.Trace.TracerProviderBuilder AddAzureMonitorTraceExporter(this OpenTelemetry.Trace.TracerProviderBuilder builder, System.Action configure = null, Azure.Core.TokenCredential credential = null, string name = null) { throw null; } - } - public partial class AzureMonitorExporterOptions : Azure.Core.ClientOptions - { - public AzureMonitorExporterOptions() { } - public AzureMonitorExporterOptions(Azure.Monitor.OpenTelemetry.Exporter.AzureMonitorExporterOptions.ServiceVersion version = Azure.Monitor.OpenTelemetry.Exporter.AzureMonitorExporterOptions.ServiceVersion.v2_1) { } - public string ConnectionString { get { throw null; } set { } } - public Azure.Core.TokenCredential Credential { get { throw null; } set { } } - public bool DisableOfflineStorage { get { throw null; } set { } } - public float SamplingRatio { get { throw null; } set { } } - public string StorageDirectory { get { throw null; } set { } } - public Azure.Monitor.OpenTelemetry.Exporter.AzureMonitorExporterOptions.ServiceVersion Version { get { throw null; } set { } } - public enum ServiceVersion - { - v2_1 = 1, - } - } -} From be6012321b5c90783d9050af98be239b3c6bd5e5 Mon Sep 17 00:00:00 2001 From: nisha-bhatia <67986960+nisha-bhatia@users.noreply.github.com> Date: Tue, 17 Oct 2023 16:31:31 -0700 Subject: [PATCH 36/36] Update README.md --- sdk/monitor/Azure.Monitor.Query/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/monitor/Azure.Monitor.Query/README.md b/sdk/monitor/Azure.Monitor.Query/README.md index 237eaf69530c..ed78c8002450 100644 --- a/sdk/monitor/Azure.Monitor.Query/README.md +++ b/sdk/monitor/Azure.Monitor.Query/README.md @@ -588,7 +588,7 @@ foreach (MetricResult metric in result.Value.Metrics) #### Metrics batch query -A user can also query metrics from multiple resources at once using the `Batch` method of `MetricsBatchQueryClient`. This uses a different API than the `MetricsQueryClient` and requires that a user pass in a regional endpoint when instantiating the client (for example, "https://westus3.metrics.monitor.azure.com"). +A user can also query metrics from multiple resources at once using the `QueryBatch` method of `MetricsBatchQueryClient`. This uses a different API than the `MetricsQueryClient` and requires that a user pass in a regional endpoint when instantiating the client (for example, "https://westus3.metrics.monitor.azure.com"). Note, each resource must be in the same region as the endpoint passed in when instantiating the client, and each resource must be in the same Azure subscription. Furthermore, the metric namespace that contains the metrics to be queried must also be passed. A list of metric namespaces can be found [here][metric_namespaces].