Skip to content

Commit

Permalink
Fix readme and regenerate code (#22762)
Browse files Browse the repository at this point in the history
* Fix readme and regenerate code

* Use https

* run embedme
  • Loading branch information
srnagar authored Jul 2, 2021
1 parent 384d774 commit f8f388d
Show file tree
Hide file tree
Showing 20 changed files with 519 additions and 167 deletions.
12 changes: 6 additions & 6 deletions sdk/monitor/azure-monitor-query/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ This client library provides access to query metrics and logs collected by Azure
<!-- embedme ./src/samples/java/com/azure/monitor/query/ReadmeSamples.java#L41-L43 -->
```java
LogsQueryClient logsQueryClient = new LogsQueryClientBuilder()
.credential(tokenCredential)
.credential(new DefaultAzureCredentialBuilder().build())
.buildClient();
```

Expand All @@ -50,7 +50,7 @@ LogsQueryClient logsQueryClient = new LogsQueryClientBuilder()
<!-- embedme ./src/samples/java/com/azure/monitor/query/ReadmeSamples.java#L45-L47 -->
```java
LogsQueryAsyncClient logsQueryAsyncClient = new LogsQueryClientBuilder()
.credential(tokenCredential)
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
```

Expand Down Expand Up @@ -268,7 +268,7 @@ for (LogsTable table : logsQueryResult.getLogsTables()) {
<!-- embedme ./src/samples/java/com/azure/monitor/query/ReadmeSamples.java#L56-L58 -->
```java
MetricsQueryClient metricsQueryClient = new MetricsQueryClientBuilder()
.credential(tokenCredential)
.credential(new DefaultAzureCredentialBuilder().build())
.buildClient();
```

Expand All @@ -277,7 +277,7 @@ MetricsQueryClient metricsQueryClient = new MetricsQueryClientBuilder()
<!-- embedme ./src/samples/java/com/azure/monitor/query/ReadmeSamples.java#L60-L62 -->
```java
MetricsQueryAsyncClient metricsQueryAsyncClient = new MetricsQueryClientBuilder()
.credential(tokenCredential)
.credential(new DefaultAzureCredentialBuilder().build())
.buildAsyncClient();
```

Expand Down Expand Up @@ -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]: https://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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -258,10 +259,48 @@ private LogsQueryResult getLogsQueryResult(QueryResults queryResults) {
List<LogsTableColumn> tableColumns = new ArrayList<>();
LogsTable logsTable = new LogsTable(tableCells, tableRows, tableColumns);
tables.add(logsTable);
List<List<String>> rows = table.getRows();
List<List<Object>> rows = table.getRows();

for (int i = 0; i < rows.size(); i++) {
List<String> row = rows.get(i);
List<Object> 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<LogsTable> tables = null;

if (queryResults.getTables() != null) {
tables = new ArrayList<>();
for (Table table : queryResults.getTables()) {
List<LogsTableCell> tableCells = new ArrayList<>();
List<LogsTableRow> tableRows = new ArrayList<>();
List<LogsTableColumn> tableColumns = new ArrayList<>();
LogsTable logsTable = new LogsTable(tableCells, tableRows, tableColumns);
tables.add(logsTable);
List<List<Object>> rows = table.getRows();

for (int i = 0; i < rows.size(); i++) {
List<Object> row = rows.get(i);
LogsTableRow tableRow = new LogsTableRow(i, new ArrayList<>());
tableRows.add(tableRow);
for (int j = 0; j < row.size(); j++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <string>
Expand Down Expand Up @@ -80,7 +80,7 @@ public BatchQueryResponse setStatus(Integer status) {
*
* @return the body value.
*/
public QueryResults getBody() {
public BatchQueryResults getBody() {
return this.body;
}

Expand All @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 &amp; rows resulting from a query. */
@Fluent
public final class BatchQueryResults {
/*
* The list of tables, columns and rows.
*/
@JsonProperty(value = "tables")
private List<Table> 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<Table> 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<Table> 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();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<Table> tables;

/*
Expand All @@ -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.
*/
Expand All @@ -36,7 +42,7 @@ public final class QueryResults {
* @param tables the tables value to set.
*/
@JsonCreator
public QueryResults(@JsonProperty(value = "tables") List<Table> tables) {
public QueryResults(@JsonProperty(value = "tables", required = true) List<Table> tables) {
this.tables = tables;
}

Expand Down Expand Up @@ -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.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public final class Table {
* The resulting rows from this query.
*/
@JsonProperty(value = "rows", required = true)
private List<List<String>> rows;
private List<List<Object>> rows;

/**
* Creates an instance of Table class.
Expand All @@ -41,7 +41,7 @@ public final class Table {
public Table(
@JsonProperty(value = "name", required = true) String name,
@JsonProperty(value = "columns", required = true) List<Column> columns,
@JsonProperty(value = "rows", required = true) List<List<String>> rows) {
@JsonProperty(value = "rows", required = true) List<List<Object>> rows) {
this.name = name;
this.columns = columns;
this.rows = rows;
Expand Down Expand Up @@ -70,7 +70,7 @@ public List<Column> getColumns() {
*
* @return the rows value.
*/
public List<List<String>> getRows() {
public List<List<Object>> getRows() {
return this.rows;
}

Expand Down
Loading

0 comments on commit f8f388d

Please sign in to comment.