Skip to content

Azure Monitor Query: Update to latest GA service version #39051

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions sdk/monitor/azure-monitor-query/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ MetricsQueryClient metricsQueryClient = new MetricsQueryClientBuilder()
```

```java readme-sample-createMetricsBatchQueryClient
MetricsBatchQueryClient metricsBatchQueryClient = new MetricsBatchQueryClientBuilder()
MetricsClient metricsBatchQueryClient = new MetricsClientBuilder()
.credential(new DefaultAzureCredentialBuilder().build())
.endpoint("{endpoint}")
.buildClient();
Expand All @@ -130,7 +130,7 @@ MetricsQueryAsyncClient metricsQueryAsyncClient = new MetricsQueryClientBuilder(
```

```java readme-sample-createMetricsBatchQueryAsyncClient
MetricsBatchQueryAsyncClient metricsBatchQueryAsyncClient = new MetricsBatchQueryClientBuilder()
MetricsAsyncClient metricsAsyncClient = new MetricsClientBuilder()
.credential(new DefaultAzureCredentialBuilder().build())
.endpoint("{endpoint}")
.buildAsyncClient();
Expand Down Expand Up @@ -534,7 +534,7 @@ for (MetricResult metric : metricsQueryResult.getMetrics()) {
#### Handle metrics batch query response

```java readme-sample-metricsquerybatch
MetricsBatchQueryClient metricsBatchQueryClient = new MetricsBatchQueryClientBuilder()
MetricsClient metricsBatchQueryClient = new MetricsClientBuilder()
.credential(new DefaultAzureCredentialBuilder().build())
.endpoint("{endpoint}")
.buildClient();
Expand Down
2 changes: 1 addition & 1 deletion sdk/monitor/azure-monitor-query/assets.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
"AssetsRepo": "Azure/azure-sdk-assets",
"AssetsRepoPrefixPath": "java",
"TagPrefix": "java/monitor/azure-monitor-query",
"Tag": "java/monitor/azure-monitor-query_a12f5cac4c"
"Tag": "java/monitor/azure-monitor-query_cc58179f15"
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
* This class provides an asynchronous client that contains all the query operations that use batch requests to retrieve
* metrics for multiple resources.
*/
@ServiceClient(builder = MetricsBatchQueryClientBuilder.class, isAsync = true)
public final class MetricsBatchQueryAsyncClient {
private static final ClientLogger LOGGER = new ClientLogger(MetricsBatchQueryAsyncClient.class);
@ServiceClient(builder = MetricsClientBuilder.class, isAsync = true)
public final class MetricsAsyncClient {
private static final ClientLogger LOGGER = new ClientLogger(MetricsAsyncClient.class);

private final AzureMonitorMetricBatch serviceClient;

MetricsBatchQueryAsyncClient(AzureMonitorMetricBatch azureMonitorMetricBatch) {
MetricsAsyncClient(AzureMonitorMetricBatch azureMonitorMetricBatch) {
this.serviceClient = azureMonitorMetricBatch;
}

Expand Down Expand Up @@ -91,7 +91,9 @@ public Mono<Response<MetricsBatchQueryResult>> queryBatchWithResponse(List<Strin
Integer top = null;
String orderBy = null;
String endTime = null;
String rollupBy = null;
if (options != null) {
rollupBy = options.getRollupBy();
filter = options.getFilter();
granularity = options.getGranularity();

Expand Down Expand Up @@ -122,7 +124,7 @@ public Mono<Response<MetricsBatchQueryResult>> queryBatchWithResponse(List<Strin
resourceIdList.setResourceids(resourceUris);
Mono<Response<MetricResultsResponse>> responseMono = this.serviceClient.getMetricsBatches()
.batchWithResponseAsync(subscriptionId, metricsNamespace, metricsNames, resourceIdList, startTime,
endTime, granularity, aggregations, top, orderBy, filter, null);
endTime, granularity, aggregations, top, orderBy, filter, rollupBy);


return responseMono.map(response -> {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@
* This class provides an asynchronous client that contains all the query operations that use batch requests to retrieve
* metrics for multiple resources.
*/
@ServiceClient(builder = MetricsBatchQueryClientBuilder.class)
public final class MetricsBatchQueryClient {
private static final ClientLogger LOGGER = new ClientLogger(MetricsBatchQueryClient.class);
@ServiceClient(builder = MetricsClientBuilder.class)
public final class MetricsClient {
private static final ClientLogger LOGGER = new ClientLogger(MetricsClient.class);

private final AzureMonitorMetricBatch serviceClient;

MetricsBatchQueryClient(AzureMonitorMetricBatch azureMonitorMetricBatch) {
MetricsClient(AzureMonitorMetricBatch azureMonitorMetricBatch) {
this.serviceClient = azureMonitorMetricBatch;
}

Expand Down Expand Up @@ -90,7 +90,9 @@ public Response<MetricsBatchQueryResult> queryBatchWithResponse(List<String> res
Integer top = null;
String orderBy = null;
String endTime = null;
String rollupBy = null;
if (options != null) {
rollupBy = options.getRollupBy();
filter = options.getFilter();
granularity = options.getGranularity();

Expand Down Expand Up @@ -121,7 +123,7 @@ public Response<MetricsBatchQueryResult> queryBatchWithResponse(List<String> res
resourceIdList.setResourceids(resourceUris);
Response<MetricResultsResponse> response = this.serviceClient.getMetricsBatches()
.batchWithResponse(subscriptionId, metricsNamespace, metricsNames, resourceIdList, startTime,
endTime, granularity, aggregations, top, orderBy, filter, context);
endTime, granularity, aggregations, top, orderBy, filter, rollupBy, context);
MetricResultsResponse value = response.getValue();
List<MetricResultsResponseValuesItem> values = value.getValues();
List<MetricsQueryResult> metricsQueryResults = values.stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,147 +20,147 @@
import com.azure.monitor.query.implementation.metricsbatch.AzureMonitorMetricBatchBuilder;

/**
* Fluent builder for creating instances of {@link MetricsBatchQueryClient} and {@link MetricsBatchQueryAsyncClient}.
* Fluent builder for creating instances of {@link MetricsClient} and {@link MetricsAsyncClient}.
*/
@ServiceClientBuilder(serviceClients = {MetricsBatchQueryClient.class, MetricsBatchQueryAsyncClient.class})
public final class MetricsBatchQueryClientBuilder implements EndpointTrait<MetricsBatchQueryClientBuilder>,
HttpTrait<MetricsBatchQueryClientBuilder>, ConfigurationTrait<MetricsBatchQueryClientBuilder>, TokenCredentialTrait<MetricsBatchQueryClientBuilder> {
@ServiceClientBuilder(serviceClients = {MetricsClient.class, MetricsAsyncClient.class})
public final class MetricsClientBuilder implements EndpointTrait<MetricsClientBuilder>,
HttpTrait<MetricsClientBuilder>, ConfigurationTrait<MetricsClientBuilder>, TokenCredentialTrait<MetricsClientBuilder> {

private final AzureMonitorMetricBatchBuilder innerMetricsBatchBuilder = new AzureMonitorMetricBatchBuilder();

/**
* Sets the metrics batch query endpoint.
* @param endpoint the endpoint.
* @return the {@link MetricsBatchQueryClientBuilder}.
* @return the {@link MetricsClientBuilder}.
*/
@Override
public MetricsBatchQueryClientBuilder endpoint(String endpoint) {
public MetricsClientBuilder endpoint(String endpoint) {
innerMetricsBatchBuilder.endpoint(endpoint);
return this;
}

/**
* Sets The HTTP pipeline to send requests through.
* @param pipeline the pipeline value.
* @return the {@link MetricsBatchQueryClientBuilder}.
* @return the {@link MetricsClientBuilder}.
*/
@Override
public MetricsBatchQueryClientBuilder pipeline(HttpPipeline pipeline) {
public MetricsClientBuilder pipeline(HttpPipeline pipeline) {
innerMetricsBatchBuilder.pipeline(pipeline);
return this;
}

/**
* Sets The HTTP client used to send the request.
* @param httpClient the httpClient value.
* @return the {@link MetricsBatchQueryClientBuilder}.
* @return the {@link MetricsClientBuilder}.
*/
@Override
public MetricsBatchQueryClientBuilder httpClient(HttpClient httpClient) {
public MetricsClientBuilder httpClient(HttpClient httpClient) {
innerMetricsBatchBuilder.httpClient(httpClient);
return this;
}

/**
* Sets The configuration store that is used during construction of the service client.
* @param configuration the configuration value.
* @return the {@link MetricsBatchQueryClientBuilder}.
* @return the {@link MetricsClientBuilder}.
*/
@Override
public MetricsBatchQueryClientBuilder configuration(Configuration configuration) {
public MetricsClientBuilder configuration(Configuration configuration) {
innerMetricsBatchBuilder.configuration(configuration);
return this;
}

/**
* Sets The logging configuration for HTTP requests and responses.
* @param httpLogOptions the httpLogOptions value.
* @return the {@link MetricsBatchQueryClientBuilder}.
* @return the {@link MetricsClientBuilder}.
*/
@Override
public MetricsBatchQueryClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) {
public MetricsClientBuilder httpLogOptions(HttpLogOptions httpLogOptions) {
innerMetricsBatchBuilder.httpLogOptions(httpLogOptions);
return this;
}

/**
* Sets The retry policy that will attempt to retry failed requests, if applicable.
* @param retryPolicy the retryPolicy value.
* @return the {@link MetricsBatchQueryClientBuilder}.
* @return the {@link MetricsClientBuilder}.
*/
public MetricsBatchQueryClientBuilder retryPolicy(RetryPolicy retryPolicy) {
public MetricsClientBuilder retryPolicy(RetryPolicy retryPolicy) {
innerMetricsBatchBuilder.retryPolicy(retryPolicy);
return this;
}

/**
* Sets the {@link RetryOptions} used for creating the client.
* @param retryOptions The {@link RetryOptions}.
* @return the updated {@link MetricsBatchQueryClientBuilder}.
* @return the updated {@link MetricsClientBuilder}.
*/
@Override
public MetricsBatchQueryClientBuilder retryOptions(RetryOptions retryOptions) {
public MetricsClientBuilder retryOptions(RetryOptions retryOptions) {
innerMetricsBatchBuilder.retryOptions(retryOptions);
return this;
}

/**
* Adds a custom Http pipeline policy.
* @param customPolicy The custom Http pipeline policy to add.
* @return the {@link MetricsBatchQueryClientBuilder}.
* @return the {@link MetricsClientBuilder}.
*/
@Override
public MetricsBatchQueryClientBuilder addPolicy(HttpPipelinePolicy customPolicy) {
public MetricsClientBuilder addPolicy(HttpPipelinePolicy customPolicy) {
innerMetricsBatchBuilder.addPolicy(customPolicy);
return this;
}

/**
* Sets The TokenCredential used for authentication.
* @param tokenCredential the tokenCredential value.
* @return the {@link MetricsBatchQueryClientBuilder}.
* @return the {@link MetricsClientBuilder}.
*/
@Override
public MetricsBatchQueryClientBuilder credential(TokenCredential tokenCredential) {
public MetricsClientBuilder credential(TokenCredential tokenCredential) {
innerMetricsBatchBuilder.credential(tokenCredential);
return this;
}

/**
* Set the {@link ClientOptions} used for creating the client.
* @param clientOptions The {@link ClientOptions}.
* @return the {@link MetricsBatchQueryClientBuilder}.
* @return the {@link MetricsClientBuilder}.
*/
@Override
public MetricsBatchQueryClientBuilder clientOptions(ClientOptions clientOptions) {
public MetricsClientBuilder clientOptions(ClientOptions clientOptions) {
innerMetricsBatchBuilder.clientOptions(clientOptions);
return this;
}

/**
* The service version to use when creating the client.
* @param serviceVersion The {@link MetricsBatchQueryServiceVersion}.
* @return the {@link MetricsBatchQueryClientBuilder}.
* @param serviceVersion The {@link MetricsServiceVersion}.
* @return the {@link MetricsClientBuilder}.
*/
public MetricsBatchQueryClientBuilder serviceVersion(MetricsBatchQueryServiceVersion serviceVersion) {
public MetricsClientBuilder serviceVersion(MetricsServiceVersion serviceVersion) {
innerMetricsBatchBuilder.apiVersion(serviceVersion.getVersion());
return this;
}

/**
* Creates a synchronous client with the configured options in this builder.
* @return A synchronous {@link MetricsBatchQueryClient}.
* @return A synchronous {@link MetricsClient}.
*/
public MetricsBatchQueryClient buildClient() {
return new MetricsBatchQueryClient(innerMetricsBatchBuilder.buildClient());
public MetricsClient buildClient() {
return new MetricsClient(innerMetricsBatchBuilder.buildClient());
}

/**
* Creates an asynchronous client with the configured options in this builder.
* @return An asynchronous {@link MetricsBatchQueryAsyncClient}.
* @return An asynchronous {@link MetricsAsyncClient}.
*/
public MetricsBatchQueryAsyncClient buildAsyncClient() {
return new MetricsBatchQueryAsyncClient(innerMetricsBatchBuilder.buildClient());
public MetricsAsyncClient buildAsyncClient() {
return new MetricsAsyncClient(innerMetricsBatchBuilder.buildClient());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ Mono<Response<MetricsQueryResult>> queryResourceWithResponse(String resourceUri,
.getMetrics()
.listWithResponseAsync(resourceUri, timespan, options.getGranularity(),
String.join(",", metricsNames), aggregation, options.getTop(), options.getOrderBy(),
options.getFilter(), ResultType.DATA, options.getMetricNamespace(), context)
options.getFilter(), ResultType.DATA, options.getMetricNamespace(), null, null, null, context)
.map(response -> convertToMetricsQueryResult(response))
.onErrorMap(ErrorResponseException.class, ex -> {
return new HttpResponseException(ex.getMessage(), ex.getResponse(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public Response<MetricsQueryResult> queryResourceWithResponse(String resourceUri
Response<MetricsResponse> metricsResponseResponse = metricsClient
.getMetrics()
.listWithResponse(resourceUri, timespan, granularity, String.join(",", metricsNames),
aggregation, top, orderBy, filter, ResultType.DATA, metricNamespace, context);
aggregation, top, orderBy, filter, ResultType.DATA, metricNamespace, null, null, null, context);
return convertToMetricsQueryResult(metricsResponseResponse);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.monitor.query;

import com.azure.core.util.ServiceVersion;

/**
* The versions of Azure Monitor Metrics Query supported by this client library.
*/
public enum MetricsServiceVersion implements ServiceVersion {
/**
* The preview version of the Metrics Query service.
*/
V2023_10_01("2023-10-01");

private final String version;

MetricsServiceVersion(String version) {
this.version = version;
}

@Override
public String getVersion() {
return version;
}

/**
* Gets the latest service version supported by this client library.
* @return the latest {@link MetricsServiceVersion}.
*/
public static MetricsServiceVersion getLatest() {
return V2023_10_01;
}
}
Loading