queryBatchWithResponse(LogsBatchQuery logsBatchQuery, Context context) {
return asyncClient.queryBatchWithResponse(logsBatchQuery, context).block();
}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/LogsQueryClientBuilder.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/LogsQueryClientBuilder.java
index 1aac0843d661d..53458299f1bb4 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/LogsQueryClientBuilder.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/LogsQueryClientBuilder.java
@@ -13,10 +13,18 @@
import com.azure.core.util.ClientOptions;
import com.azure.core.util.Configuration;
import com.azure.core.util.logging.ClientLogger;
-import com.azure.monitor.query.log.implementation.AzureLogAnalyticsImplBuilder;
+import com.azure.monitor.query.implementation.logs.AzureLogAnalyticsImplBuilder;
/**
* Fluent builder for creating instances of {@link LogsQueryClient} and {@link LogsQueryAsyncClient}.
+ *
+ * Instantiating an asynchronous Logs query Client
+ *
+ * {@codesnippet com.azure.monitor.query.LogsQueryAsyncClient.instantiation}
+ *
+ * Instantiating a synchronous Logs query Client
+ *
+ * {@codesnippet com.azure.monitor.query.LogsQueryClient.instantiation}
*/
@ServiceClientBuilder(serviceClients = {LogsQueryClient.class, LogsQueryAsyncClient.class})
public final class LogsQueryClientBuilder {
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/MetricsQueryAsyncClient.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/MetricsQueryAsyncClient.java
index f7ac55c27aca2..a8f984b8f43ed 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/MetricsQueryAsyncClient.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/MetricsQueryAsyncClient.java
@@ -6,34 +6,44 @@
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
import com.azure.core.annotation.ServiceMethod;
+import com.azure.core.experimental.models.TimeInterval;
import com.azure.core.http.rest.PagedFlux;
import com.azure.core.http.rest.Response;
import com.azure.core.http.rest.SimpleResponse;
+import com.azure.core.models.HttpResponseError;
import com.azure.core.util.Context;
import com.azure.core.util.CoreUtils;
-import com.azure.monitor.query.metrics.implementation.MonitorManagementClientImpl;
-import com.azure.monitor.query.metrics.implementation.models.MetricsResponse;
-import com.azure.monitor.query.metrics.implementation.models.ResultType;
-import com.azure.monitor.query.metrics.implementation.models.TimeSeriesElement;
-import com.azure.monitor.query.metricsdefinitions.implementation.MetricsDefinitionsClientImpl;
-import com.azure.monitor.query.metricsnamespaces.implementation.MetricsNamespacesClientImpl;
+import com.azure.monitor.query.implementation.metrics.models.Metric;
+import com.azure.monitor.query.implementation.metrics.MonitorManagementClientImpl;
+import com.azure.monitor.query.implementation.metrics.models.MetadataValue;
+import com.azure.monitor.query.implementation.metrics.models.MetricsHelper;
+import com.azure.monitor.query.implementation.metrics.models.MetricsResponse;
+import com.azure.monitor.query.implementation.metrics.models.ResultType;
+import com.azure.monitor.query.implementation.metricsdefinitions.MetricsDefinitionsClientImpl;
+import com.azure.monitor.query.implementation.metricsdefinitions.models.LocalizableString;
+import com.azure.monitor.query.implementation.metricsnamespaces.MetricsNamespacesClientImpl;
+import com.azure.monitor.query.models.MetricAvailability;
import com.azure.monitor.query.models.MetricDefinition;
+import com.azure.monitor.query.models.MetricResult;
import com.azure.monitor.query.models.MetricNamespace;
-import com.azure.monitor.query.models.Metric;
import com.azure.monitor.query.models.MetricsQueryOptions;
import com.azure.monitor.query.models.MetricsQueryResult;
-import com.azure.monitor.query.models.MetricTimeSeriesElement;
+import com.azure.monitor.query.models.TimeSeriesElement;
import com.azure.monitor.query.models.MetricValue;
import reactor.core.publisher.Mono;
import java.time.OffsetDateTime;
import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
import static com.azure.core.util.FluxUtil.withContext;
/**
* The asynchronous client for querying Azure Monitor metrics.
+ * Instantiating an asynchronous Metrics query Client
+ *
+ * {@codesnippet com.azure.monitor.query.MetricsQueryAsyncClient.instantiation}
*/
@ServiceClient(builder = MetricsQueryClientBuilder.class, isAsync = true)
public final class MetricsQueryAsyncClient {
@@ -51,6 +61,11 @@ public final class MetricsQueryAsyncClient {
/**
* Returns all the Azure Monitor metrics requested for the resource.
+ *
+ * Query metrics for an Azure resource
+ *
+ * {@codesnippet com.azure.monitor.query.MetricsQueryAsyncClient.query#String-List}
+ *
* @param resourceUri The resource URI for which the metrics is requested.
* @param metricsNames The names of the metrics to query.
* @return A time-series metrics result for the requested metric names.
@@ -80,10 +95,12 @@ public Mono> queryWithResponse(String resourceUri,
* @return List of metrics namespaces.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
+ @SuppressWarnings("deprecation")
public PagedFlux listMetricNamespaces(String resourceUri, OffsetDateTime startTime) {
return metricsNamespaceClient
.getMetricNamespaces()
- .listAsync(resourceUri, startTime.toString());
+ .listAsync(resourceUri, startTime.toString())
+ .mapPage(this::mapMetricNamespace);
}
/**
@@ -103,21 +120,64 @@ public PagedFlux listMetricDefinitions(String resourceUri) {
* @return List of metrics definitions.
*/
@ServiceMethod(returns = ReturnType.COLLECTION)
+ @SuppressWarnings("deprecation")
public PagedFlux listMetricDefinitions(String resourceUri, String metricsNamespace) {
return metricsDefinitionsClient
.getMetricDefinitions()
- .listAsync(resourceUri, metricsNamespace);
+ .listAsync(resourceUri, metricsNamespace)
+ .mapPage(this::mapToMetricDefinition);
}
+ private MetricDefinition mapToMetricDefinition(com.azure.monitor.query.implementation.metricsdefinitions.models.MetricDefinition definition) {
+ MetricDefinition metricDefinition = new MetricDefinition();
+ List dimensions = null;
+ if (!CoreUtils.isNullOrEmpty(definition.getDimensions())) {
+ dimensions = definition.getDimensions().stream().map(LocalizableString::getValue)
+ .collect(Collectors.toList());
+ }
+ MetricsHelper.setMetricDefinitionProperties(metricDefinition,
+ definition.isDimensionRequired(), definition.getResourceId(), definition.getNamespace(),
+ definition.getName().getValue(), definition.getDisplayDescription(), definition.getCategory(),
+ definition.getMetricClass(), definition.getUnit(), definition.getPrimaryAggregationType(),
+ definition.getSupportedAggregationTypes(),
+ mapMetricAvailabilities(definition.getMetricAvailabilities()), definition.getId(),
+ dimensions);
+ return metricDefinition;
+ }
+
+ private List mapMetricAvailabilities(List metricAvailabilities) {
+ return metricAvailabilities.stream()
+ .map(availabilityImpl -> {
+ MetricAvailability metricAvailability = new MetricAvailability();
+ MetricsHelper.setMetricAvailabilityProperties(metricAvailability, availabilityImpl.getRetention(),
+ availabilityImpl.getTimeGrain());
+ return metricAvailability;
+ }).collect(Collectors.toList());
+ }
+
+ @SuppressWarnings("deprecation")
PagedFlux listMetricNamespaces(String resourceUri, OffsetDateTime startTime, Context context) {
return metricsNamespaceClient
.getMetricNamespaces()
- .listAsync(resourceUri, startTime.toString(), context);
+ .listAsync(resourceUri, startTime.toString(), context)
+ .mapPage(this::mapMetricNamespace);
}
+ private MetricNamespace mapMetricNamespace(com.azure.monitor.query.implementation.metricsnamespaces.models.MetricNamespace namespaceImpl) {
+ MetricNamespace metricNamespace = new MetricNamespace();
+ MetricsHelper.setMetricNamespaceProperties(metricNamespace, namespaceImpl.getClassification(),
+ namespaceImpl.getId(), namespaceImpl.getName(),
+ namespaceImpl.getProperties() == null ? null : namespaceImpl.getProperties().getMetricNamespaceName(),
+ namespaceImpl.getType());
+
+ return metricNamespace;
+ }
+
+ @SuppressWarnings("deprecation")
PagedFlux listMetricDefinitions(String resourceUri, String metricsNamespace, Context context) {
return metricsDefinitionsClient.getMetricDefinitions()
- .listAsync(resourceUri, metricsNamespace, context);
+ .listAsync(resourceUri, metricsNamespace, context)
+ .mapPage(this::mapToMetricDefinition);
}
Mono> queryWithResponse(String resourceUri, List metricsNames,
@@ -129,10 +189,10 @@ Mono> queryWithResponse(String resourceUri, List String.valueOf(type.ordinal()))
.collect(Collectors.joining(","));
}
- String timespan = options.getTimeSpan() == null ? null : options.getTimeSpan().toIso8601Format();
+ String timespan = options.getTimeInterval() == null ? null : options.getTimeInterval().toIso8601Format();
return metricsClient
.getMetrics()
- .listWithResponseAsync(resourceUri, timespan, options.getInterval(),
+ .listWithResponseAsync(resourceUri, timespan, options.getGranularity(),
String.join(",", metricsNames), aggregation, options.getTop(), options.getOrderBy(),
options.getFilter(), ResultType.DATA, options.getMetricNamespace(), context)
.map(response -> convertToMetricsQueryResult(response));
@@ -141,26 +201,38 @@ Mono> queryWithResponse(String resourceUri, List convertToMetricsQueryResult(Response response) {
MetricsResponse metricsResponse = response.getValue();
MetricsQueryResult metricsQueryResult = new MetricsQueryResult(
- metricsResponse.getCost(), metricsResponse.getTimespan(), metricsResponse.getInterval(),
+ metricsResponse.getCost(),
+ metricsResponse.getTimespan() == null ? null : TimeInterval.parse(metricsResponse.getTimespan()),
+ metricsResponse.getInterval(),
metricsResponse.getNamespace(), metricsResponse.getResourceregion(), mapMetrics(metricsResponse.getValue()));
return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), metricsQueryResult);
}
- private List mapMetrics(List value) {
+ private List mapMetrics(List value) {
return value.stream()
- .map(metric -> new Metric(metric.getId(), metric.getType(), metric.getUnit(), metric.getName().getValue(),
- mapTimeSeries(metric.getTimeseries())))
+ .map(metric -> new MetricResult(metric.getId(), metric.getType(), metric.getUnit(), metric.getName().getValue(),
+ mapTimeSeries(metric.getTimeseries()), metric.getDisplayDescription(),
+ new HttpResponseError(metric.getErrorCode(), metric.getErrorMessage())))
.collect(Collectors.toList());
}
- private List mapTimeSeries(List timeseries) {
+ private List mapTimeSeries(List timeseries) {
return timeseries.stream()
- .map(timeSeriesElement -> new MetricTimeSeriesElement(mapMetricsData(timeSeriesElement.getData())))
+ .map(timeSeriesElement -> new TimeSeriesElement(mapMetricsData(timeSeriesElement.getData()),
+ mapMetricsMetadata(timeSeriesElement.getMetadatavalues())))
.collect(Collectors.toList());
}
- private List mapMetricsData(List data) {
+ private Map mapMetricsMetadata(List metadataValues) {
+ if (metadataValues == null) {
+ return null;
+ }
+ return metadataValues.stream()
+ .collect(Collectors.toMap(value -> value.getName().getValue(), MetadataValue::getValue));
+ }
+
+ private List mapMetricsData(List data) {
return data.stream()
.map(metricValue -> new MetricValue(metricValue.getTimeStamp(),
metricValue.getAverage(), metricValue.getMinimum(), metricValue.getMaximum(), metricValue.getTotal(),
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/MetricsQueryClient.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/MetricsQueryClient.java
index 53de9e27cc8ce..a5150c0d108e7 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/MetricsQueryClient.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/MetricsQueryClient.java
@@ -19,6 +19,10 @@
/**
* The synchronous client for querying Azure Monitor metrics.
+ *
+ * Instantiating a synchronous Metrics query Client
+ *
+ * {@codesnippet com.azure.monitor.query.MetricsQueryClient.instantiation}
*/
@ServiceClient(builder = MetricsQueryClientBuilder.class)
public final class MetricsQueryClient {
@@ -28,9 +32,13 @@ public final class MetricsQueryClient {
this.asyncClient = asyncClient;
}
-
/**
* Returns all the Azure Monitor metrics requested for the resource.
+ *
+ * Query metrics for an Azure resource
+ *
+ * {@codesnippet com.azure.monitor.query.MetricsQueryClient.query#String-List}
+ *
* @param resourceUri The resource URI for which the metrics is requested.
* @param metricsNames The names of the metrics to query.
* @return A time-series metrics result for the requested metric names.
@@ -54,7 +62,6 @@ public Response queryWithResponse(String resourceUri, List listMetricNamespaces(String resourceUri, O
* @param resourceUri The resource URI for which the metrics definitions are listed.
* @return List of metrics definitions.
*/
- @ServiceMethod(returns = ReturnType.SINGLE)
+ @ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listMetricDefinitions(String resourceUri) {
return listMetricDefinitions(resourceUri, null, Context.NONE);
}
@@ -96,7 +103,7 @@ public PagedIterable listMetricDefinitions(String resourceUri)
* @param context Additional context that is passed through the Http pipeline during the service call.
* @return List of metrics definitions.
*/
- @ServiceMethod(returns = ReturnType.SINGLE)
+ @ServiceMethod(returns = ReturnType.COLLECTION)
public PagedIterable listMetricDefinitions(String resourceUri, String metricsNamespace,
Context context) {
return new PagedIterable<>(asyncClient.listMetricDefinitions(resourceUri, metricsNamespace, context));
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/MetricsQueryClientBuilder.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/MetricsQueryClientBuilder.java
index 5167367d600c1..903812e3a572d 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/MetricsQueryClientBuilder.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/MetricsQueryClientBuilder.java
@@ -13,12 +13,20 @@
import com.azure.core.util.ClientOptions;
import com.azure.core.util.Configuration;
import com.azure.core.util.logging.ClientLogger;
-import com.azure.monitor.query.metrics.implementation.MonitorManagementClientImplBuilder;
-import com.azure.monitor.query.metricsdefinitions.implementation.MetricsDefinitionsClientImplBuilder;
-import com.azure.monitor.query.metricsnamespaces.implementation.MetricsNamespacesClientImplBuilder;
+import com.azure.monitor.query.implementation.metrics.MonitorManagementClientImplBuilder;
+import com.azure.monitor.query.implementation.metricsdefinitions.MetricsDefinitionsClientImplBuilder;
+import com.azure.monitor.query.implementation.metricsnamespaces.MetricsNamespacesClientImplBuilder;
/**
* Fluent builder for creating instances of {@link MetricsQueryClient} and {@link MetricsQueryAsyncClient}.
+ *
+ * Instantiating an asynchronous Metrics query Client
+ *
+ * {@codesnippet com.azure.monitor.query.MetricsQueryAsyncClient.instantiation}
+ *
+ * Instantiating a synchronous Metrics query Client
+ *
+ * {@codesnippet com.azure.monitor.query.MetricsQueryClient.instantiation}
*/
@ServiceClientBuilder(serviceClients = {MetricsQueryClient.class, MetricsQueryAsyncClient.class})
public final class MetricsQueryClientBuilder {
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/MetricsQueryServiceVersion.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/MetricsQueryServiceVersion.java
index c06d87579cd39..e3b57a2a2c8bf 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/MetricsQueryServiceVersion.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/MetricsQueryServiceVersion.java
@@ -9,7 +9,7 @@
* The service version of the Metrics service that can be queried to retrieved Azure Monitor metrics.
*/
public enum MetricsQueryServiceVersion implements ServiceVersion {
- V_1("v1");
+ V2018_01_01("2018-01-01");
String version;
@@ -26,7 +26,7 @@ public enum MetricsQueryServiceVersion implements ServiceVersion {
* @return The latest supported service version by this library.
*/
public static MetricsQueryServiceVersion getLatest() {
- return V_1;
+ return V2018_01_01;
}
@Override
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/AzureLogAnalyticsImpl.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/AzureLogAnalyticsImpl.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/AzureLogAnalyticsImpl.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/AzureLogAnalyticsImpl.java
index c47156999d5e2..c0b6283bb99cb 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/AzureLogAnalyticsImpl.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/AzureLogAnalyticsImpl.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation;
+package com.azure.monitor.query.implementation.logs;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpPipelineBuilder;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/AzureLogAnalyticsImplBuilder.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/AzureLogAnalyticsImplBuilder.java
similarity index 99%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/AzureLogAnalyticsImplBuilder.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/AzureLogAnalyticsImplBuilder.java
index 8fc843ab919c5..084d78f71dd4a 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/AzureLogAnalyticsImplBuilder.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/AzureLogAnalyticsImplBuilder.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation;
+package com.azure.monitor.query.implementation.logs;
import com.azure.core.annotation.ServiceClientBuilder;
import com.azure.core.credential.TokenCredential;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/MetadatasImpl.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/MetadatasImpl.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/MetadatasImpl.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/MetadatasImpl.java
index 942b025f14a1a..d509133c949b7 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/MetadatasImpl.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/MetadatasImpl.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation;
+package com.azure.monitor.query.implementation.logs;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
@@ -19,8 +19,8 @@
import com.azure.core.http.rest.RestProxy;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
-import com.azure.monitor.query.log.implementation.models.ErrorResponseException;
-import com.azure.monitor.query.log.implementation.models.MetadataResults;
+import com.azure.monitor.query.implementation.logs.models.ErrorResponseException;
+import com.azure.monitor.query.implementation.logs.models.MetadataResults;
import reactor.core.publisher.Mono;
/** An instance of this class provides access to all the operations defined in Metadatas. */
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/QueriesImpl.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/QueriesImpl.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/QueriesImpl.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/QueriesImpl.java
index 6e5d14ca7167b..5ee3536a0478a 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/QueriesImpl.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/QueriesImpl.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation;
+package com.azure.monitor.query.implementation.logs;
import com.azure.core.annotation.BodyParam;
import com.azure.core.annotation.ExpectedResponses;
@@ -21,11 +21,12 @@
import com.azure.core.http.rest.RestProxy;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
-import com.azure.monitor.query.log.implementation.models.BatchRequest;
-import com.azure.monitor.query.log.implementation.models.BatchResponse;
-import com.azure.monitor.query.log.implementation.models.ErrorResponseException;
-import com.azure.monitor.query.log.implementation.models.QueryBody;
-import com.azure.monitor.query.log.implementation.models.QueryResults;
+import com.azure.monitor.query.implementation.logs.models.QueryBody;
+import com.azure.monitor.query.implementation.logs.models.QueryResults;
+import com.azure.monitor.query.implementation.logs.models.BatchRequest;
+import com.azure.monitor.query.implementation.logs.models.BatchResponse;
+import com.azure.monitor.query.implementation.logs.models.ErrorResponseException;
+
import java.time.Duration;
import reactor.core.publisher.Mono;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchQueryRequest.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchQueryRequest.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchQueryRequest.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchQueryRequest.java
index 5efb84caa3c8b..7b52a9d65d7a8 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchQueryRequest.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchQueryRequest.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchQueryResponse.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchQueryResponse.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchQueryResponse.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchQueryResponse.java
index 0d90a0599f4b5..0a85f5e826d5a 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchQueryResponse.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchQueryResponse.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchQueryResults.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchQueryResults.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchQueryResults.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchQueryResults.java
index 3daf562c3fdce..199b2d758a8fd 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchQueryResults.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchQueryResults.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchRequest.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchRequest.java
similarity index 96%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchRequest.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchRequest.java
index 9c3fa4535b876..b218fe22e8b34 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchRequest.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchRequest.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchResponse.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchResponse.java
similarity index 96%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchResponse.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchResponse.java
index 1fef944fb8aab..5157c9a50ac93 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchResponse.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchResponse.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchResponseError.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchResponseError.java
similarity index 97%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchResponseError.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchResponseError.java
index 24fbbb336d7e2..23f1ee0af0552 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchResponseError.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchResponseError.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchResponseErrorInnerError.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchResponseErrorInnerError.java
similarity index 97%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchResponseErrorInnerError.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchResponseErrorInnerError.java
index 40f3c644f12c5..fbcbe26622479 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchResponseErrorInnerError.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/BatchResponseErrorInnerError.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/Column.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/Column.java
similarity index 96%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/Column.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/Column.java
index dfb3306168ec7..e0d839223a8d4 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/Column.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/Column.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.azure.monitor.query.models.LogsColumnType;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/ErrorDetail.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/ErrorDetail.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/ErrorDetail.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/ErrorDetail.java
index 3b89c1cc3685c..73b8255e7ec53 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/ErrorDetail.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/ErrorDetail.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/ErrorDetails.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/ErrorDetails.java
similarity index 97%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/ErrorDetails.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/ErrorDetails.java
index 8482c05d20362..a4b8566389576 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/ErrorDetails.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/ErrorDetails.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/ErrorInfo.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/ErrorInfo.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/ErrorInfo.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/ErrorInfo.java
index 857114a403361..0d163e1c815c9 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/ErrorInfo.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/ErrorInfo.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/ErrorResponse.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/ErrorResponse.java
similarity index 95%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/ErrorResponse.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/ErrorResponse.java
index dbd7019d9c982..3333cb0d2c837 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/ErrorResponse.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/ErrorResponse.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/ErrorResponseException.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/ErrorResponseException.java
similarity index 95%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/ErrorResponseException.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/ErrorResponseException.java
index 5d4851f0384f6..137150270d531 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/ErrorResponseException.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/ErrorResponseException.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.http.HttpResponse;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/LogsQueryHelper.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/LogsQueryHelper.java
new file mode 100644
index 0000000000000..a8a0623854f57
--- /dev/null
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/LogsQueryHelper.java
@@ -0,0 +1,153 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.monitor.query.implementation.logs.models;
+
+import com.azure.core.util.logging.ClientLogger;
+import com.azure.core.util.serializer.TypeReference;
+import com.azure.monitor.query.LogsQueryAsyncClient;
+import com.azure.monitor.query.models.LogsBatchQuery;
+import com.azure.monitor.query.models.LogsColumnType;
+import com.azure.monitor.query.models.LogsQueryOptions;
+import com.azure.monitor.query.models.LogsTable;
+import com.azure.monitor.query.models.LogsTableRow;
+
+import java.lang.reflect.Field;
+import java.time.Duration;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+/**
+ * Helper to access package-private method of {@link LogsBatchQuery} from {@link LogsQueryAsyncClient}.
+ */
+public final class LogsQueryHelper {
+ private static final ClientLogger LOGGER = new ClientLogger(LogsQueryHelper.class);
+ private static BatchQueryAccessor accessor;
+
+ public static Duration getMaxServerTimeout(LogsBatchQuery query) {
+ return accessor.getMaxServerTimeout(query);
+ }
+
+ /**
+ * Accessor interface
+ */
+ public interface BatchQueryAccessor {
+ List getBatchQueries(LogsBatchQuery query);
+
+ Duration getMaxServerTimeout(LogsBatchQuery query);
+ }
+
+ /**
+ * Sets the accessor instance.
+ * @param batchQueryAccessor the accessor instance
+ */
+ public static void setAccessor(final BatchQueryAccessor batchQueryAccessor) {
+ accessor = batchQueryAccessor;
+ }
+
+ /**
+ * Returns the list of batch queries.
+ * @param query the {@link LogsBatchQuery} to access {@link @BatchQueryRequest} from.
+ * @return the list of batch queries.
+ */
+ public static List getBatchQueries(LogsBatchQuery query) {
+ return accessor.getBatchQueries(query);
+ }
+
+ public static String buildPreferHeaderString(LogsQueryOptions options) {
+ if (options == null) {
+ return null;
+ }
+ StringBuilder sb = new StringBuilder();
+ if (options.isIncludeVisualization()) {
+ sb.append("include-render=true");
+ }
+
+ if (options.isIncludeStatistics()) {
+ if (sb.length() > 0) {
+ sb.append(",");
+ }
+ sb.append("include-statistics=true");
+ }
+
+ if (options.getServerTimeout() != null) {
+ if (sb.length() > 0) {
+ sb.append(",");
+ }
+ sb.append("wait=");
+ sb.append(options.getServerTimeout().getSeconds());
+ }
+
+ return sb.toString().isEmpty() ? null : sb.toString();
+ }
+
+ /**
+ * Returns the table as a list of objects of the given {@code type}. The field names on the type should be
+ * reflectively accessible and the names should match the column names. If the table row contains columns that
+ * are not available on the object, they are ignored and similarly if the fields in the object are not found in
+ * the table columns, they will be null.
+ * @param table The table that contains the query result.
+ * @param type The type of the object to be returned
+ * @param The class type.
+ * @return A list of objects that table is mapped to.
+ * @throws IllegalArgumentException if an instance of the object cannot be created.
+ */
+ public static List toObject(LogsTable table, Class type) {
+ List result = new ArrayList<>();
+ for (LogsTableRow tableRow : table.getRows()) {
+ try {
+ T t = type.newInstance();
+
+ Map declaredFieldMapping = Arrays.stream(type.getDeclaredFields())
+ .collect(Collectors.toMap(field -> field.getName().toLowerCase(Locale.ROOT), field -> field));
+
+ tableRow.getRow().stream()
+ .forEach(tableCell -> {
+ String columnName = tableCell.getColumnName();
+ try {
+ Field field = declaredFieldMapping.get(columnName.toLowerCase(Locale.ROOT));
+ if (field == null) {
+ return;
+ }
+ field.setAccessible(true);
+ if (tableCell.getColumnType() == LogsColumnType.BOOL) {
+ field.set(t, tableCell.getValueAsBoolean());
+ } else if (tableCell.getColumnType() == LogsColumnType.DATETIME) {
+ field.set(t, tableCell.getValueAsDateTime());
+ } else if (tableCell.getColumnType() == LogsColumnType.DYNAMIC) {
+ if (tableCell.getValueAsDynamic() != null) {
+ field.set(t,
+ tableCell.getValueAsDynamic()
+ .toObject(TypeReference.createInstance(field.getType())));
+ }
+ } else if (tableCell.getColumnType() == LogsColumnType.INT) {
+ field.set(t, tableCell.getValueAsInteger());
+ } else if (tableCell.getColumnType() == LogsColumnType.LONG) {
+ field.set(t, tableCell.getValueAsLong());
+ } else if (tableCell.getColumnType() == LogsColumnType.REAL
+ || tableCell.getColumnType() == LogsColumnType.DECIMAL) {
+ field.set(t, tableCell.getValueAsDouble());
+ } else if (tableCell.getColumnType() == LogsColumnType.STRING
+ || tableCell.getColumnType() == LogsColumnType.GUID
+ || tableCell.getColumnType() == LogsColumnType.TIMESPAN) {
+ field.set(t, tableCell.getValueAsString());
+ }
+ field.setAccessible(false);
+ } catch (IllegalAccessException ex) {
+ throw LOGGER.logExceptionAsError(
+ new IllegalArgumentException("Failed to set column value for " + columnName, ex));
+ }
+ });
+ result.add(t);
+ } catch (InstantiationException | IllegalAccessException ex) {
+ throw LOGGER.logExceptionAsError(
+ new IllegalArgumentException("Cannot create an instance of class " + type.getName(), ex));
+ }
+ }
+ return result;
+ }
+}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataApplication.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataApplication.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataApplication.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataApplication.java
index ae9503a2ea77d..3e1624660165f 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataApplication.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataApplication.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataApplicationRelated.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataApplicationRelated.java
similarity index 97%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataApplicationRelated.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataApplicationRelated.java
index b41e1c5852c80..a3373e8d8f06d 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataApplicationRelated.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataApplicationRelated.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataCategory.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataCategory.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataCategory.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataCategory.java
index f1f664a3bcce9..360575db15503 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataCategory.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataCategory.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataCategoryRelated.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataCategoryRelated.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataCategoryRelated.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataCategoryRelated.java
index 5582478469cb8..af14653ae2b1c 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataCategoryRelated.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataCategoryRelated.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataColumnDataType.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataColumnDataType.java
similarity index 97%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataColumnDataType.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataColumnDataType.java
index 4b5c126e587c4..f3d15d6fb077c 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataColumnDataType.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataColumnDataType.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.util.ExpandableStringEnum;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataFunction.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataFunction.java
similarity index 99%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataFunction.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataFunction.java
index 7633321f09edc..289513c2c103a 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataFunction.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataFunction.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataFunctionRelated.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataFunctionRelated.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataFunctionRelated.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataFunctionRelated.java
index 9817cbad7f250..43bd2d4fd0bc0 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataFunctionRelated.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataFunctionRelated.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataPermissions.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataPermissions.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataPermissions.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataPermissions.java
index 75aa721389908..e418e711cdaf7 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataPermissions.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataPermissions.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataPermissionsApplicationsItem.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataPermissionsApplicationsItem.java
similarity index 96%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataPermissionsApplicationsItem.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataPermissionsApplicationsItem.java
index f3dd0ee5aea1d..0944034752de9 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataPermissionsApplicationsItem.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataPermissionsApplicationsItem.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataPermissionsResourcesItem.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataPermissionsResourcesItem.java
similarity index 97%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataPermissionsResourcesItem.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataPermissionsResourcesItem.java
index 81a499a29ddab..8c836cdd9c1ce 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataPermissionsResourcesItem.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataPermissionsResourcesItem.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataPermissionsWorkspacesItem.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataPermissionsWorkspacesItem.java
similarity index 97%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataPermissionsWorkspacesItem.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataPermissionsWorkspacesItem.java
index 48f4bdd3a2814..226752a4b0130 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataPermissionsWorkspacesItem.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataPermissionsWorkspacesItem.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataQuery.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataQuery.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataQuery.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataQuery.java
index 8841ef952c331..04ac29d58a585 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataQuery.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataQuery.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataQueryRelated.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataQueryRelated.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataQueryRelated.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataQueryRelated.java
index 2d23d5b16180b..304734e8853d9 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataQueryRelated.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataQueryRelated.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataResourceType.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataResourceType.java
similarity index 99%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataResourceType.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataResourceType.java
index a3b955218480c..32b65f1407af2 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataResourceType.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataResourceType.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataResourceTypeRelated.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataResourceTypeRelated.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataResourceTypeRelated.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataResourceTypeRelated.java
index 7f84b54d903b0..ca0948bf70254 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataResourceTypeRelated.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataResourceTypeRelated.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataResults.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataResults.java
similarity index 99%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataResults.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataResults.java
index 0db709ca1e278..c620c7984bce4 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataResults.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataResults.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataSolution.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataSolution.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataSolution.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataSolution.java
index a69f2033e347d..237e04bf77b91 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataSolution.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataSolution.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataSolutionRelated.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataSolutionRelated.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataSolutionRelated.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataSolutionRelated.java
index 65cde0a7cc6c3..125e516e8c3f1 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataSolutionRelated.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataSolutionRelated.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataTable.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataTable.java
similarity index 99%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataTable.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataTable.java
index 1397ebdf3d13f..965c75663604c 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataTable.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataTable.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataTableColumnsItem.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataTableColumnsItem.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataTableColumnsItem.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataTableColumnsItem.java
index 05a02a4395858..c63502a963cd5 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataTableColumnsItem.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataTableColumnsItem.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataTableRelated.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataTableRelated.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataTableRelated.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataTableRelated.java
index 1a9d4d548bf89..5049c719aa0bf 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataTableRelated.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataTableRelated.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataWorkspace.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataWorkspace.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataWorkspace.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataWorkspace.java
index 6de9ed102d409..d329a91034dab 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataWorkspace.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataWorkspace.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataWorkspaceRelated.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataWorkspaceRelated.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataWorkspaceRelated.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataWorkspaceRelated.java
index 9bb57583028cf..a6e2383a6f4f8 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/MetadataWorkspaceRelated.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/MetadataWorkspaceRelated.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/QueryBody.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/QueryBody.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/QueryBody.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/QueryBody.java
index 9e3e47fb84ed8..27c674cf0e71d 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/QueryBody.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/QueryBody.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/QueryResults.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/QueryResults.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/QueryResults.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/QueryResults.java
index ecd8560b9d1a5..d857ef693b051 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/QueryResults.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/QueryResults.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/Table.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/Table.java
similarity index 97%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/Table.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/Table.java
index aecb1c1cc23b7..9bf5024e0ae44 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/Table.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/Table.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/package-info.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/package-info.java
similarity index 82%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/package-info.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/package-info.java
index 3191d86415125..a7fcf3b0b83cc 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/package-info.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/models/package-info.java
@@ -5,4 +5,4 @@
/**
* Package containing the data models for AzureLogAnalytics. This API exposes Azure Log Analytics query capabilities.
*/
-package com.azure.monitor.query.log.implementation.models;
+package com.azure.monitor.query.implementation.logs.models;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/package-info.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/package-info.java
similarity index 84%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/package-info.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/package-info.java
index e0b2f0abb616a..d82d75e303b88 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/package-info.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/logs/package-info.java
@@ -6,4 +6,4 @@
* Package containing the implementations for AzureLogAnalytics. This API exposes Azure Log Analytics query
* capabilities.
*/
-package com.azure.monitor.query.log.implementation;
+package com.azure.monitor.query.implementation.logs;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/MetricsImpl.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/MetricsImpl.java
similarity index 99%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/MetricsImpl.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/MetricsImpl.java
index 0f6870be52e5b..bc041ad677983 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/MetricsImpl.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/MetricsImpl.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metrics.implementation;
+package com.azure.monitor.query.implementation.metrics;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
@@ -19,9 +19,9 @@
import com.azure.core.http.rest.RestProxy;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
-import com.azure.monitor.query.metrics.implementation.models.ErrorResponseException;
-import com.azure.monitor.query.metrics.implementation.models.MetricsResponse;
-import com.azure.monitor.query.metrics.implementation.models.ResultType;
+import com.azure.monitor.query.implementation.metrics.models.ErrorResponseException;
+import com.azure.monitor.query.implementation.metrics.models.MetricsResponse;
+import com.azure.monitor.query.implementation.metrics.models.ResultType;
import java.time.Duration;
import reactor.core.publisher.Mono;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorManagementClientImpl.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/MonitorManagementClientImpl.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorManagementClientImpl.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/MonitorManagementClientImpl.java
index 70f4118b6577a..55aba62da72c0 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorManagementClientImpl.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/MonitorManagementClientImpl.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metrics.implementation;
+package com.azure.monitor.query.implementation.metrics;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpPipelineBuilder;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorManagementClientImplBuilder.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/MonitorManagementClientImplBuilder.java
similarity index 99%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorManagementClientImplBuilder.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/MonitorManagementClientImplBuilder.java
index d7e54f31d8255..4acc85e81e693 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/MonitorManagementClientImplBuilder.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/MonitorManagementClientImplBuilder.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metrics.implementation;
+package com.azure.monitor.query.implementation.metrics;
import com.azure.core.annotation.ServiceClientBuilder;
import com.azure.core.credential.TokenCredential;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/ErrorResponse.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/ErrorResponse.java
similarity index 96%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/ErrorResponse.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/ErrorResponse.java
index 04ff3a5a6e5c7..24404be716fa7 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/ErrorResponse.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/ErrorResponse.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metrics.implementation.models;
+package com.azure.monitor.query.implementation.metrics.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/ErrorResponseException.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/ErrorResponseException.java
similarity index 95%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/ErrorResponseException.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/ErrorResponseException.java
index bf45367584985..b0dcfa75a560b 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/ErrorResponseException.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/ErrorResponseException.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metrics.implementation.models;
+package com.azure.monitor.query.implementation.metrics.models;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.http.HttpResponse;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/LocalizableString.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/LocalizableString.java
similarity index 96%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/LocalizableString.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/LocalizableString.java
index b78af0c031785..ebe8d60607ab8 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/LocalizableString.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/LocalizableString.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metrics.implementation.models;
+package com.azure.monitor.query.implementation.metrics.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/MetadataValue.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/MetadataValue.java
similarity index 96%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/MetadataValue.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/MetadataValue.java
index 5b43442eb26cd..caaa5807ff26c 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/MetadataValue.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/MetadataValue.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metrics.implementation.models;
+package com.azure.monitor.query.implementation.metrics.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/Metric.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/Metric.java
similarity index 99%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/Metric.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/Metric.java
index 77e0e23f8b4b1..633f533121714 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/Metric.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/Metric.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metrics.implementation.models;
+package com.azure.monitor.query.implementation.metrics.models;
import com.azure.core.annotation.Fluent;
import com.azure.monitor.query.models.MetricUnit;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/MetricValue.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/MetricValue.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/MetricValue.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/MetricValue.java
index a2bc309ac50af..7b0ea8d3032ca 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/MetricValue.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/MetricValue.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metrics.implementation.models;
+package com.azure.monitor.query.implementation.metrics.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/MetricsHelper.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/MetricsHelper.java
new file mode 100644
index 0000000000000..116c0db0d85d4
--- /dev/null
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/MetricsHelper.java
@@ -0,0 +1,103 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.monitor.query.implementation.metrics.models;
+
+import com.azure.monitor.query.LogsQueryAsyncClient;
+import com.azure.monitor.query.models.AggregationType;
+import com.azure.monitor.query.models.LogsBatchQuery;
+import com.azure.monitor.query.models.MetricAvailability;
+import com.azure.monitor.query.models.MetricClass;
+import com.azure.monitor.query.models.MetricDefinition;
+import com.azure.monitor.query.models.MetricNamespace;
+import com.azure.monitor.query.models.MetricUnit;
+import com.azure.monitor.query.models.NamespaceClassification;
+
+import java.time.Duration;
+import java.util.List;
+
+/**
+ * Helper to access package-private method of {@link LogsBatchQuery} from {@link LogsQueryAsyncClient}.
+ */
+public final class MetricsHelper {
+ private static MetricDefinitionAccessor metricDefinitionAccessor;
+ private static MetricAvailabilityAccessor metricAvailabilityAccessor;
+ private static MetricNamespaceAccessor metricNamespaceAccessor;
+
+ /**
+ * Accessor interface
+ */
+ public interface MetricDefinitionAccessor {
+ void setMetricDefinitionProperties(MetricDefinition metricDefinition, Boolean dimensionRequired,
+ String resourceId, String namespace, String name,
+ String displayDescription, String category,
+ MetricClass metricClass,
+ MetricUnit unit, AggregationType primaryAggregationType,
+ List supportedAggregationTypes,
+ List metricAvailabilities, String id,
+ List dimensions);
+ }
+
+ /**
+ * Accessor interface
+ */
+ public interface MetricAvailabilityAccessor {
+ void setMetricAvailabilityProperties(MetricAvailability metricAvailability, Duration retention,
+ Duration granularity);
+ }
+
+ /**
+ * Accessor interface
+ */
+ public interface MetricNamespaceAccessor {
+ void setMetricNamespaceProperties(MetricNamespace metricNamespace, NamespaceClassification classification, String id, String name,
+ String fullyQualifiedName, String type);
+ }
+
+ /**
+ * Sets the accessor instance.
+ * @param metricDefinitionAccessor the accessor instance
+ */
+ public static void setMetricDefinitionAccessor(final MetricDefinitionAccessor metricDefinitionAccessor) {
+ MetricsHelper.metricDefinitionAccessor = metricDefinitionAccessor;
+ }
+
+ public static void setMetricAvailabilityAccessor(final MetricAvailabilityAccessor metricAvailabilityAccessor) {
+ MetricsHelper.metricAvailabilityAccessor = metricAvailabilityAccessor;
+ }
+
+ public static void setMetricNamespaceAccessor(MetricNamespaceAccessor metricNamespaceAccessor) {
+ MetricsHelper.metricNamespaceAccessor = metricNamespaceAccessor;
+ }
+
+ public static void setMetricDefinitionProperties(MetricDefinition metricDefinition, Boolean dimensionRequired,
+ String resourceId, String namespace, String name,
+ String displayDescription, String category,
+ MetricClass metricClass,
+ MetricUnit unit, AggregationType primaryAggregationType,
+ List supportedAggregationTypes,
+ List metricAvailabilities, String id,
+ List dimensions) {
+ metricDefinitionAccessor.setMetricDefinitionProperties(metricDefinition, dimensionRequired, resourceId, namespace,
+ name, displayDescription, category, metricClass, unit, primaryAggregationType,
+ supportedAggregationTypes, metricAvailabilities, id, dimensions);
+ }
+
+ public static void setMetricAvailabilityProperties(MetricAvailability metricAvailability, Duration retention,
+ Duration granularity) {
+ metricAvailabilityAccessor.setMetricAvailabilityProperties(metricAvailability, retention, granularity);
+
+ }
+
+ public static void setMetricNamespaceProperties(MetricNamespace metricNamespace, NamespaceClassification classification, String id, String name,
+ String fullyQualifiedName, String type) {
+ metricNamespaceAccessor.setMetricNamespaceProperties(metricNamespace, classification, id, name,
+ fullyQualifiedName, type);
+
+ }
+
+ private MetricsHelper() {
+ // private ctor
+ }
+
+}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/MetricsResponse.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/MetricsResponse.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/MetricsResponse.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/MetricsResponse.java
index 9e86279829137..6e5f50b4cd372 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/MetricsResponse.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/MetricsResponse.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metrics.implementation.models;
+package com.azure.monitor.query.implementation.metrics.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonCreator;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/ResultType.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/ResultType.java
similarity index 95%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/ResultType.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/ResultType.java
index 785f2bedaaf84..148509ccd8fe1 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/ResultType.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/ResultType.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metrics.implementation.models;
+package com.azure.monitor.query.implementation.metrics.models;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/TimeSeriesElement.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/TimeSeriesElement.java
similarity index 97%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/TimeSeriesElement.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/TimeSeriesElement.java
index 9ae2af11b7069..e4d64b6a73089 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/TimeSeriesElement.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/TimeSeriesElement.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metrics.implementation.models;
+package com.azure.monitor.query.implementation.metrics.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/package-info.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/package-info.java
similarity index 78%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/package-info.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/package-info.java
index 0a21c70e60701..0a3f9b9802b1f 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/models/package-info.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/models/package-info.java
@@ -3,4 +3,4 @@
// Code generated by Microsoft (R) AutoRest Code Generator.
/** Package containing the data models for MonitorManagementClient. null. */
-package com.azure.monitor.query.metrics.implementation.models;
+package com.azure.monitor.query.implementation.metrics.models;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/package-info.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/package-info.java
similarity index 80%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/package-info.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/package-info.java
index 7e88ded4fcee3..0a81f3d2bb4b7 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metrics/implementation/package-info.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metrics/package-info.java
@@ -3,4 +3,4 @@
// Code generated by Microsoft (R) AutoRest Code Generator.
/** Package containing the implementations for MonitorManagementClient. null. */
-package com.azure.monitor.query.metrics.implementation;
+package com.azure.monitor.query.implementation.metrics;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/MetricDefinitionsImpl.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/MetricDefinitionsImpl.java
similarity index 97%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/MetricDefinitionsImpl.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/MetricDefinitionsImpl.java
index 0bf219e079418..47f4eb1763e07 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/MetricDefinitionsImpl.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/MetricDefinitionsImpl.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metricsdefinitions.implementation;
+package com.azure.monitor.query.implementation.metricsdefinitions;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
@@ -23,9 +23,9 @@
import com.azure.core.http.rest.RestProxy;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
-import com.azure.monitor.query.metricsdefinitions.implementation.models.ErrorResponseException;
-import com.azure.monitor.query.models.MetricDefinition;
-import com.azure.monitor.query.metricsdefinitions.implementation.models.MetricDefinitionCollection;
+import com.azure.monitor.query.implementation.metricsdefinitions.models.ErrorResponseException;
+import com.azure.monitor.query.implementation.metricsdefinitions.models.MetricDefinitionCollection;
+import com.azure.monitor.query.implementation.metricsdefinitions.models.MetricDefinition;
import reactor.core.publisher.Mono;
/** An instance of this class provides access to all the operations defined in MetricDefinitions. */
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/MetricsDefinitionsClientImpl.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/MetricsDefinitionsClientImpl.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/MetricsDefinitionsClientImpl.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/MetricsDefinitionsClientImpl.java
index 6f3e71745b5f6..92d3c48d5b0c1 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/MetricsDefinitionsClientImpl.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/MetricsDefinitionsClientImpl.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metricsdefinitions.implementation;
+package com.azure.monitor.query.implementation.metricsdefinitions;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpPipelineBuilder;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/MetricsDefinitionsClientImplBuilder.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/MetricsDefinitionsClientImplBuilder.java
similarity index 99%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/MetricsDefinitionsClientImplBuilder.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/MetricsDefinitionsClientImplBuilder.java
index 04ca72d2a0292..6743c7c098c05 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/MetricsDefinitionsClientImplBuilder.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/MetricsDefinitionsClientImplBuilder.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metricsdefinitions.implementation;
+package com.azure.monitor.query.implementation.metricsdefinitions;
import com.azure.core.annotation.ServiceClientBuilder;
import com.azure.core.credential.TokenCredential;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/models/ErrorResponse.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/ErrorResponse.java
similarity index 95%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/models/ErrorResponse.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/ErrorResponse.java
index 6b81b7fd09997..a7e1634817276 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/models/ErrorResponse.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/ErrorResponse.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metricsdefinitions.implementation.models;
+package com.azure.monitor.query.implementation.metricsdefinitions.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/models/ErrorResponseException.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/ErrorResponseException.java
similarity index 94%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/models/ErrorResponseException.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/ErrorResponseException.java
index 4bac5b2f0bad4..2c3c2c418792a 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/models/ErrorResponseException.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/ErrorResponseException.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metricsdefinitions.implementation.models;
+package com.azure.monitor.query.implementation.metricsdefinitions.models;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.http.HttpResponse;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LocalizableString.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/LocalizableString.java
similarity index 96%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LocalizableString.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/LocalizableString.java
index 1ee9aa5e7d077..3707196b0f354 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LocalizableString.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/LocalizableString.java
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
-package com.azure.monitor.query.models;
+package com.azure.monitor.query.implementation.metricsdefinitions.models;
import com.azure.core.annotation.Fluent;
import com.azure.core.util.logging.ClientLogger;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/MetricAvailability.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/MetricAvailability.java
new file mode 100644
index 0000000000000..ae458f30a0d01
--- /dev/null
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/MetricAvailability.java
@@ -0,0 +1,80 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.monitor.query.implementation.metricsdefinitions.models;
+
+import com.azure.core.annotation.Fluent;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.time.Duration;
+
+/**
+ * Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that
+ * time grain.
+ */
+@Fluent
+public final class MetricAvailability {
+ /*
+ * the time grain specifies the aggregation interval for the metric.
+ * Expressed as a duration 'PT1M', 'P1D', etc.
+ */
+ @JsonProperty(value = "timeGrain")
+ private Duration timeGrain;
+
+ /*
+ * the retention period for the metric at the specified timegrain.
+ * Expressed as a duration 'PT1M', 'P1D', etc.
+ */
+ @JsonProperty(value = "retention")
+ private Duration retention;
+
+ /**
+ * Get the timeGrain property: the time grain specifies the aggregation interval for the metric. Expressed as a
+ * duration 'PT1M', 'P1D', etc.
+ *
+ * @return the timeGrain value.
+ */
+ public Duration getTimeGrain() {
+ return this.timeGrain;
+ }
+
+ /**
+ * Set the timeGrain property: the time grain specifies the aggregation interval for the metric. Expressed as a
+ * duration 'PT1M', 'P1D', etc.
+ *
+ * @param timeGrain the timeGrain value to set.
+ * @return the MetricAvailability object itself.
+ */
+ public MetricAvailability setTimeGrain(Duration timeGrain) {
+ this.timeGrain = timeGrain;
+ return this;
+ }
+
+ /**
+ * Get the retention property: the retention period for the metric at the specified timegrain. Expressed as a
+ * duration 'PT1M', 'P1D', etc.
+ *
+ * @return the retention value.
+ */
+ public Duration getRetention() {
+ return this.retention;
+ }
+
+ /**
+ * Set the retention property: the retention period for the metric at the specified timegrain. Expressed as a
+ * duration 'PT1M', 'P1D', etc.
+ *
+ * @param retention the retention value to set.
+ * @return the MetricAvailability object itself.
+ */
+ public MetricAvailability setRetention(Duration retention) {
+ this.retention = retention;
+ return this;
+ }
+
+ /**
+ * Validates the instance.
+ *
+ * @throws IllegalArgumentException thrown if the instance is not valid.
+ */
+ public void validate() { }
+}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/MetricDefinition.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/MetricDefinition.java
new file mode 100644
index 0000000000000..20031f24350ea
--- /dev/null
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/MetricDefinition.java
@@ -0,0 +1,376 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.monitor.query.implementation.metricsdefinitions.models;
+
+import com.azure.core.annotation.Fluent;
+import com.azure.monitor.query.models.AggregationType;
+import com.azure.monitor.query.models.MetricClass;
+import com.azure.monitor.query.models.MetricUnit;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import java.util.List;
+
+/** Metric definition class specifies the metadata for a metric. */
+@Fluent
+public final class MetricDefinition {
+ /*
+ * Flag to indicate whether the dimension is required.
+ */
+ @JsonProperty(value = "isDimensionRequired")
+ private Boolean isDimensionRequired;
+
+ /*
+ * the resource identifier of the resource that emitted the metric.
+ */
+ @JsonProperty(value = "resourceId")
+ private String resourceId;
+
+ /*
+ * the namespace the metric belongs to.
+ */
+ @JsonProperty(value = "namespace")
+ private String namespace;
+
+ /*
+ * the name and the display name of the metric, i.e. it is a localizable
+ * string.
+ */
+ @JsonProperty(value = "name")
+ private LocalizableString name;
+
+ /*
+ * Detailed description of this metric.
+ */
+ @JsonProperty(value = "displayDescription")
+ private String displayDescription;
+
+ /*
+ * Custom category name for this metric.
+ */
+ @JsonProperty(value = "category")
+ private String category;
+
+ /*
+ * The class of the metric.
+ */
+ @JsonProperty(value = "metricClass")
+ private MetricClass metricClass;
+
+ /*
+ * The unit of the metric.
+ */
+ @JsonProperty(value = "unit")
+ private MetricUnit unit;
+
+ /*
+ * the primary aggregation type value defining how to use the values for
+ * display.
+ */
+ @JsonProperty(value = "primaryAggregationType")
+ private AggregationType primaryAggregationType;
+
+ /*
+ * the collection of what aggregation types are supported.
+ */
+ @JsonProperty(value = "supportedAggregationTypes")
+ private List supportedAggregationTypes;
+
+ /*
+ * the collection of what aggregation intervals are available to be
+ * queried.
+ */
+ @JsonProperty(value = "metricAvailabilities")
+ private List metricAvailabilities;
+
+ /*
+ * the resource identifier of the metric definition.
+ */
+ @JsonProperty(value = "id")
+ private String id;
+
+ /*
+ * the name and the display name of the dimension, i.e. it is a localizable
+ * string.
+ */
+ @JsonProperty(value = "dimensions")
+ private List dimensions;
+
+ /**
+ * Get the isDimensionRequired property: Flag to indicate whether the dimension is required.
+ *
+ * @return the isDimensionRequired value.
+ */
+ public Boolean isDimensionRequired() {
+ return this.isDimensionRequired;
+ }
+
+ /**
+ * Set the isDimensionRequired property: Flag to indicate whether the dimension is required.
+ *
+ * @param isDimensionRequired the isDimensionRequired value to set.
+ * @return the MetricDefinition object itself.
+ */
+ public MetricDefinition setIsDimensionRequired(Boolean isDimensionRequired) {
+ this.isDimensionRequired = isDimensionRequired;
+ return this;
+ }
+
+ /**
+ * Get the resourceId property: the resource identifier of the resource that emitted the metric.
+ *
+ * @return the resourceId value.
+ */
+ public String getResourceId() {
+ return this.resourceId;
+ }
+
+ /**
+ * Set the resourceId property: the resource identifier of the resource that emitted the metric.
+ *
+ * @param resourceId the resourceId value to set.
+ * @return the MetricDefinition object itself.
+ */
+ public MetricDefinition setResourceId(String resourceId) {
+ this.resourceId = resourceId;
+ return this;
+ }
+
+ /**
+ * Get the namespace property: the namespace the metric belongs to.
+ *
+ * @return the namespace value.
+ */
+ public String getNamespace() {
+ return this.namespace;
+ }
+
+ /**
+ * Set the namespace property: the namespace the metric belongs to.
+ *
+ * @param namespace the namespace value to set.
+ * @return the MetricDefinition object itself.
+ */
+ public MetricDefinition setNamespace(String namespace) {
+ this.namespace = namespace;
+ return this;
+ }
+
+ /**
+ * Get the name property: the name and the display name of the metric, i.e. it is a localizable string.
+ *
+ * @return the name value.
+ */
+ public LocalizableString getName() {
+ return this.name;
+ }
+
+ /**
+ * Set the name property: the name and the display name of the metric, i.e. it is a localizable string.
+ *
+ * @param name the name value to set.
+ * @return the MetricDefinition object itself.
+ */
+ public MetricDefinition setName(LocalizableString name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * Get the displayDescription property: Detailed description of this metric.
+ *
+ * @return the displayDescription value.
+ */
+ public String getDisplayDescription() {
+ return this.displayDescription;
+ }
+
+ /**
+ * Set the displayDescription property: Detailed description of this metric.
+ *
+ * @param displayDescription the displayDescription value to set.
+ * @return the MetricDefinition object itself.
+ */
+ public MetricDefinition setDisplayDescription(String displayDescription) {
+ this.displayDescription = displayDescription;
+ return this;
+ }
+
+ /**
+ * Get the category property: Custom category name for this metric.
+ *
+ * @return the category value.
+ */
+ public String getCategory() {
+ return this.category;
+ }
+
+ /**
+ * Set the category property: Custom category name for this metric.
+ *
+ * @param category the category value to set.
+ * @return the MetricDefinition object itself.
+ */
+ public MetricDefinition setCategory(String category) {
+ this.category = category;
+ return this;
+ }
+
+ /**
+ * Get the metricClass property: The class of the metric.
+ *
+ * @return the metricClass value.
+ */
+ public MetricClass getMetricClass() {
+ return this.metricClass;
+ }
+
+ /**
+ * Set the metricClass property: The class of the metric.
+ *
+ * @param metricClass the metricClass value to set.
+ * @return the MetricDefinition object itself.
+ */
+ public MetricDefinition setMetricClass(MetricClass metricClass) {
+ this.metricClass = metricClass;
+ return this;
+ }
+
+ /**
+ * Get the unit property: The unit of the metric.
+ *
+ * @return the unit value.
+ */
+ public MetricUnit getUnit() {
+ return this.unit;
+ }
+
+ /**
+ * Set the unit property: The unit of the metric.
+ *
+ * @param unit the unit value to set.
+ * @return the MetricDefinition object itself.
+ */
+ public MetricDefinition setUnit(MetricUnit unit) {
+ this.unit = unit;
+ return this;
+ }
+
+ /**
+ * Get the primaryAggregationType property: the primary aggregation type value defining how to use the values for
+ * display.
+ *
+ * @return the primaryAggregationType value.
+ */
+ public AggregationType getPrimaryAggregationType() {
+ return this.primaryAggregationType;
+ }
+
+ /**
+ * Set the primaryAggregationType property: the primary aggregation type value defining how to use the values for
+ * display.
+ *
+ * @param primaryAggregationType the primaryAggregationType value to set.
+ * @return the MetricDefinition object itself.
+ */
+ public MetricDefinition setPrimaryAggregationType(AggregationType primaryAggregationType) {
+ this.primaryAggregationType = primaryAggregationType;
+ return this;
+ }
+
+ /**
+ * Get the supportedAggregationTypes property: the collection of what aggregation types are supported.
+ *
+ * @return the supportedAggregationTypes value.
+ */
+ public List getSupportedAggregationTypes() {
+ return this.supportedAggregationTypes;
+ }
+
+ /**
+ * Set the supportedAggregationTypes property: the collection of what aggregation types are supported.
+ *
+ * @param supportedAggregationTypes the supportedAggregationTypes value to set.
+ * @return the MetricDefinition object itself.
+ */
+ public MetricDefinition setSupportedAggregationTypes(List supportedAggregationTypes) {
+ this.supportedAggregationTypes = supportedAggregationTypes;
+ return this;
+ }
+
+ /**
+ * Get the metricAvailabilities property: the collection of what aggregation intervals are available to be queried.
+ *
+ * @return the metricAvailabilities value.
+ */
+ public List getMetricAvailabilities() {
+ return this.metricAvailabilities;
+ }
+
+ /**
+ * Set the metricAvailabilities property: the collection of what aggregation intervals are available to be queried.
+ *
+ * @param metricAvailabilities the metricAvailabilities value to set.
+ * @return the MetricDefinition object itself.
+ */
+ public MetricDefinition setMetricAvailabilities(List metricAvailabilities) {
+ this.metricAvailabilities = metricAvailabilities;
+ return this;
+ }
+
+ /**
+ * Get the id property: the resource identifier of the metric definition.
+ *
+ * @return the id value.
+ */
+ public String getId() {
+ return this.id;
+ }
+
+ /**
+ * Set the id property: the resource identifier of the metric definition.
+ *
+ * @param id the id value to set.
+ * @return the MetricDefinition object itself.
+ */
+ public MetricDefinition setId(String id) {
+ this.id = id;
+ return this;
+ }
+
+ /**
+ * Get the dimensions property: the name and the display name of the dimension, i.e. it is a localizable string.
+ *
+ * @return the dimensions value.
+ */
+ public List getDimensions() {
+ return this.dimensions;
+ }
+
+ /**
+ * Set the dimensions property: the name and the display name of the dimension, i.e. it is a localizable string.
+ *
+ * @param dimensions the dimensions value to set.
+ * @return the MetricDefinition object itself.
+ */
+ public MetricDefinition setDimensions(List dimensions) {
+ this.dimensions = dimensions;
+ return this;
+ }
+
+ /**
+ * Validates the instance.
+ *
+ * @throws IllegalArgumentException thrown if the instance is not valid.
+ */
+ public void validate() {
+ if (getName() != null) {
+ getName().validate();
+ }
+ if (getMetricAvailabilities() != null) {
+ getMetricAvailabilities().forEach(e -> e.validate());
+ }
+ if (getDimensions() != null) {
+ getDimensions().forEach(e -> e.validate());
+ }
+ }
+}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/models/MetricDefinitionCollection.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/MetricDefinitionCollection.java
similarity index 92%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/models/MetricDefinitionCollection.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/MetricDefinitionCollection.java
index a7bf960396cb9..7d256e5cf3d1d 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/models/MetricDefinitionCollection.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/MetricDefinitionCollection.java
@@ -2,10 +2,9 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metricsdefinitions.implementation.models;
+package com.azure.monitor.query.implementation.metricsdefinitions.models;
import com.azure.core.annotation.Fluent;
-import com.azure.monitor.query.models.MetricDefinition;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/models/package-info.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/package-info.java
similarity index 76%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/models/package-info.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/package-info.java
index 5e80ae7f1344d..7803bf8299200 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/models/package-info.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/models/package-info.java
@@ -3,4 +3,4 @@
// Code generated by Microsoft (R) AutoRest Code Generator.
/** Package containing the data models for MetricsDefinitionsClient. null. */
-package com.azure.monitor.query.metricsdefinitions.implementation.models;
+package com.azure.monitor.query.implementation.metricsdefinitions.models;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/package-info.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/package-info.java
similarity index 78%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/package-info.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/package-info.java
index 7ee942b2847e5..8ad520831fbd7 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsdefinitions/implementation/package-info.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsdefinitions/package-info.java
@@ -3,4 +3,4 @@
// Code generated by Microsoft (R) AutoRest Code Generator.
/** Package containing the implementations for MetricsDefinitionsClient. null. */
-package com.azure.monitor.query.metricsdefinitions.implementation;
+package com.azure.monitor.query.implementation.metricsdefinitions;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/MetricNamespacesImpl.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/MetricNamespacesImpl.java
similarity index 97%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/MetricNamespacesImpl.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/MetricNamespacesImpl.java
index 81ad0dc4839a6..164d4378fef10 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/MetricNamespacesImpl.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/MetricNamespacesImpl.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metricsnamespaces.implementation;
+package com.azure.monitor.query.implementation.metricsnamespaces;
import com.azure.core.annotation.ExpectedResponses;
import com.azure.core.annotation.Get;
@@ -23,9 +23,9 @@
import com.azure.core.http.rest.RestProxy;
import com.azure.core.util.Context;
import com.azure.core.util.FluxUtil;
-import com.azure.monitor.query.metricsnamespaces.implementation.models.ErrorResponseException;
-import com.azure.monitor.query.models.MetricNamespace;
-import com.azure.monitor.query.metricsnamespaces.implementation.models.MetricNamespaceCollection;
+import com.azure.monitor.query.implementation.metricsnamespaces.models.ErrorResponseException;
+import com.azure.monitor.query.implementation.metricsnamespaces.models.MetricNamespaceCollection;
+import com.azure.monitor.query.implementation.metricsnamespaces.models.MetricNamespace;
import reactor.core.publisher.Mono;
/** An instance of this class provides access to all the operations defined in MetricNamespaces. */
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/MetricsNamespacesClientImpl.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/MetricsNamespacesClientImpl.java
similarity index 98%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/MetricsNamespacesClientImpl.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/MetricsNamespacesClientImpl.java
index 6d00f97470c0c..c0837e3582058 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/MetricsNamespacesClientImpl.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/MetricsNamespacesClientImpl.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metricsnamespaces.implementation;
+package com.azure.monitor.query.implementation.metricsnamespaces;
import com.azure.core.http.HttpPipeline;
import com.azure.core.http.HttpPipelineBuilder;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/MetricsNamespacesClientImplBuilder.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/MetricsNamespacesClientImplBuilder.java
similarity index 99%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/MetricsNamespacesClientImplBuilder.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/MetricsNamespacesClientImplBuilder.java
index 8b1ac275487c7..ae7e680aa02c9 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/MetricsNamespacesClientImplBuilder.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/MetricsNamespacesClientImplBuilder.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metricsnamespaces.implementation;
+package com.azure.monitor.query.implementation.metricsnamespaces;
import com.azure.core.annotation.ServiceClientBuilder;
import com.azure.core.credential.TokenCredential;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/models/ErrorResponse.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/models/ErrorResponse.java
similarity index 96%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/models/ErrorResponse.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/models/ErrorResponse.java
index e83ce73af8be5..0f073203fa216 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/models/ErrorResponse.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/models/ErrorResponse.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metricsnamespaces.implementation.models;
+package com.azure.monitor.query.implementation.metricsnamespaces.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/models/ErrorResponseException.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/models/ErrorResponseException.java
similarity index 95%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/models/ErrorResponseException.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/models/ErrorResponseException.java
index 590578126456a..8503371c96b68 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/models/ErrorResponseException.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/models/ErrorResponseException.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metricsnamespaces.implementation.models;
+package com.azure.monitor.query.implementation.metricsnamespaces.models;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.http.HttpResponse;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/models/MetricNamespace.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/models/MetricNamespace.java
new file mode 100644
index 0000000000000..d4fc049178952
--- /dev/null
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/models/MetricNamespace.java
@@ -0,0 +1,153 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.monitor.query.implementation.metricsnamespaces.models;
+
+import com.azure.core.annotation.Fluent;
+import com.azure.monitor.query.models.NamespaceClassification;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
+/** Metric namespace class specifies the metadata for a metric namespace. */
+@Fluent
+public final class MetricNamespace {
+ /*
+ * The ID of the metric namespace.
+ */
+ @JsonProperty(value = "id")
+ private String id;
+
+ /*
+ * The type of the namespace.
+ */
+ @JsonProperty(value = "type")
+ private String type;
+
+ /*
+ * The escaped name of the namespace.
+ */
+ @JsonProperty(value = "name")
+ private String name;
+
+ /*
+ * Kind of namespace
+ */
+ @JsonProperty(value = "classification")
+ private NamespaceClassification classification;
+
+ /*
+ * Properties which include the fully qualified namespace name.
+ */
+ @JsonProperty(value = "properties")
+ private MetricNamespaceName properties;
+
+ /**
+ * Get the id property: The ID of the metric namespace.
+ *
+ * @return the id value.
+ */
+ public String getId() {
+ return this.id;
+ }
+
+ /**
+ * Set the id property: The ID of the metric namespace.
+ *
+ * @param id the id value to set.
+ * @return the MetricNamespace object itself.
+ */
+ public MetricNamespace setId(String id) {
+ this.id = id;
+ return this;
+ }
+
+ /**
+ * Get the type property: The type of the namespace.
+ *
+ * @return the type value.
+ */
+ public String getType() {
+ return this.type;
+ }
+
+ /**
+ * Set the type property: The type of the namespace.
+ *
+ * @param type the type value to set.
+ * @return the MetricNamespace object itself.
+ */
+ public MetricNamespace setType(String type) {
+ this.type = type;
+ return this;
+ }
+
+ /**
+ * Get the name property: The escaped name of the namespace.
+ *
+ * @return the name value.
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Set the name property: The escaped name of the namespace.
+ *
+ * @param name the name value to set.
+ * @return the MetricNamespace object itself.
+ */
+ public MetricNamespace setName(String name) {
+ this.name = name;
+ return this;
+ }
+
+ /**
+ * Get the classification property: Kind of namespace.
+ *
+ * @return the classification value.
+ */
+ public NamespaceClassification getClassification() {
+ return this.classification;
+ }
+
+ /**
+ * Set the classification property: Kind of namespace.
+ *
+ * @param classification the classification value to set.
+ * @return the MetricNamespace object itself.
+ */
+ public MetricNamespace setClassification(NamespaceClassification classification) {
+ this.classification = classification;
+ return this;
+ }
+
+ /**
+ * Get the properties property: Properties which include the fully qualified namespace name.
+ *
+ * @return the properties value.
+ */
+ public MetricNamespaceName getProperties() {
+ return this.properties;
+ }
+
+ /**
+ * Set the properties property: Properties which include the fully qualified namespace name.
+ *
+ * @param properties the properties value to set.
+ * @return the MetricNamespace object itself.
+ */
+ public MetricNamespace setProperties(MetricNamespaceName properties) {
+ this.properties = properties;
+ return this;
+ }
+
+ /**
+ * Validates the instance.
+ *
+ * @throws IllegalArgumentException thrown if the instance is not valid.
+ */
+ public void validate() {
+ if (getProperties() != null) {
+ getProperties().validate();
+ }
+ }
+}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/models/MetricNamespaceCollection.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/models/MetricNamespaceCollection.java
similarity index 92%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/models/MetricNamespaceCollection.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/models/MetricNamespaceCollection.java
index bb56e3f5e6a82..88b89d13d878d 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/models/MetricNamespaceCollection.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/models/MetricNamespaceCollection.java
@@ -2,10 +2,9 @@
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.
-package com.azure.monitor.query.metricsnamespaces.implementation.models;
+package com.azure.monitor.query.implementation.metricsnamespaces.models;
import com.azure.core.annotation.Fluent;
-import com.azure.monitor.query.models.MetricNamespace;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricNamespaceName.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/models/MetricNamespaceName.java
similarity index 94%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricNamespaceName.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/models/MetricNamespaceName.java
index 01d976070d6c4..e678deaa6ecd2 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricNamespaceName.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/models/MetricNamespaceName.java
@@ -1,7 +1,7 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
-package com.azure.monitor.query.models;
+package com.azure.monitor.query.implementation.metricsnamespaces.models;
import com.azure.core.annotation.Fluent;
import com.fasterxml.jackson.annotation.JsonProperty;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/models/package-info.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/models/package-info.java
similarity index 79%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/models/package-info.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/models/package-info.java
index c348ea74d7c53..4c2129e97bf22 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/models/package-info.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/models/package-info.java
@@ -3,4 +3,4 @@
// Code generated by Microsoft (R) AutoRest Code Generator.
/** Package containing the data models for MetricsNamespacesClient. null. */
-package com.azure.monitor.query.metricsnamespaces.implementation.models;
+package com.azure.monitor.query.implementation.metricsnamespaces.models;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/package-info.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/package-info.java
similarity index 78%
rename from sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/package-info.java
rename to sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/package-info.java
index 6fae096b76762..1c58fcafb72c6 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/metricsnamespaces/implementation/package-info.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/implementation/metricsnamespaces/package-info.java
@@ -3,4 +3,4 @@
// Code generated by Microsoft (R) AutoRest Code Generator.
/** Package containing the implementations for MetricsNamespacesClient. null. */
-package com.azure.monitor.query.metricsnamespaces.implementation;
+package com.azure.monitor.query.implementation.metricsnamespaces;
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/LogsQueryHelper.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/LogsQueryHelper.java
deleted file mode 100644
index 5805ea5735eed..0000000000000
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/LogsQueryHelper.java
+++ /dev/null
@@ -1,71 +0,0 @@
-package com.azure.monitor.query.log.implementation.models;
-
-import com.azure.monitor.query.LogsQueryAsyncClient;
-import com.azure.monitor.query.models.LogsBatchQuery;
-import com.azure.monitor.query.models.LogsQueryOptions;
-
-import java.time.Duration;
-import java.util.List;
-
-/**
- * Helper to access package-private method of {@link LogsBatchQuery} from {@link LogsQueryAsyncClient}.
- */
-public final class LogsQueryHelper {
- private static BatchQueryAccessor accessor;
-
- public static Duration getMaxServerTimeout(LogsBatchQuery query) {
- return accessor.getMaxServerTimeout(query);
- }
-
- /**
- * Accessor interface
- */
- public interface BatchQueryAccessor {
- List getBatchQueries(LogsBatchQuery query);
- Duration getMaxServerTimeout(LogsBatchQuery query);
- }
-
- /**
- * Sets the accessor instance.
- * @param batchQueryAccessor the accessor instance
- */
- public static void setAccessor(final BatchQueryAccessor batchQueryAccessor) {
- accessor = batchQueryAccessor;
- }
-
- /**
- * Returns the list of batch queries.
- * @param query the {@link LogsBatchQuery} to access {@link @BatchQueryRequest} from.
- * @return the list of batch queries.
- */
- public static List getBatchQueries(LogsBatchQuery query) {
- return accessor.getBatchQueries(query);
- }
-
- public static String buildPreferHeaderString(LogsQueryOptions options) {
- if (options == null) {
- return null;
- }
- StringBuilder sb = new StringBuilder();
- if (options.isIncludeVisualization()) {
- sb.append("include-render=true");
- }
-
- if (options.isIncludeStatistics()) {
- if (sb.length() > 0) {
- sb.append(",");
- }
- sb.append("include-statistics=true");
- }
-
- if (options.getServerTimeout() != null) {
- if (sb.length() > 0) {
- sb.append(",");
- }
- sb.append("wait=");
- sb.append(options.getServerTimeout().getSeconds());
- }
-
- return sb.toString().isEmpty() ? null : sb.toString();
- }
-}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQuery.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQuery.java
index cc430950b242e..a5ed395108b87 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQuery.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQuery.java
@@ -6,9 +6,9 @@
import com.azure.core.annotation.Fluent;
import com.azure.core.experimental.models.TimeInterval;
import com.azure.core.util.CoreUtils;
-import com.azure.monitor.query.log.implementation.models.LogsQueryHelper;
-import com.azure.monitor.query.log.implementation.models.BatchQueryRequest;
-import com.azure.monitor.query.log.implementation.models.QueryBody;
+import com.azure.monitor.query.implementation.logs.models.LogsQueryHelper;
+import com.azure.monitor.query.implementation.logs.models.BatchQueryRequest;
+import com.azure.monitor.query.implementation.logs.models.QueryBody;
import java.time.Duration;
import java.util.ArrayList;
@@ -17,7 +17,7 @@
import java.util.Map;
import java.util.Objects;
-import static com.azure.monitor.query.log.implementation.models.LogsQueryHelper.buildPreferHeaderString;
+import static com.azure.monitor.query.implementation.logs.models.LogsQueryHelper.buildPreferHeaderString;
/**
* A fluent class to create a batch of logs queries.
@@ -47,9 +47,9 @@ public Duration getMaxServerTimeout(LogsBatchQuery query) {
* @param workspaceId The workspaceId on which the query is executed.
* @param query The Kusto query.
* @param timeInterval The time period for which the logs should be queried.
- * @return The updated {@link LogsBatchQuery}.
+ * @return The index of the query in the batch.
*/
- public LogsBatchQuery addQuery(String workspaceId, String query, TimeInterval timeInterval) {
+ public String addQuery(String workspaceId, String query, TimeInterval timeInterval) {
return addQuery(workspaceId, query, timeInterval, new LogsQueryOptions());
}
@@ -60,9 +60,9 @@ public LogsBatchQuery addQuery(String workspaceId, String query, TimeInterval ti
* @param timeInterval The time period for which the logs should be queried.
* @param logsQueryOptions The log query options to configure server timeout, set additional workspaces or enable
* statistics and rendering information in response.
- * @return The updated {@link LogsBatchQuery}.
+ * @return The index of the query in the batch.
*/
- public LogsBatchQuery addQuery(String workspaceId, String query, TimeInterval timeInterval,
+ public String addQuery(String workspaceId, String query, TimeInterval timeInterval,
LogsQueryOptions logsQueryOptions) {
Objects.requireNonNull(query, "'query' cannot be null.");
Objects.requireNonNull(workspaceId, "'workspaceId' cannot be null.");
@@ -87,7 +87,7 @@ public LogsBatchQuery addQuery(String workspaceId, String query, TimeInterval ti
.setMethod("POST");
queries.add(batchQueryRequest);
- return this;
+ return String.valueOf(index);
}
List getBatchQueries() {
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQueryResult.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQueryResult.java
index a73ed5cb15555..50d481e9d1575 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQueryResult.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQueryResult.java
@@ -4,26 +4,34 @@
package com.azure.monitor.query.models;
import com.azure.core.annotation.Immutable;
+import com.azure.core.models.HttpResponseError;
+import com.azure.core.util.BinaryData;
+import com.azure.core.util.CoreUtils;
+
+import java.util.List;
/**
* Class containing the result of a single logs query in a batch.
*/
@Immutable
-public final class LogsBatchQueryResult {
+public final class LogsBatchQueryResult extends LogsQueryResult {
private final String id;
private final int status;
- private final LogsQueryResult queryResult;
/**
* Creates an instance of {@link LogsBatchQueryResult} containing the result of a single logs query in a batch.
* @param id The query id.
* @param status The response status of the query.
- * @param queryResult The result of the query.
+ * @param logsTables The list of {@link LogsTable} returned as query result.
+ * @param statistics The query execution statistics.
+ * @param visualization The visualization information for the logs query.
+ * @param error The error details if there was an error executing the query.
*/
- public LogsBatchQueryResult(String id, int status, LogsQueryResult queryResult) {
+ public LogsBatchQueryResult(String id, int status, List logsTables, BinaryData statistics,
+ BinaryData visualization, HttpResponseError error) {
+ super(logsTables, statistics, visualization, error);
this.id = id;
this.status = status;
- this.queryResult = queryResult;
}
/**
@@ -43,11 +51,16 @@ public int getStatus() {
}
/**
- * Returns the logs query result.
- * @return The logs query result.
+ * Returns true if the query failed. If the query partially succeeded i.e. there are tables returned in the
+ * response, then this method will return {@code false}.
+ *
+ * @return Returns true if the query failed.
*/
- public LogsQueryResult getQueryResult() {
- return queryResult;
+ public boolean hasFailed() {
+ if (getError() != null && CoreUtils.isNullOrEmpty(getAllTables())) {
+ return true;
+ }
+ return false;
}
}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQueryResultCollection.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQueryResultCollection.java
deleted file mode 100644
index c9cc1e853b0f6..0000000000000
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQueryResultCollection.java
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-package com.azure.monitor.query.models;
-
-import com.azure.core.annotation.Immutable;
-
-import java.util.List;
-
-/**
- * The collection wrapper to hold all results of a batch of logs queries.
- */
-@Immutable
-public final class LogsBatchQueryResultCollection {
- private final List batchResults;
-
- /**
- * Creates an instance of {@link LogsBatchQueryResultCollection} to hold all results of a batch of logs queries.
- * @param batchResults The results of a batch of logs queries.
- */
- public LogsBatchQueryResultCollection(List batchResults) {
- this.batchResults = batchResults;
- }
-
- /**
- * Returns the results of a batch of logs queries.
- * @return The results of a batch of logs queries.
- */
- public List getBatchResults() {
- return batchResults;
- }
-}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQueryResults.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQueryResults.java
new file mode 100644
index 0000000000000..bdbadb8d598d2
--- /dev/null
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsBatchQueryResults.java
@@ -0,0 +1,64 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.monitor.query.models;
+
+import com.azure.core.annotation.Immutable;
+import com.azure.core.util.logging.ClientLogger;
+import com.azure.monitor.query.implementation.logs.models.LogsQueryHelper;
+
+import java.util.List;
+
+/**
+ * The collection wrapper to hold all results of a batch of logs queries.
+ */
+@Immutable
+public final class LogsBatchQueryResults {
+ private final ClientLogger logger = new ClientLogger(LogsBatchQueryResults.class);
+ private final List batchResults;
+
+ /**
+ * Creates an instance of {@link LogsBatchQueryResults} to hold all results of a batch of logs queries.
+ * @param batchResults The results of a batch of logs queries.
+ */
+ public LogsBatchQueryResults(List batchResults) {
+ this.batchResults = batchResults;
+ }
+
+ /**
+ * Returns the results of a batch of logs queries.
+ * @return The results of a batch of logs queries.
+ */
+ public List getBatchResults() {
+ return batchResults;
+ }
+
+ /**
+ * Returns the batch query result of a specific query identified by the queryId.
+ * @param queryId The query id of a query in the batch request.
+ * @param type The model type to which the result will be deserialized to.
+ * @param The type parameter.
+ * @return A list of objects of type T that contain the query result of the given query id.
+ * @throws IllegalArgumentException if the result does not contain the query id.
+ */
+ public List getResult(String queryId, Class type) {
+ return batchResults.stream()
+ .filter(result -> result.getId().equals(queryId))
+ .map(queryResult -> LogsQueryHelper.toObject(queryResult.getTable(), type))
+ .findFirst()
+ .orElseThrow(() -> logger.logExceptionAsError(new IllegalArgumentException(queryId + " not found in the batch result")));
+ }
+
+ /**
+ * Returns the batch query result of a specific query identified by the queryId.
+ * @param queryId The query id of a query in the batch request.
+ * @return the result of the given query id.
+ * @throws IllegalArgumentException if the result does not contain the query id.
+ */
+ public LogsBatchQueryResult getResult(String queryId) {
+ return batchResults.stream()
+ .filter(result -> result.getId().equals(queryId))
+ .findFirst()
+ .orElseThrow(() -> logger.logExceptionAsError(new IllegalArgumentException(queryId + " not found in the batch result")));
+ }
+}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryError.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryError.java
deleted file mode 100644
index 7b144d6f69df1..0000000000000
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryError.java
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-package com.azure.monitor.query.models;
-
-import com.azure.core.annotation.Immutable;
-
-import java.util.List;
-
-/**
- * The error details of a failed log query.
- */
-@Immutable
-public final class LogsQueryError {
- private final String message;
- private final String code;
- private final List errors;
-
- /**
- * Creates an instance of {@link LogsQueryError} with the failure code and target.
- * @param message The error message.
- * @param code The error code indicating the reason for the error.
- * @param errors The list of additional error details.
- */
- public LogsQueryError(String message, String code, List errors) {
- this.message = message;
- this.code = code;
- this.errors = errors;
- }
-
- /**
- * Returns the error message.
- * @return The error message.
- */
- public String getMessage() {
- return message;
- }
-
- /**
- * Returns the error code indicating the reason for the error
- * @return The error code indicating the reason for the error
- */
- public String getCode() {
- return code;
- }
-
- /**
- * Returns the list of additional error details.
- * @return the list of additional error details.
- */
- public List getErrors() {
- return errors;
- }
-}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryErrorDetail.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryErrorDetail.java
deleted file mode 100644
index dcde69e3efb08..0000000000000
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryErrorDetail.java
+++ /dev/null
@@ -1,116 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-package com.azure.monitor.query.models;
-
-import com.azure.core.annotation.Immutable;
-
-import java.util.List;
-
-/**
- * Error details of a failed log query.
- */
-@Immutable
-public final class LogsQueryErrorDetail {
- /*
- * The error's code.
- */
- private final String code;
-
- /*
- * A human readable error message.
- */
- private final String message;
-
- /*
- * Indicates which property in the request is responsible for the error.
- */
- private final String target;
-
- /*
- * Indicates which value in 'target' is responsible for the error.
- */
- private final String value;
-
- /*
- * Indicates resources which were responsible for the error.
- */
- private final List resources;
-
- /*
- * Additional properties that can be provided on the error details object
- */
- private final Object additionalProperties;
-
- /**
- * Creates an instance of ErrorDetail class.
- * @param code the code value to set.
- * @param message the message value to set.
- * @param target indicates which property in the request is responsible for the error.
- * @param value indicates which value in 'target' is responsible for the error.
- * @param resources indicates resources which were responsible for the error.
- * @param additionalProperties additional properties that can be provided on the error details object
- */
- public LogsQueryErrorDetail(
- String code,
- String message,
- String target,
- String value,
- List resources,
- Object additionalProperties) {
- this.code = code;
- this.message = message;
- this.target = target;
- this.value = value;
- this.resources = resources;
- this.additionalProperties = additionalProperties;
- }
-
- /**
- * Get the code property: The error's code.
- * @return the code value.
- */
- public String getCode() {
- return this.code;
- }
-
- /**
- * Get the message property: A human readable error message.
- * @return the message value.
- */
- public String getMessage() {
- return this.message;
- }
-
- /**
- * Get the target property: Indicates which property in the request is responsible for the error.
- * @return the target value.
- */
- public String getTarget() {
- return this.target;
- }
-
- /**
- * Get the value property: Indicates which value in 'target' is responsible for the error.
- * @return the value value.
- */
- public String getValue() {
- return this.value;
- }
-
- /**
- * Get the resources property: Indicates resources which were responsible for the error.
- * @return the resources value.
- */
- public List getResources() {
- return this.resources;
- }
-
- /**
- * Get the additionalProperties property: Additional properties that can be provided on the error details object.
- * @return the additionalProperties value.
- */
- public Object getAdditionalProperties() {
- return this.additionalProperties;
- }
-}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryException.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryException.java
deleted file mode 100644
index 9836f6d059ff0..0000000000000
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryException.java
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-package com.azure.monitor.query.models;
-
-import com.azure.core.exception.HttpResponseException;
-import com.azure.core.http.HttpResponse;
-
-/**
- * Exception thrown when a query to retrieve logs fails.
- */
-public final class LogsQueryException extends HttpResponseException {
- private final transient LogsQueryError error;
-
- /**
- * Creates a new instance of this exception with the {@link HttpResponse} and {@link LogsQueryErrorDetail error}
- * information.
- * @param response The {@link HttpResponse}.
- * @param error The {@link LogsQueryError error} details.
- */
- public LogsQueryException(HttpResponse response, LogsQueryError error) {
- super("Failed to execute logs query", response, error);
- this.error = error;
- }
-
- @Override
- public LogsQueryError getValue() {
- return this.error;
- }
-}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryOptions.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryOptions.java
index 6b7ae5c4a094b..effab6ecc59a4 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryOptions.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryOptions.java
@@ -6,6 +6,7 @@
import com.azure.core.annotation.Fluent;
import java.time.Duration;
+import java.util.Arrays;
import java.util.List;
/**
@@ -107,4 +108,23 @@ public LogsQueryOptions setAdditionalWorkspaces(List additionalWorkspace
this.additionalWorkspaces = additionalWorkspaces;
return this;
}
+
+ /**
+ * Sets the list of additional workspaces on which this query is executed. The list can contain any of the
+ * following workspace identifiers:
+ *
+ * - Workspace Name - human-readable string {@code } of the OMS workspace
+ * - Qualified Name - string with format {@code //}
+ * - Workspace ID - GUID string
+ * - Azure Resource ID - string with format
+ * {@code /subscriptions//resourceGroups//providers/microsoft
+ * .operationalinsights/workspaces/}
+ *
+ * @param additionalWorkspaces additional workspaces on which this query is executed.
+ * @return The updated options instance.
+ */
+ public LogsQueryOptions setAdditionalWorkspaces(String... additionalWorkspaces) {
+ this.additionalWorkspaces = Arrays.asList(additionalWorkspaces);
+ return this;
+ }
}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryResult.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryResult.java
index e06b0107c2527..a62971a2f103a 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryResult.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryResult.java
@@ -4,6 +4,8 @@
package com.azure.monitor.query.models;
import com.azure.core.annotation.Immutable;
+import com.azure.core.models.HttpResponseError;
+import com.azure.core.util.BinaryData;
import com.azure.core.util.logging.ClientLogger;
import java.util.List;
@@ -13,22 +15,22 @@
* The result of a logs query.
*/
@Immutable
-public final class LogsQueryResult {
+public class LogsQueryResult {
private final List logsTables;
- private final LogsQueryStatistics statistics;
- private final LogsQueryError error;
- private final LogsQueryVisualization visualization;
+ private final BinaryData statistics;
+ private final HttpResponseError error;
+ private final BinaryData visualization;
private final ClientLogger logger = new ClientLogger(LogsQueryResult.class);
/**
* Creates an instance {@link LogsQueryResult} with a list of {@link LogsTable}.
* @param logsTables The list of {@link LogsTable} returned as query result.
* @param statistics The query execution statistics.
- * @param error The error details if there was an error executing the query.
* @param visualization The visualization information for the logs query.
+ * @param error The error details if there was an error executing the query.
*/
- public LogsQueryResult(List logsTables, LogsQueryStatistics statistics,
- LogsQueryVisualization visualization, LogsQueryError error) {
+ public LogsQueryResult(List logsTables, BinaryData statistics,
+ BinaryData visualization, HttpResponseError error) {
this.logsTables = logsTables;
this.statistics = statistics;
this.error = error;
@@ -39,10 +41,27 @@ public LogsQueryResult(List logsTables, LogsQueryStatistics statistic
* The list of {@link LogsTable} returned as query result.
* @return The list of {@link LogsTable} returned as query result.
*/
- public List getLogsTables() {
+ public List getAllTables() {
return logsTables;
}
+ /**
+ * The primary {@link LogsTable} returned as query result.
+ * @return The primary {@link LogsTable} returned as query result.
+ * @throws IllegalStateException If this method is called when the query result contains more than one table.
+ */
+ public LogsTable getTable() {
+ if (logsTables == null) {
+ return null;
+ }
+
+ if (logsTables.size() > 1) {
+ throw logger.logExceptionAsError(new IllegalStateException("The query result contains more than one table."
+ + " Use getAllTables() method instead."));
+ }
+ return logsTables.get(0);
+ }
+
/**
* Returns the result of the logs query as a list of objects of type {@code T} where each row of the table is
* mapped to this object type. This conversion of query result into an object model is supported only if the query
@@ -52,7 +71,7 @@ public List getLogsTables() {
* @return A list of objects corresponding to the list of rows in the response table.
* @throws IllegalStateException if the query response contains more than one table.
*/
- public List toObject(Class type) {
+ List toObject(Class type) {
if (this.logsTables.size() != 1) {
throw logger.logExceptionAsError(
new IllegalStateException("Cannot map result to object if the response contains multiple tables."));
@@ -69,7 +88,7 @@ public List toObject(Class type) {
* Returns the query statistics.
* @return the query statistics.
*/
- public LogsQueryStatistics getStatistics() {
+ public BinaryData getStatistics() {
return statistics;
}
@@ -77,7 +96,7 @@ public LogsQueryStatistics getStatistics() {
* Returns the error details if there was an error executing the query.
* @return the error details if there was an error executing the query.
*/
- public LogsQueryError getError() {
+ public HttpResponseError getError() {
return error;
}
@@ -85,7 +104,7 @@ public LogsQueryError getError() {
* Returns the visualization information for the logs query.
* @return the visualization information for the logs query.
*/
- public LogsQueryVisualization getVisualization() {
+ public BinaryData getVisualization() {
return visualization;
}
}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryStatistics.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryStatistics.java
deleted file mode 100644
index f817ef38c1274..0000000000000
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryStatistics.java
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-package com.azure.monitor.query.models;
-
-import com.azure.core.annotation.Immutable;
-
-/**
- * The statistics information related to query execution.
- */
-@Immutable
-public final class LogsQueryStatistics {
- private final Object rawStatistics;
-
- /**
- * Creates an instance with the statistics information related to query execution.
- * @param rawStatistics the statistics information related to query execution.
- */
- public LogsQueryStatistics(Object rawStatistics) {
- this.rawStatistics = rawStatistics;
- }
-
- /**
- * Returns the raw statistics information related to query execution as JSON object.
- * @return the raw statistics information related to query execution as JSON object.
- */
- public Object getRawStatistics() {
- return rawStatistics;
- }
-}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryVisualization.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryVisualization.java
deleted file mode 100644
index 90d29b60110a6..0000000000000
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryVisualization.java
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-package com.azure.monitor.query.models;
-
-/**
- * The visualization information related to query execution.
- */
-public class LogsQueryVisualization {
- private final Object rawVisualization;
-
- /**
- * Creates an instance with the visualization information related to query execution.
- * @param rawVisualization the visualization information related to query execution.
- */
- public LogsQueryVisualization(Object rawVisualization) {
- this.rawVisualization = rawVisualization;
- }
-
- /**
- * Returns the raw statistics information related to query execution as JSON object.
- * @return the raw statistics information related to query execution as JSON object.
- */
- public Object getRawVisualization() {
- return rawVisualization;
- }
-}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsTable.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsTable.java
index e26ef30ca113d..8fa78995242f2 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsTable.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsTable.java
@@ -61,7 +61,7 @@ public List getColumns() {
* @param The type into which each row of the table is converted to.
* @return A list of objects corresponding to the list of rows in the table.
*/
- public List toObject(Class type) {
+ List toObject(Class type) {
return tableRows
.stream()
.map(row -> row.toObject(type))
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsTableRow.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsTableRow.java
index c4e9f03374502..b034f0bf2dadc 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsTableRow.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsTableRow.java
@@ -72,7 +72,7 @@ public Optional getColumnValue(String columnName) {
* @return The object that this table row is mapped to.
* @throws IllegalArgumentException if an instance of the object cannot be created.
*/
- public T toObject(Class type) {
+ T toObject(Class type) {
try {
T t = type.newInstance();
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/Metric.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/Metric.java
deleted file mode 100644
index b024a5add767b..0000000000000
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/Metric.java
+++ /dev/null
@@ -1,77 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-package com.azure.monitor.query.models;
-
-import com.azure.core.annotation.Immutable;
-
-import java.util.List;
-
-/**
- * The metrics result of a query.
- */
-@Immutable
-public final class Metric {
- private final String id;
- private final String type;
- private final MetricUnit unit;
- private final String metricsName;
- private final List timeSeries;
-
- /**
- * Creates an instance of the result data of a query.
- * @param id The metrics id.
- * @param type The resource type of the metrics resource.
- * @param unit The metrics unit.
- * @param metricsName The name of the metrics.
- * @param timeseries The time series returned when the query is performed.
- */
- public Metric(String id, String type, MetricUnit unit,
- String metricsName, List timeseries) {
- this.id = id;
- this.type = type;
- this.unit = unit;
- this.metricsName = metricsName;
- this.timeSeries = timeseries;
- }
-
- /**
- * Returns the name of the metrics.
- * @return the name of the metrics.
- */
- public String getMetricsName() {
- return metricsName;
- }
-
- /**
- * Returns the metrics id.
- * @return the metrics id.
- */
- public String getId() {
- return id;
- }
-
- /**
- * Returns the resource type of the metric resource.
- * @return the resource type of the metric resource.
- */
- public String getType() {
- return type;
- }
-
- /**
- * Returns the metrics unit of the metrics.
- * @return the unit of the metrics.
- */
- public MetricUnit getUnit() {
- return unit;
- }
-
- /**
- * Returns the time series returned when a data query is performed.
- * @return the time series returned when a data query is performed.
- */
- public List getTimeSeries() {
- return timeSeries;
- }
-}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricAvailability.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricAvailability.java
index 955a736229171..8d875fd773786 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricAvailability.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricAvailability.java
@@ -3,78 +3,40 @@
package com.azure.monitor.query.models;
-import com.azure.core.annotation.Fluent;
-import com.fasterxml.jackson.annotation.JsonProperty;
+import com.azure.monitor.query.implementation.metrics.models.MetricsHelper;
+
import java.time.Duration;
/**
- * Metric availability specifies the time grain (aggregation interval or frequency) and the retention period for that
- * time grain.
+ * Metric availability specifies the granularity and the retention period for that
+ * granularity.
*/
-@Fluent
public final class MetricAvailability {
- /*
- * the time grain specifies the aggregation interval for the metric.
- * Expressed as a duration 'PT1M', 'P1D', etc.
- */
- @JsonProperty(value = "timeGrain")
- private Duration timeGrain;
-
- /*
- * the retention period for the metric at the specified timegrain.
- * Expressed as a duration 'PT1M', 'P1D', etc.
- */
- @JsonProperty(value = "retention")
private Duration retention;
+ private Duration granularity;
- /**
- * Get the timeGrain property: the time grain specifies the aggregation interval for the metric. Expressed as a
- * duration 'PT1M', 'P1D', etc.
- *
- * @return the timeGrain value.
- */
- public Duration getTimeGrain() {
- return this.timeGrain;
+ static {
+ MetricsHelper.setMetricAvailabilityAccessor(MetricAvailability::setMetricAvailabilityProperties);
}
- /**
- * Set the timeGrain property: the time grain specifies the aggregation interval for the metric. Expressed as a
- * duration 'PT1M', 'P1D', etc.
- *
- * @param timeGrain the timeGrain value to set.
- * @return the MetricAvailability object itself.
- */
- public MetricAvailability setTimeGrain(Duration timeGrain) {
- this.timeGrain = timeGrain;
- return this;
+ private void setMetricAvailabilityProperties(Duration retention, Duration granularity) {
+ this.retention = retention;
+ this.granularity = granularity;
}
/**
- * Get the retention property: the retention period for the metric at the specified timegrain. Expressed as a
- * duration 'PT1M', 'P1D', etc.
- *
- * @return the retention value.
+ * Returns the retention period for the metric at the specified granularity.
+ * @return the retention period for the metric at the specified granularity.
*/
public Duration getRetention() {
- return this.retention;
+ return retention;
}
/**
- * Set the retention property: the retention period for the metric at the specified timegrain. Expressed as a
- * duration 'PT1M', 'P1D', etc.
- *
- * @param retention the retention value to set.
- * @return the MetricAvailability object itself.
+ * Returns the granularity specifies the aggregation interval for the metric.
+ * @return the granularity specifies the aggregation interval for the metric.
*/
- public MetricAvailability setRetention(Duration retention) {
- this.retention = retention;
- return this;
+ public Duration getGranularity() {
+ return granularity;
}
-
- /**
- * Validates the instance.
- *
- * @throws IllegalArgumentException thrown if the instance is not valid.
- */
- public void validate() { }
}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricDefinition.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricDefinition.java
index c06b3b1f9287c..afa2531e88d5c 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricDefinition.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricDefinition.java
@@ -3,371 +3,163 @@
package com.azure.monitor.query.models;
-import com.azure.core.annotation.Fluent;
-import com.fasterxml.jackson.annotation.JsonProperty;
+import com.azure.monitor.query.implementation.metrics.models.MetricsHelper;
+
import java.util.List;
-/** Metric definition class specifies the metadata for a metric. */
-@Fluent
+/**
+ * Metric definition class specifies the metadata for a metric.
+ */
public final class MetricDefinition {
- /*
- * Flag to indicate whether the dimension is required.
- */
- @JsonProperty(value = "isDimensionRequired")
- private Boolean isDimensionRequired;
- /*
- * the resource identifier of the resource that emitted the metric.
- */
- @JsonProperty(value = "resourceId")
+ private Boolean isDimensionRequired;
private String resourceId;
-
- /*
- * the namespace the metric belongs to.
- */
- @JsonProperty(value = "namespace")
private String namespace;
-
- /*
- * the name and the display name of the metric, i.e. it is a localizable
- * string.
- */
- @JsonProperty(value = "name")
- private LocalizableString name;
-
- /*
- * Detailed description of this metric.
- */
- @JsonProperty(value = "displayDescription")
- private String displayDescription;
-
- /*
- * Custom category name for this metric.
- */
- @JsonProperty(value = "category")
+ private String name;
+ private String description;
private String category;
-
- /*
- * The class of the metric.
- */
- @JsonProperty(value = "metricClass")
private MetricClass metricClass;
-
- /*
- * The unit of the metric.
- */
- @JsonProperty(value = "unit")
private MetricUnit unit;
-
- /*
- * the primary aggregation type value defining how to use the values for
- * display.
- */
- @JsonProperty(value = "primaryAggregationType")
private AggregationType primaryAggregationType;
-
- /*
- * the collection of what aggregation types are supported.
- */
- @JsonProperty(value = "supportedAggregationTypes")
private List supportedAggregationTypes;
-
- /*
- * the collection of what aggregation intervals are available to be
- * queried.
- */
- @JsonProperty(value = "metricAvailabilities")
private List metricAvailabilities;
-
- /*
- * the resource identifier of the metric definition.
- */
- @JsonProperty(value = "id")
private String id;
-
- /*
- * the name and the display name of the dimension, i.e. it is a localizable
- * string.
- */
- @JsonProperty(value = "dimensions")
- private List dimensions;
-
- /**
- * Get the isDimensionRequired property: Flag to indicate whether the dimension is required.
- *
- * @return the isDimensionRequired value.
- */
- public Boolean isDimensionRequired() {
- return this.isDimensionRequired;
+ private List dimensions;
+
+ static {
+ MetricsHelper.setMetricDefinitionAccessor(MetricDefinition::setMetricDefinitionProperties);
+ }
+
+ private void setMetricDefinitionProperties(Boolean dimensionRequired,
+ String resourceId,
+ String namespace,
+ String name,
+ String displayDescription,
+ String category,
+ MetricClass metricClass,
+ MetricUnit unit,
+ AggregationType primaryAggregationType,
+ List supportedAggregationTypes,
+ List metricAvailabilities,
+ String id,
+ List dimensions) {
+
+ this.isDimensionRequired = dimensionRequired;
+ this.resourceId = resourceId;
+ this.namespace = namespace;
+ this.name = name;
+ this.description = displayDescription;
+ this.category = category;
+ this.metricClass = metricClass;
+ this.unit = unit;
+ this.primaryAggregationType = primaryAggregationType;
+ this.supportedAggregationTypes = supportedAggregationTypes;
+ this.metricAvailabilities = metricAvailabilities;
+ this.id = id;
+ this.dimensions = dimensions;
}
/**
- * Set the isDimensionRequired property: Flag to indicate whether the dimension is required.
- *
- * @param isDimensionRequired the isDimensionRequired value to set.
- * @return the MetricDefinition object itself.
+ * Returns a flag to indicate whether the dimension is required.
+ * @return Flag to indicate whether the dimension is required.
*/
- public MetricDefinition setIsDimensionRequired(Boolean isDimensionRequired) {
- this.isDimensionRequired = isDimensionRequired;
- return this;
+ public Boolean isDimensionRequired() {
+ return isDimensionRequired;
}
/**
- * Get the resourceId property: the resource identifier of the resource that emitted the metric.
- *
- * @return the resourceId value.
+ * Returns the resource identifier of the resource that emitted the metric.
+ * @return the resource identifier of the resource that emitted the metric.
*/
public String getResourceId() {
- return this.resourceId;
+ return resourceId;
}
/**
- * Set the resourceId property: the resource identifier of the resource that emitted the metric.
- *
- * @param resourceId the resourceId value to set.
- * @return the MetricDefinition object itself.
- */
- public MetricDefinition setResourceId(String resourceId) {
- this.resourceId = resourceId;
- return this;
- }
-
- /**
- * Get the namespace property: the namespace the metric belongs to.
- *
- * @return the namespace value.
+ * Returns the namespace the metric belongs to.
+ * @return the namespace the metric belongs to.
*/
public String getNamespace() {
- return this.namespace;
- }
-
- /**
- * Set the namespace property: the namespace the metric belongs to.
- *
- * @param namespace the namespace value to set.
- * @return the MetricDefinition object itself.
- */
- public MetricDefinition setNamespace(String namespace) {
- this.namespace = namespace;
- return this;
+ return namespace;
}
/**
- * Get the name property: the name and the display name of the metric, i.e. it is a localizable string.
- *
- * @return the name value.
+ * Returns the name of the metric,
+ * @return the name of the metric,
*/
- public LocalizableString getName() {
- return this.name;
+ public String getName() {
+ return name;
}
/**
- * Set the name property: the name and the display name of the metric, i.e. it is a localizable string.
- *
- * @param name the name value to set.
- * @return the MetricDefinition object itself.
+ * Returns the detailed description of this metric.
+ * @return detailed description of this metric.
*/
- public MetricDefinition setName(LocalizableString name) {
- this.name = name;
- return this;
- }
-
- /**
- * Get the displayDescription property: Detailed description of this metric.
- *
- * @return the displayDescription value.
- */
- public String getDisplayDescription() {
- return this.displayDescription;
- }
-
- /**
- * Set the displayDescription property: Detailed description of this metric.
- *
- * @param displayDescription the displayDescription value to set.
- * @return the MetricDefinition object itself.
- */
- public MetricDefinition setDisplayDescription(String displayDescription) {
- this.displayDescription = displayDescription;
- return this;
+ public String getDescription() {
+ return description;
}
/**
- * Get the category property: Custom category name for this metric.
- *
- * @return the category value.
+ * Returns the custom category name for this metric.
+ * @return custom category name for this metric.
*/
public String getCategory() {
- return this.category;
- }
-
- /**
- * Set the category property: Custom category name for this metric.
- *
- * @param category the category value to set.
- * @return the MetricDefinition object itself.
- */
- public MetricDefinition setCategory(String category) {
- this.category = category;
- return this;
+ return category;
}
/**
- * Get the metricClass property: The class of the metric.
- *
- * @return the metricClass value.
+ * Returns the class of the metric.
+ * @return the class of the metric.
*/
public MetricClass getMetricClass() {
- return this.metricClass;
+ return metricClass;
}
/**
- * Set the metricClass property: The class of the metric.
- *
- * @param metricClass the metricClass value to set.
- * @return the MetricDefinition object itself.
- */
- public MetricDefinition setMetricClass(MetricClass metricClass) {
- this.metricClass = metricClass;
- return this;
- }
-
- /**
- * Get the unit property: The unit of the metric.
- *
- * @return the unit value.
+ * Returns the unit of the metric.
+ * @return the unit of the metric.
*/
public MetricUnit getUnit() {
- return this.unit;
+ return unit;
}
/**
- * Set the unit property: The unit of the metric.
- *
- * @param unit the unit value to set.
- * @return the MetricDefinition object itself.
- */
- public MetricDefinition setUnit(MetricUnit unit) {
- this.unit = unit;
- return this;
- }
-
- /**
- * Get the primaryAggregationType property: the primary aggregation type value defining how to use the values for
- * display.
- *
- * @return the primaryAggregationType value.
+ * Returns the primary aggregation type value defining how to use the values for display.
+ * @return the primary aggregation type value defining how to use the values for display.
*/
public AggregationType getPrimaryAggregationType() {
- return this.primaryAggregationType;
+ return primaryAggregationType;
}
/**
- * Set the primaryAggregationType property: the primary aggregation type value defining how to use the values for
- * display.
- *
- * @param primaryAggregationType the primaryAggregationType value to set.
- * @return the MetricDefinition object itself.
- */
- public MetricDefinition setPrimaryAggregationType(AggregationType primaryAggregationType) {
- this.primaryAggregationType = primaryAggregationType;
- return this;
- }
-
- /**
- * Get the supportedAggregationTypes property: the collection of what aggregation types are supported.
- *
- * @return the supportedAggregationTypes value.
+ * Returns the collection of what aggregation types are supported.
+ * @return the collection of what aggregation types are supported.
*/
public List getSupportedAggregationTypes() {
- return this.supportedAggregationTypes;
- }
-
- /**
- * Set the supportedAggregationTypes property: the collection of what aggregation types are supported.
- *
- * @param supportedAggregationTypes the supportedAggregationTypes value to set.
- * @return the MetricDefinition object itself.
- */
- public MetricDefinition setSupportedAggregationTypes(List supportedAggregationTypes) {
- this.supportedAggregationTypes = supportedAggregationTypes;
- return this;
+ return supportedAggregationTypes;
}
/**
- * Get the metricAvailabilities property: the collection of what aggregation intervals are available to be queried.
- *
- * @return the metricAvailabilities value.
+ * Returns the collection of what aggregation intervals are available to be queried.
+ * @return the collection of what aggregation intervals are available to be queried.
*/
public List getMetricAvailabilities() {
- return this.metricAvailabilities;
+ return metricAvailabilities;
}
/**
- * Set the metricAvailabilities property: the collection of what aggregation intervals are available to be queried.
- *
- * @param metricAvailabilities the metricAvailabilities value to set.
- * @return the MetricDefinition object itself.
- */
- public MetricDefinition setMetricAvailabilities(List metricAvailabilities) {
- this.metricAvailabilities = metricAvailabilities;
- return this;
- }
-
- /**
- * Get the id property: the resource identifier of the metric definition.
- *
- * @return the id value.
+ * The resource identifier of the metric definition.
+ * @return the resource identifier of the metric definition.
*/
public String getId() {
- return this.id;
- }
-
- /**
- * Set the id property: the resource identifier of the metric definition.
- *
- * @param id the id value to set.
- * @return the MetricDefinition object itself.
- */
- public MetricDefinition setId(String id) {
- this.id = id;
- return this;
- }
-
- /**
- * Get the dimensions property: the name and the display name of the dimension, i.e. it is a localizable string.
- *
- * @return the dimensions value.
- */
- public List getDimensions() {
- return this.dimensions;
- }
-
- /**
- * Set the dimensions property: the name and the display name of the dimension, i.e. it is a localizable string.
- *
- * @param dimensions the dimensions value to set.
- * @return the MetricDefinition object itself.
- */
- public MetricDefinition setDimensions(List dimensions) {
- this.dimensions = dimensions;
- return this;
+ return id;
}
/**
- * Validates the instance.
- *
- * @throws IllegalArgumentException thrown if the instance is not valid.
+ * Returns the names of all the dimensions available for this metric.
+ * @return the names of all the dimensions available for this metric.
*/
- public void validate() {
- if (getName() != null) {
- getName().validate();
- }
- if (getMetricAvailabilities() != null) {
- getMetricAvailabilities().forEach(e -> e.validate());
- }
- if (getDimensions() != null) {
- getDimensions().forEach(e -> e.validate());
- }
+ public List getDimensions() {
+ return dimensions;
}
}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricNamespace.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricNamespace.java
index fdaeba4288fcc..50ce627056404 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricNamespace.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricNamespace.java
@@ -3,150 +3,68 @@
package com.azure.monitor.query.models;
-import com.azure.core.annotation.Fluent;
-import com.fasterxml.jackson.annotation.JsonProperty;
+import com.azure.monitor.query.implementation.metrics.models.MetricsHelper;
-/** Metric namespace class specifies the metadata for a metric namespace. */
-@Fluent
+/**
+ * Metric namespace class specifies the metadata for a metric namespace.
+ */
public final class MetricNamespace {
- /*
- * The ID of the metric namespace.
- */
- @JsonProperty(value = "id")
+ private NamespaceClassification classification;
private String id;
-
- /*
- * The type of the namespace.
- */
- @JsonProperty(value = "type")
- private String type;
-
- /*
- * The escaped name of the namespace.
- */
- @JsonProperty(value = "name")
private String name;
+ private String fullyQualifiedName;
+ private String type;
- /*
- * Kind of namespace
- */
- @JsonProperty(value = "classification")
- private NamespaceClassification classification;
-
- /*
- * Properties which include the fully qualified namespace name.
- */
- @JsonProperty(value = "properties")
- private MetricNamespaceName properties;
-
- /**
- * Get the id property: The ID of the metric namespace.
- *
- * @return the id value.
- */
- public String getId() {
- return this.id;
+ static {
+ MetricsHelper.setMetricNamespaceAccessor(MetricNamespace::setMetricNamespaceProperties);
}
- /**
- * Set the id property: The ID of the metric namespace.
- *
- * @param id the id value to set.
- * @return the MetricNamespace object itself.
- */
- public MetricNamespace setId(String id) {
+ private void setMetricNamespaceProperties(NamespaceClassification classification, String id, String name,
+ String fullyQualifiedName, String type) {
+ this.classification = classification;
this.id = id;
- return this;
- }
-
- /**
- * Get the type property: The type of the namespace.
- *
- * @return the type value.
- */
- public String getType() {
- return this.type;
- }
-
- /**
- * Set the type property: The type of the namespace.
- *
- * @param type the type value to set.
- * @return the MetricNamespace object itself.
- */
- public MetricNamespace setType(String type) {
- this.type = type;
- return this;
- }
-
- /**
- * Get the name property: The escaped name of the namespace.
- *
- * @return the name value.
- */
- public String getName() {
- return this.name;
- }
-
- /**
- * Set the name property: The escaped name of the namespace.
- *
- * @param name the name value to set.
- * @return the MetricNamespace object itself.
- */
- public MetricNamespace setName(String name) {
this.name = name;
- return this;
+ this.fullyQualifiedName = fullyQualifiedName;
+ this.type = type;
}
/**
- * Get the classification property: Kind of namespace.
- *
- * @return the classification value.
+ * Returns the kind of namespace.
+ * @return the kind of namespace.
*/
public NamespaceClassification getClassification() {
- return this.classification;
+ return classification;
}
/**
- * Set the classification property: Kind of namespace.
- *
- * @param classification the classification value to set.
- * @return the MetricNamespace object itself.
+ * Returns the ID of the metric namespace.
+ * @return the ID of the metric namespace.
*/
- public MetricNamespace setClassification(NamespaceClassification classification) {
- this.classification = classification;
- return this;
+ public String getId() {
+ return id;
}
/**
- * Get the properties property: Properties which include the fully qualified namespace name.
- *
- * @return the properties value.
+ * Returns the escaped name of the namespace.
+ * @return the escaped name of the namespace.
*/
- public MetricNamespaceName getProperties() {
- return this.properties;
+ public String getName() {
+ return name;
}
/**
- * Set the properties property: Properties which include the fully qualified namespace name.
- *
- * @param properties the properties value to set.
- * @return the MetricNamespace object itself.
+ * Returns the fully qualified name of the metric namespace.
+ * @return the fully qualified name of the metric namespace.
*/
- public MetricNamespace setProperties(MetricNamespaceName properties) {
- this.properties = properties;
- return this;
+ public String getFullyQualifiedName() {
+ return fullyQualifiedName;
}
/**
- * Validates the instance.
- *
- * @throws IllegalArgumentException thrown if the instance is not valid.
+ * Returns the type of the namespace.
+ * @return the type of the namespace.
*/
- public void validate() {
- if (getProperties() != null) {
- getProperties().validate();
- }
+ public String getType() {
+ return type;
}
}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricResult.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricResult.java
new file mode 100644
index 0000000000000..8e09e649ddd48
--- /dev/null
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricResult.java
@@ -0,0 +1,100 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.monitor.query.models;
+
+import com.azure.core.annotation.Immutable;
+import com.azure.core.models.HttpResponseError;
+
+import java.util.List;
+
+/**
+ * The metrics result of a query.
+ */
+@Immutable
+public final class MetricResult {
+ private final String id;
+ private final String resourceType;
+ private final MetricUnit unit;
+ private final String metricName;
+ private final List timeSeries;
+ private final String description;
+ private final HttpResponseError error;
+
+ /**
+ * Creates an instance of the result data of a query.
+ * @param id The metrics id.
+ * @param resourceType The resource type of the metrics resource.
+ * @param unit The metrics unit.
+ * @param metricName The name of the metrics.
+ * @param timeSeries The time series returned when the query is performed.
+ * @param description The display description of the metric.
+ * @param httpResponseError The error information if the request failed to fetch the queried metric.
+ */
+ public MetricResult(String id, String resourceType, MetricUnit unit, String metricName, List timeSeries,
+ String description, HttpResponseError httpResponseError) {
+ this.id = id;
+ this.resourceType = resourceType;
+ this.unit = unit;
+ this.metricName = metricName;
+ this.timeSeries = timeSeries;
+ this.description = description;
+ this.error = httpResponseError;
+ }
+
+ /**
+ * Returns the name of the metrics.
+ * @return the name of the metrics.
+ */
+ public String getMetricName() {
+ return metricName;
+ }
+
+ /**
+ * Returns the metrics id.
+ * @return the metrics id.
+ */
+ public String getId() {
+ return id;
+ }
+
+ /**
+ * Returns the resource type of the metric resource.
+ * @return the resource type of the metric resource.
+ */
+ public String getResourceType() {
+ return resourceType;
+ }
+
+ /**
+ * Returns the metrics unit of the metrics.
+ * @return the unit of the metrics.
+ */
+ public MetricUnit getUnit() {
+ return unit;
+ }
+
+ /**
+ * Returns the time series returned when a data query is performed.
+ * @return the time series returned when a data query is performed.
+ */
+ public List getTimeSeries() {
+ return timeSeries;
+ }
+
+ /**
+ * Returns the description of the metric.
+ * @return the description of the metric.
+ */
+ public String getDescription() {
+ return description;
+ }
+
+ /**
+ * Returns the error message encountered querying this specific metric.
+ * @return the error message encountered querying this specific metric.
+ */
+ public HttpResponseError getError() {
+ return error;
+ }
+}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricTimeSeriesElement.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricTimeSeriesElement.java
deleted file mode 100644
index 104f84e3dca58..0000000000000
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricTimeSeriesElement.java
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright (c) Microsoft Corporation. All rights reserved.
-// Licensed under the MIT License.
-
-package com.azure.monitor.query.models;
-
-import java.util.List;
-
-/**
- * A time series result type.
- */
-public final class MetricTimeSeriesElement {
- private final List data;
-
- /**
- * Creates an instance of {@link MetricTimeSeriesElement} with a list of data points representing the metric
- * values.
- * @param data a list of data points representing the metric values.
- */
- public MetricTimeSeriesElement(List data) {
- this.data = data;
- }
-
- /**
- * Returns a list of data points representing the metric values.
- * @return a list of data points representing the metric
- */
- public List getData() {
- return data;
- }
-}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricsQueryOptions.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricsQueryOptions.java
index e359d49a8df04..e0ada07f33137 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricsQueryOptions.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricsQueryOptions.java
@@ -16,7 +16,7 @@
@Fluent
public final class MetricsQueryOptions {
private TimeInterval timeInterval;
- private Duration interval;
+ private Duration granularity;
private List aggregations;
private Integer top;
private String orderBy;
@@ -27,7 +27,7 @@ public final class MetricsQueryOptions {
* Returns the time span for which the metrics data is queried.
* @return the time span for which the metrics data is queried.
*/
- public TimeInterval getTimeSpan() {
+ public TimeInterval getTimeInterval() {
return timeInterval;
}
@@ -37,7 +37,7 @@ public TimeInterval getTimeSpan() {
*
* @return The updated options instance
*/
- public MetricsQueryOptions setTimeSpan(TimeInterval timeInterval) {
+ public MetricsQueryOptions setTimeInterval(TimeInterval timeInterval) {
this.timeInterval = timeInterval;
return this;
}
@@ -46,18 +46,18 @@ public MetricsQueryOptions setTimeSpan(TimeInterval timeInterval) {
* Returns the interval (window size) for which the metric data was returned in.
* @return The interval (window size) for which the metric data was returned in.
*/
- public Duration getInterval() {
- return interval;
+ public Duration getGranularity() {
+ return granularity;
}
/**
* Sets the interval (window size) for which the metric data was returned in.
- * @param interval The interval (window size) for which the metric data was returned in.
+ * @param granularity The interval (window size) for which the metric data was returned in.
*
* @return The updated options instance
*/
- public MetricsQueryOptions setInterval(Duration interval) {
- this.interval = interval;
+ public MetricsQueryOptions setGranularity(Duration granularity) {
+ this.granularity = granularity;
return this;
}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricsQueryResult.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricsQueryResult.java
index 7e4d24f323e77..385992ca67e07 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricsQueryResult.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricsQueryResult.java
@@ -4,6 +4,7 @@
package com.azure.monitor.query.models;
import com.azure.core.annotation.Immutable;
+import com.azure.core.experimental.models.TimeInterval;
import java.time.Duration;
import java.util.List;
@@ -15,26 +16,26 @@
public final class MetricsQueryResult {
private final Integer cost;
- private final String timeSpan;
- private final Duration interval;
+ private final TimeInterval timeInterval;
+ private final Duration granularity;
private final String namespace;
private final String resourceRegion;
- private final List metrics;
+ private final List metrics;
/**
* Creates an instance of the response to a metrics query.
* @param cost the integer value representing the cost of the query, for data case.
- * @param timeSpan the timespan for which the data was retrieved. Its value consists of two
- * datetimes concatenated, separated by '/'.
- * @param interval the interval (window size) for which the metric data was returned in.
+ * @param timeInterval the time interval for which the data was retrieved.
+ * @param granularity the interval (window size) for which the metric data was returned in.
* @param namespace the namespace of the metrics been queried.
* @param resourceRegion the region of the resource been queried for metrics.
* @param metrics the value of the collection.
*/
- public MetricsQueryResult(Integer cost, String timeSpan, Duration interval, String namespace, String resourceRegion, List metrics) {
+ public MetricsQueryResult(Integer cost, TimeInterval timeInterval, Duration granularity, String namespace,
+ String resourceRegion, List metrics) {
this.cost = cost;
- this.timeSpan = timeSpan;
- this.interval = interval;
+ this.timeInterval = timeInterval;
+ this.granularity = granularity;
this.namespace = namespace;
this.resourceRegion = resourceRegion;
this.metrics = metrics;
@@ -49,21 +50,19 @@ public Integer getCost() {
}
/**
- * Returns the timespan for which the data was retrieved. Its value consists of two
- * datetimes concatenated, separated by '/'.
- * @return the timespan for which the data was retrieved. Its value consists of two
- * datetimes concatenated, separated by '/'.
+ * Returns the time interval for which the data was retrieved.
+ * @return the time interval for which the data was retrieved.
*/
- public String getTimeSpan() {
- return timeSpan;
+ public TimeInterval getTimeInterval() {
+ return timeInterval;
}
/**
* Returns the interval (window size) for which the metric data was returned in.
* @return the interval (window size) for which the metric data was returned in.
*/
- public Duration getInterval() {
- return interval;
+ public Duration getGranularity() {
+ return granularity;
}
/**
@@ -86,7 +85,7 @@ public String getResourceRegion() {
* Returns the value of the collection.
* @return the value of the collection.
*/
- public List getMetrics() {
+ public List getMetrics() {
return metrics;
}
}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/TimeSeriesElement.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/TimeSeriesElement.java
new file mode 100644
index 0000000000000..32f2365aad481
--- /dev/null
+++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/TimeSeriesElement.java
@@ -0,0 +1,42 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.monitor.query.models;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A time series result type.
+ */
+public final class TimeSeriesElement {
+ private final List values;
+ private final Map metadata;
+
+ /**
+ * Creates an instance of {@link TimeSeriesElement} with a list of data points representing the metric
+ * values.
+ * @param values a list of data points representing the metric values.
+ * @param metadata the metadata values if filter is specified in the request.
+ */
+ public TimeSeriesElement(List values, Map metadata) {
+ this.values = values;
+ this.metadata = metadata;
+ }
+
+ /**
+ * Returns a list of data points representing the metric values.
+ * @return a list of data points representing the metric
+ */
+ public List getValues() {
+ return values;
+ }
+
+ /**
+ * Returns the metadata values if filter is specified in the request.
+ * @return the metadata values if filter is specified in the request.
+ */
+ public Map getMetadata() {
+ return metadata;
+ }
+}
diff --git a/sdk/monitor/azure-monitor-query/src/main/java/module-info.java b/sdk/monitor/azure-monitor-query/src/main/java/module-info.java
index 0b6d3960e4058..f135d758ef33b 100644
--- a/sdk/monitor/azure-monitor-query/src/main/java/module-info.java
+++ b/sdk/monitor/azure-monitor-query/src/main/java/module-info.java
@@ -9,9 +9,9 @@
requires transitive com.azure.core.experimental;
exports com.azure.monitor.query;
exports com.azure.monitor.query.models;
- opens com.azure.monitor.query.log.implementation.models to com.fasterxml.jackson.databind, com.azure.core;
- opens com.azure.monitor.query.metrics.implementation.models to com.fasterxml.jackson.databind, com.azure.core;
- opens com.azure.monitor.query.metricsdefinitions.implementation.models to com.fasterxml.jackson.databind, com.azure.core;
- opens com.azure.monitor.query.metricsnamespaces.implementation.models to com.fasterxml.jackson.databind, com.azure.core;
opens com.azure.monitor.query.models to com.fasterxml.jackson.databind, com.azure.core;
+ opens com.azure.monitor.query.implementation.logs.models to com.fasterxml.jackson.databind, com.azure.core;
+ opens com.azure.monitor.query.implementation.metrics.models to com.fasterxml.jackson.databind, com.azure.core;
+ opens com.azure.monitor.query.implementation.metricsdefinitions.models to com.fasterxml.jackson.databind, com.azure.core;
+ opens com.azure.monitor.query.implementation.metricsnamespaces.models to com.fasterxml.jackson.databind, com.azure.core;
}
diff --git a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/LogsQueryBatchSample.java b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/LogsQueryBatchSample.java
index bf221acce3ad4..2869dc3075cbf 100644
--- a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/LogsQueryBatchSample.java
+++ b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/LogsQueryBatchSample.java
@@ -11,9 +11,8 @@
import com.azure.identity.ClientSecretCredentialBuilder;
import com.azure.monitor.query.models.LogsBatchQuery;
import com.azure.monitor.query.models.LogsBatchQueryResult;
-import com.azure.monitor.query.models.LogsBatchQueryResultCollection;
+import com.azure.monitor.query.models.LogsBatchQueryResults;
import com.azure.monitor.query.models.LogsQueryOptions;
-import com.azure.monitor.query.models.LogsQueryResult;
import com.azure.monitor.query.models.LogsTable;
import com.azure.monitor.query.models.LogsTableRow;
@@ -39,22 +38,21 @@ public static void main(String[] args) {
.httpLogOptions(new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS))
.buildClient();
- LogsBatchQuery logsBatchQuery = new LogsBatchQuery()
- .addQuery("d2d0e126-fa1e-4b0a-b647-250cdd471e68", "AppRequests | take 2", null)
- .addQuery("d2d0e126-fa1e-4b0a-b647-250cdd471e68", "AppRequests | take 3", null)
- .addQuery("d2d0e126-fa1e-4b0a-b647-250cdd471e68", "AppRequests | take 4", null,
+ LogsBatchQuery logsBatchQuery = new LogsBatchQuery();
+ logsBatchQuery.addQuery("d2d0e126-fa1e-4b0a-b647-250cdd471e68", "AppRequests | take 2", null);
+ logsBatchQuery.addQuery("d2d0e126-fa1e-4b0a-b647-250cdd471e68", "AppRequests | take 3", null);
+ logsBatchQuery.addQuery("d2d0e126-fa1e-4b0a-b647-250cdd471e68", "AppRequests | take 4", null,
new LogsQueryOptions().setIncludeStatistics(true));
- LogsBatchQueryResultCollection batchResultCollection = logsQueryClient
+ LogsBatchQueryResults batchResultCollection = logsQueryClient
.queryBatchWithResponse(logsBatchQuery, Context.NONE).getValue();
List responses = batchResultCollection.getBatchResults();
for (LogsBatchQueryResult response : responses) {
- LogsQueryResult queryResult = response.getQueryResult();
// Sample to iterate by row
- for (LogsTable table : queryResult.getLogsTables()) {
+ for (LogsTable table : response.getAllTables()) {
for (LogsTableRow row : table.getRows()) {
System.out.println("Row index " + row.getRowIndex());
row.getRow()
diff --git a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/LogsQuerySample.java b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/LogsQuerySample.java
index 108d8d6ea7bfb..72091dcc19bdb 100644
--- a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/LogsQuerySample.java
+++ b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/LogsQuerySample.java
@@ -35,17 +35,17 @@ public static void main(String[] args) {
LogsQueryResult queryResults = logsQueryClient.query("d2d0e126-fa1e-4b0a-b647-250cdd471e68", "AppRequests",
null);
- System.out.println("Number of tables = " + queryResults.getLogsTables().size());
+ System.out.println("Number of tables = " + queryResults.getAllTables().size());
// Sample to iterate over all cells in the table
- for (LogsTable table : queryResults.getLogsTables()) {
+ for (LogsTable table : queryResults.getAllTables()) {
for (LogsTableCell tableCell : table.getAllTableCells()) {
System.out.println("Column = " + tableCell.getColumnName() + "; value = " + tableCell.getValueAsString());
}
}
// Sample to iterate by row
- for (LogsTable table : queryResults.getLogsTables()) {
+ for (LogsTable table : queryResults.getAllTables()) {
for (LogsTableRow row : table.getRows()) {
row.getRow()
.forEach(cell -> System.out.println("Column = " + cell.getColumnName() + "; value = " + cell.getValueAsString()));
@@ -53,7 +53,7 @@ public static void main(String[] args) {
}
// Sample to get value of a column
- for (LogsTable table : queryResults.getLogsTables()) {
+ for (LogsTable table : queryResults.getAllTables()) {
for (LogsTableRow row : table.getRows()) {
Optional resourceGroup = row.getColumnValue("DurationMs");
if (resourceGroup.isPresent()) {
diff --git a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/LogsQueryWithModels.java b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/LogsQueryWithModels.java
index 4b76ea31ead74..f192713b878ae 100644
--- a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/LogsQueryWithModels.java
+++ b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/LogsQueryWithModels.java
@@ -3,12 +3,12 @@
package com.azure.monitor.query;
+import com.azure.core.experimental.models.TimeInterval;
import com.azure.core.util.Configuration;
import com.azure.identity.ClientSecretCredential;
import com.azure.identity.ClientSecretCredentialBuilder;
-import com.azure.monitor.query.models.LogsQueryResult;
-import com.azure.monitor.query.models.LogsTable;
-import com.azure.monitor.query.models.LogsTableRow;
+
+import java.util.List;
/**
* Sample to demonstrate using a custom model to read the results of a logs query.
@@ -30,17 +30,12 @@ public static void main(String[] args) {
.credential(tokenCredential)
.buildClient();
- LogsQueryResult queryResults = logsQueryClient
- .query("{workspace-id}", "AppRequests", null);
-
// Sample to use a model type to read the results
- for (LogsTable table : queryResults.getLogsTables()) {
- for (LogsTableRow row : table.getRows()) {
- CustomModel model = row.toObject(CustomModel.class);
- System.out.println("Time generated " + model.getTimeGenerated() + "; success = " + model.getSuccess()
- + "; operation name = " + model.getOperationName());
- }
- }
+ List customModels = logsQueryClient
+ .query("{workspace-id}", "AppRequests", TimeInterval.ALL, CustomModel.class);
+
+ customModels.forEach(model -> System.out.println("Time generated " + model.getTimeGenerated()
+ + "; success = " + model.getSuccess() + "; operation name = " + model.getOperationName()));
}
}
diff --git a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/MetricsQuerySample.java b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/MetricsQuerySample.java
index 6c73586d157a7..54ef828cde5d0 100644
--- a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/MetricsQuerySample.java
+++ b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/MetricsQuerySample.java
@@ -10,7 +10,7 @@
import com.azure.identity.ClientSecretCredential;
import com.azure.identity.ClientSecretCredentialBuilder;
import com.azure.monitor.query.models.AggregationType;
-import com.azure.monitor.query.models.Metric;
+import com.azure.monitor.query.models.MetricResult;
import com.azure.monitor.query.models.MetricsQueryOptions;
import com.azure.monitor.query.models.MetricsQueryResult;
@@ -45,25 +45,25 @@ public static void main(String[] args) {
Arrays.asList("SuccessfulCalls"),
new MetricsQueryOptions()
.setMetricNamespace("Microsoft.CognitiveServices/accounts")
- .setTimeSpan(new TimeInterval(Duration.ofDays(30)))
- .setInterval(Duration.ofHours(1))
+ .setTimeInterval(new TimeInterval(Duration.ofDays(30)))
+ .setGranularity(Duration.ofHours(1))
.setTop(100)
.setAggregations(Arrays.asList(AggregationType.AVERAGE, AggregationType.COUNT)),
Context.NONE);
MetricsQueryResult metricsQueryResult = metricsResponse.getValue();
- List metrics = metricsQueryResult.getMetrics();
+ List metrics = metricsQueryResult.getMetrics();
metrics.stream()
.forEach(metric -> {
- System.out.println(metric.getMetricsName());
+ System.out.println(metric.getMetricName());
System.out.println(metric.getId());
- System.out.println(metric.getType());
+ System.out.println(metric.getResourceType());
System.out.println(metric.getUnit());
System.out.println(metric.getTimeSeries().size());
- System.out.println(metric.getTimeSeries().get(0).getData().size());
+ System.out.println(metric.getTimeSeries().get(0).getValues().size());
metric.getTimeSeries()
.stream()
- .flatMap(ts -> ts.getData().stream())
+ .flatMap(ts -> ts.getValues().stream())
.forEach(mv -> System.out.println(mv.getTimeStamp().toString()
+ "; Count = " + mv.getCount()
+ "; Average = " + mv.getAverage()));
diff --git a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/MultiWorkspaceSample.java b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/MultiWorkspaceSample.java
index 76e22a87b4a43..9cbe90f985856 100644
--- a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/MultiWorkspaceSample.java
+++ b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/MultiWorkspaceSample.java
@@ -40,11 +40,11 @@ public static void main(String[] args) {
.setAdditionalWorkspaces(Arrays.asList("srnagar-log-analytics-ws-2", "srnagar-log-analytics-ws")),
Context.NONE).getValue();
- System.out.println("Number of tables = " + queryResults.getLogsTables().size());
+ System.out.println("Number of tables = " + queryResults.getAllTables().size());
// Sample to iterate by row
Set results = new HashSet<>();
- for (LogsTable table : queryResults.getLogsTables()) {
+ for (LogsTable table : queryResults.getAllTables()) {
for (LogsTableRow row : table.getRows()) {
Set collect =
row.getRow().stream().map(cell -> cell.getValueAsString())
diff --git a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/ReadmeSamples.java b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/ReadmeSamples.java
index f75430dc28ede..4856873962735 100644
--- a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/ReadmeSamples.java
+++ b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/ReadmeSamples.java
@@ -10,20 +10,19 @@
import com.azure.monitor.query.models.AggregationType;
import com.azure.monitor.query.models.LogsBatchQuery;
import com.azure.monitor.query.models.LogsBatchQueryResult;
-import com.azure.monitor.query.models.LogsBatchQueryResultCollection;
+import com.azure.monitor.query.models.LogsBatchQueryResults;
import com.azure.monitor.query.models.LogsQueryOptions;
import com.azure.monitor.query.models.LogsQueryResult;
-import com.azure.monitor.query.models.LogsTable;
-import com.azure.monitor.query.models.LogsTableCell;
import com.azure.monitor.query.models.LogsTableRow;
-import com.azure.monitor.query.models.Metric;
+import com.azure.monitor.query.models.MetricResult;
+import com.azure.monitor.query.models.MetricValue;
import com.azure.monitor.query.models.MetricsQueryOptions;
import com.azure.monitor.query.models.MetricsQueryResult;
+import com.azure.monitor.query.models.TimeSeriesElement;
import java.time.Duration;
import java.util.Arrays;
import java.util.List;
-import java.util.Optional;
/**
* WARNING: MODIFYING THIS FILE WILL REQUIRE CORRESPONDING UPDATES TO README.md FILE. LINE NUMBERS
@@ -60,159 +59,100 @@ public void createMetricsClients() {
}
/**
- * Sample to demonstrate executing a batch of Kusto queries for logs.
+ * Sample to query logs using a single Kusto query.
*/
- public void getLogsQueryBatch() {
+ public void queryLogs() {
LogsQueryClient logsQueryClient = new LogsQueryClientBuilder()
- .credential(new DefaultAzureCredentialBuilder().build())
- .buildClient();
-
- LogsBatchQuery logsBatchQuery = new LogsBatchQuery()
- .addQuery("{workspace-id}", "{query-1}", new TimeInterval(Duration.ofDays(2)))
- .addQuery("{workspace-id}", "{query-2}", new TimeInterval(Duration.ofDays(30)));
-
- LogsBatchQueryResultCollection batchResultCollection = logsQueryClient
- .queryBatchWithResponse(logsBatchQuery, Context.NONE).getValue();
-
- List responses = batchResultCollection.getBatchResults();
+ .credential(new DefaultAzureCredentialBuilder().build())
+ .buildClient();
- for (LogsBatchQueryResult response : responses) {
- LogsQueryResult queryResult = response.getQueryResult();
+ LogsQueryResult queryResults = logsQueryClient.query("{workspace-id}", "{kusto-query}",
+ new TimeInterval(Duration.ofDays(2)));
- // Sample to iterate by row
- for (LogsTable table : queryResult.getLogsTables()) {
- for (LogsTableRow row : table.getRows()) {
- System.out.println("Row index " + row.getRowIndex());
- row.getRow()
- .forEach(cell -> System.out.println("Column = " + cell.getColumnName() + "; value = " + cell.getValueAsString()));
- }
- }
+ for (LogsTableRow row : queryResults.getTable().getRows()) {
+ System.out.println(row.getColumnValue("OperationName") + " " + row.getColumnValue("ResourceGroup"));
}
}
/**
- * Sample to demonstrate executing a complex Kusto query for logs that requires a long time to complete and
- * requires extending server timeout.
+ * A custom model type to map logs query result to an object.
*/
- public void getLogsWithServerTimeout() {
- LogsQueryClient logsQueryClient = new LogsQueryClientBuilder()
- .credential(new DefaultAzureCredentialBuilder().build())
- .buildClient();
+ public class CustomLogModel {
+ private String resourceGroup;
+ private String operationName;
- // set request options: server timeout, rendering, statistics
- LogsQueryOptions options = new LogsQueryOptions()
- .setServerTimeout(Duration.ofMinutes(10));
+ public String getResourceGroup() {
+ return resourceGroup;
+ }
- // make service call with these request options set as filter header
- Response response = logsQueryClient.queryWithResponse("{workspace-id}",
- "{query}", new TimeInterval(Duration.ofDays(2)), options, Context.NONE);
- LogsQueryResult logsQueryResult = response.getValue();
-
- // Sample to iterate by row
- for (LogsTable table : logsQueryResult.getLogsTables()) {
- for (LogsTableRow row : table.getRows()) {
- System.out.println("Row index " + row.getRowIndex());
- row.getRow()
- .forEach(cell -> System.out.println("Column = " + cell.getColumnName() + "; value = " + cell.getValueAsString()));
- }
+ public String getOperationName() {
+ return operationName;
}
}
/**
- * Sample to demonstrate querying Azure Monitor for metrics.
+ * Sample to query logs and convert the response to a strongly-typed list of objects.
*/
- public void getMetrics() {
- MetricsQueryClient metricsQueryClient = new MetricsQueryClientBuilder()
- .credential(new DefaultAzureCredentialBuilder().build())
- .buildClient();
+ public void queryLogsAsModel() {
+ LogsQueryClient logsQueryClient = new LogsQueryClientBuilder()
+ .credential(new DefaultAzureCredentialBuilder().build())
+ .buildClient();
- Response metricsResponse = metricsQueryClient
- .queryWithResponse(
- "{resource-id}",
- Arrays.asList("SuccessfulCalls"),
- new MetricsQueryOptions()
- .setMetricNamespace("Microsoft.CognitiveServices/accounts")
- .setTimeSpan(new TimeInterval(Duration.ofDays(30)))
- .setInterval(Duration.ofHours(1))
- .setTop(100)
- .setAggregations(Arrays.asList(AggregationType.AVERAGE, AggregationType.COUNT)),
- Context.NONE);
+ List customLogModels = logsQueryClient.query("{workspace-id}", "{kusto-query}",
+ new TimeInterval(Duration.ofDays(2)), CustomLogModel.class);
- MetricsQueryResult metricsQueryResult = metricsResponse.getValue();
- List metrics = metricsQueryResult.getMetrics();
- metrics.stream()
- .forEach(metric -> {
- System.out.println(metric.getMetricsName());
- System.out.println(metric.getId());
- System.out.println(metric.getType());
- System.out.println(metric.getUnit());
- System.out.println(metric.getTimeSeries().size());
- System.out.println(metric.getTimeSeries().get(0).getData().size());
- metric.getTimeSeries()
- .stream()
- .flatMap(ts -> ts.getData().stream())
- .forEach(mv -> System.out.println(mv.getTimeStamp().toString() + "; Count = " + mv.getCount()
- + "; Average = " + mv.getAverage()));
- });
+ for (CustomLogModel customLogModel : customLogModels) {
+ System.out.println(customLogModel.getOperationName() + " " + customLogModel.getResourceGroup());
+ }
}
/**
- * Sample to demonstrate accessing query results.
+ * Sample to execute a batch of logs queries.
*/
- public void getLogsQueryWithColumnNameAccess() {
+ public void queryBatch() {
LogsQueryClient logsQueryClient = new LogsQueryClientBuilder()
- .credential(new DefaultAzureCredentialBuilder().build())
- .buildClient();
+ .credential(new DefaultAzureCredentialBuilder().build())
+ .buildClient();
- LogsQueryResult queryResults = logsQueryClient.query("{workspace-id}", "{kusto-query}",
- new TimeInterval(Duration.ofDays(2)));
- System.out.println("Number of tables = " + queryResults.getLogsTables().size());
+ LogsBatchQuery logsBatchQuery = new LogsBatchQuery();
+ String query1 = logsBatchQuery.addQuery("{workspace-id}", "{query-1}", new TimeInterval(Duration.ofDays(2)));
+ String query2 = logsBatchQuery.addQuery("{workspace-id}", "{query-2}", new TimeInterval(Duration.ofDays(30)));
+ String query3 = logsBatchQuery.addQuery("{workspace-id}", "{query-3}", new TimeInterval(Duration.ofDays(10)));
- // Sample to iterate over all cells in the table
- for (LogsTable table : queryResults.getLogsTables()) {
- for (LogsTableCell tableCell : table.getAllTableCells()) {
- System.out.println("Column = " + tableCell.getColumnName() + "; value = " + tableCell.getValueAsString());
- }
+ LogsBatchQueryResults batchResults = logsQueryClient
+ .queryBatchWithResponse(logsBatchQuery, Context.NONE).getValue();
+
+ LogsBatchQueryResult query1Result = batchResults.getResult(query1);
+ for (LogsTableRow row : query1Result.getTable().getRows()) {
+ System.out.println(row.getColumnValue("OperationName") + " " + row.getColumnValue("ResourceGroup"));
}
- // Sample to iterate over each row
- for (LogsTable table : queryResults.getLogsTables()) {
- for (LogsTableRow tableRow : table.getRows()) {
- for (LogsTableCell tableCell : tableRow.getRow()) {
- System.out.println("Column = " + tableCell.getColumnName()
- + "; value = " + tableCell.getValueAsString());
- }
- }
+ List customLogModels = batchResults.getResult(query2, CustomLogModel.class);
+ for (CustomLogModel customLogModel : customLogModels) {
+ System.out.println(customLogModel.getOperationName() + " " + customLogModel.getResourceGroup());
}
- // Sample to get a specific column by name
- for (LogsTable table : queryResults.getLogsTables()) {
- for (LogsTableRow tableRow : table.getRows()) {
- Optional tableCell = tableRow.getColumnValue("DurationMs");
- tableCell
- .ifPresent(logsTableCell ->
- System.out.println("Column = " + logsTableCell.getColumnName()
- + "; value = " + logsTableCell.getValueAsString()));
- }
+ LogsBatchQueryResult query3Result = batchResults.getResult(query3);
+ if (query3Result.hasFailed()) {
+ System.out.println(query3Result.getError().getMessage());
}
}
/**
- * Sample to demonstrate reading the response as a strongly-typed object.
+ * Sample to demonstrate executing an advanced Kusto query for logs that requires a long time to complete and
+ * requires extending server timeout.
*/
- public void getLogsQueryResultAsModel() {
+ public void getLogsWithServerTimeout() {
LogsQueryClient logsQueryClient = new LogsQueryClientBuilder()
- .credential(new DefaultAzureCredentialBuilder().build())
- .buildClient();
+ .credential(new DefaultAzureCredentialBuilder().build())
+ .buildClient();
- LogsQueryResult queryResults = logsQueryClient.query("{workspace-id}", "{kusto-query}",
- new TimeInterval(Duration.ofDays(2)));
+ // set request options: server timeout
+ LogsQueryOptions options = new LogsQueryOptions()
+ .setServerTimeout(Duration.ofMinutes(10));
- List results = queryResults.toObject(CustomModel.class);
- results.forEach(model -> {
- System.out.println("Time generated " + model.getTimeGenerated() + "; success = " + model.getSuccess()
- + "; operation name = " + model.getOperationName());
- });
+ Response response = logsQueryClient.queryWithResponse("{workspace-id}",
+ "{kusto-query}", new TimeInterval(Duration.ofDays(2)), options, Context.NONE);
}
/**
@@ -228,6 +168,56 @@ public void getLogsQueryFromMultipleWorkspaces() {
.setAdditionalWorkspaces(Arrays.asList("{additional-workspace-identifiers}")),
Context.NONE);
LogsQueryResult result = response.getValue();
+ }
+
+
+ /**
+ * Sample to demonstrate querying Azure Monitor for metrics.
+ */
+ public void getMetrics() {
+ MetricsQueryClient metricsQueryClient = new MetricsQueryClientBuilder()
+ .credential(new DefaultAzureCredentialBuilder().build())
+ .buildClient();
+ MetricsQueryResult metricsQueryResult = metricsQueryClient.query("{resource-uri}",
+ Arrays.asList("SuccessfulCalls", "TotalCalls"));
+
+ for (MetricResult metric : metricsQueryResult.getMetrics()) {
+ System.out.println("Metric name " + metric.getMetricName());
+ for (TimeSeriesElement timeSeriesElement : metric.getTimeSeries()) {
+ System.out.println("Dimensions " + timeSeriesElement.getMetadata());
+ for (MetricValue metricValue : timeSeriesElement.getValues()) {
+ System.out.println(metricValue.getTimeStamp() + " " + metricValue.getTotal());
+ }
+ }
+ }
+ }
+
+ /**
+ * Sample to demonstrate querying Azure Monitor for metrics with advanced options.
+ */
+ public void getMetricsWithOptions() {
+ MetricsQueryClient metricsQueryClient = new MetricsQueryClientBuilder()
+ .credential(new DefaultAzureCredentialBuilder().build())
+ .buildClient();
+
+ Response metricsResponse = metricsQueryClient
+ .queryWithResponse("{resource-id}", Arrays.asList("SuccessfulCalls", "TotalCalls"),
+ new MetricsQueryOptions()
+ .setGranularity(Duration.ofHours(1))
+ .setAggregations(Arrays.asList(AggregationType.AVERAGE, AggregationType.COUNT)),
+ Context.NONE);
+
+ MetricsQueryResult metricsQueryResult = metricsResponse.getValue();
+
+ for (MetricResult metric : metricsQueryResult.getMetrics()) {
+ System.out.println("Metric name " + metric.getMetricName());
+ for (TimeSeriesElement timeSeriesElement : metric.getTimeSeries()) {
+ System.out.println("Dimensions " + timeSeriesElement.getMetadata());
+ for (MetricValue metricValue : timeSeriesElement.getValues()) {
+ System.out.println(metricValue.getTimeStamp() + " " + metricValue.getTotal());
+ }
+ }
+ }
}
}
diff --git a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/ServerTimeoutSample.java b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/ServerTimeoutSample.java
index 3fcf09c3e4a8b..3ce777bc3c052 100644
--- a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/ServerTimeoutSample.java
+++ b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/ServerTimeoutSample.java
@@ -52,7 +52,7 @@ public static void main(String[] args) {
LogsQueryResult logsQueryResult = response.getValue();
// Sample to iterate by row
- for (LogsTable table : logsQueryResult.getLogsTables()) {
+ for (LogsTable table : logsQueryResult.getAllTables()) {
for (LogsTableRow row : table.getRows()) {
System.out.println("Row index " + row.getRowIndex());
row.getRow()
diff --git a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/codesnippets/LogsQueryClientJavaDocCodeSnippets.java b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/codesnippets/LogsQueryClientJavaDocCodeSnippets.java
new file mode 100644
index 0000000000000..7cee378e69843
--- /dev/null
+++ b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/codesnippets/LogsQueryClientJavaDocCodeSnippets.java
@@ -0,0 +1,176 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.monitor.query.codesnippets;
+
+import com.azure.core.credential.TokenCredential;
+import com.azure.core.experimental.models.TimeInterval;
+import com.azure.core.http.rest.Response;
+import com.azure.core.util.Context;
+import com.azure.identity.DefaultAzureCredentialBuilder;
+import com.azure.monitor.query.LogsQueryAsyncClient;
+import com.azure.monitor.query.LogsQueryClient;
+import com.azure.monitor.query.LogsQueryClientBuilder;
+import com.azure.monitor.query.models.LogsBatchQuery;
+import com.azure.monitor.query.models.LogsBatchQueryResult;
+import com.azure.monitor.query.models.LogsBatchQueryResults;
+import com.azure.monitor.query.models.LogsQueryOptions;
+import com.azure.monitor.query.models.LogsQueryResult;
+import com.azure.monitor.query.models.LogsTableCell;
+import com.azure.monitor.query.models.LogsTableRow;
+import reactor.core.publisher.Mono;
+
+import java.time.Duration;
+import java.util.stream.Collectors;
+
+/**
+ * Class containing javadoc code snippets for Logs Query client.
+ */
+public class LogsQueryClientJavaDocCodeSnippets {
+
+ /**
+ * Code snippet for creating a logs query client.
+ */
+ public void instantiation() {
+ TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build();
+ // BEGIN: com.azure.monitor.query.LogsQueryClient.instantiation
+ LogsQueryClient logsQueryClient = new LogsQueryClientBuilder()
+ .credential(tokenCredential)
+ .buildClient();
+ // END: com.azure.monitor.query.LogsQueryClient.instantiation
+
+ // BEGIN: com.azure.monitor.query.LogsQueryAsyncClient.instantiation
+ LogsQueryAsyncClient logsQueryAsyncClient = new LogsQueryClientBuilder()
+ .credential(tokenCredential)
+ .buildAsyncClient();
+ // END: com.azure.monitor.query.LogsQueryAsyncClient.instantiation
+ }
+
+ public void singleQueryAsync() {
+ LogsQueryAsyncClient logsQueryAsyncClient = new LogsQueryClientBuilder()
+ .credential(new DefaultAzureCredentialBuilder().build())
+ .buildAsyncClient();
+ // BEGIN: com.azure.monitor.query.LogsQueryAsyncClient.query#String-String-TimeInterval
+ Mono queryResult = logsQueryAsyncClient.query("{workspace-id}", "{kusto-query}",
+ TimeInterval.LAST_DAY);
+ queryResult.subscribe(result -> {
+ for (LogsTableRow row : result.getTable().getRows()) {
+ System.out.println(row.getRow()
+ .stream()
+ .map(LogsTableCell::getValueAsString)
+ .collect(Collectors.joining(",")));
+ }
+ });
+ // END: com.azure.monitor.query.LogsQueryAsyncClient.query#String-String-TimeInterval
+ }
+
+ public void singleQuery() {
+ LogsQueryClient logsQueryClient = new LogsQueryClientBuilder()
+ .credential(new DefaultAzureCredentialBuilder().build())
+ .buildClient();
+
+ // BEGIN: com.azure.monitor.query.LogsQueryClient.query#String-String-TimeInterval
+ LogsQueryResult queryResult = logsQueryClient.query("{workspace-id}", "{kusto-query}", TimeInterval.LAST_DAY);
+ for (LogsTableRow row : queryResult.getTable().getRows()) {
+ System.out.println(row.getRow()
+ .stream()
+ .map(LogsTableCell::getValueAsString)
+ .collect(Collectors.joining(",")));
+ }
+ // END: com.azure.monitor.query.LogsQueryClient.query#String-String-TimeInterval
+ }
+
+ public void singleQueryWithResponseAsync() {
+ LogsQueryAsyncClient logsQueryAsyncClient = new LogsQueryClientBuilder()
+ .credential(new DefaultAzureCredentialBuilder().build())
+ .buildAsyncClient();
+ // BEGIN: com.azure.monitor.query.LogsQueryAsyncClient.queryWithResponse#String-String-TimeInterval-LogsQueryOptions
+ Mono> queryResult = logsQueryAsyncClient.queryWithResponse("{workspace-id}",
+ "{kusto-query}",
+ TimeInterval.LAST_7_DAYS,
+ new LogsQueryOptions().setServerTimeout(Duration.ofMinutes(2)));
+
+ queryResult.subscribe(result -> {
+ for (LogsTableRow row : result.getValue().getTable().getRows()) {
+ System.out.println(row.getRow()
+ .stream()
+ .map(LogsTableCell::getValueAsString)
+ .collect(Collectors.joining(",")));
+ }
+ });
+ // END: com.azure.monitor.query.LogsQueryAsyncClient.queryWithResponse#String-String-TimeInterval-LogsQueryOptions
+ }
+
+ public void singleQueryWithResponse() {
+ LogsQueryClient logsQueryClient = new LogsQueryClientBuilder()
+ .credential(new DefaultAzureCredentialBuilder().build())
+ .buildClient();
+
+ // BEGIN: com.azure.monitor.query.LogsQueryClient.queryWithResponse#String-String-TimeInterval-LogsQueryOptions-Context
+ Response queryResult = logsQueryClient.queryWithResponse("{workspace-id}",
+ "{kusto-query}",
+ TimeInterval.LAST_7_DAYS,
+ new LogsQueryOptions().setServerTimeout(Duration.ofMinutes(2)),
+ Context.NONE);
+
+ for (LogsTableRow row : queryResult.getValue().getTable().getRows()) {
+ System.out.println(row.getRow()
+ .stream()
+ .map(LogsTableCell::getValueAsString)
+ .collect(Collectors.joining(",")));
+ }
+ // END: com.azure.monitor.query.LogsQueryClient.queryWithResponse#String-String-TimeInterval-LogsQueryOptions-Context
+ }
+
+ public void batchQueryAsync() {
+ LogsQueryAsyncClient logsQueryAsyncClient = new LogsQueryClientBuilder()
+ .credential(new DefaultAzureCredentialBuilder().build())
+ .buildAsyncClient();
+
+ // BEGIN: com.azure.monitor.query.LogsQueryAsyncClient.queryBatch#LogsBatchQuery
+ LogsBatchQuery batchQuery = new LogsBatchQuery();
+ String queryId1 = batchQuery.addQuery("{workspace-id-1}", "{kusto-query-1}", TimeInterval.LAST_DAY);
+ String queryId2 = batchQuery.addQuery("{workspace-id-2}", "{kusto-query-2}", TimeInterval.LAST_7_DAYS,
+ new LogsQueryOptions().setServerTimeout(Duration.ofMinutes(2)));
+
+ Mono batchQueryResponse = logsQueryAsyncClient.queryBatch(batchQuery);
+
+ batchQueryResponse.subscribe(result -> {
+ for (LogsBatchQueryResult queryResult : result.getBatchResults()) {
+ System.out.println("Logs query result for query id " + queryResult.getId());
+ for (LogsTableRow row : queryResult.getTable().getRows()) {
+ System.out.println(row.getRow()
+ .stream()
+ .map(LogsTableCell::getValueAsString)
+ .collect(Collectors.joining(",")));
+ }
+ }
+ });
+ // END: com.azure.monitor.query.LogsQueryAsyncClient.queryBatch#LogsBatchQuery
+ }
+
+ public void batchQuery() {
+ LogsQueryClient logsQueryClient = new LogsQueryClientBuilder()
+ .credential(new DefaultAzureCredentialBuilder().build())
+ .buildClient();
+
+ // BEGIN: com.azure.monitor.query.LogsQueryClient.queryBatch#LogsBatchQuery
+ LogsBatchQuery batchQuery = new LogsBatchQuery();
+ String queryId1 = batchQuery.addQuery("{workspace-id-1}", "{kusto-query-1}", TimeInterval.LAST_DAY);
+ String queryId2 = batchQuery.addQuery("{workspace-id-2}", "{kusto-query-2}", TimeInterval.LAST_7_DAYS,
+ new LogsQueryOptions().setServerTimeout(Duration.ofMinutes(2)));
+
+ LogsBatchQueryResults batchQueryResponse = logsQueryClient.queryBatch(batchQuery);
+
+ for (LogsBatchQueryResult queryResult : batchQueryResponse.getBatchResults()) {
+ System.out.println("Logs query result for query id " + queryResult.getId());
+ for (LogsTableRow row : queryResult.getTable().getRows()) {
+ System.out.println(row.getRow()
+ .stream()
+ .map(LogsTableCell::getValueAsString)
+ .collect(Collectors.joining(",")));
+ }
+ }
+ // END: com.azure.monitor.query.LogsQueryClient.queryBatch#LogsBatchQuery
+ }
+}
diff --git a/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/codesnippets/MetricsQueryClientJavaDocCodeSnippets.java b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/codesnippets/MetricsQueryClientJavaDocCodeSnippets.java
new file mode 100644
index 0000000000000..cfe3288bee992
--- /dev/null
+++ b/sdk/monitor/azure-monitor-query/src/samples/java/com/azure/monitor/query/codesnippets/MetricsQueryClientJavaDocCodeSnippets.java
@@ -0,0 +1,80 @@
+// Copyright (c) Microsoft Corporation. All rights reserved.
+// Licensed under the MIT License.
+
+package com.azure.monitor.query.codesnippets;
+
+import com.azure.core.credential.TokenCredential;
+import com.azure.identity.DefaultAzureCredentialBuilder;
+import com.azure.monitor.query.MetricsQueryAsyncClient;
+import com.azure.monitor.query.MetricsQueryClient;
+import com.azure.monitor.query.MetricsQueryClientBuilder;
+import com.azure.monitor.query.models.MetricResult;
+import com.azure.monitor.query.models.MetricsQueryResult;
+import reactor.core.publisher.Mono;
+
+import java.util.Arrays;
+
+/**
+ * Class containing JavaDoc codesnippets for metrics query client.
+ */
+public class MetricsQueryClientJavaDocCodeSnippets {
+ /**
+ * Code snippet for creating a metrics query client.
+ */
+ public void instantiation() {
+ TokenCredential tokenCredential = new DefaultAzureCredentialBuilder().build();
+
+ // BEGIN: com.azure.monitor.query.MetricsQueryClient.instantiation
+ MetricsQueryClient metricsQueryClient = new MetricsQueryClientBuilder()
+ .credential(tokenCredential)
+ .buildClient();
+ // END: com.azure.monitor.query.MetricsQueryClient.instantiation
+
+ // BEGIN: com.azure.monitor.query.MetricsQueryAsyncClient.instantiation
+ MetricsQueryAsyncClient metricsQueryAsyncClient = new MetricsQueryClientBuilder()
+ .credential(tokenCredential)
+ .buildAsyncClient();
+ // END: com.azure.monitor.query.MetricsQueryAsyncClient.instantiation
+ }
+
+ public void queryMetricsAsync() {
+ MetricsQueryAsyncClient metricsQueryAsyncClient = new MetricsQueryClientBuilder()
+ .credential(new DefaultAzureCredentialBuilder().build())
+ .buildAsyncClient();
+ // BEGIN: com.azure.monitor.query.MetricsQueryAsyncClient.query#String-List
+ Mono response = metricsQueryAsyncClient
+ .query("{resource-id}", Arrays.asList("{metric-1}", "{metric-2}"));
+
+ response.subscribe(result -> {
+ for (MetricResult metricResult : result.getMetrics()) {
+ System.out.println("Metric name " + metricResult.getMetricName());
+ metricResult.getTimeSeries().stream()
+ .flatMap(timeSeriesElement -> timeSeriesElement.getValues().stream())
+ .forEach(metricValue ->
+ System.out.println("Time stamp: " + metricValue.getTimeStamp() + "; Total: "
+ + metricValue.getTotal()));
+ }
+ });
+ // END: com.azure.monitor.query.MetricsQueryAsyncClient.query#String-List
+ }
+
+ public void queryMetrics() {
+ MetricsQueryClient metricsQueryClient = new MetricsQueryClientBuilder()
+ .credential(new DefaultAzureCredentialBuilder().build())
+ .buildClient();
+
+ // BEGIN: com.azure.monitor.query.MetricsQueryClient.query#String-List
+ MetricsQueryResult response = metricsQueryClient.query("{resource-id}", Arrays.asList("{metric-1}", "{metric-2}"));
+ for (MetricResult metricResult : response.getMetrics()) {
+ System.out.println("Metric name " + metricResult.getMetricName());
+
+ metricResult.getTimeSeries().stream()
+ .flatMap(timeSeriesElement -> timeSeriesElement.getValues().stream())
+ .forEach(metricValue ->
+ System.out.println("Time stamp: " + metricValue.getTimeStamp() + "; Total: "
+ + metricValue.getTotal()));
+ }
+
+ // END: com.azure.monitor.query.MetricsQueryClient.query#String-List
+ }
+}
diff --git a/sdk/monitor/azure-monitor-query/src/test/java/com/azure/monitor/query/LogsQueryClientTest.java b/sdk/monitor/azure-monitor-query/src/test/java/com/azure/monitor/query/LogsQueryClientTest.java
index 10ad4adaa5684..03731a11b1207 100644
--- a/sdk/monitor/azure-monitor-query/src/test/java/com/azure/monitor/query/LogsQueryClientTest.java
+++ b/sdk/monitor/azure-monitor-query/src/test/java/com/azure/monitor/query/LogsQueryClientTest.java
@@ -5,6 +5,7 @@
import com.azure.core.credential.AccessToken;
import com.azure.core.credential.TokenCredential;
+import com.azure.core.exception.HttpResponseException;
import com.azure.core.experimental.models.TimeInterval;
import com.azure.core.http.policy.HttpLogDetailLevel;
import com.azure.core.http.policy.HttpLogOptions;
@@ -17,8 +18,7 @@
import com.azure.identity.ClientSecretCredentialBuilder;
import com.azure.monitor.query.models.LogsBatchQuery;
import com.azure.monitor.query.models.LogsBatchQueryResult;
-import com.azure.monitor.query.models.LogsBatchQueryResultCollection;
-import com.azure.monitor.query.models.LogsQueryException;
+import com.azure.monitor.query.models.LogsBatchQueryResults;
import com.azure.monitor.query.models.LogsQueryOptions;
import com.azure.monitor.query.models.LogsQueryResult;
import org.junit.jupiter.api.BeforeEach;
@@ -89,31 +89,31 @@ public void testLogsQuery() {
LogsQueryResult queryResults = client.query(WORKSPACE_ID, "AppRequests",
new TimeInterval(OffsetDateTime.of(LocalDateTime.of(2021, 01, 01, 0, 0), ZoneOffset.UTC),
OffsetDateTime.of(LocalDateTime.of(2021, 06, 10, 0, 0), ZoneOffset.UTC)));
- assertEquals(1, queryResults.getLogsTables().size());
- assertEquals(902, queryResults.getLogsTables().get(0).getAllTableCells().size());
- assertEquals(22, queryResults.getLogsTables().get(0).getRows().size());
+ assertEquals(1, queryResults.getAllTables().size());
+ assertEquals(902, queryResults.getAllTables().get(0).getAllTableCells().size());
+ assertEquals(22, queryResults.getAllTables().get(0).getRows().size());
}
@Test
public void testLogsQueryBatch() {
- LogsBatchQuery logsBatchQuery = new LogsBatchQuery()
- .addQuery(WORKSPACE_ID, "AppRequests | take 2", null)
- .addQuery(WORKSPACE_ID, "AppRequests | take 3", null);
+ LogsBatchQuery logsBatchQuery = new LogsBatchQuery();
+ logsBatchQuery.addQuery(WORKSPACE_ID, "AppRequests | take 2", null);
+ logsBatchQuery.addQuery(WORKSPACE_ID, "AppRequests | take 3", null);
- LogsBatchQueryResultCollection batchResultCollection = client
+ LogsBatchQueryResults batchResultCollection = client
.queryBatchWithResponse(logsBatchQuery, Context.NONE).getValue();
List responses = batchResultCollection.getBatchResults();
assertEquals(2, responses.size());
- assertEquals(1, responses.get(0).getQueryResult().getLogsTables().size());
- assertEquals(82, responses.get(0).getQueryResult().getLogsTables().get(0).getAllTableCells().size());
- assertEquals(2, responses.get(0).getQueryResult().getLogsTables().get(0).getRows().size());
+ assertEquals(1, responses.get(0).getAllTables().size());
+ assertEquals(82, responses.get(0).getAllTables().get(0).getAllTableCells().size());
+ assertEquals(2, responses.get(0).getAllTables().get(0).getRows().size());
- assertEquals(1, responses.get(1).getQueryResult().getLogsTables().size());
- assertEquals(123, responses.get(1).getQueryResult().getLogsTables().get(0).getAllTableCells().size());
- assertEquals(3, responses.get(1).getQueryResult().getLogsTables().get(0).getRows().size());
+ assertEquals(1, responses.get(1).getAllTables().size());
+ assertEquals(123, responses.get(1).getAllTables().get(0).getAllTableCells().size());
+ assertEquals(3, responses.get(1).getAllTables().get(0).getRows().size());
}
@Test
@@ -123,9 +123,9 @@ public void testMultipleWorkspaces() {
new LogsQueryOptions()
.setAdditionalWorkspaces(Arrays.asList("9dad0092-fd13-403a-b367-a189a090a541")), Context.NONE)
.getValue();
- assertEquals(1, queryResults.getLogsTables().size());
+ assertEquals(1, queryResults.getAllTables().size());
assertEquals(2, queryResults
- .getLogsTables()
+ .getAllTables()
.get(0)
.getRows()
.stream()
@@ -139,22 +139,21 @@ public void testMultipleWorkspaces() {
@Test
public void testBatchQueryPartialSuccess() {
- LogsBatchQuery logsBatchQuery = new LogsBatchQuery()
- .addQuery(WORKSPACE_ID, "AppRequests | take 2", null)
- .addQuery(WORKSPACE_ID, "AppRequests | take", null);
+ LogsBatchQuery logsBatchQuery = new LogsBatchQuery();
+ logsBatchQuery.addQuery(WORKSPACE_ID, "AppRequests | take 2", null);
+ logsBatchQuery.addQuery(WORKSPACE_ID, "AppRequests | take", null);
- LogsBatchQueryResultCollection batchResultCollection = client
+ LogsBatchQueryResults batchResultCollection = client
.queryBatchWithResponse(logsBatchQuery, Context.NONE).getValue();
List responses = batchResultCollection.getBatchResults();
assertEquals(2, responses.size());
assertEquals(200, responses.get(0).getStatus());
- assertNotNull(responses.get(0).getQueryResult());
- assertNull(responses.get(0).getQueryResult().getError());
+ assertNull(responses.get(0).getError());
assertEquals(400, responses.get(1).getStatus());
- assertNotNull(responses.get(1).getQueryResult().getError());
- assertEquals("BadArgumentError", responses.get(1).getQueryResult().getError().getCode());
+ assertNotNull(responses.get(1).getError());
+ assertEquals("BadArgumentError", responses.get(1).getError().getCode());
}
@Test
@@ -162,31 +161,29 @@ public void testStatistics() {
LogsQueryResult queryResults = client.queryWithResponse(WORKSPACE_ID,
"AppRequests", null, new LogsQueryOptions().setIncludeStatistics(true), Context.NONE).getValue();
- assertEquals(1, queryResults.getLogsTables().size());
+ assertEquals(1, queryResults.getAllTables().size());
assertNotNull(queryResults.getStatistics());
}
@Test
public void testBatchStatistics() {
- LogsBatchQuery logsBatchQuery = new LogsBatchQuery()
- .addQuery(WORKSPACE_ID, "AppRequests | take 2", null)
- .addQuery(WORKSPACE_ID, "AppRequests | take 2", null,
+ LogsBatchQuery logsBatchQuery = new LogsBatchQuery();
+ logsBatchQuery.addQuery(WORKSPACE_ID, "AppRequests | take 2", null);
+ logsBatchQuery.addQuery(WORKSPACE_ID, "AppRequests | take 2", null,
new LogsQueryOptions().setIncludeStatistics(true));
- LogsBatchQueryResultCollection batchResultCollection = client
+ LogsBatchQueryResults batchResultCollection = client
.queryBatchWithResponse(logsBatchQuery, Context.NONE).getValue();
List responses = batchResultCollection.getBatchResults();
assertEquals(2, responses.size());
assertEquals(200, responses.get(0).getStatus());
- assertNotNull(responses.get(0).getQueryResult());
- assertNull(responses.get(0).getQueryResult().getError());
- assertNull(responses.get(0).getQueryResult().getStatistics());
+ assertNull(responses.get(0).getError());
+ assertNull(responses.get(0).getStatistics());
assertEquals(200, responses.get(1).getStatus());
- assertNotNull(responses.get(1).getQueryResult());
- assertNull(responses.get(1).getQueryResult().getError());
- assertNotNull(responses.get(1).getQueryResult().getStatistics());
+ assertNull(responses.get(1).getError());
+ assertNotNull(responses.get(1).getStatistics());
}
@Test
@@ -205,8 +202,8 @@ public void testServerTimeout() {
.setServerTimeout(Duration.ofSeconds(5)),
Context.NONE);
} catch (Exception exception) {
- if (exception instanceof LogsQueryException) {
- LogsQueryException logsQueryException = (LogsQueryException) exception;
+ if (exception instanceof HttpResponseException) {
+ HttpResponseException logsQueryException = (HttpResponseException) exception;
if (logsQueryException.getResponse().getStatusCode() == 504) {
break;
}
diff --git a/sdk/monitor/azure-monitor-query/src/test/java/com/azure/monitor/query/MetricsQueryClientTest.java b/sdk/monitor/azure-monitor-query/src/test/java/com/azure/monitor/query/MetricsQueryClientTest.java
index 74da032df1da4..67ff4588e969c 100644
--- a/sdk/monitor/azure-monitor-query/src/test/java/com/azure/monitor/query/MetricsQueryClientTest.java
+++ b/sdk/monitor/azure-monitor-query/src/test/java/com/azure/monitor/query/MetricsQueryClientTest.java
@@ -17,9 +17,9 @@
import com.azure.identity.ClientSecretCredentialBuilder;
import com.azure.identity.DefaultAzureCredentialBuilder;
import com.azure.monitor.query.models.AggregationType;
-import com.azure.monitor.query.models.Metric;
-import com.azure.monitor.query.models.MetricDefinition;
import com.azure.monitor.query.models.MetricNamespace;
+import com.azure.monitor.query.models.MetricResult;
+import com.azure.monitor.query.models.MetricDefinition;
import com.azure.monitor.query.models.MetricsQueryOptions;
import com.azure.monitor.query.models.MetricsQueryResult;
import org.junit.jupiter.api.Assertions;
@@ -78,25 +78,25 @@ public void testMetricsQuery() {
.queryWithResponse(RESOURCE_URI, Arrays.asList("SuccessfulCalls"),
new MetricsQueryOptions()
.setMetricNamespace("Microsoft.CognitiveServices/accounts")
- .setTimeSpan(new TimeInterval(Duration.ofDays(10)))
- .setInterval(Duration.ofHours(1))
+ .setTimeInterval(new TimeInterval(Duration.ofDays(10)))
+ .setGranularity(Duration.ofHours(1))
.setTop(100)
.setAggregations(Arrays.asList(AggregationType.COUNT, AggregationType.TOTAL,
AggregationType.MAXIMUM, AggregationType.MINIMUM, AggregationType.AVERAGE)),
Context.NONE);
MetricsQueryResult metricsQueryResult = metricsResponse.getValue();
- List metrics = metricsQueryResult.getMetrics();
+ List metrics = metricsQueryResult.getMetrics();
assertEquals(1, metrics.size());
- Metric successfulCallsMetric = metrics.get(0);
- assertEquals("SuccessfulCalls", successfulCallsMetric.getMetricsName());
- assertEquals("Microsoft.Insights/metrics", successfulCallsMetric.getType());
+ MetricResult successfulCallsMetric = metrics.get(0);
+ assertEquals("SuccessfulCalls", successfulCallsMetric.getMetricName());
+ assertEquals("Microsoft.Insights/metrics", successfulCallsMetric.getResourceType());
assertEquals(1, successfulCallsMetric.getTimeSeries().size());
Assertions.assertTrue(successfulCallsMetric.getTimeSeries()
.stream()
- .flatMap(timeSeriesElement -> timeSeriesElement.getData().stream())
+ .flatMap(timeSeriesElement -> timeSeriesElement.getValues().stream())
.anyMatch(metricsValue -> Double.compare(0.0, metricsValue.getCount()) == 0));
}