Skip to content

Commit

Permalink
rerun maven in monitor query sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
mssfang committed Dec 3, 2024
1 parent 6e8ca6f commit 67a9947
Show file tree
Hide file tree
Showing 50 changed files with 940 additions and 1,069 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public final class LogsQueryAsyncClient {
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<LogsQueryResult> queryWorkspace(String workspaceId, String query, QueryTimeInterval timeInterval) {
return queryWorkspaceWithResponse(workspaceId, query, timeInterval, new LogsQueryOptions())
.map(Response::getValue);
.map(Response::getValue);
}

/**
Expand All @@ -142,9 +142,10 @@ public Mono<LogsQueryResult> queryWorkspace(String workspaceId, String query, Qu
* @return The logs matching the query as a list of objects of type T.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public <T> Mono<List<T>> queryWorkspace(String workspaceId, String query, QueryTimeInterval timeInterval, Class<T> type) {
public <T> Mono<List<T>> queryWorkspace(String workspaceId, String query, QueryTimeInterval timeInterval,
Class<T> type) {
return queryWorkspace(workspaceId, query, timeInterval)
.map(result -> LogsQueryHelper.toObject(result.getTable(), type));
.map(result -> LogsQueryHelper.toObject(result.getTable(), type));
}

/**
Expand All @@ -161,9 +162,9 @@ public <T> Mono<List<T>> queryWorkspace(String workspaceId, String query, QueryT
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public <T> Mono<List<T>> queryWorkspace(String workspaceId, String query, QueryTimeInterval timeInterval,
Class<T> type, LogsQueryOptions options) {
Class<T> type, LogsQueryOptions options) {
return queryWorkspaceWithResponse(workspaceId, query, timeInterval, options, Context.NONE)
.map(response -> LogsQueryHelper.toObject(response.getValue().getTable(), type));
.map(response -> LogsQueryHelper.toObject(response.getValue().getTable(), type));
}

/**
Expand Down Expand Up @@ -198,7 +199,7 @@ public <T> Mono<List<T>> queryWorkspace(String workspaceId, String query, QueryT
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<LogsQueryResult>> queryWorkspaceWithResponse(String workspaceId, String query,
QueryTimeInterval timeInterval, LogsQueryOptions options) {
QueryTimeInterval timeInterval, LogsQueryOptions options) {
return withContext(context -> queryWorkspaceWithResponse(workspaceId, query, timeInterval, options, context));
}

Expand All @@ -215,15 +216,13 @@ public Mono<Response<LogsQueryResult>> queryWorkspaceWithResponse(String workspa
* @return The logs matching the query including the HTTP response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public <T> Mono<Response<List<T>>> queryWorkspaceWithResponse(String workspaceId, String query, QueryTimeInterval timeInterval,
Class<T> type, LogsQueryOptions options) {
public <T> Mono<Response<List<T>>> queryWorkspaceWithResponse(String workspaceId, String query,
QueryTimeInterval timeInterval, Class<T> type, LogsQueryOptions options) {
return queryWorkspaceWithResponse(workspaceId, query, timeInterval, options)
.map(response -> new SimpleResponse<>(response.getRequest(),
response.getStatusCode(), response.getHeaders(),
LogsQueryHelper.toObject(response.getValue().getTable(), type)));
.map(response -> new SimpleResponse<>(response.getRequest(), response.getStatusCode(),
response.getHeaders(), LogsQueryHelper.toObject(response.getValue().getTable(), type)));
}


/**
* Returns all the Azure Monitor logs matching the given batch of queries.
*
Expand Down Expand Up @@ -257,8 +256,7 @@ public <T> Mono<Response<List<T>>> queryWorkspaceWithResponse(String workspaceId
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<LogsBatchQueryResultCollection> queryBatch(LogsBatchQuery logsBatchQuery) {
return queryBatchWithResponse(logsBatchQuery)
.map(Response::getValue);
return queryBatchWithResponse(logsBatchQuery).map(Response::getValue);
}

/**
Expand Down Expand Up @@ -312,7 +310,8 @@ public Mono<LogsQueryResult> queryResource(String resourceId, String query, Quer
* @return The logs matching the query as a list of objects of type T.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public <T> Mono<List<T>> queryResource(String resourceId, String query, QueryTimeInterval timeInterval, Class<T> type) {
public <T> Mono<List<T>> queryResource(String resourceId, String query, QueryTimeInterval timeInterval,
Class<T> type) {
return queryResource(resourceId, query, timeInterval)
.map(result -> LogsQueryHelper.toObject(result.getTable(), type));
}
Expand All @@ -331,7 +330,7 @@ public <T> Mono<List<T>> queryResource(String resourceId, String query, QueryTim
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public <T> Mono<List<T>> queryResource(String resourceId, String query, QueryTimeInterval timeInterval,
Class<T> type, LogsQueryOptions options) {
Class<T> type, LogsQueryOptions options) {
return queryResourceWithResponse(resourceId, query, timeInterval, options, Context.NONE)
.map(response -> LogsQueryHelper.toObject(response.getValue().getTable(), type));
}
Expand Down Expand Up @@ -368,7 +367,7 @@ public <T> Mono<List<T>> queryResource(String resourceId, String query, QueryTim
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public Mono<Response<LogsQueryResult>> queryResourceWithResponse(String resourceId, String query,
QueryTimeInterval timeInterval, LogsQueryOptions options) {
QueryTimeInterval timeInterval, LogsQueryOptions options) {
return withContext(context -> queryResourceWithResponse(resourceId, query, timeInterval, options, context));
}

Expand All @@ -385,15 +384,15 @@ public Mono<Response<LogsQueryResult>> queryResourceWithResponse(String resource
* @return The logs matching the query including the HTTP response.
*/
@ServiceMethod(returns = ReturnType.SINGLE)
public <T> Mono<Response<List<T>>> queryResourceWithResponse(String resourceId, String query, QueryTimeInterval timeInterval,
Class<T> type, LogsQueryOptions options) {
public <T> Mono<Response<List<T>>> queryResourceWithResponse(String resourceId, String query,
QueryTimeInterval timeInterval, Class<T> type, LogsQueryOptions options) {
return queryResourceWithResponse(resourceId, query, timeInterval, options)
.map(response -> new SimpleResponse<>(response.getRequest(),
response.getStatusCode(), response.getHeaders(),
LogsQueryHelper.toObject(response.getValue().getTable(), type)));
.map(response -> new SimpleResponse<>(response.getRequest(), response.getStatusCode(),
response.getHeaders(), LogsQueryHelper.toObject(response.getValue().getTable(), type)));
}

Mono<Response<LogsBatchQueryResultCollection>> queryBatchWithResponse(LogsBatchQuery logsBatchQuery, Context context) {
Mono<Response<LogsBatchQueryResultCollection>> queryBatchWithResponse(LogsBatchQuery logsBatchQuery,
Context context) {
List<BatchQueryRequest> requests = LogsQueryHelper.getBatchQueries(logsBatchQuery);
Duration maxServerTimeout = LogsQueryHelper.getMaxServerTimeout(logsBatchQuery);
if (maxServerTimeout != null) {
Expand All @@ -402,17 +401,14 @@ Mono<Response<LogsBatchQueryResultCollection>> queryBatchWithResponse(LogsBatchQ

BatchRequest batchRequest = new BatchRequest(requests);

return innerClient.getQueries().batchWithResponseAsync(batchRequest, context)
.onErrorMap(ex -> {
if (ex instanceof ErrorResponseException) {
ErrorResponseException error = (ErrorResponseException) ex;
ErrorInfo errorInfo = error.getValue().getError();
return new HttpResponseException(error.getMessage(), error.getResponse(),
mapLogsQueryError(errorInfo));
}
return ex;
})
.map(LogsQueryHelper::convertToLogQueryBatchResult);
return innerClient.getQueries().batchWithResponseAsync(batchRequest, context).onErrorMap(ex -> {
if (ex instanceof ErrorResponseException) {
ErrorResponseException error = (ErrorResponseException) ex;
ErrorInfo errorInfo = error.getValue().getError();
return new HttpResponseException(error.getMessage(), error.getResponse(), mapLogsQueryError(errorInfo));
}
return ex;
}).map(LogsQueryHelper::convertToLogQueryBatchResult);
}

private Context updateContext(Duration serverTimeout, Context context) {
Expand All @@ -422,9 +418,8 @@ private Context updateContext(Duration serverTimeout, Context context) {
return context;
}


Mono<Response<LogsQueryResult>> queryWorkspaceWithResponse(String workspaceId, String query, QueryTimeInterval timeInterval,
LogsQueryOptions options, Context context) {
Mono<Response<LogsQueryResult>> queryWorkspaceWithResponse(String workspaceId, String query,
QueryTimeInterval timeInterval, LogsQueryOptions options, Context context) {
String preferHeader = LogsQueryHelper.buildPreferHeaderString(options);
context = updateContext(options.getServerTimeout(), context);

Expand All @@ -433,37 +428,33 @@ Mono<Response<LogsQueryResult>> queryWorkspaceWithResponse(String workspaceId, S
queryBody.setTimespan(LogsQueryHelper.toIso8601Format(timeInterval));
}
queryBody.setWorkspaces(getAllWorkspaces(options));
return innerClient
.getQueries()
.executeWithResponseAsync(workspaceId,
queryBody,
preferHeader,
context)
.onErrorMap(ex -> {
if (ex instanceof ErrorResponseException) {
ErrorResponseException error = (ErrorResponseException) ex;
ErrorInfo errorInfo = error.getValue().getError();
return new HttpResponseException(error.getMessage(), error.getResponse(),
mapLogsQueryError(errorInfo));
}
return ex;
})
.map(LogsQueryHelper::convertToLogQueryResult)
.handle((Response<LogsQueryResult> response, SynchronousSink<Response<LogsQueryResult>> sink) -> {
if (response.getValue().getQueryResultStatus() == LogsQueryResultStatus.PARTIAL_FAILURE
&& !options.isAllowPartialErrors()) {
return innerClient.getQueries()
.executeWithResponseAsync(workspaceId, queryBody, preferHeader, context)
.onErrorMap(ex -> {
if (ex instanceof ErrorResponseException) {
ErrorResponseException error = (ErrorResponseException) ex;
ErrorInfo errorInfo = error.getValue().getError();
return new HttpResponseException(error.getMessage(), error.getResponse(),
mapLogsQueryError(errorInfo));
}
return ex;
})
.map(LogsQueryHelper::convertToLogQueryResult)
.handle((Response<LogsQueryResult> response, SynchronousSink<Response<LogsQueryResult>> sink) -> {
if (response.getValue().getQueryResultStatus() == LogsQueryResultStatus.PARTIAL_FAILURE
&& !options.isAllowPartialErrors()) {

sink.error(new ServiceResponseException("Query execution returned partial errors. To "
+ "disable exceptions on partial errors, set setAllowPartialErrors in "
+ "LogsQueryOptions to true."));
} else {
sink.next(response);
}
});
sink.error(new ServiceResponseException("Query execution returned partial errors. To "
+ "disable exceptions on partial errors, set setAllowPartialErrors in "
+ "LogsQueryOptions to true."));
} else {
sink.next(response);
}
});
}

Mono<Response<LogsQueryResult>> queryResourceWithResponse(String resourceId, String query, QueryTimeInterval timeInterval,
LogsQueryOptions options, Context context) {
Mono<Response<LogsQueryResult>> queryResourceWithResponse(String resourceId, String query,
QueryTimeInterval timeInterval, LogsQueryOptions options, Context context) {
if (resourceId != null && resourceId.startsWith("/")) {
resourceId = resourceId.substring(1);
}
Expand All @@ -474,12 +465,8 @@ Mono<Response<LogsQueryResult>> queryResourceWithResponse(String resourceId, Str
queryBody.setTimespan(LogsQueryHelper.toIso8601Format(timeInterval));
}
queryBody.setWorkspaces(getAllWorkspaces(options));
return innerClient
.getQueries()
.resourceExecuteWithResponseAsync(resourceId,
queryBody,
preferHeader,
context)
return innerClient.getQueries()
.resourceExecuteWithResponseAsync(resourceId, queryBody, preferHeader, context)
.onErrorMap(ex -> {
if (ex instanceof ErrorResponseException) {
ErrorResponseException error = (ErrorResponseException) ex;
Expand Down
Loading

0 comments on commit 67a9947

Please sign in to comment.