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 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/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/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/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..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 @@ -221,18 +221,6 @@ public MonitorQueryMetricsClientBuilder endpoint(String endpoint) { @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; - } - /* * The retry policy that will attempt to retry failed requests, if applicable. */ @@ -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(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 3deb930fea9a..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 @@ -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() { @@ -70,7 +70,7 @@ public String getEndpoint() { /** * Gets Service version. - * + * * @return the serviceVersion value. */ public MetricsServiceVersion getServiceVersion() { @@ -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,7 +107,7 @@ 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'. @@ -120,7 +120,7 @@ public SerializerAdapter getSerializerAdapter() { /** * 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 @@ -133,7 +133,7 @@ public SerializerAdapter getSerializerAdapter() { /** * 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 @@ -228,7 +228,7 @@ Response queryResourcesSync(@HostParam("endpoint") String endpoint, * * You can add these to a request with {@link RequestOptions#addQueryParam} *

Request Body Schema

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

Response Body Schema

- * + * *
      * {@code
      * {
@@ -291,7 +291,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 +361,7 @@ public Mono> queryResourcesWithResponseAsync(String subscri * * You can add these to a request with {@link RequestOptions#addQueryParam} *

Request Body Schema

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

Response Body Schema

- * + * *
      * {@code
      * {
@@ -424,7 +424,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..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 @@ -1,10 +1,9 @@ // 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. + * 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/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..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.Duration; import java.time.OffsetDateTime; import java.util.Objects; @@ -19,75 +18,14 @@ public final class MetricsQueryTimeInterval { /** * Time interval of all time. */ - 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 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 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,40 +35,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; - } - - /** - * 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.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; } /** @@ -142,11 +46,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 +58,6 @@ public OffsetDateTime getEndTime() { if (endTime != null) { return endTime; } - if (startTime != null && duration != null) { - return startTime.plusNanos(duration.toNanos()); - } return null; } @@ -176,33 +72,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 +88,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 +105,12 @@ public boolean equals(Object o) { } MetricsQueryTimeInterval that = (MetricsQueryTimeInterval) o; - return Objects.equals(this.duration, that.duration) - && 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 public int hashCode() { - return Objects.hash(duration, startTime, endTime); + return Objects.hash(startTime, endTime); } private static OffsetDateTime parseTime(String value) { @@ -252,12 +120,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; - } - } } 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; 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/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 diff --git a/sdk/monitor/azure-monitor-query-metrics/tsp-location.yaml b/sdk/monitor/azure-monitor-query-metrics/tsp-location.yaml index d5bd4a28a99d..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: 4d8a05a94caac5554f690560c4463ea19e16e38e +commit: 87735b5e5af779cff60c30b28e4bea502e9ffe90 repo: Azure/azure-rest-api-specs -additionalDirectories: +additionalDirectories: