From ce8e492582868c6c46b8dc90d4f98f92d279b223 Mon Sep 17 00:00:00 2001 From: Jair Myree Date: Wed, 30 Jul 2025 17:19:32 -0700 Subject: [PATCH 1/9] Updates to Metrics Query --- .../query/metrics/MetricsClientBuilder.java | 1 + .../models/MetricsQueryResourcesResult.java | 5 +- .../models/MetricsQueryTimeInterval.java | 122 +----------------- .../metrics/models/TimeSeriesElement.java | 5 +- 4 files changed, 12 insertions(+), 121 deletions(-) diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/MetricsClientBuilder.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/MetricsClientBuilder.java index f9d468473721..a826b1fe95cb 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/MetricsClientBuilder.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/MetricsClientBuilder.java @@ -137,6 +137,7 @@ public MetricsClientBuilder addPolicy(HttpPipelinePolicy customPolicy) { * @param tokenCredential the tokenCredential value. * @return the {@link MetricsClientBuilder}. */ + @Override public MetricsClientBuilder credential(TokenCredential tokenCredential) { innerBuilder.credential(tokenCredential); return this; diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/MetricsQueryResourcesResult.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/MetricsQueryResourcesResult.java index f79596312727..4e89a2a1654e 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/MetricsQueryResourcesResult.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/MetricsQueryResourcesResult.java @@ -3,12 +3,15 @@ package com.azure.monitor.query.metrics.models; +import com.azure.core.annotation.Immutable; + import java.util.List; /** * The result of a metrics query. It contains the results of individual queries. */ -public class MetricsQueryResourcesResult { +@Immutable +public final class MetricsQueryResourcesResult { private final List metricsQueryResults; /** diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/MetricsQueryTimeInterval.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/MetricsQueryTimeInterval.java index f9b198dd8dcc..d981af79d48b 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/MetricsQueryTimeInterval.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/MetricsQueryTimeInterval.java @@ -22,72 +22,14 @@ public final class MetricsQueryTimeInterval { public static final MetricsQueryTimeInterval ALL = new MetricsQueryTimeInterval(OffsetDateTime.MIN, OffsetDateTime.MAX); - /** - * Time interval of the last 5 minutes. - */ - public static final MetricsQueryTimeInterval LAST_5_MINUTES = new MetricsQueryTimeInterval(Duration.ofMinutes(5)); - - /** - * Time interval of the last 30 minutes. - */ - public static final MetricsQueryTimeInterval LAST_30_MINUTES = new MetricsQueryTimeInterval(Duration.ofMinutes(30)); - - /** - * Time interval of the last hour. - */ - public static final MetricsQueryTimeInterval LAST_1_HOUR = new MetricsQueryTimeInterval(Duration.ofHours(1)); - - /** - * Time interval of the last 4 hours. - */ - public static final MetricsQueryTimeInterval LAST_4_HOURS = new MetricsQueryTimeInterval(Duration.ofHours(4)); - - /** - * Time interval of the last 12 hours. - */ - public static final MetricsQueryTimeInterval LAST_12_HOURS = new MetricsQueryTimeInterval(Duration.ofHours(12)); - - /** - * Time interval of the last day. - */ - public static final MetricsQueryTimeInterval LAST_DAY = new MetricsQueryTimeInterval(Duration.ofDays(1)); - - /** - * Time interval of the last 2 days. - */ - public static final MetricsQueryTimeInterval LAST_2_DAYS = new MetricsQueryTimeInterval(Duration.ofDays(2)); - - /** - * Time interval of the last 3 days. - */ - public static final MetricsQueryTimeInterval LAST_3_DAYS = new MetricsQueryTimeInterval(Duration.ofDays(3)); - - /** - * Time interval of the last 7 days. - */ - public static final MetricsQueryTimeInterval LAST_7_DAYS = new MetricsQueryTimeInterval(Duration.ofDays(7)); - private static final ClientLogger LOGGER = new ClientLogger(MetricsQueryTimeInterval.class); private static final String ERROR_MESSAGE = "%s is an invalid time interval. It must be in one of the " + "following ISO 8601 time interval formats: duration, startDuration/endTime, " + "startTime/endTime, startTime/endDuration"; - private final Duration duration; private final OffsetDateTime startTime; private final OffsetDateTime endTime; - /** - * Creates an instance of {@link MetricsQueryTimeInterval} using the provided duration. The duration is the interval that starts - * from the provided duration and ends at the current time. - * - * @param duration the duration for this query time span. - */ - public MetricsQueryTimeInterval(Duration duration) { - this.duration = Objects.requireNonNull(duration, "'duration' cannot be null"); - this.startTime = null; - this.endTime = null; - } - /** * Creates an instance of {@link MetricsQueryTimeInterval} using the start and end {@link OffsetDateTime OffsetDateTimes}. * @@ -97,19 +39,6 @@ public MetricsQueryTimeInterval(Duration duration) { public MetricsQueryTimeInterval(OffsetDateTime startTime, OffsetDateTime endTime) { this.startTime = Objects.requireNonNull(startTime, "'startTime' cannot be null"); this.endTime = Objects.requireNonNull(endTime, "'endTime' cannot be null"); - this.duration = null; - } - - /** - * Creates an instance of {@link MetricsQueryTimeInterval} using the start and end duration of the interval. - * - * @param startTime The start time of the interval. - * @param duration The end duration of the interval. - */ - public MetricsQueryTimeInterval(OffsetDateTime startTime, Duration duration) { - this.startTime = Objects.requireNonNull(startTime, "'startTime' cannot be null"); - this.duration = Objects.requireNonNull(duration, "'duration' cannot be null"); - this.endTime = null; } /** @@ -120,19 +49,9 @@ public MetricsQueryTimeInterval(OffsetDateTime startTime, Duration duration) { */ MetricsQueryTimeInterval(Duration duration, OffsetDateTime endTime) { this.endTime = Objects.requireNonNull(endTime, "'endTime' cannot be null"); - this.duration = Objects.requireNonNull(duration, "'duration' cannot be null"); this.startTime = null; } - /** - * Returns the duration of this {@link MetricsQueryTimeInterval} instance. - * - * @return the duration of this {@link MetricsQueryTimeInterval} instance. - */ - public Duration getDuration() { - return duration; - } - /** * Returns the start time of this {@link MetricsQueryTimeInterval} instance. * @@ -142,11 +61,6 @@ public OffsetDateTime getStartTime() { if (startTime != null) { return startTime; } - // This check is not required as the constructor would not allow duration and endtime to be null if - // startTime is null. But spotbugs raises an error for not checking null here. - if (duration != null && endTime != null) { - return endTime.minusNanos(duration.toNanos()); - } return null; } @@ -159,9 +73,6 @@ public OffsetDateTime getEndTime() { if (endTime != null) { return endTime; } - if (startTime != null && duration != null) { - return startTime.plusNanos(duration.toNanos()); - } return null; } @@ -176,33 +87,13 @@ public static MetricsQueryTimeInterval parse(String value) { Objects.requireNonNull(value); String[] parts = value.split("/"); - if (parts.length == 1) { - // duration - Duration duration = parseDuration(parts[0]); - if (duration == null || parts[0].length() + 1 == value.length()) { - // input strings like "PT24H/" are invalid - throw LOGGER.logExceptionAsError(new IllegalArgumentException(String.format(ERROR_MESSAGE, value))); - } - - return new MetricsQueryTimeInterval(duration); - } - if (parts.length == 2) { - Duration startDuration = parseDuration(parts[0]); OffsetDateTime startTime = parseTime(parts[0]); - Duration endDuration = parseDuration(parts[1]); OffsetDateTime endTime = parseTime(parts[1]); - - if (startDuration != null && endTime != null) { - return new MetricsQueryTimeInterval(startDuration, endTime); - } if (startTime != null && endTime != null) { return new MetricsQueryTimeInterval(startTime, endTime); } - if (startTime != null && endDuration != null) { - return new MetricsQueryTimeInterval(startTime, endDuration); - } } throw LOGGER.logExceptionAsError(new IllegalArgumentException(String.format(ERROR_MESSAGE, value))); } @@ -212,14 +103,8 @@ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("["); - if (duration != null && endTime != null) { - sb.append("duration: ").append(duration).append(", ").append("end time: ").append(endTime); - } else if (startTime != null && endTime != null) { + if (startTime != null && endTime != null) { sb.append("start time: ").append(startTime).append(", ").append("end time: ").append(endTime); - } else if (startTime != null && duration != null) { - sb.append("start time: ").append(startTime).append(", ").append("duration: ").append(duration); - } else { - sb.append("duration: ").append(duration); } sb.append("]"); return sb.toString(); @@ -235,14 +120,13 @@ public boolean equals(Object o) { } MetricsQueryTimeInterval that = (MetricsQueryTimeInterval) o; - return Objects.equals(this.duration, that.duration) - && Objects.equals(this.startTime, that.startTime) + return Objects.equals(this.startTime, that.startTime) && Objects.equals(this.endTime, that.endTime); } @Override public int hashCode() { - return Objects.hash(duration, startTime, endTime); + return Objects.hash(startTime, endTime); } private static OffsetDateTime parseTime(String value) { diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/TimeSeriesElement.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/TimeSeriesElement.java index 843dd4afc18d..8b9eb9e3018f 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/TimeSeriesElement.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/TimeSeriesElement.java @@ -2,13 +2,16 @@ // Licensed under the MIT License. package com.azure.monitor.query.metrics.models; +import com.azure.core.annotation.Immutable; + import java.util.List; import java.util.Map; /** * A time series result type. The discriminator value is always TimeSeries in this case. */ -public class TimeSeriesElement { +@Immutable +public final class TimeSeriesElement { private final List values; private final Map metadata; From 1edc298e38bf87985d18af06f7b6815dc0f31448 Mon Sep 17 00:00:00 2001 From: Jair Myree Date: Wed, 30 Jul 2025 17:29:43 -0700 Subject: [PATCH 2/9] Removing duration --- .../models/MetricsQueryTimeInterval.java | 25 +++---------------- 1 file changed, 3 insertions(+), 22 deletions(-) diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/MetricsQueryTimeInterval.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/MetricsQueryTimeInterval.java index d981af79d48b..c91442c253c3 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/MetricsQueryTimeInterval.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/MetricsQueryTimeInterval.java @@ -6,7 +6,7 @@ import com.azure.core.annotation.Immutable; import com.azure.core.util.logging.ClientLogger; -import java.time.Duration; + import java.time.OffsetDateTime; import java.util.Objects; @@ -23,9 +23,8 @@ public final class MetricsQueryTimeInterval { = new MetricsQueryTimeInterval(OffsetDateTime.MIN, OffsetDateTime.MAX); private static final ClientLogger LOGGER = new ClientLogger(MetricsQueryTimeInterval.class); - private static final String ERROR_MESSAGE = "%s is an invalid time interval. It must be in one of the " - + "following ISO 8601 time interval formats: duration, startDuration/endTime, " - + "startTime/endTime, startTime/endDuration"; + private static final String ERROR_MESSAGE = "%s is an invalid time interval. It must be in the " + + "following ISO 8601 time interval format: startTime/endTime"; private final OffsetDateTime startTime; private final OffsetDateTime endTime; @@ -41,16 +40,6 @@ public MetricsQueryTimeInterval(OffsetDateTime startTime, OffsetDateTime endTime this.endTime = Objects.requireNonNull(endTime, "'endTime' cannot be null"); } - /** - * Creates an instance of {@link MetricsQueryTimeInterval} using the start and end duration of the interval. - * - * @param duration The duration of the interval. - * @param endTime The end time of the interval. - */ - MetricsQueryTimeInterval(Duration duration, OffsetDateTime endTime) { - this.endTime = Objects.requireNonNull(endTime, "'endTime' cannot be null"); - this.startTime = null; - } /** * Returns the start time of this {@link MetricsQueryTimeInterval} instance. @@ -136,12 +125,4 @@ private static OffsetDateTime parseTime(String value) { return null; } } - - private static Duration parseDuration(String value) { - try { - return Duration.parse(value); - } catch (Exception exception) { - return null; - } - } } From f78f09658f858703765b106650c8b7a3cc86a37e Mon Sep 17 00:00:00 2001 From: Jair Myree Date: Wed, 30 Jul 2025 17:33:14 -0700 Subject: [PATCH 3/9] formatting update and removing unnecessary static constant. --- .../query/metrics/models/MetricsQueryTimeInterval.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/MetricsQueryTimeInterval.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/MetricsQueryTimeInterval.java index c91442c253c3..271849957d83 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/MetricsQueryTimeInterval.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/MetricsQueryTimeInterval.java @@ -6,7 +6,6 @@ import com.azure.core.annotation.Immutable; import com.azure.core.util.logging.ClientLogger; - import java.time.OffsetDateTime; import java.util.Objects; @@ -19,8 +18,6 @@ public final class MetricsQueryTimeInterval { /** * Time interval of all time. */ - public static final MetricsQueryTimeInterval ALL - = new MetricsQueryTimeInterval(OffsetDateTime.MIN, OffsetDateTime.MAX); private static final ClientLogger LOGGER = new ClientLogger(MetricsQueryTimeInterval.class); private static final String ERROR_MESSAGE = "%s is an invalid time interval. It must be in the " @@ -40,7 +37,6 @@ public MetricsQueryTimeInterval(OffsetDateTime startTime, OffsetDateTime endTime this.endTime = Objects.requireNonNull(endTime, "'endTime' cannot be null"); } - /** * Returns the start time of this {@link MetricsQueryTimeInterval} instance. * @@ -109,8 +105,7 @@ public boolean equals(Object o) { } MetricsQueryTimeInterval that = (MetricsQueryTimeInterval) o; - return Objects.equals(this.startTime, that.startTime) - && Objects.equals(this.endTime, that.endTime); + return Objects.equals(this.startTime, that.startTime) && Objects.equals(this.endTime, that.endTime); } @Override From 3a7aa1edb368580d295bfd7328dd62ed91837bae Mon Sep 17 00:00:00 2001 From: Jair Myree Date: Wed, 30 Jul 2025 17:37:47 -0700 Subject: [PATCH 4/9] Updating CHANGELOG.md --- sdk/monitor/azure-monitor-query-metrics/CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/monitor/azure-monitor-query-metrics/CHANGELOG.md b/sdk/monitor/azure-monitor-query-metrics/CHANGELOG.md index 0ab82a7eea50..ab4b3b5141e9 100644 --- a/sdk/monitor/azure-monitor-query-metrics/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-query-metrics/CHANGELOG.md @@ -1,6 +1,6 @@ # Release History -## 1.0.0 (07-30-2025) +## 1.0.0 (2025-07-30) ### Features Added From 4c761650cdff9370b963c37d86d1127c4052a7fc Mon Sep 17 00:00:00 2001 From: Jair Myree Date: Wed, 30 Jul 2025 17:51:01 -0700 Subject: [PATCH 5/9] regen TypeSpec --- .../MonitorQueryMetricsAsyncClient.java | 10 ++--- .../MonitorQueryMetricsClient.java | 10 ++--- .../MonitorQueryMetricsClientBuilder.java | 32 +++++++------- .../MonitorQueryMetricsClientImpl.java | 43 ++++++++++--------- .../models/LocalizableString.java | 12 +++--- .../implementation/models/MetadataValue.java | 10 ++--- .../metrics/implementation/models/Metric.java | 24 +++++------ .../models/MetricResultsResponse.java | 8 ++-- .../MetricResultsResponseValuesItem.java | 28 ++++++------ .../implementation/models/ResourceIdList.java | 10 ++--- .../models/TimeSeriesElement.java | 10 ++--- .../implementation/models/package-info.java | 1 - sdk/monitor/pom.xml | 25 +++++++++++ 13 files changed, 117 insertions(+), 106 deletions(-) diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsAsyncClient.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsAsyncClient.java index a680dbf60cb1..f7a1a4cab03c 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsAsyncClient.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsAsyncClient.java @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. - package com.azure.monitor.query.metrics.implementation; import com.azure.core.annotation.Generated; @@ -26,12 +25,13 @@ */ @ServiceClient(builder = MonitorQueryMetricsClientBuilder.class, isAsync = true) public final class MonitorQueryMetricsAsyncClient { + @Generated private final MonitorQueryMetricsClientImpl serviceClient; /** * Initializes an instance of MonitorQueryMetricsAsyncClient class. - * + * * @param serviceClient the service client implementation. */ @Generated @@ -147,7 +147,7 @@ public final class MonitorQueryMetricsAsyncClient { * } * } * - * + * * @param subscriptionId The subscription identifier for the resources in this batch. * @param metricNamespace Metric namespace that contains the requested metric names. * @param metricNames The names of the metrics (comma separated) to retrieve. @@ -169,7 +169,7 @@ public Mono> queryResourcesWithResponse(String subscription /** * Lists the metric values for multiple resources. - * + * * @param subscriptionId The subscription identifier for the resources in this batch. * @param metricNamespace Metric namespace that contains the requested metric names. * @param metricNames The names of the metrics (comma separated) to retrieve. @@ -251,7 +251,7 @@ public Mono queryResources(String subscriptionId, String /** * Lists the metric values for multiple resources. - * + * * @param subscriptionId The subscription identifier for the resources in this batch. * @param metricNamespace Metric namespace that contains the requested metric names. * @param metricNames The names of the metrics (comma separated) to retrieve. diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsClient.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsClient.java index e538e5c012d5..c3c06defc40a 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsClient.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsClient.java @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. - package com.azure.monitor.query.metrics.implementation; import com.azure.core.annotation.Generated; @@ -24,12 +23,13 @@ */ @ServiceClient(builder = MonitorQueryMetricsClientBuilder.class) public final class MonitorQueryMetricsClient { + @Generated private final MonitorQueryMetricsClientImpl serviceClient; /** * Initializes an instance of MonitorQueryMetricsClient class. - * + * * @param serviceClient the service client implementation. */ @Generated @@ -145,7 +145,7 @@ public final class MonitorQueryMetricsClient { * } * } * - * + * * @param subscriptionId The subscription identifier for the resources in this batch. * @param metricNamespace Metric namespace that contains the requested metric names. * @param metricNames The names of the metrics (comma separated) to retrieve. @@ -167,7 +167,7 @@ public Response queryResourcesWithResponse(String subscriptionId, St /** * Lists the metric values for multiple resources. - * + * * @param subscriptionId The subscription identifier for the resources in this batch. * @param metricNamespace Metric namespace that contains the requested metric names. * @param metricNames The names of the metrics (comma separated) to retrieve. @@ -248,7 +248,7 @@ public MetricResultsResponse queryResources(String subscriptionId, String metric /** * Lists the metric values for multiple resources. - * + * * @param subscriptionId The subscription identifier for the resources in this batch. * @param metricNamespace Metric namespace that contains the requested metric names. * @param metricNames The names of the metrics (comma separated) to retrieve. diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsClientBuilder.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsClientBuilder.java index c7a82bcf1df3..c9a05dfdf1d9 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsClientBuilder.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsClientBuilder.java @@ -34,7 +34,7 @@ import com.azure.core.util.builder.ClientBuilderUtil; import com.azure.core.util.logging.ClientLogger; import com.azure.core.util.serializer.JacksonAdapter; -import com.azure.monitor.query.metrics.MetricsServiceVersion; +import com.azure.monitor.query.metrics.MetricsQueryServiceVersion; import com.azure.monitor.query.metrics.models.MetricsQueryAudience; import java.util.ArrayList; import java.util.List; @@ -219,19 +219,7 @@ public MonitorQueryMetricsClientBuilder endpoint(String endpoint) { * Service version */ @Generated - private MetricsServiceVersion serviceVersion; - - /** - * Sets Service version. - * - * @param serviceVersion the serviceVersion value. - * @return the MonitorQueryMetricsClientBuilder. - */ - @Generated - public MonitorQueryMetricsClientBuilder serviceVersion(MetricsServiceVersion serviceVersion) { - this.serviceVersion = serviceVersion; - return this; - } + private MetricsQueryServiceVersion serviceVersion; /* * The retry policy that will attempt to retry failed requests, if applicable. @@ -260,8 +248,8 @@ public MonitorQueryMetricsClientBuilder retryPolicy(RetryPolicy retryPolicy) { private MonitorQueryMetricsClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - MetricsServiceVersion localServiceVersion - = (serviceVersion != null) ? serviceVersion : MetricsServiceVersion.getLatest(); + MetricsQueryServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : MetricsQueryServiceVersion.getLatest(); MonitorQueryMetricsClientImpl client = new MonitorQueryMetricsClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, localServiceVersion); return client; @@ -355,4 +343,16 @@ public MonitorQueryMetricsClientBuilder audience(MetricsQueryAudience audience) this.audience = audience; return this; } + + /** + * Sets Service version. + * + * @param serviceVersion the serviceVersion value. + * @return the MonitorQueryMetricsClientBuilder. + */ + @Generated + public MonitorQueryMetricsClientBuilder serviceVersion(MetricsQueryServiceVersion serviceVersion) { + this.serviceVersion = serviceVersion; + return this; + } } diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsClientImpl.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsClientImpl.java index 3deb930fea9a..2ef83f5ac07f 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsClientImpl.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsClientImpl.java @@ -32,7 +32,7 @@ import com.azure.core.util.FluxUtil; import com.azure.core.util.serializer.JacksonAdapter; import com.azure.core.util.serializer.SerializerAdapter; -import com.azure.monitor.query.metrics.MetricsServiceVersion; +import com.azure.monitor.query.metrics.MetricsQueryServiceVersion; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -56,7 +56,7 @@ public final class MonitorQueryMetricsClientImpl { /** * Gets 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'. - * + * * @return the endpoint value. */ public String getEndpoint() { @@ -66,14 +66,14 @@ public String getEndpoint() { /** * Service version. */ - private final MetricsServiceVersion serviceVersion; + private final MetricsQueryServiceVersion serviceVersion; /** * Gets Service version. - * + * * @return the serviceVersion value. */ - public MetricsServiceVersion getServiceVersion() { + public MetricsQueryServiceVersion getServiceVersion() { return this.serviceVersion; } @@ -84,7 +84,7 @@ public MetricsServiceVersion getServiceVersion() { /** * Gets The HTTP pipeline to send requests through. - * + * * @return the httpPipeline value. */ public HttpPipeline getHttpPipeline() { @@ -98,7 +98,7 @@ public HttpPipeline getHttpPipeline() { /** * Gets The serializer to serialize an object into a string. - * + * * @return the serializerAdapter value. */ public SerializerAdapter getSerializerAdapter() { @@ -107,33 +107,34 @@ public SerializerAdapter getSerializerAdapter() { /** * Initializes an instance of MonitorQueryMetricsClient client. - * + * * @param endpoint 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'. * @param serviceVersion Service version. */ - MonitorQueryMetricsClientImpl(String endpoint, MetricsServiceVersion serviceVersion) { + MonitorQueryMetricsClientImpl(String endpoint, MetricsQueryServiceVersion serviceVersion) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); } /** * Initializes an instance of MonitorQueryMetricsClient client. - * + * * @param httpPipeline The HTTP pipeline to send requests through. * @param endpoint 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'. * @param serviceVersion Service version. */ - MonitorQueryMetricsClientImpl(HttpPipeline httpPipeline, String endpoint, MetricsServiceVersion serviceVersion) { + MonitorQueryMetricsClientImpl(HttpPipeline httpPipeline, String endpoint, + MetricsQueryServiceVersion serviceVersion) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); } /** * Initializes an instance of MonitorQueryMetricsClient client. - * + * * @param httpPipeline The HTTP pipeline to send requests through. * @param serializerAdapter The serializer to serialize an object into a string. * @param endpoint The regional endpoint to use, for example https://eastus.metrics.monitor.azure.com. The region @@ -142,7 +143,7 @@ public SerializerAdapter getSerializerAdapter() { * @param serviceVersion Service version. */ MonitorQueryMetricsClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, - MetricsServiceVersion serviceVersion) { + MetricsQueryServiceVersion serviceVersion) { this.httpPipeline = httpPipeline; this.serializerAdapter = serializerAdapter; this.endpoint = endpoint; @@ -228,7 +229,7 @@ Response queryResourcesSync(@HostParam("endpoint") String endpoint, * * You can add these to a request with {@link RequestOptions#addQueryParam} *

Request Body Schema

- * + * *
      * {@code
      * {
@@ -238,9 +239,9 @@ Response queryResourcesSync(@HostParam("endpoint") String endpoint,
      * }
      * }
      * 
- * + * *

Response Body Schema

- * + * *
      * {@code
      * {
@@ -291,7 +292,7 @@ Response queryResourcesSync(@HostParam("endpoint") String endpoint,
      * }
      * }
      * 
- * + * * @param subscriptionId The subscription identifier for the resources in this batch. * @param metricNamespace Metric namespace that contains the requested metric names. * @param metricNames The names of the metrics (comma separated) to retrieve. @@ -361,7 +362,7 @@ public Mono> queryResourcesWithResponseAsync(String subscri * * You can add these to a request with {@link RequestOptions#addQueryParam} *

Request Body Schema

- * + * *
      * {@code
      * {
@@ -371,9 +372,9 @@ public Mono> queryResourcesWithResponseAsync(String subscri
      * }
      * }
      * 
- * + * *

Response Body Schema

- * + * *
      * {@code
      * {
@@ -424,7 +425,7 @@ public Mono> queryResourcesWithResponseAsync(String subscri
      * }
      * }
      * 
- * + * * @param subscriptionId The subscription identifier for the resources in this batch. * @param metricNamespace Metric namespace that contains the requested metric names. * @param metricNames The names of the metrics (comma separated) to retrieve. diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/LocalizableString.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/LocalizableString.java index 3c8753e29fd1..09a8692fab4a 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/LocalizableString.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/LocalizableString.java @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. - package com.azure.monitor.query.metrics.implementation.models; import com.azure.core.annotation.Generated; @@ -17,6 +16,7 @@ */ @Immutable public final class LocalizableString implements JsonSerializable { + /* * The invariant value. */ @@ -31,7 +31,7 @@ public final class LocalizableString implements JsonSerializable { + /* * The name of the metadata. */ @@ -38,7 +38,7 @@ private MetadataValue() { /** * Get the name property: The name of the metadata. - * + * * @return the name value. */ @Generated @@ -48,7 +48,7 @@ public LocalizableString getName() { /** * Get the value property: The value of the metadata. - * + * * @return the value value. */ @Generated @@ -70,7 +70,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of MetadataValue from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of MetadataValue if the JsonReader was pointing to an instance of it, or null if it was * pointing to JSON null. @@ -83,7 +83,6 @@ public static MetadataValue fromJson(JsonReader jsonReader) throws IOException { while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); - if ("name".equals(fieldName)) { deserializedMetadataValue.name = LocalizableString.fromJson(reader); } else if ("value".equals(fieldName)) { @@ -92,7 +91,6 @@ public static MetadataValue fromJson(JsonReader jsonReader) throws IOException { reader.skipChildren(); } } - return deserializedMetadataValue; }); } diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/Metric.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/Metric.java index 86ef75bbc9ca..f4b36fd9f092 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/Metric.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/Metric.java @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. - package com.azure.monitor.query.metrics.implementation.models; import com.azure.core.annotation.Generated; @@ -19,6 +18,7 @@ */ @Immutable public final class Metric implements JsonSerializable { + /* * The metric Id. */ @@ -69,7 +69,7 @@ public final class Metric implements JsonSerializable { /** * Creates an instance of Metric class. - * + * * @param id the id value to set. * @param type the type value to set. * @param name the name value to set. @@ -88,7 +88,7 @@ private Metric(String id, String type, LocalizableString name, MetricUnit unit, /** * Get the id property: The metric Id. - * + * * @return the id value. */ @Generated @@ -98,7 +98,7 @@ public String getId() { /** * Get the type property: The resource type of the metric resource. - * + * * @return the type value. */ @Generated @@ -108,7 +108,7 @@ public String getType() { /** * Get the name property: The name and the display name of the metric, i.e. it is localizable string. - * + * * @return the name value. */ @Generated @@ -118,7 +118,7 @@ public LocalizableString getName() { /** * Get the displayDescription property: Detailed description of this metric. - * + * * @return the displayDescription value. */ @Generated @@ -128,7 +128,7 @@ public String getDisplayDescription() { /** * Get the errorCode property: 'Success' or the error details on query failures for this metric. - * + * * @return the errorCode value. */ @Generated @@ -138,7 +138,7 @@ public String getErrorCode() { /** * Get the errorMessage property: Error message encountered querying this specific metric. - * + * * @return the errorMessage value. */ @Generated @@ -148,7 +148,7 @@ public String getErrorMessage() { /** * Get the unit property: The unit of the metric. - * + * * @return the unit value. */ @Generated @@ -158,7 +158,7 @@ public MetricUnit getUnit() { /** * Get the timeSeries property: The time series returned when a data query is performed. - * + * * @return the timeSeries value. */ @Generated @@ -186,7 +186,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of Metric from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of Metric if the JsonReader was pointing to an instance of it, or null if it was pointing to * JSON null. @@ -207,7 +207,6 @@ public static Metric fromJson(JsonReader jsonReader) throws IOException { while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); - if ("id".equals(fieldName)) { id = reader.getString(); } else if ("type".equals(fieldName)) { @@ -232,7 +231,6 @@ public static Metric fromJson(JsonReader jsonReader) throws IOException { deserializedMetric.displayDescription = displayDescription; deserializedMetric.errorCode = errorCode; deserializedMetric.errorMessage = errorMessage; - return deserializedMetric; }); } diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/MetricResultsResponse.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/MetricResultsResponse.java index 126374b0d696..df29fa95cdc5 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/MetricResultsResponse.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/MetricResultsResponse.java @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. - package com.azure.monitor.query.metrics.implementation.models; import com.azure.core.annotation.Generated; @@ -18,6 +17,7 @@ */ @Immutable public final class MetricResultsResponse implements JsonSerializable { + /* * The collection of metric data responses per resource, per metric. */ @@ -33,7 +33,7 @@ private MetricResultsResponse() { /** * Get the values property: The collection of metric data responses per resource, per metric. - * + * * @return the values value. */ @Generated @@ -54,7 +54,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of MetricResultsResponse from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of MetricResultsResponse if the JsonReader was pointing to an instance of it, or null if it * was pointing to JSON null. @@ -67,7 +67,6 @@ public static MetricResultsResponse fromJson(JsonReader jsonReader) throws IOExc while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); - if ("values".equals(fieldName)) { List values = reader.readArray(reader1 -> MetricResultsResponseValuesItem.fromJson(reader1)); @@ -76,7 +75,6 @@ public static MetricResultsResponse fromJson(JsonReader jsonReader) throws IOExc reader.skipChildren(); } } - return deserializedMetricResultsResponse; }); } diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/MetricResultsResponseValuesItem.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/MetricResultsResponseValuesItem.java index 63cf5e863110..5e0ce745ddb7 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/MetricResultsResponseValuesItem.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/MetricResultsResponseValuesItem.java @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. - package com.azure.monitor.query.metrics.implementation.models; import com.azure.core.annotation.Generated; @@ -18,6 +17,7 @@ */ @Immutable public final class MetricResultsResponseValuesItem implements JsonSerializable { + /* * The start time, in datetime format, for which the data was retrieved. */ @@ -41,13 +41,13 @@ public final class MetricResultsResponseValuesItem implements JsonSerializable { + /* * The list of resource IDs to query metrics for. */ @@ -33,7 +33,7 @@ public ResourceIdList() { /** * Get the resourceids property: The list of resource IDs to query metrics for. - * + * * @return the resourceids value. */ @Generated @@ -43,7 +43,7 @@ public List getResourceids() { /** * Set the resourceids property: The list of resource IDs to query metrics for. - * + * * @param resourceids the resourceids value to set. * @return the ResourceIdList object itself. */ @@ -66,7 +66,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of ResourceIdList from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of ResourceIdList if the JsonReader was pointing to an instance of it, or null if it was * pointing to JSON null. @@ -79,7 +79,6 @@ public static ResourceIdList fromJson(JsonReader jsonReader) throws IOException while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); - if ("resourceids".equals(fieldName)) { List resourceids = reader.readArray(reader1 -> reader1.getString()); deserializedResourceIdList.resourceids = resourceids; @@ -87,7 +86,6 @@ public static ResourceIdList fromJson(JsonReader jsonReader) throws IOException reader.skipChildren(); } } - return deserializedResourceIdList; }); } diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/TimeSeriesElement.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/TimeSeriesElement.java index feac5236058a..623019592b7b 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/TimeSeriesElement.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/TimeSeriesElement.java @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. - package com.azure.monitor.query.metrics.implementation.models; import com.azure.core.annotation.Generated; @@ -20,6 +19,7 @@ */ @Immutable public final class TimeSeriesElement implements JsonSerializable { + /* * The metadata values returned if $filter was specified in the call. */ @@ -42,7 +42,7 @@ private TimeSeriesElement() { /** * Get the metadatavalues property: The metadata values returned if $filter was specified in the call. - * + * * @return the metadatavalues value. */ @Generated @@ -53,7 +53,7 @@ public List getMetadatavalues() { /** * Get the data property: An array of data points representing the metric values. This is only returned * if a result type of data is specified. - * + * * @return the data value. */ @Generated @@ -76,7 +76,7 @@ public JsonWriter toJson(JsonWriter jsonWriter) throws IOException { /** * Reads an instance of TimeSeriesElement from the JsonReader. - * + * * @param jsonReader The JsonReader being read. * @return An instance of TimeSeriesElement if the JsonReader was pointing to an instance of it, or null if it was * pointing to JSON null. @@ -89,7 +89,6 @@ public static TimeSeriesElement fromJson(JsonReader jsonReader) throws IOExcepti while (reader.nextToken() != JsonToken.END_OBJECT) { String fieldName = reader.getFieldName(); reader.nextToken(); - if ("metadatavalues".equals(fieldName)) { List metadatavalues = reader.readArray(reader1 -> MetadataValue.fromJson(reader1)); deserializedTimeSeriesElement.metadatavalues = metadatavalues; @@ -100,7 +99,6 @@ public static TimeSeriesElement fromJson(JsonReader jsonReader) throws IOExcepti reader.skipChildren(); } } - return deserializedTimeSeriesElement; }); } diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/package-info.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/package-info.java index 775112d3fbcd..a5a4d832f71f 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/package-info.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/package-info.java @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. // Code generated by Microsoft (R) TypeSpec Code Generator. - /** * * Package containing the data models for MetricsQuery. diff --git a/sdk/monitor/pom.xml b/sdk/monitor/pom.xml index fa1709aee930..14f73ed2361a 100644 --- a/sdk/monitor/pom.xml +++ b/sdk/monitor/pom.xml @@ -7,6 +7,31 @@ com.azure azure-monitor-service pom + + + com.azure + azure-core + 1.56.0-beta.1 + compile + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + + + + 8 + 8 + + + + 1.0.0 From 7ac15b4753453d7895cff54c7745c1b37975d389 Mon Sep 17 00:00:00 2001 From: Jair Myree Date: Wed, 30 Jul 2025 18:07:26 -0700 Subject: [PATCH 6/9] regen TypeSpec --- .../query/metrics/MetricsServiceVersion.java | 2 +- .../MonitorQueryMetricsClientBuilder.java | 10 +++++----- .../MonitorQueryMetricsClientImpl.java | 13 ++++++------- .../metrics/implementation/models/package-info.java | 2 +- .../query/metrics/implementation/package-info.java | 2 +- .../monitor/query/metrics/models/package-info.java | 2 +- .../azure-monitor-query-metrics/tsp-location.yaml | 4 ++-- 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/MetricsServiceVersion.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/MetricsServiceVersion.java index dcd1195ec81d..e45d794d7109 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/MetricsServiceVersion.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/MetricsServiceVersion.java @@ -31,7 +31,7 @@ public String getVersion() { /** * Gets the latest service version supported by this client library. - * + * * @return The latest {@link MetricsServiceVersion}. */ public static MetricsServiceVersion getLatest() { diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsClientBuilder.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsClientBuilder.java index c9a05dfdf1d9..2a9035ffbcf9 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsClientBuilder.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsClientBuilder.java @@ -34,7 +34,7 @@ import com.azure.core.util.builder.ClientBuilderUtil; import com.azure.core.util.logging.ClientLogger; import com.azure.core.util.serializer.JacksonAdapter; -import com.azure.monitor.query.metrics.MetricsQueryServiceVersion; +import com.azure.monitor.query.metrics.MetricsServiceVersion; import com.azure.monitor.query.metrics.models.MetricsQueryAudience; import java.util.ArrayList; import java.util.List; @@ -219,7 +219,7 @@ public MonitorQueryMetricsClientBuilder endpoint(String endpoint) { * Service version */ @Generated - private MetricsQueryServiceVersion serviceVersion; + private MetricsServiceVersion serviceVersion; /* * The retry policy that will attempt to retry failed requests, if applicable. @@ -248,8 +248,8 @@ public MonitorQueryMetricsClientBuilder retryPolicy(RetryPolicy retryPolicy) { private MonitorQueryMetricsClientImpl buildInnerClient() { this.validateClient(); HttpPipeline localPipeline = (pipeline != null) ? pipeline : createHttpPipeline(); - MetricsQueryServiceVersion localServiceVersion - = (serviceVersion != null) ? serviceVersion : MetricsQueryServiceVersion.getLatest(); + MetricsServiceVersion localServiceVersion + = (serviceVersion != null) ? serviceVersion : MetricsServiceVersion.getLatest(); MonitorQueryMetricsClientImpl client = new MonitorQueryMetricsClientImpl(localPipeline, JacksonAdapter.createDefaultSerializerAdapter(), this.endpoint, localServiceVersion); return client; @@ -351,7 +351,7 @@ public MonitorQueryMetricsClientBuilder audience(MetricsQueryAudience audience) * @return the MonitorQueryMetricsClientBuilder. */ @Generated - public MonitorQueryMetricsClientBuilder serviceVersion(MetricsQueryServiceVersion serviceVersion) { + public MonitorQueryMetricsClientBuilder serviceVersion(MetricsServiceVersion serviceVersion) { this.serviceVersion = serviceVersion; return this; } diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsClientImpl.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsClientImpl.java index 2ef83f5ac07f..f26678f5d2b8 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsClientImpl.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorQueryMetricsClientImpl.java @@ -32,7 +32,7 @@ import com.azure.core.util.FluxUtil; import com.azure.core.util.serializer.JacksonAdapter; import com.azure.core.util.serializer.SerializerAdapter; -import com.azure.monitor.query.metrics.MetricsQueryServiceVersion; +import com.azure.monitor.query.metrics.MetricsServiceVersion; import java.util.List; import java.util.Objects; import java.util.stream.Collectors; @@ -66,14 +66,14 @@ public String getEndpoint() { /** * Service version. */ - private final MetricsQueryServiceVersion serviceVersion; + private final MetricsServiceVersion serviceVersion; /** * Gets Service version. * * @return the serviceVersion value. */ - public MetricsQueryServiceVersion getServiceVersion() { + public MetricsServiceVersion getServiceVersion() { return this.serviceVersion; } @@ -113,7 +113,7 @@ public SerializerAdapter getSerializerAdapter() { * the region of the requested resources. For global resources, the region should be 'global'. * @param serviceVersion Service version. */ - MonitorQueryMetricsClientImpl(String endpoint, MetricsQueryServiceVersion serviceVersion) { + MonitorQueryMetricsClientImpl(String endpoint, MetricsServiceVersion serviceVersion) { this(new HttpPipelineBuilder().policies(new UserAgentPolicy(), new RetryPolicy()).build(), JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); } @@ -127,8 +127,7 @@ public SerializerAdapter getSerializerAdapter() { * the region of the requested resources. For global resources, the region should be 'global'. * @param serviceVersion Service version. */ - MonitorQueryMetricsClientImpl(HttpPipeline httpPipeline, String endpoint, - MetricsQueryServiceVersion serviceVersion) { + MonitorQueryMetricsClientImpl(HttpPipeline httpPipeline, String endpoint, MetricsServiceVersion serviceVersion) { this(httpPipeline, JacksonAdapter.createDefaultSerializerAdapter(), endpoint, serviceVersion); } @@ -143,7 +142,7 @@ public SerializerAdapter getSerializerAdapter() { * @param serviceVersion Service version. */ MonitorQueryMetricsClientImpl(HttpPipeline httpPipeline, SerializerAdapter serializerAdapter, String endpoint, - MetricsQueryServiceVersion serviceVersion) { + MetricsServiceVersion serviceVersion) { this.httpPipeline = httpPipeline; this.serializerAdapter = serializerAdapter; this.endpoint = endpoint; diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/package-info.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/package-info.java index a5a4d832f71f..bf2e27bea93f 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/package-info.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/models/package-info.java @@ -3,7 +3,7 @@ // Code generated by Microsoft (R) TypeSpec Code Generator. /** * - * Package containing the data models for MetricsQuery. + * Package containing the data models for Metrics. * */ package com.azure.monitor.query.metrics.implementation.models; diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/package-info.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/package-info.java index 0b6ef9021cf4..729ccd1ff49b 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/package-info.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/implementation/package-info.java @@ -3,7 +3,7 @@ // Code generated by Microsoft (R) TypeSpec Code Generator. /** * - * Package containing the implementations for MetricsQuery. + * Package containing the implementations for Metrics. * */ package com.azure.monitor.query.metrics.implementation; diff --git a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/package-info.java b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/package-info.java index ab955a2292e7..650992f3b88d 100644 --- a/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/package-info.java +++ b/sdk/monitor/azure-monitor-query-metrics/src/main/java/com/azure/monitor/query/metrics/models/package-info.java @@ -3,7 +3,7 @@ // Code generated by Microsoft (R) TypeSpec Code Generator. /** * - * Package containing the data models for MetricsQuery. + * Package containing the data models for Metrics. * */ package com.azure.monitor.query.metrics.models; diff --git a/sdk/monitor/azure-monitor-query-metrics/tsp-location.yaml b/sdk/monitor/azure-monitor-query-metrics/tsp-location.yaml index d5bd4a28a99d..599458b17035 100644 --- a/sdk/monitor/azure-monitor-query-metrics/tsp-location.yaml +++ b/sdk/monitor/azure-monitor-query-metrics/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/monitor/Monitor.Query.Metrics -commit: 4d8a05a94caac5554f690560c4463ea19e16e38e +commit: 9ecbfbe10a455fa1ed4f4826cb0bbfb5590e9296 repo: Azure/azure-rest-api-specs -additionalDirectories: +additionalDirectories: From a91b9dd3fb76139214a19f6c79bfcb6ed80b1539 Mon Sep 17 00:00:00 2001 From: Jair Myree Date: Wed, 30 Jul 2025 18:36:42 -0700 Subject: [PATCH 7/9] regen TypeSpec - need to update the tsp-location after specs PR merges --- .../src/main/java/MetricsQueryCustomization.java | 6 ++++++ sdk/monitor/azure-monitor-query-metrics/tsp-location.yaml | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/sdk/monitor/azure-monitor-query-metrics/customization/src/main/java/MetricsQueryCustomization.java b/sdk/monitor/azure-monitor-query-metrics/customization/src/main/java/MetricsQueryCustomization.java index cd7ed8deb61c..c336eead7f65 100644 --- a/sdk/monitor/azure-monitor-query-metrics/customization/src/main/java/MetricsQueryCustomization.java +++ b/sdk/monitor/azure-monitor-query-metrics/customization/src/main/java/MetricsQueryCustomization.java @@ -16,12 +16,18 @@ public class MetricsQueryCustomization extends Customization { * Customizes the MonitorQueryMetricsClientBuilder by adding audience support for authorization scopes. * This customization adds a MetricsQueryAudience field and setter to the builder, and modifies * the HTTP pipeline creation to use the audience when configuring bearer token authentication. + * This customization also updates the module-info.java file to export the metrics models package. * * @param libraryCustomization The library customization object for modifying generated code. * @param logger The logger for recording customization activities. */ @Override public void customize(LibraryCustomization libraryCustomization, Logger logger) { + String original = libraryCustomization.getRawEditor().getFileContent("src/main/java/module-info.java"); + String replace = original.replace("exports com.azure.monitor.query.metrics.implementation;", ""); + + libraryCustomization.getRawEditor().replaceFile("src/main/java/module-info.java", replace); + libraryCustomization.getClass("com.azure.monitor.query.metrics.implementation", "MonitorQueryMetricsClientBuilder") .customizeAst(ast -> { ast.addImport("com.azure.monitor.query.metrics.models.MetricsQueryAudience"); diff --git a/sdk/monitor/azure-monitor-query-metrics/tsp-location.yaml b/sdk/monitor/azure-monitor-query-metrics/tsp-location.yaml index 599458b17035..cfabad8cf21c 100644 --- a/sdk/monitor/azure-monitor-query-metrics/tsp-location.yaml +++ b/sdk/monitor/azure-monitor-query-metrics/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/monitor/Monitor.Query.Metrics -commit: 9ecbfbe10a455fa1ed4f4826cb0bbfb5590e9296 +commit: 87735b5e5af779cff60c30b28e4bea502e9ffe90 repo: Azure/azure-rest-api-specs additionalDirectories: From ddd05b69b9c26a47920e201d499d330e93b67008 Mon Sep 17 00:00:00 2001 From: Jair Myree Date: Wed, 30 Jul 2025 23:43:06 -0700 Subject: [PATCH 8/9] Removing unnecessary changes from pom --- sdk/monitor/pom.xml | 25 ------------------------- 1 file changed, 25 deletions(-) diff --git a/sdk/monitor/pom.xml b/sdk/monitor/pom.xml index 14f73ed2361a..fa1709aee930 100644 --- a/sdk/monitor/pom.xml +++ b/sdk/monitor/pom.xml @@ -7,31 +7,6 @@ com.azure azure-monitor-service pom - - - com.azure - azure-core - 1.56.0-beta.1 - compile - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - - - - - 8 - 8 - - - - 1.0.0 From 3342d81b5d9bc255d43123b28318358b20454f36 Mon Sep 17 00:00:00 2001 From: Jair Myree Date: Thu, 31 Jul 2025 09:05:58 -0700 Subject: [PATCH 9/9] adding samples README.md --- .../src/samples/java/README.md | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 sdk/monitor/azure-monitor-query-metrics/src/samples/java/README.md diff --git a/sdk/monitor/azure-monitor-query-metrics/src/samples/java/README.md b/sdk/monitor/azure-monitor-query-metrics/src/samples/java/README.md new file mode 100644 index 000000000000..2870d015136a --- /dev/null +++ b/sdk/monitor/azure-monitor-query-metrics/src/samples/java/README.md @@ -0,0 +1,49 @@ +--- +page_type: sample +languages: + - java +products: + - azure + - azure-monitor +urlFragment: query-azuremonitor-java-samples +--- + +# Azure Monitor Metrics Query client library samples for Java + +Azure Monitor Metrics Query samples are a set of self-contained Java programs that demonstrate interacting with Azure self +-contained service using the client library. Each sample focuses on a specific scenario and can be executed independently. + +## Key concepts + +Key concepts are explained in detail [here][SDK_README_KEY_CONCEPTS]. + +## Getting started + +Getting started explained in detail [here][SDK_README_GETTING_STARTED]. + +## Examples + +The following section provides a code sample covering common operations with the Azure Monitor Metrics Query client library. + +* [Get metrics][get_metrics] + +## Troubleshooting + +Troubleshooting steps can be found [here][SDK_README_TROUBLESHOOTING]. + +## Next steps + +See [Next steps][SDK_README_NEXT_STEPS]. + +## Contributing + +If you would like to become an active contributor to this project please refer to our [Contribution +Guidelines][SDK_README_CONTRIBUTING] for more information. + + +[SDK_README_CONTRIBUTING]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/monitor/azure-monitor-query-metrics#contributing +[SDK_README_GETTING_STARTED]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/monitor/azure-monitor-query-metrics#getting-started +[SDK_README_TROUBLESHOOTING]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/monitor/azure-monitor-query-metrics#troubleshooting +[SDK_README_KEY_CONCEPTS]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/monitor/azure-monitor-query-metrics#key-concepts +[SDK_README_NEXT_STEPS]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/monitor/azure-monitor-query-metrics#next-steps +[get_metrics]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/monitor/azure-monitor-query-metrics/src/samples/java/com/azure/monitor/query/metrics/MetricsQuerySample.java