From f8621455f5ee728cbe57280727a2110775aa785b Mon Sep 17 00:00:00 2001 From: Srikanta Date: Fri, 2 Jul 2021 13:29:00 -0700 Subject: [PATCH 1/3] Fix readme and regenerate code --- sdk/monitor/azure-monitor-query/README.md | 4 +- .../monitor/query/LogsQueryAsyncClient.java | 43 ++++- .../models/BatchQueryResponse.java | 6 +- .../models/BatchQueryResults.java | 131 +++++++++++++++ .../implementation/models/QueryResults.java | 30 +++- .../log/implementation/models/Table.java | 6 +- .../metrics/implementation/MetricsImpl.java | 152 ++++++++++-------- .../MonitorManagementClientImplBuilder.java | 6 +- .../metrics/implementation/models/Metric.java | 49 ++++-- .../implementation/models/MetricValue.java | 6 +- .../models/MetricsResponse.java | 12 +- .../implementation/MetricDefinitionsImpl.java | 4 +- .../monitor/query/models/LogsTableCell.java | 4 +- .../monitor/query/models/MetricClass.java | 42 +++++ .../query/models/MetricDefinition.java | 84 +++++++++- .../monitor/query/models/MetricValue.java | 6 +- .../query/models/NamespaceClassification.java | 47 ++---- .../azure/monitor/query/ReadmeSamples.java | 34 ++-- ...tricsQueryClientTest.testMetricsQuery.json | 4 +- .../azure-monitor-query/swagger/README.md | 8 +- 20 files changed, 515 insertions(+), 163 deletions(-) create mode 100644 sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchQueryResults.java create mode 100644 sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricClass.java diff --git a/sdk/monitor/azure-monitor-query/README.md b/sdk/monitor/azure-monitor-query/README.md index f2b6721085a9c..59156824fb76f 100644 --- a/sdk/monitor/azure-monitor-query/README.md +++ b/sdk/monitor/azure-monitor-query/README.md @@ -419,11 +419,11 @@ comments. [samples_readme]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/monitor/azure-monitor-query/src/samples/java/README.md -[azure_subscription]: https://azure.microsoft.com/free +[azure_subscription]: http://azure.microsoft.com/free/java [jdk_link]: https://docs.microsoft.com/java/azure/jdk/?view=azure-java-stable -[product_documentation]: https://aka.ms/awps/doc +[product_documentation]: https://docs.microsoft.com/azure/azure-monitor/overview [log_levels]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/core/azure-core/src/main/java/com/azure/core/util/logging/ClientLogger.java diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/LogsQueryAsyncClient.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/LogsQueryAsyncClient.java index ca38775fc3b4a..dade59355db2f 100644 --- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/LogsQueryAsyncClient.java +++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/LogsQueryAsyncClient.java @@ -13,6 +13,7 @@ import com.azure.monitor.query.log.implementation.AzureLogAnalyticsImpl; import com.azure.monitor.query.log.implementation.models.BatchQueryRequest; import com.azure.monitor.query.log.implementation.models.BatchQueryResponse; +import com.azure.monitor.query.log.implementation.models.BatchQueryResults; 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.ErrorInfo; @@ -258,10 +259,48 @@ private LogsQueryResult getLogsQueryResult(QueryResults queryResults) { List tableColumns = new ArrayList<>(); LogsTable logsTable = new LogsTable(tableCells, tableRows, tableColumns); tables.add(logsTable); - List> rows = table.getRows(); + List> rows = table.getRows(); for (int i = 0; i < rows.size(); i++) { - List row = rows.get(i); + List row = rows.get(i); + LogsTableRow tableRow = new LogsTableRow(i, new ArrayList<>()); + tableRows.add(tableRow); + for (int j = 0; j < row.size(); j++) { + LogsTableCell cell = new LogsTableCell(table.getColumns().get(j).getName(), + table.getColumns().get(j).getType(), j, i, row.get(j)); + tableCells.add(cell); + tableRow.getTableRow().add(cell); + } + } + } + } + + LogsQueryStatistics statistics = null; + + if (queryResults.getStatistics() != null) { + statistics = new LogsQueryStatistics(queryResults.getStatistics()); + } + + LogsQueryResult logsQueryResult = new LogsQueryResult(tables, statistics, + mapLogsQueryError(queryResults.getError())); + return logsQueryResult; + } + + private LogsQueryResult getLogsQueryResult(BatchQueryResults queryResults) { + List tables = null; + + if (queryResults.getTables() != null) { + tables = new ArrayList<>(); + for (Table table : queryResults.getTables()) { + List tableCells = new ArrayList<>(); + List tableRows = new ArrayList<>(); + List tableColumns = new ArrayList<>(); + LogsTable logsTable = new LogsTable(tableCells, tableRows, tableColumns); + tables.add(logsTable); + List> rows = table.getRows(); + + for (int i = 0; i < rows.size(); i++) { + List row = rows.get(i); LogsTableRow tableRow = new LogsTableRow(i, new ArrayList<>()); tableRows.add(tableRow); for (int j = 0; j < row.size(); j++) { 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/log/implementation/models/BatchQueryResponse.java index 2808ee98a7856..0d90a0599f4b5 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/log/implementation/models/BatchQueryResponse.java @@ -27,7 +27,7 @@ public final class BatchQueryResponse { * Contains the tables, columns & rows resulting from a query. */ @JsonProperty(value = "body") - private QueryResults body; + private BatchQueryResults body; /* * Dictionary of @@ -80,7 +80,7 @@ public BatchQueryResponse setStatus(Integer status) { * * @return the body value. */ - public QueryResults getBody() { + public BatchQueryResults getBody() { return this.body; } @@ -90,7 +90,7 @@ public QueryResults getBody() { * @param body the body value to set. * @return the BatchQueryResponse object itself. */ - public BatchQueryResponse setBody(QueryResults body) { + public BatchQueryResponse setBody(BatchQueryResults body) { this.body = body; return this; } 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/log/implementation/models/BatchQueryResults.java new file mode 100644 index 0000000000000..3daf562c3fdce --- /dev/null +++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/log/implementation/models/BatchQueryResults.java @@ -0,0 +1,131 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. +// Code generated by Microsoft (R) AutoRest Code Generator. + +package com.azure.monitor.query.log.implementation.models; + +import com.azure.core.annotation.Fluent; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.List; + +/** Contains the tables, columns & rows resulting from a query. */ +@Fluent +public final class BatchQueryResults { + /* + * The list of tables, columns and rows. + */ + @JsonProperty(value = "tables") + private List tables; + + /* + * Statistics represented in JSON format. + */ + @JsonProperty(value = "statistics") + private Object statistics; + + /* + * Visualization data in JSON format. + */ + @JsonProperty(value = "render") + private Object render; + + /* + * The code and message for an error. + */ + @JsonProperty(value = "error") + private ErrorInfo error; + + /** + * Get the tables property: The list of tables, columns and rows. + * + * @return the tables value. + */ + public List
getTables() { + return this.tables; + } + + /** + * Set the tables property: The list of tables, columns and rows. + * + * @param tables the tables value to set. + * @return the BatchQueryResults object itself. + */ + public BatchQueryResults setTables(List
tables) { + this.tables = tables; + return this; + } + + /** + * Get the statistics property: Statistics represented in JSON format. + * + * @return the statistics value. + */ + public Object getStatistics() { + return this.statistics; + } + + /** + * Set the statistics property: Statistics represented in JSON format. + * + * @param statistics the statistics value to set. + * @return the BatchQueryResults object itself. + */ + public BatchQueryResults setStatistics(Object statistics) { + this.statistics = statistics; + return this; + } + + /** + * Get the render property: Visualization data in JSON format. + * + * @return the render value. + */ + public Object getRender() { + return this.render; + } + + /** + * Set the render property: Visualization data in JSON format. + * + * @param render the render value to set. + * @return the BatchQueryResults object itself. + */ + public BatchQueryResults setRender(Object render) { + this.render = render; + return this; + } + + /** + * Get the error property: The code and message for an error. + * + * @return the error value. + */ + public ErrorInfo getError() { + return this.error; + } + + /** + * Set the error property: The code and message for an error. + * + * @param error the error value to set. + * @return the BatchQueryResults object itself. + */ + public BatchQueryResults setError(ErrorInfo error) { + this.error = error; + return this; + } + + /** + * Validates the instance. + * + * @throws IllegalArgumentException thrown if the instance is not valid. + */ + public void validate() { + if (getTables() != null) { + getTables().forEach(e -> e.validate()); + } + if (getError() != null) { + getError().validate(); + } + } +} 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/log/implementation/models/QueryResults.java index bdf22cebd1b1d..ecd8560b9d1a5 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/log/implementation/models/QueryResults.java @@ -15,7 +15,7 @@ public final class QueryResults { /* * The list of tables, columns and rows. */ - @JsonProperty(value = "tables") + @JsonProperty(value = "tables", required = true) private List
tables; /* @@ -24,6 +24,12 @@ public final class QueryResults { @JsonProperty(value = "statistics") private Object statistics; + /* + * Visualization data in JSON format. + */ + @JsonProperty(value = "render") + private Object render; + /* * The code and message for an error. */ @@ -36,7 +42,7 @@ public final class QueryResults { * @param tables the tables value to set. */ @JsonCreator - public QueryResults(@JsonProperty(value = "tables") List
tables) { + public QueryResults(@JsonProperty(value = "tables", required = true) List
tables) { this.tables = tables; } @@ -69,6 +75,26 @@ public QueryResults setStatistics(Object statistics) { return this; } + /** + * Get the render property: Visualization data in JSON format. + * + * @return the render value. + */ + public Object getRender() { + return this.render; + } + + /** + * Set the render property: Visualization data in JSON format. + * + * @param render the render value to set. + * @return the QueryResults object itself. + */ + public QueryResults setRender(Object render) { + this.render = render; + return this; + } + /** * Get the error property: The code and message for an error. * 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/log/implementation/models/Table.java index 94580808a0cc7..aecb1c1cc23b7 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/log/implementation/models/Table.java @@ -28,7 +28,7 @@ public final class Table { * The resulting rows from this query. */ @JsonProperty(value = "rows", required = true) - private List> rows; + private List> rows; /** * Creates an instance of Table class. @@ -41,7 +41,7 @@ public final class Table { public Table( @JsonProperty(value = "name", required = true) String name, @JsonProperty(value = "columns", required = true) List columns, - @JsonProperty(value = "rows", required = true) List> rows) { + @JsonProperty(value = "rows", required = true) List> rows) { this.name = name; this.columns = columns; this.rows = rows; @@ -70,7 +70,7 @@ public List getColumns() { * * @return the rows value. */ - public List> getRows() { + public List> getRows() { return this.rows; } 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/metrics/implementation/MetricsImpl.java index 72d486f94a852..0f6870be52e5b 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/metrics/implementation/MetricsImpl.java @@ -58,7 +58,7 @@ Mono> list( @PathParam(value = "resourceUri", encoded = true) String resourceUri, @QueryParam("timespan") String timespan, @QueryParam("interval") Duration interval, - @QueryParam("metric") String metric, + @QueryParam("metricnames") String metricnames, @QueryParam("aggregation") String aggregation, @QueryParam("top") Integer top, @QueryParam("orderby") String orderby, @@ -77,19 +77,22 @@ Mono> list( * @param timespan The timespan of the query. It is a string with the following format * 'startDateTime_ISO/endDateTime_ISO'. * @param interval The interval (i.e. timegrain) of the query. - * @param metric The name of the metric to retrieve. + * @param metricnames The names of the metrics (comma separated) to retrieve. Special case: If a metricname itself + * has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be **'Metric%2Name1'**. * @param aggregation The list of aggregation types (comma separated) to retrieve. * @param top The maximum number of records to retrieve. Valid only if $filter is specified. Defaults to 10. * @param orderby The aggregation to use for sorting results and the direction of the sort. Only one order can be * specified. Examples: sum asc. - * @param filter The **$filter** is used to reduce the set of metric data - * returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series - * of C where A = a1 and B = b1 or b2<br>**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq - * ‘*’**<br>- Invalid variant:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = - * ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata - * names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**$filter=A eq ‘a1’ and B - * eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**$filter=A eq ‘a1’ and B eq - * ‘*’ and C eq ‘*’**. + * @param filter The **$filter** is used to reduce the set of metric data returned. Example: Metric contains + * metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or b2 **$filter=A eq 'a1' and B eq + * 'b1' or B eq 'b2' and C eq '*'** - Invalid variant: **$filter=A eq 'a1' and B eq 'b1' and C eq '*' or B = + * 'b2'** This is invalid because the logical or operator cannot separate two different metadata names. - Return + * all time series where A = a1, B = b1 and C = c1: **$filter=A eq 'a1' and B eq 'b1' and C eq 'c1'** - Return + * all time series where A = a1 **$filter=A eq 'a1' and B eq '*' and C eq '*'**. Special case: When dimension + * name or dimension value uses round brackets. Eg: When dimension name is **dim (test) 1** Instead of using + * $filter= "dim (test) 1 eq '*' " use **$filter= "dim %2528test%2529 1 eq '*' "** When dimension name is **dim + * (test) 3** and dimension value is **dim3 (test) val** Instead of using $filter= "dim (test) 3 eq 'dim3 (test) + * val' " use **$filter= "dim %2528test%2529 3 eq 'dim3 %2528test%2529 val' "**. * @param resultType Reduces the set of data collected. The syntax allowed depends on the operation. See the * operation's description for details. * @param metricnamespace Metric namespace to query metric definitions for. @@ -103,7 +106,7 @@ public Mono> listWithResponseAsync( String resourceUri, String timespan, Duration interval, - String metric, + String metricnames, String aggregation, Integer top, String orderby, @@ -125,7 +128,7 @@ public Mono> listWithResponseAsync( resourceUri, timespan, interval, - metric, + metricnames, aggregation, top, orderby, @@ -144,19 +147,22 @@ public Mono> listWithResponseAsync( * @param timespan The timespan of the query. It is a string with the following format * 'startDateTime_ISO/endDateTime_ISO'. * @param interval The interval (i.e. timegrain) of the query. - * @param metric The name of the metric to retrieve. + * @param metricnames The names of the metrics (comma separated) to retrieve. Special case: If a metricname itself + * has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be **'Metric%2Name1'**. * @param aggregation The list of aggregation types (comma separated) to retrieve. * @param top The maximum number of records to retrieve. Valid only if $filter is specified. Defaults to 10. * @param orderby The aggregation to use for sorting results and the direction of the sort. Only one order can be * specified. Examples: sum asc. - * @param filter The **$filter** is used to reduce the set of metric data - * returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series - * of C where A = a1 and B = b1 or b2<br>**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq - * ‘*’**<br>- Invalid variant:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = - * ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata - * names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**$filter=A eq ‘a1’ and B - * eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**$filter=A eq ‘a1’ and B eq - * ‘*’ and C eq ‘*’**. + * @param filter The **$filter** is used to reduce the set of metric data returned. Example: Metric contains + * metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or b2 **$filter=A eq 'a1' and B eq + * 'b1' or B eq 'b2' and C eq '*'** - Invalid variant: **$filter=A eq 'a1' and B eq 'b1' and C eq '*' or B = + * 'b2'** This is invalid because the logical or operator cannot separate two different metadata names. - Return + * all time series where A = a1, B = b1 and C = c1: **$filter=A eq 'a1' and B eq 'b1' and C eq 'c1'** - Return + * all time series where A = a1 **$filter=A eq 'a1' and B eq '*' and C eq '*'**. Special case: When dimension + * name or dimension value uses round brackets. Eg: When dimension name is **dim (test) 1** Instead of using + * $filter= "dim (test) 1 eq '*' " use **$filter= "dim %2528test%2529 1 eq '*' "** When dimension name is **dim + * (test) 3** and dimension value is **dim3 (test) val** Instead of using $filter= "dim (test) 3 eq 'dim3 (test) + * val' " use **$filter= "dim %2528test%2529 3 eq 'dim3 %2528test%2529 val' "**. * @param resultType Reduces the set of data collected. The syntax allowed depends on the operation. See the * operation's description for details. * @param metricnamespace Metric namespace to query metric definitions for. @@ -171,7 +177,7 @@ public Mono> listWithResponseAsync( String resourceUri, String timespan, Duration interval, - String metric, + String metricnames, String aggregation, Integer top, String orderby, @@ -192,7 +198,7 @@ public Mono> listWithResponseAsync( resourceUri, timespan, interval, - metric, + metricnames, aggregation, top, orderby, @@ -211,19 +217,22 @@ public Mono> listWithResponseAsync( * @param timespan The timespan of the query. It is a string with the following format * 'startDateTime_ISO/endDateTime_ISO'. * @param interval The interval (i.e. timegrain) of the query. - * @param metric The name of the metric to retrieve. + * @param metricnames The names of the metrics (comma separated) to retrieve. Special case: If a metricname itself + * has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be **'Metric%2Name1'**. * @param aggregation The list of aggregation types (comma separated) to retrieve. * @param top The maximum number of records to retrieve. Valid only if $filter is specified. Defaults to 10. * @param orderby The aggregation to use for sorting results and the direction of the sort. Only one order can be * specified. Examples: sum asc. - * @param filter The **$filter** is used to reduce the set of metric data - * returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series - * of C where A = a1 and B = b1 or b2<br>**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq - * ‘*’**<br>- Invalid variant:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = - * ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata - * names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**$filter=A eq ‘a1’ and B - * eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**$filter=A eq ‘a1’ and B eq - * ‘*’ and C eq ‘*’**. + * @param filter The **$filter** is used to reduce the set of metric data returned. Example: Metric contains + * metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or b2 **$filter=A eq 'a1' and B eq + * 'b1' or B eq 'b2' and C eq '*'** - Invalid variant: **$filter=A eq 'a1' and B eq 'b1' and C eq '*' or B = + * 'b2'** This is invalid because the logical or operator cannot separate two different metadata names. - Return + * all time series where A = a1, B = b1 and C = c1: **$filter=A eq 'a1' and B eq 'b1' and C eq 'c1'** - Return + * all time series where A = a1 **$filter=A eq 'a1' and B eq '*' and C eq '*'**. Special case: When dimension + * name or dimension value uses round brackets. Eg: When dimension name is **dim (test) 1** Instead of using + * $filter= "dim (test) 1 eq '*' " use **$filter= "dim %2528test%2529 1 eq '*' "** When dimension name is **dim + * (test) 3** and dimension value is **dim3 (test) val** Instead of using $filter= "dim (test) 3 eq 'dim3 (test) + * val' " use **$filter= "dim %2528test%2529 3 eq 'dim3 %2528test%2529 val' "**. * @param resultType Reduces the set of data collected. The syntax allowed depends on the operation. See the * operation's description for details. * @param metricnamespace Metric namespace to query metric definitions for. @@ -237,7 +246,7 @@ public Mono listAsync( String resourceUri, String timespan, Duration interval, - String metric, + String metricnames, String aggregation, Integer top, String orderby, @@ -248,7 +257,7 @@ public Mono listAsync( resourceUri, timespan, interval, - metric, + metricnames, aggregation, top, orderby, @@ -272,19 +281,22 @@ public Mono listAsync( * @param timespan The timespan of the query. It is a string with the following format * 'startDateTime_ISO/endDateTime_ISO'. * @param interval The interval (i.e. timegrain) of the query. - * @param metric The name of the metric to retrieve. + * @param metricnames The names of the metrics (comma separated) to retrieve. Special case: If a metricname itself + * has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be **'Metric%2Name1'**. * @param aggregation The list of aggregation types (comma separated) to retrieve. * @param top The maximum number of records to retrieve. Valid only if $filter is specified. Defaults to 10. * @param orderby The aggregation to use for sorting results and the direction of the sort. Only one order can be * specified. Examples: sum asc. - * @param filter The **$filter** is used to reduce the set of metric data - * returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series - * of C where A = a1 and B = b1 or b2<br>**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq - * ‘*’**<br>- Invalid variant:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = - * ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata - * names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**$filter=A eq ‘a1’ and B - * eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**$filter=A eq ‘a1’ and B eq - * ‘*’ and C eq ‘*’**. + * @param filter The **$filter** is used to reduce the set of metric data returned. Example: Metric contains + * metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or b2 **$filter=A eq 'a1' and B eq + * 'b1' or B eq 'b2' and C eq '*'** - Invalid variant: **$filter=A eq 'a1' and B eq 'b1' and C eq '*' or B = + * 'b2'** This is invalid because the logical or operator cannot separate two different metadata names. - Return + * all time series where A = a1, B = b1 and C = c1: **$filter=A eq 'a1' and B eq 'b1' and C eq 'c1'** - Return + * all time series where A = a1 **$filter=A eq 'a1' and B eq '*' and C eq '*'**. Special case: When dimension + * name or dimension value uses round brackets. Eg: When dimension name is **dim (test) 1** Instead of using + * $filter= "dim (test) 1 eq '*' " use **$filter= "dim %2528test%2529 1 eq '*' "** When dimension name is **dim + * (test) 3** and dimension value is **dim3 (test) val** Instead of using $filter= "dim (test) 3 eq 'dim3 (test) + * val' " use **$filter= "dim %2528test%2529 3 eq 'dim3 %2528test%2529 val' "**. * @param resultType Reduces the set of data collected. The syntax allowed depends on the operation. See the * operation's description for details. * @param metricnamespace Metric namespace to query metric definitions for. @@ -299,7 +311,7 @@ public Mono listAsync( String resourceUri, String timespan, Duration interval, - String metric, + String metricnames, String aggregation, Integer top, String orderby, @@ -311,7 +323,7 @@ public Mono listAsync( resourceUri, timespan, interval, - metric, + metricnames, aggregation, top, orderby, @@ -336,19 +348,22 @@ public Mono listAsync( * @param timespan The timespan of the query. It is a string with the following format * 'startDateTime_ISO/endDateTime_ISO'. * @param interval The interval (i.e. timegrain) of the query. - * @param metric The name of the metric to retrieve. + * @param metricnames The names of the metrics (comma separated) to retrieve. Special case: If a metricname itself + * has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be **'Metric%2Name1'**. * @param aggregation The list of aggregation types (comma separated) to retrieve. * @param top The maximum number of records to retrieve. Valid only if $filter is specified. Defaults to 10. * @param orderby The aggregation to use for sorting results and the direction of the sort. Only one order can be * specified. Examples: sum asc. - * @param filter The **$filter** is used to reduce the set of metric data - * returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series - * of C where A = a1 and B = b1 or b2<br>**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq - * ‘*’**<br>- Invalid variant:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = - * ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata - * names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**$filter=A eq ‘a1’ and B - * eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**$filter=A eq ‘a1’ and B eq - * ‘*’ and C eq ‘*’**. + * @param filter The **$filter** is used to reduce the set of metric data returned. Example: Metric contains + * metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or b2 **$filter=A eq 'a1' and B eq + * 'b1' or B eq 'b2' and C eq '*'** - Invalid variant: **$filter=A eq 'a1' and B eq 'b1' and C eq '*' or B = + * 'b2'** This is invalid because the logical or operator cannot separate two different metadata names. - Return + * all time series where A = a1, B = b1 and C = c1: **$filter=A eq 'a1' and B eq 'b1' and C eq 'c1'** - Return + * all time series where A = a1 **$filter=A eq 'a1' and B eq '*' and C eq '*'**. Special case: When dimension + * name or dimension value uses round brackets. Eg: When dimension name is **dim (test) 1** Instead of using + * $filter= "dim (test) 1 eq '*' " use **$filter= "dim %2528test%2529 1 eq '*' "** When dimension name is **dim + * (test) 3** and dimension value is **dim3 (test) val** Instead of using $filter= "dim (test) 3 eq 'dim3 (test) + * val' " use **$filter= "dim %2528test%2529 3 eq 'dim3 %2528test%2529 val' "**. * @param resultType Reduces the set of data collected. The syntax allowed depends on the operation. See the * operation's description for details. * @param metricnamespace Metric namespace to query metric definitions for. @@ -362,7 +377,7 @@ public MetricsResponse list( String resourceUri, String timespan, Duration interval, - String metric, + String metricnames, String aggregation, Integer top, String orderby, @@ -373,7 +388,7 @@ public MetricsResponse list( resourceUri, timespan, interval, - metric, + metricnames, aggregation, top, orderby, @@ -390,19 +405,22 @@ public MetricsResponse list( * @param timespan The timespan of the query. It is a string with the following format * 'startDateTime_ISO/endDateTime_ISO'. * @param interval The interval (i.e. timegrain) of the query. - * @param metric The name of the metric to retrieve. + * @param metricnames The names of the metrics (comma separated) to retrieve. Special case: If a metricname itself + * has a comma in it then use %2 to indicate it. Eg: 'Metric,Name1' should be **'Metric%2Name1'**. * @param aggregation The list of aggregation types (comma separated) to retrieve. * @param top The maximum number of records to retrieve. Valid only if $filter is specified. Defaults to 10. * @param orderby The aggregation to use for sorting results and the direction of the sort. Only one order can be * specified. Examples: sum asc. - * @param filter The **$filter** is used to reduce the set of metric data - * returned.<br>Example:<br>Metric contains metadata A, B and C.<br>- Return all time series - * of C where A = a1 and B = b1 or b2<br>**$filter=A eq ‘a1’ and B eq ‘b1’ or B eq ‘b2’ and C eq - * ‘*’**<br>- Invalid variant:<br>**$filter=A eq ‘a1’ and B eq ‘b1’ and C eq ‘*’ or B = - * ‘b2’**<br>This is invalid because the logical or operator cannot separate two different metadata - * names.<br>- Return all time series where A = a1, B = b1 and C = c1:<br>**$filter=A eq ‘a1’ and B - * eq ‘b1’ and C eq ‘c1’**<br>- Return all time series where A = a1<br>**$filter=A eq ‘a1’ and B eq - * ‘*’ and C eq ‘*’**. + * @param filter The **$filter** is used to reduce the set of metric data returned. Example: Metric contains + * metadata A, B and C. - Return all time series of C where A = a1 and B = b1 or b2 **$filter=A eq 'a1' and B eq + * 'b1' or B eq 'b2' and C eq '*'** - Invalid variant: **$filter=A eq 'a1' and B eq 'b1' and C eq '*' or B = + * 'b2'** This is invalid because the logical or operator cannot separate two different metadata names. - Return + * all time series where A = a1, B = b1 and C = c1: **$filter=A eq 'a1' and B eq 'b1' and C eq 'c1'** - Return + * all time series where A = a1 **$filter=A eq 'a1' and B eq '*' and C eq '*'**. Special case: When dimension + * name or dimension value uses round brackets. Eg: When dimension name is **dim (test) 1** Instead of using + * $filter= "dim (test) 1 eq '*' " use **$filter= "dim %2528test%2529 1 eq '*' "** When dimension name is **dim + * (test) 3** and dimension value is **dim3 (test) val** Instead of using $filter= "dim (test) 3 eq 'dim3 (test) + * val' " use **$filter= "dim %2528test%2529 3 eq 'dim3 %2528test%2529 val' "**. * @param resultType Reduces the set of data collected. The syntax allowed depends on the operation. See the * operation's description for details. * @param metricnamespace Metric namespace to query metric definitions for. @@ -417,7 +435,7 @@ public Response listWithResponse( String resourceUri, String timespan, Duration interval, - String metric, + String metricnames, String aggregation, Integer top, String orderby, @@ -429,7 +447,7 @@ public Response listWithResponse( resourceUri, timespan, interval, - metric, + metricnames, aggregation, top, orderby, 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/metrics/implementation/MonitorManagementClientImplBuilder.java index 347582b24a5fe..d7e54f31d8255 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/metrics/implementation/MonitorManagementClientImplBuilder.java @@ -211,7 +211,7 @@ public MonitorManagementClientImpl buildClient() { this.host = "https://management.azure.com"; } if (apiVersion == null) { - this.apiVersion = "2017-05-01-preview"; + this.apiVersion = "2018-01-01"; } if (pipeline == null) { this.pipeline = createHttpPipeline(); @@ -236,10 +236,10 @@ private HttpPipeline createHttpPipeline() { policies.add( new UserAgentPolicy(httpLogOptions.getApplicationId(), clientName, clientVersion, buildConfiguration)); HttpPolicyProviders.addBeforeRetryPolicies(policies); + policies.add(retryPolicy == null ? new RetryPolicy() : retryPolicy); BearerTokenAuthenticationPolicy tokenPolicy = new BearerTokenAuthenticationPolicy(this.tokenCredential, " https://management.azure.com" + - "/.default"); + "/.default"); policies.add(tokenPolicy); - policies.add(retryPolicy == null ? new RetryPolicy() : retryPolicy); policies.add(new CookiePolicy()); policies.addAll(this.pipelinePolicies); HttpPolicyProviders.addAfterRetryPolicies(policies); 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/metrics/implementation/models/Metric.java index ac4f76ac3d65e..77e0e23f8b4b1 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/metrics/implementation/models/Metric.java @@ -35,7 +35,7 @@ public final class Metric { /* * Detailed description of this metric. */ - @JsonProperty(value = "displayDescription", required = true) + @JsonProperty(value = "displayDescription") private String displayDescription; /* @@ -45,7 +45,13 @@ public final class Metric { private String errorCode; /* - * the unit of the metric. + * Error message encountered querying this specific metric. + */ + @JsonProperty(value = "errorMessage") + private String errorMessage; + + /* + * The unit of the metric. */ @JsonProperty(value = "unit", required = true) private MetricUnit unit; @@ -62,7 +68,6 @@ public final class Metric { * @param id the id value to set. * @param type the type value to set. * @param name the name value to set. - * @param displayDescription the displayDescription value to set. * @param unit the unit value to set. * @param timeseries the timeseries value to set. */ @@ -71,13 +76,11 @@ public Metric( @JsonProperty(value = "id", required = true) String id, @JsonProperty(value = "type", required = true) String type, @JsonProperty(value = "name", required = true) LocalizableString name, - @JsonProperty(value = "displayDescription", required = true) String displayDescription, @JsonProperty(value = "unit", required = true) MetricUnit unit, @JsonProperty(value = "timeseries", required = true) List timeseries) { this.id = id; this.type = type; this.name = name; - this.displayDescription = displayDescription; this.unit = unit; this.timeseries = timeseries; } @@ -118,6 +121,17 @@ public String getDisplayDescription() { return this.displayDescription; } + /** + * Set the displayDescription property: Detailed description of this metric. + * + * @param displayDescription the displayDescription value to set. + * @return the Metric object itself. + */ + public Metric setDisplayDescription(String displayDescription) { + this.displayDescription = displayDescription; + return this; + } + /** * Get the errorCode property: 'Success' or the error details on query failures for this metric. * @@ -139,7 +153,27 @@ public Metric setErrorCode(String errorCode) { } /** - * Get the unit property: the unit of the metric. + * Get the errorMessage property: Error message encountered querying this specific metric. + * + * @return the errorMessage value. + */ + public String getErrorMessage() { + return this.errorMessage; + } + + /** + * Set the errorMessage property: Error message encountered querying this specific metric. + * + * @param errorMessage the errorMessage value to set. + * @return the Metric object itself. + */ + public Metric setErrorMessage(String errorMessage) { + this.errorMessage = errorMessage; + return this; + } + + /** + * Get the unit property: The unit of the metric. * * @return the unit value. */ @@ -173,9 +207,6 @@ public void validate() { } else { getName().validate(); } - if (getDisplayDescription() == null) { - throw new IllegalArgumentException("Missing required property displayDescription in model Metric"); - } if (getUnit() == null) { throw new IllegalArgumentException("Missing required property unit in model Metric"); } 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/metrics/implementation/models/MetricValue.java index b976313d131b9..a2bc309ac50af 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/metrics/implementation/models/MetricValue.java @@ -47,7 +47,7 @@ public final class MetricValue { * number of values that contributed to the average value. */ @JsonProperty(value = "count") - private Long count; + private Double count; /** * Creates an instance of MetricValue class. @@ -154,7 +154,7 @@ public MetricValue setTotal(Double total) { * * @return the count value. */ - public Long getCount() { + public Double getCount() { return this.count; } @@ -165,7 +165,7 @@ public Long getCount() { * @param count the count value to set. * @return the MetricValue object itself. */ - public MetricValue setCount(Long count) { + public MetricValue setCount(Double count) { this.count = count; return this; } 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/metrics/implementation/models/MetricsResponse.java index a19f9999ed2a0..9e86279829137 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/metrics/implementation/models/MetricsResponse.java @@ -37,13 +37,13 @@ public final class MetricsResponse { private Duration interval; /* - * The namespace of the metrics been queried + * The namespace of the metrics being queried */ @JsonProperty(value = "namespace") private String namespace; /* - * The region of the resource been queried for metrics. + * The region of the resource being queried for metrics. */ @JsonProperty(value = "resourceregion") private String resourceregion; @@ -124,7 +124,7 @@ public MetricsResponse setInterval(Duration interval) { } /** - * Get the namespace property: The namespace of the metrics been queried. + * Get the namespace property: The namespace of the metrics being queried. * * @return the namespace value. */ @@ -133,7 +133,7 @@ public String getNamespace() { } /** - * Set the namespace property: The namespace of the metrics been queried. + * Set the namespace property: The namespace of the metrics being queried. * * @param namespace the namespace value to set. * @return the MetricsResponse object itself. @@ -144,7 +144,7 @@ public MetricsResponse setNamespace(String namespace) { } /** - * Get the resourceregion property: The region of the resource been queried for metrics. + * Get the resourceregion property: The region of the resource being queried for metrics. * * @return the resourceregion value. */ @@ -153,7 +153,7 @@ public String getResourceregion() { } /** - * Set the resourceregion property: The region of the resource been queried for metrics. + * Set the resourceregion property: The region of the resource being queried for metrics. * * @param resourceregion the resourceregion value to set. * @return the MetricsResponse object itself. 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/metricsdefinitions/implementation/MetricDefinitionsImpl.java index eb62da3d9243c..0bf219e079418 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/metricsdefinitions/implementation/MetricDefinitionsImpl.java @@ -24,8 +24,8 @@ 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.metricsdefinitions.implementation.models.MetricDefinitionCollection; import com.azure.monitor.query.models.MetricDefinition; +import com.azure.monitor.query.metricsdefinitions.implementation.models.MetricDefinitionCollection; import reactor.core.publisher.Mono; /** An instance of this class provides access to all the operations defined in MetricDefinitions. */ @@ -55,7 +55,7 @@ public final class MetricDefinitionsImpl { @Host("{$host}") @ServiceInterface(name = "MetricsDefinitionsCl") private interface MetricDefinitionsService { - @Get("/{resourceUri}/providers/microsoft.insights/metricDefinitions") + @Get("/{resourceUri}/providers/Microsoft.Insights/metricDefinitions") @ExpectedResponses({200}) @UnexpectedResponseExceptionType(ErrorResponseException.class) Mono> list( diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsTableCell.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsTableCell.java index 5a864a86ca34b..963f4297d2c0a 100644 --- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsTableCell.java +++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsTableCell.java @@ -27,12 +27,12 @@ public final class LogsTableCell { * @param rowIndex The row index of the row this cell is associated with. * @param rowValue The value of the cell. */ - public LogsTableCell(String columnName, LogsColumnType columnType, int columnIndex, int rowIndex, String rowValue) { + public LogsTableCell(String columnName, LogsColumnType columnType, int columnIndex, int rowIndex, Object rowValue) { this.columnName = columnName; this.columnType = columnType; this.columnIndex = columnIndex; this.rowIndex = rowIndex; - this.rowValue = rowValue; + this.rowValue = rowValue == null ? null : rowValue.toString(); } /** diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricClass.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricClass.java new file mode 100644 index 0000000000000..15010f5b9a7b7 --- /dev/null +++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricClass.java @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.monitor.query.models; + +import com.azure.core.util.ExpandableStringEnum; +import com.fasterxml.jackson.annotation.JsonCreator; +import java.util.Collection; + +/** Defines values for MetricClass. */ +public final class MetricClass extends ExpandableStringEnum { + /** Static value Availability for MetricClass. */ + public static final MetricClass AVAILABILITY = fromString("Availability"); + + /** Static value Transactions for MetricClass. */ + public static final MetricClass TRANSACTIONS = fromString("Transactions"); + + /** Static value Errors for MetricClass. */ + public static final MetricClass ERRORS = fromString("Errors"); + + /** Static value Latency for MetricClass. */ + public static final MetricClass LATENCY = fromString("Latency"); + + /** Static value Saturation for MetricClass. */ + public static final MetricClass SATURATION = fromString("Saturation"); + + /** + * Creates or finds a MetricClass from its string representation. + * + * @param name a name to look for. + * @return the corresponding MetricClass. + */ + @JsonCreator + public static MetricClass fromString(String name) { + return fromString(name, MetricClass.class); + } + + /** @return known MetricClass values. */ + public static Collection values() { + return values(MetricClass.class); + } +} 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 b9dfa7e0eb9ea..c06b3b1f9287c 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 @@ -22,6 +22,12 @@ public final class MetricDefinition { @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. @@ -42,7 +48,13 @@ public final class MetricDefinition { private String category; /* - * the unit of the metric. + * The class of the metric. + */ + @JsonProperty(value = "metricClass") + private MetricClass metricClass; + + /* + * The unit of the metric. */ @JsonProperty(value = "unit") private MetricUnit unit; @@ -54,6 +66,12 @@ public final class MetricDefinition { @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. @@ -114,6 +132,26 @@ public MetricDefinition setResourceId(String 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. * @@ -175,7 +213,27 @@ public MetricDefinition setCategory(String category) { } /** - * Get the unit property: the unit of the metric. + * 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. */ @@ -184,7 +242,7 @@ public MetricUnit getUnit() { } /** - * Set the unit property: the unit of the metric. + * Set the unit property: The unit of the metric. * * @param unit the unit value to set. * @return the MetricDefinition object itself. @@ -216,6 +274,26 @@ public MetricDefinition setPrimaryAggregationType(AggregationType primaryAggrega 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. * diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricValue.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricValue.java index e334086752b80..3c25b2f3fdd80 100644 --- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricValue.java +++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/MetricValue.java @@ -17,7 +17,7 @@ public final class MetricValue { private final Double minimum; private final Double maximum; private final Double total; - private final Long count; + private final Double count; /** * Creates an instance of {@link MetricValue}. @@ -29,7 +29,7 @@ public final class MetricValue { * @param count the number of samples in the time range. */ public MetricValue(OffsetDateTime timeStamp, Double average, Double minimum, Double maximum, Double total, - Long count) { + Double count) { this.timeStamp = timeStamp; this.average = average; this.minimum = minimum; @@ -82,7 +82,7 @@ public Double getTotal() { * Returns the number of samples in the time range. * @return the number of samples in the time range. */ - public Long getCount() { + public Double getCount() { return count; } } diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/NamespaceClassification.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/NamespaceClassification.java index c29b8d9b0270c..e366de2d3c572 100644 --- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/NamespaceClassification.java +++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/NamespaceClassification.java @@ -3,47 +3,34 @@ package com.azure.monitor.query.models; +import com.azure.core.util.ExpandableStringEnum; import com.fasterxml.jackson.annotation.JsonCreator; -import com.fasterxml.jackson.annotation.JsonValue; +import java.util.Collection; /** Defines values for NamespaceClassification. */ -public enum NamespaceClassification { - /** Enum value Platform. */ - PLATFORM("Platform"), +public final class NamespaceClassification extends ExpandableStringEnum { + /** Static value Platform for NamespaceClassification. */ + public static final NamespaceClassification PLATFORM = fromString("Platform"); - /** Enum value Custom. */ - CUSTOM("Custom"), + /** Static value Custom for NamespaceClassification. */ + public static final NamespaceClassification CUSTOM = fromString("Custom"); - /** Enum value Qos. */ - QOS("Qos"); - - /** The actual serialized value for a NamespaceClassification instance. */ - private final String value; - - NamespaceClassification(String value) { - this.value = value; - } + /** Static value Qos for NamespaceClassification. */ + public static final NamespaceClassification QOS = fromString("Qos"); /** - * Parses a serialized value to a NamespaceClassification instance. + * Creates or finds a NamespaceClassification from its string representation. * - * @param value the serialized value to parse. - * @return the parsed NamespaceClassification object, or null if unable to parse. + * @param name a name to look for. + * @return the corresponding NamespaceClassification. */ @JsonCreator - public static NamespaceClassification fromString(String value) { - NamespaceClassification[] items = NamespaceClassification.values(); - for (NamespaceClassification item : items) { - if (item.toString().equalsIgnoreCase(value)) { - return item; - } - } - return null; + public static NamespaceClassification fromString(String name) { + return fromString(name, NamespaceClassification.class); } - @JsonValue - @Override - public String toString() { - return this.value; + /** @return known NamespaceClassification values. */ + public static Collection values() { + return values(NamespaceClassification.class); } } 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 95e80f21dd7b0..5453d79d6656e 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 @@ -3,9 +3,9 @@ package com.azure.monitor.query; -import com.azure.core.credential.TokenCredential; import com.azure.core.http.rest.Response; import com.azure.core.util.Context; +import com.azure.identity.DefaultAzureCredentialBuilder; import com.azure.monitor.query.models.AggregationType; import com.azure.monitor.query.models.LogsBatchQuery; import com.azure.monitor.query.models.LogsBatchQueryResult; @@ -36,14 +36,14 @@ public class ReadmeSamples { * Sample for creating sync and async clients for querying logs. */ public void createLogsClients() { - TokenCredential tokenCredential = null; + LogsQueryClient logsQueryClient = new LogsQueryClientBuilder() - .credential(tokenCredential) + .credential(new DefaultAzureCredentialBuilder().build()) .buildClient(); LogsQueryAsyncClient logsQueryAsyncClient = new LogsQueryClientBuilder() - .credential(tokenCredential) + .credential(new DefaultAzureCredentialBuilder().build()) .buildAsyncClient(); } @@ -51,14 +51,14 @@ public void createLogsClients() { * Sample for creating sync and async clients for querying metrics. */ public void createMetricsClients() { - TokenCredential tokenCredential = null; + MetricsQueryClient metricsQueryClient = new MetricsQueryClientBuilder() - .credential(tokenCredential) + .credential(new DefaultAzureCredentialBuilder().build()) .buildClient(); MetricsQueryAsyncClient metricsQueryAsyncClient = new MetricsQueryClientBuilder() - .credential(tokenCredential) + .credential(new DefaultAzureCredentialBuilder().build()) .buildAsyncClient(); } @@ -66,10 +66,10 @@ public void createMetricsClients() { * Sample to demonstrate executing a Kusto query for logs. */ public void getLogsQuery() { - TokenCredential tokenCredential = null; + LogsQueryClient logsQueryClient = new LogsQueryClientBuilder() - .credential(tokenCredential) + .credential(new DefaultAzureCredentialBuilder().build()) .buildClient(); LogsQueryResult queryResults = logsQueryClient.queryLogs("{workspace-id}", "{kusto-query}", @@ -88,10 +88,10 @@ public void getLogsQuery() { * Sample to demonstrate executing a batch of Kusto queries for logs. */ public void getLogsQueryBatch() { - TokenCredential tokenCredential = null; + LogsQueryClient logsQueryClient = new LogsQueryClientBuilder() - .credential(tokenCredential) + .credential(new DefaultAzureCredentialBuilder().build()) .buildClient(); LogsBatchQuery logsBatchQuery = new LogsBatchQuery() @@ -123,10 +123,10 @@ public void getLogsQueryBatch() { * requires extending server timeout. */ public void getLogsWithServerTimeout() { - TokenCredential tokenCredential = null; + LogsQueryClient logsQueryClient = new LogsQueryClientBuilder() - .credential(tokenCredential) + .credential(new DefaultAzureCredentialBuilder().build()) .buildClient(); // set request options: server timeout, rendering, statistics @@ -152,10 +152,10 @@ public void getLogsWithServerTimeout() { * Sample to demonstrate querying Azure Monitor for metrics. */ public void getMetrics() { - TokenCredential tokenCredential = null; + MetricsQueryClient metricsQueryClient = new MetricsQueryClientBuilder() - .credential(tokenCredential) + .credential(new DefaultAzureCredentialBuilder().build()) .buildClient(); Response metricsResponse = metricsQueryClient @@ -192,10 +192,10 @@ public void getMetrics() { * */ public void getLogsQueryWithColumnNameAccess() { - TokenCredential tokenCredential = null; + LogsQueryClient logsQueryClient = new LogsQueryClientBuilder() - .credential(tokenCredential) + .credential(new DefaultAzureCredentialBuilder().build()) .buildClient(); LogsQueryResult queryResults = logsQueryClient.queryLogs("{workspace-id}", "{kusto-query}", diff --git a/sdk/monitor/azure-monitor-query/src/test/resources/session-records/MetricsQueryClientTest.testMetricsQuery.json b/sdk/monitor/azure-monitor-query/src/test/resources/session-records/MetricsQueryClientTest.testMetricsQuery.json index 7b76a13aa7393..8bc0a8a46d094 100644 --- a/sdk/monitor/azure-monitor-query/src/test/resources/session-records/MetricsQueryClientTest.testMetricsQuery.json +++ b/sdk/monitor/azure-monitor-query/src/test/resources/session-records/MetricsQueryClientTest.testMetricsQuery.json @@ -1,7 +1,7 @@ { "networkCallRecords" : [ { "Method" : "GET", - "Uri" : "https://REDACTED.azure.com/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/srnagar-azuresdkgroup/providers/Microsoft.CognitiveServices/accounts/srnagara-textanalytics/providers/microsoft.insights/metrics?timespan=PT240H&interval=PT1H&metric=SuccessfulCalls&aggregation=2%2C5%2C4%2C3%2C1&top=100&resultType=Data&api-version=2017-05-01-preview&metricnamespace=Microsoft.CognitiveServices/accounts", + "Uri" : "https://REDACTED.azure.com/subscriptions/faa080af-c1d8-40ad-9cce-e1a450ca5b57/resourceGroups/srnagar-azuresdkgroup/providers/Microsoft.CognitiveServices/accounts/srnagara-textanalytics/providers/microsoft.insights/metrics?timespan=PT240H&interval=PT1H&metricnames=SuccessfulCalls&aggregation=2%2C5%2C4%2C3%2C1&top=100&resultType=Data&api-version=2018-01-01&metricnamespace=Microsoft.CognitiveServices/accounts", "Headers" : { "User-Agent" : "azsdk-java-UnknownName/UnknownVersion (11.0.8; Windows 10; 10.0)" }, @@ -29,4 +29,4 @@ "Exception" : null } ], "variables" : [ ] -} \ No newline at end of file +} diff --git a/sdk/monitor/azure-monitor-query/swagger/README.md b/sdk/monitor/azure-monitor-query/swagger/README.md index 87aa1025bb992..15bd16fa932b3 100644 --- a/sdk/monitor/azure-monitor-query/swagger/README.md +++ b/sdk/monitor/azure-monitor-query/swagger/README.md @@ -6,7 +6,7 @@ These settings apply only when `--tag=package-log` is specified on the command l ``` yaml $(tag) == 'package-log' use: '@autorest/java@4.0.22' -input-file: https://raw.githubusercontent.com/srnagar/azure-rest-api-specs/azmon-query-swagger/specification/operationalinsights/data-plane/Microsoft.OperationalInsights/preview/2021-05-19_Preview/OperationalInsights.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/operationalinsights/data-plane/Microsoft.OperationalInsights/preview/2021-05-19_Preview/OperationalInsights.json java: true output-folder: ../ namespace: com.azure.monitor.query.log @@ -30,7 +30,7 @@ These settings apply only when `--tag=package-metrics` is specified on the comma ``` yaml $(tag) == 'package-metrics' use: '@autorest/java@4.0.22' -input-file: https://raw.githubusercontent.com/srnagar/azure-rest-api-specs/azmon-query-swagger/specification/monitor/resource-manager/Microsoft.Insights/preview/2017-05-01-preview/metrics_API.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/metrics_API.json java: true output-folder: ../ namespace: com.azure.monitor.query.metrics @@ -59,7 +59,7 @@ These settings apply only when `--tag=package-metrics-namespaces` is specified o ``` yaml $(tag) == 'package-metrics-namespaces' use: '@autorest/java@4.0.22' service-name: MetricsNamespaces -input-file: https://raw.githubusercontent.com/srnagar/azure-rest-api-specs/azmon-query-swagger/specification/monitor/resource-manager/Microsoft.Insights/preview/2017-12-01-preview/metricNamespaces_API.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/monitor/resource-manager/Microsoft.Insights/preview/2017-12-01-preview/metricNamespaces_API.json java: true output-folder: ../ namespace: com.azure.monitor.query.metricsnamespaces @@ -83,7 +83,7 @@ These settings apply only when `--tag=package-metrics-definitions` is specified ``` yaml $(tag) == 'package-metrics-definitions' use: '@autorest/java@4.0.22' -input-file: https://raw.githubusercontent.com/srnagar/azure-rest-api-specs/azmon-query-swagger/specification/monitor/resource-manager/Microsoft.Insights/preview/2017-05-01-preview/metricDefinitions_API.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/monitor/resource-manager/Microsoft.Insights/stable/2018-01-01/metricDefinitions_API.json service-name: MetricsDefinitions java: true output-folder: ../ From 95c3055639b890e09e1dd81ad647d8a2d22078b0 Mon Sep 17 00:00:00 2001 From: Srikanta Date: Fri, 2 Jul 2021 13:33:43 -0700 Subject: [PATCH 2/3] Use https --- sdk/monitor/azure-monitor-query/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/monitor/azure-monitor-query/README.md b/sdk/monitor/azure-monitor-query/README.md index 59156824fb76f..964fd72ed0a46 100644 --- a/sdk/monitor/azure-monitor-query/README.md +++ b/sdk/monitor/azure-monitor-query/README.md @@ -419,7 +419,7 @@ comments. [samples_readme]: https://github.com/Azure/azure-sdk-for-java/blob/main/sdk/monitor/azure-monitor-query/src/samples/java/README.md -[azure_subscription]: http://azure.microsoft.com/free/java +[azure_subscription]: https://azure.microsoft.com/free/java [jdk_link]: https://docs.microsoft.com/java/azure/jdk/?view=azure-java-stable From f96b3ee7d3e6445343afee19a00de7554a8256de Mon Sep 17 00:00:00 2001 From: Srikanta Date: Fri, 2 Jul 2021 13:40:14 -0700 Subject: [PATCH 3/3] run embedme --- sdk/monitor/azure-monitor-query/README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/monitor/azure-monitor-query/README.md b/sdk/monitor/azure-monitor-query/README.md index 964fd72ed0a46..8f0f3edef91e2 100644 --- a/sdk/monitor/azure-monitor-query/README.md +++ b/sdk/monitor/azure-monitor-query/README.md @@ -40,7 +40,7 @@ This client library provides access to query metrics and logs collected by Azure ```java LogsQueryClient logsQueryClient = new LogsQueryClientBuilder() - .credential(tokenCredential) + .credential(new DefaultAzureCredentialBuilder().build()) .buildClient(); ``` @@ -50,7 +50,7 @@ LogsQueryClient logsQueryClient = new LogsQueryClientBuilder() ```java LogsQueryAsyncClient logsQueryAsyncClient = new LogsQueryClientBuilder() - .credential(tokenCredential) + .credential(new DefaultAzureCredentialBuilder().build()) .buildAsyncClient(); ``` @@ -268,7 +268,7 @@ for (LogsTable table : logsQueryResult.getLogsTables()) { ```java MetricsQueryClient metricsQueryClient = new MetricsQueryClientBuilder() - .credential(tokenCredential) + .credential(new DefaultAzureCredentialBuilder().build()) .buildClient(); ``` @@ -277,7 +277,7 @@ MetricsQueryClient metricsQueryClient = new MetricsQueryClientBuilder() ```java MetricsQueryAsyncClient metricsQueryAsyncClient = new MetricsQueryClientBuilder() - .credential(tokenCredential) + .credential(new DefaultAzureCredentialBuilder().build()) .buildAsyncClient(); ```