From 9191c65d40ddc7cad88297b28ded7c64e160d0ba Mon Sep 17 00:00:00 2001 From: Ace Eldeib Date: Tue, 19 Jun 2018 14:05:42 -0700 Subject: [PATCH 1/6] adding log analytics data plane --- api-specs.json | 4 + loganalytics/data-plane/pom.xml | 115 ++++++++ .../loganalytics/LogAnalyticsDataClient.java | 138 +++++++++ .../LogAnalyticsDataClientImpl.java | 269 ++++++++++++++++++ .../implementation/package-info.java | 11 + .../azure/loganalytics/models/Column.java | 70 +++++ .../loganalytics/models/ErrorDetail.java | 174 +++++++++++ .../azure/loganalytics/models/ErrorInfo.java | 148 ++++++++++ .../loganalytics/models/ErrorResponse.java | 44 +++ .../models/ErrorResponseException.java | 44 +++ .../azure/loganalytics/models/QueryBody.java | 99 +++++++ .../loganalytics/models/QueryResults.java | 45 +++ .../azure/loganalytics/models/Table.java | 97 +++++++ .../loganalytics/models/package-info.java | 11 + .../azure/loganalytics/package-info.java | 11 + 15 files changed, 1280 insertions(+) create mode 100644 loganalytics/data-plane/pom.xml create mode 100644 loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/LogAnalyticsDataClient.java create mode 100644 loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/implementation/LogAnalyticsDataClientImpl.java create mode 100644 loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/implementation/package-info.java create mode 100644 loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/Column.java create mode 100644 loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/ErrorDetail.java create mode 100644 loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/ErrorInfo.java create mode 100644 loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/ErrorResponse.java create mode 100644 loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/ErrorResponseException.java create mode 100644 loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/QueryBody.java create mode 100644 loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/QueryResults.java create mode 100644 loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/Table.java create mode 100644 loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/package-info.java create mode 100644 loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/package-info.java diff --git a/api-specs.json b/api-specs.json index 3cf2a840a50c..1959721b41e7 100644 --- a/api-specs.json +++ b/api-specs.json @@ -80,6 +80,10 @@ "source": "specification/notificationhubs/resource-manager/readme.md", "args": "--multiapi --fluent" }, + "loganalytics/data-plane": { + "source": "specification/operationalinsights/data-plane/readme.md", + "args": "--payload-flattening-threshold=1 --override-client-name=LogAnalyticsDataClient" + }, "mediaservices/resource-manager": { "source": "specification/mediaservices/resource-manager/readme.md", "args": "--multiapi --fluent" diff --git a/loganalytics/data-plane/pom.xml b/loganalytics/data-plane/pom.xml new file mode 100644 index 000000000000..1ea55f720941 --- /dev/null +++ b/loganalytics/data-plane/pom.xml @@ -0,0 +1,115 @@ + + + 4.0.0 + com.microsoft.azure + azure-loganalytics + 0.0.1-beta + jar + Microsoft Azure SDK for Log Analytics + This package contains Microsoft Log Analytics SDK. + https://github.com/Azure/azure-sdk-for-java + + + The MIT License (MIT) + http://opensource.org/licenses/MIT + repo + + + + scm:git:https://github.com/Azure/azure-sdk-for-java + scm:git:git@github.com:Azure/azure-sdk-for-java.git + HEAD + + + UTF-8 + + + + + microsoft + Microsoft + + + + + com.microsoft.azure + azure-client-runtime + 1.5.0 + + + junit + junit + 4.12 + test + + + com.microsoft.azure + azure-client-authentication + 1.5.0 + test + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + true + true + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.7 + 1.7 + + + com.microsoft.azure.management.apigeneration.LangDefinitionProcessor + + + true + true + + true + true + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.8 + + *.implementation.*;*.utils.*;com.microsoft.schemas._2003._10.serialization;*.blob.core.search + + + /** +
* Copyright (c) Microsoft Corporation. All rights reserved. +
* Licensed under the MIT License. See License.txt in the project root for +
* license information. +
*/ + ]]> +
+
+
+
+
+
diff --git a/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/LogAnalyticsDataClient.java b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/LogAnalyticsDataClient.java new file mode 100644 index 000000000000..8f2a9a889658 --- /dev/null +++ b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/LogAnalyticsDataClient.java @@ -0,0 +1,138 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.loganalytics; + +import com.microsoft.azure.AzureClient; +import com.microsoft.azure.loganalytics.models.ErrorResponseException; +import com.microsoft.azure.loganalytics.models.QueryBody; +import com.microsoft.azure.loganalytics.models.QueryResults; +import com.microsoft.rest.RestClient; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import rx.Observable; + +/** + * The interface for LogAnalyticsDataClient class. + */ +public interface LogAnalyticsDataClient { + /** + * Gets the REST client. + * + * @return the {@link RestClient} object. + */ + RestClient restClient(); + + /** + * Gets the {@link AzureClient} used for long running operations. + * @return the azure client; + */ + AzureClient getAzureClient(); + + /** + * Gets the User-Agent header for the client. + * + * @return the user agent string. + */ + String userAgent(); + + /** + * Gets Gets or sets the preferred language for the response.. + * + * @return the acceptLanguage value. + */ + String acceptLanguage(); + + /** + * Sets Gets or sets the preferred language for the response.. + * + * @param acceptLanguage the acceptLanguage value. + * @return the service client itself + */ + LogAnalyticsDataClient withAcceptLanguage(String acceptLanguage); + + /** + * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.. + * + * @return the longRunningOperationRetryTimeout value. + */ + int longRunningOperationRetryTimeout(); + + /** + * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.. + * + * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + * @return the service client itself + */ + LogAnalyticsDataClient withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout); + + /** + * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.. + * + * @return the generateClientRequestId value. + */ + boolean generateClientRequestId(); + + /** + * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.. + * + * @param generateClientRequestId the generateClientRequestId value. + * @return the service client itself + */ + LogAnalyticsDataClient withGenerateClientRequestId(boolean generateClientRequestId); + + /** + * Execute an Analytics query. + * Executes an Analytics query for data. [Here](https://dev.loganalytics.io/documentation/Using-the-API) is an example for using POST with an Analytics query. + * + * @param workspaceId ID of the workspace. This is Workspace ID from the Properties blade in the Azure portal. + * @param body The Analytics query. Learn more about the [Analytics query syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/) + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the QueryResults object if successful. + */ + QueryResults query(String workspaceId, QueryBody body); + + /** + * Execute an Analytics query. + * Executes an Analytics query for data. [Here](https://dev.loganalytics.io/documentation/Using-the-API) is an example for using POST with an Analytics query. + * + * @param workspaceId ID of the workspace. This is Workspace ID from the Properties blade in the Azure portal. + * @param body The Analytics query. Learn more about the [Analytics query syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/) + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + ServiceFuture queryAsync(String workspaceId, QueryBody body, final ServiceCallback serviceCallback); + + /** + * Execute an Analytics query. + * Executes an Analytics query for data. [Here](https://dev.loganalytics.io/documentation/Using-the-API) is an example for using POST with an Analytics query. + * + * @param workspaceId ID of the workspace. This is Workspace ID from the Properties blade in the Azure portal. + * @param body The Analytics query. Learn more about the [Analytics query syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/) + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the QueryResults object + */ + Observable queryAsync(String workspaceId, QueryBody body); + + /** + * Execute an Analytics query. + * Executes an Analytics query for data. [Here](https://dev.loganalytics.io/documentation/Using-the-API) is an example for using POST with an Analytics query. + * + * @param workspaceId ID of the workspace. This is Workspace ID from the Properties blade in the Azure portal. + * @param body The Analytics query. Learn more about the [Analytics query syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/) + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the QueryResults object + */ + Observable> queryWithServiceResponseAsync(String workspaceId, QueryBody body); + +} diff --git a/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/implementation/LogAnalyticsDataClientImpl.java b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/implementation/LogAnalyticsDataClientImpl.java new file mode 100644 index 000000000000..b820dce30f5e --- /dev/null +++ b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/implementation/LogAnalyticsDataClientImpl.java @@ -0,0 +1,269 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.loganalytics.implementation; + +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureClient; +import com.microsoft.azure.AzureServiceClient; +import com.microsoft.azure.loganalytics.LogAnalyticsDataClient; +import com.microsoft.azure.loganalytics.models.ErrorResponseException; +import com.microsoft.azure.loganalytics.models.QueryBody; +import com.microsoft.azure.loganalytics.models.QueryResults; +import com.microsoft.rest.credentials.ServiceClientCredentials; +import com.microsoft.rest.RestClient; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import com.microsoft.rest.Validator; +import java.io.IOException; +import okhttp3.ResponseBody; +import retrofit2.http.Body; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Path; +import retrofit2.http.POST; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * Initializes a new instance of the LogAnalyticsDataClientImpl class. + */ +public class LogAnalyticsDataClientImpl extends AzureServiceClient implements LogAnalyticsDataClient { + /** The Retrofit service to perform REST calls. */ + private LogAnalyticsDataClientService service; + /** the {@link AzureClient} used for long running operations. */ + private AzureClient azureClient; + + /** + * Gets the {@link AzureClient} used for long running operations. + * @return the azure client; + */ + public AzureClient getAzureClient() { + return this.azureClient; + } + + /** Gets or sets the preferred language for the response. */ + private String acceptLanguage; + + /** + * Gets Gets or sets the preferred language for the response. + * + * @return the acceptLanguage value. + */ + public String acceptLanguage() { + return this.acceptLanguage; + } + + /** + * Sets Gets or sets the preferred language for the response. + * + * @param acceptLanguage the acceptLanguage value. + * @return the service client itself + */ + public LogAnalyticsDataClientImpl withAcceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + return this; + } + + /** Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. */ + private int longRunningOperationRetryTimeout; + + /** + * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @return the longRunningOperationRetryTimeout value. + */ + public int longRunningOperationRetryTimeout() { + return this.longRunningOperationRetryTimeout; + } + + /** + * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * + * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + * @return the service client itself + */ + public LogAnalyticsDataClientImpl withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { + this.longRunningOperationRetryTimeout = longRunningOperationRetryTimeout; + return this; + } + + /** When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ + private boolean generateClientRequestId; + + /** + * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @return the generateClientRequestId value. + */ + public boolean generateClientRequestId() { + return this.generateClientRequestId; + } + + /** + * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * + * @param generateClientRequestId the generateClientRequestId value. + * @return the service client itself + */ + public LogAnalyticsDataClientImpl withGenerateClientRequestId(boolean generateClientRequestId) { + this.generateClientRequestId = generateClientRequestId; + return this; + } + + /** + * Initializes an instance of LogAnalyticsDataClient client. + * + * @param credentials the management credentials for Azure + */ + public LogAnalyticsDataClientImpl(ServiceClientCredentials credentials) { + this("https://api.loganalytics.io/v1", credentials); + } + + /** + * Initializes an instance of LogAnalyticsDataClient client. + * + * @param baseUrl the base URL of the host + * @param credentials the management credentials for Azure + */ + public LogAnalyticsDataClientImpl(String baseUrl, ServiceClientCredentials credentials) { + super(baseUrl, credentials); + initialize(); + } + + /** + * Initializes an instance of LogAnalyticsDataClient client. + * + * @param restClient the REST client to connect to Azure. + */ + public LogAnalyticsDataClientImpl(RestClient restClient) { + super(restClient); + initialize(); + } + + protected void initialize() { + this.acceptLanguage = "en-US"; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.azureClient = new AzureClient(this); + initializeService(); + } + + /** + * Gets the User-Agent header for the client. + * + * @return the user agent string. + */ + @Override + public String userAgent() { + return String.format("%s (%s, %s)", super.userAgent(), "LogAnalyticsDataClient", "v1"); + } + + private void initializeService() { + service = restClient().retrofit().create(LogAnalyticsDataClientService.class); + } + + /** + * The interface defining all the services for LogAnalyticsDataClient to be + * used by Retrofit to perform actually REST calls. + */ + interface LogAnalyticsDataClientService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.loganalytics.LogAnalyticsDataClient query" }) + @POST("workspaces/{workspaceId}/query") + Observable> query(@Path("workspaceId") String workspaceId, @Body QueryBody body, @Header("accept-language") String acceptLanguage, @Header("User-Agent") String userAgent); + + } + + /** + * Execute an Analytics query. + * Executes an Analytics query for data. [Here](https://dev.loganalytics.io/documentation/Using-the-API) is an example for using POST with an Analytics query. + * + * @param workspaceId ID of the workspace. This is Workspace ID from the Properties blade in the Azure portal. + * @param body The Analytics query. Learn more about the [Analytics query syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/) + * @throws IllegalArgumentException thrown if parameters fail the validation + * @throws ErrorResponseException thrown if the request is rejected by server + * @throws RuntimeException all other wrapped checked exceptions if the request fails to be sent + * @return the QueryResults object if successful. + */ + public QueryResults query(String workspaceId, QueryBody body) { + return queryWithServiceResponseAsync(workspaceId, body).toBlocking().single().body(); + } + + /** + * Execute an Analytics query. + * Executes an Analytics query for data. [Here](https://dev.loganalytics.io/documentation/Using-the-API) is an example for using POST with an Analytics query. + * + * @param workspaceId ID of the workspace. This is Workspace ID from the Properties blade in the Azure portal. + * @param body The Analytics query. Learn more about the [Analytics query syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/) + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the {@link ServiceFuture} object + */ + public ServiceFuture queryAsync(String workspaceId, QueryBody body, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(queryWithServiceResponseAsync(workspaceId, body), serviceCallback); + } + + /** + * Execute an Analytics query. + * Executes an Analytics query for data. [Here](https://dev.loganalytics.io/documentation/Using-the-API) is an example for using POST with an Analytics query. + * + * @param workspaceId ID of the workspace. This is Workspace ID from the Properties blade in the Azure portal. + * @param body The Analytics query. Learn more about the [Analytics query syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/) + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the QueryResults object + */ + public Observable queryAsync(String workspaceId, QueryBody body) { + return queryWithServiceResponseAsync(workspaceId, body).map(new Func1, QueryResults>() { + @Override + public QueryResults call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Execute an Analytics query. + * Executes an Analytics query for data. [Here](https://dev.loganalytics.io/documentation/Using-the-API) is an example for using POST with an Analytics query. + * + * @param workspaceId ID of the workspace. This is Workspace ID from the Properties blade in the Azure portal. + * @param body The Analytics query. Learn more about the [Analytics query syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/) + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the QueryResults object + */ + public Observable> queryWithServiceResponseAsync(String workspaceId, QueryBody body) { + if (workspaceId == null) { + throw new IllegalArgumentException("Parameter workspaceId is required and cannot be null."); + } + if (body == null) { + throw new IllegalArgumentException("Parameter body is required and cannot be null."); + } + Validator.validate(body); + return service.query(workspaceId, body, this.acceptLanguage(), this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = queryDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse queryDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.restClient().responseBuilderFactory().newInstance(this.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/implementation/package-info.java b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/implementation/package-info.java new file mode 100644 index 000000000000..265e5e521241 --- /dev/null +++ b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/implementation/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the implementation classes for LogAnalyticsDataClient. + * Log Analytics Data Plane Client. + */ +package com.microsoft.azure.loganalytics.implementation; diff --git a/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/Column.java b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/Column.java new file mode 100644 index 000000000000..4d2103234d74 --- /dev/null +++ b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/Column.java @@ -0,0 +1,70 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.loganalytics.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A table column. + * A column in a table. + */ +public class Column { + /** + * The name of this column. + */ + @JsonProperty(value = "name") + private String name; + + /** + * The data type of this column. + */ + @JsonProperty(value = "type") + private String type; + + /** + * Get the name of this column. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name of this column. + * + * @param name the name value to set + * @return the Column object itself. + */ + public Column withName(String name) { + this.name = name; + return this; + } + + /** + * Get the data type of this column. + * + * @return the type value + */ + public String type() { + return this.type; + } + + /** + * Set the data type of this column. + * + * @param type the type value to set + * @return the Column object itself. + */ + public Column withType(String type) { + this.type = type; + return this; + } + +} diff --git a/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/ErrorDetail.java b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/ErrorDetail.java new file mode 100644 index 000000000000..cc5a332d2913 --- /dev/null +++ b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/ErrorDetail.java @@ -0,0 +1,174 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.loganalytics.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Error details. + */ +public class ErrorDetail { + /** + * The error's code. + */ + @JsonProperty(value = "code", required = true) + private String code; + + /** + * A human readable error message. + */ + @JsonProperty(value = "message", required = true) + private String message; + + /** + * Indicates which property in the request is responsible for the error. + */ + @JsonProperty(value = "target") + private String target; + + /** + * Indicates which value in 'target' is responsible for the error. + */ + @JsonProperty(value = "value") + private String value; + + /** + * Indicates resources which were responsible for the error. + */ + @JsonProperty(value = "resources") + private List resources; + + /** + * The additionalProperties property. + */ + @JsonProperty(value = "additionalProperties") + private Object additionalProperties; + + /** + * Get the error's code. + * + * @return the code value + */ + public String code() { + return this.code; + } + + /** + * Set the error's code. + * + * @param code the code value to set + * @return the ErrorDetail object itself. + */ + public ErrorDetail withCode(String code) { + this.code = code; + return this; + } + + /** + * Get a human readable error message. + * + * @return the message value + */ + public String message() { + return this.message; + } + + /** + * Set a human readable error message. + * + * @param message the message value to set + * @return the ErrorDetail object itself. + */ + public ErrorDetail withMessage(String message) { + this.message = message; + return this; + } + + /** + * Get indicates which property in the request is responsible for the error. + * + * @return the target value + */ + public String target() { + return this.target; + } + + /** + * Set indicates which property in the request is responsible for the error. + * + * @param target the target value to set + * @return the ErrorDetail object itself. + */ + public ErrorDetail withTarget(String target) { + this.target = target; + return this; + } + + /** + * Get indicates which value in 'target' is responsible for the error. + * + * @return the value value + */ + public String value() { + return this.value; + } + + /** + * Set indicates which value in 'target' is responsible for the error. + * + * @param value the value value to set + * @return the ErrorDetail object itself. + */ + public ErrorDetail withValue(String value) { + this.value = value; + return this; + } + + /** + * Get indicates resources which were responsible for the error. + * + * @return the resources value + */ + public List resources() { + return this.resources; + } + + /** + * Set indicates resources which were responsible for the error. + * + * @param resources the resources value to set + * @return the ErrorDetail object itself. + */ + public ErrorDetail withResources(List resources) { + this.resources = resources; + return this; + } + + /** + * Get the additionalProperties value. + * + * @return the additionalProperties value + */ + public Object additionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties value. + * + * @param additionalProperties the additionalProperties value to set + * @return the ErrorDetail object itself. + */ + public ErrorDetail withAdditionalProperties(Object additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + +} diff --git a/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/ErrorInfo.java b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/ErrorInfo.java new file mode 100644 index 000000000000..e65b21879935 --- /dev/null +++ b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/ErrorInfo.java @@ -0,0 +1,148 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.loganalytics.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The code and message for an error. + */ +public class ErrorInfo { + /** + * A machine readable error code. + */ + @JsonProperty(value = "code", required = true) + private String code; + + /** + * A human readable error message. + */ + @JsonProperty(value = "message", required = true) + private String message; + + /** + * error details. + */ + @JsonProperty(value = "details") + private List details; + + /** + * Inner error details if they exist. + */ + @JsonProperty(value = "innererror") + private ErrorInfo innererror; + + /** + * The additionalProperties property. + */ + @JsonProperty(value = "additionalProperties") + private Object additionalProperties; + + /** + * Get a machine readable error code. + * + * @return the code value + */ + public String code() { + return this.code; + } + + /** + * Set a machine readable error code. + * + * @param code the code value to set + * @return the ErrorInfo object itself. + */ + public ErrorInfo withCode(String code) { + this.code = code; + return this; + } + + /** + * Get a human readable error message. + * + * @return the message value + */ + public String message() { + return this.message; + } + + /** + * Set a human readable error message. + * + * @param message the message value to set + * @return the ErrorInfo object itself. + */ + public ErrorInfo withMessage(String message) { + this.message = message; + return this; + } + + /** + * Get error details. + * + * @return the details value + */ + public List details() { + return this.details; + } + + /** + * Set error details. + * + * @param details the details value to set + * @return the ErrorInfo object itself. + */ + public ErrorInfo withDetails(List details) { + this.details = details; + return this; + } + + /** + * Get inner error details if they exist. + * + * @return the innererror value + */ + public ErrorInfo innererror() { + return this.innererror; + } + + /** + * Set inner error details if they exist. + * + * @param innererror the innererror value to set + * @return the ErrorInfo object itself. + */ + public ErrorInfo withInnererror(ErrorInfo innererror) { + this.innererror = innererror; + return this; + } + + /** + * Get the additionalProperties value. + * + * @return the additionalProperties value + */ + public Object additionalProperties() { + return this.additionalProperties; + } + + /** + * Set the additionalProperties value. + * + * @param additionalProperties the additionalProperties value to set + * @return the ErrorInfo object itself. + */ + public ErrorInfo withAdditionalProperties(Object additionalProperties) { + this.additionalProperties = additionalProperties; + return this; + } + +} diff --git a/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/ErrorResponse.java b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/ErrorResponse.java new file mode 100644 index 000000000000..0a30e4e4dbf0 --- /dev/null +++ b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/ErrorResponse.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.loganalytics.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Error details. + * Contains details when the response code indicates an error. + */ +public class ErrorResponse { + /** + * The error details. + */ + @JsonProperty(value = "error", required = true) + private ErrorInfo error; + + /** + * Get the error details. + * + * @return the error value + */ + public ErrorInfo error() { + return this.error; + } + + /** + * Set the error details. + * + * @param error the error value to set + * @return the ErrorResponse object itself. + */ + public ErrorResponse withError(ErrorInfo error) { + this.error = error; + return this; + } + +} diff --git a/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/ErrorResponseException.java b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/ErrorResponseException.java new file mode 100644 index 000000000000..7a8c7771d58d --- /dev/null +++ b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/ErrorResponseException.java @@ -0,0 +1,44 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.loganalytics.models; + +import com.microsoft.rest.RestException; +import okhttp3.ResponseBody; +import retrofit2.Response; + +/** + * Exception thrown for an invalid response with ErrorResponse information. + */ +public class ErrorResponseException extends RestException { + /** + * Initializes a new instance of the ErrorResponseException class. + * + * @param message the exception message or the response content if a message is not available + * @param response the HTTP response + */ + public ErrorResponseException(final String message, final Response response) { + super(message, response); + } + + /** + * Initializes a new instance of the ErrorResponseException class. + * + * @param message the exception message or the response content if a message is not available + * @param response the HTTP response + * @param body the deserialized response body + */ + public ErrorResponseException(final String message, final Response response, final ErrorResponse body) { + super(message, response, body); + } + + @Override + public ErrorResponse body() { + return (ErrorResponse) super.body(); + } +} diff --git a/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/QueryBody.java b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/QueryBody.java new file mode 100644 index 000000000000..1fceddac6624 --- /dev/null +++ b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/QueryBody.java @@ -0,0 +1,99 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.loganalytics.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The Analytics query. Learn more about the [Analytics query + * syntax](https://azure.microsoft.com/documentation/articles/app-insights-analytics-reference/). + */ +public class QueryBody { + /** + * The query to execute. + */ + @JsonProperty(value = "query", required = true) + private String query; + + /** + * Optional. The timespan over which to query data. This is an ISO8601 time + * period value. This timespan is applied in addition to any that are + * specified in the query expression. + */ + @JsonProperty(value = "timespan") + private String timespan; + + /** + * A list of workspaces that are included in the query. + */ + @JsonProperty(value = "workspaces") + private List workspaces; + + /** + * Get the query to execute. + * + * @return the query value + */ + public String query() { + return this.query; + } + + /** + * Set the query to execute. + * + * @param query the query value to set + * @return the QueryBody object itself. + */ + public QueryBody withQuery(String query) { + this.query = query; + return this; + } + + /** + * Get optional. The timespan over which to query data. This is an ISO8601 time period value. This timespan is applied in addition to any that are specified in the query expression. + * + * @return the timespan value + */ + public String timespan() { + return this.timespan; + } + + /** + * Set optional. The timespan over which to query data. This is an ISO8601 time period value. This timespan is applied in addition to any that are specified in the query expression. + * + * @param timespan the timespan value to set + * @return the QueryBody object itself. + */ + public QueryBody withTimespan(String timespan) { + this.timespan = timespan; + return this; + } + + /** + * Get a list of workspaces that are included in the query. + * + * @return the workspaces value + */ + public List workspaces() { + return this.workspaces; + } + + /** + * Set a list of workspaces that are included in the query. + * + * @param workspaces the workspaces value to set + * @return the QueryBody object itself. + */ + public QueryBody withWorkspaces(List workspaces) { + this.workspaces = workspaces; + return this; + } + +} diff --git a/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/QueryResults.java b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/QueryResults.java new file mode 100644 index 000000000000..bde5f9b305ed --- /dev/null +++ b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/QueryResults.java @@ -0,0 +1,45 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.loganalytics.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A query response. + * Contains the tables, columns & rows resulting from a query. + */ +public class QueryResults { + /** + * The list of tables, columns and rows. + */ + @JsonProperty(value = "tables", required = true) + private List tables; + + /** + * Get the list of tables, columns and rows. + * + * @return the tables value + */ + public List
tables() { + return this.tables; + } + + /** + * Set the list of tables, columns and rows. + * + * @param tables the tables value to set + * @return the QueryResults object itself. + */ + public QueryResults withTables(List
tables) { + this.tables = tables; + return this; + } + +} diff --git a/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/Table.java b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/Table.java new file mode 100644 index 000000000000..3ad5f0999188 --- /dev/null +++ b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/Table.java @@ -0,0 +1,97 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + */ + +package com.microsoft.azure.loganalytics.models; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * A query response table. + * Contains the columns and rows for one table in a query response. + */ +public class Table { + /** + * The name of the table. + */ + @JsonProperty(value = "name", required = true) + private String name; + + /** + * The list of columns in this table. + */ + @JsonProperty(value = "columns", required = true) + private List columns; + + /** + * The resulting rows from this query. + */ + @JsonProperty(value = "rows", required = true) + private List> rows; + + /** + * Get the name of the table. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Set the name of the table. + * + * @param name the name value to set + * @return the Table object itself. + */ + public Table withName(String name) { + this.name = name; + return this; + } + + /** + * Get the list of columns in this table. + * + * @return the columns value + */ + public List columns() { + return this.columns; + } + + /** + * Set the list of columns in this table. + * + * @param columns the columns value to set + * @return the Table object itself. + */ + public Table withColumns(List columns) { + this.columns = columns; + return this; + } + + /** + * Get the resulting rows from this query. + * + * @return the rows value + */ + public List> rows() { + return this.rows; + } + + /** + * Set the resulting rows from this query. + * + * @param rows the rows value to set + * @return the Table object itself. + */ + public Table withRows(List> rows) { + this.rows = rows; + return this; + } + +} diff --git a/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/package-info.java b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/package-info.java new file mode 100644 index 000000000000..1cadbca8849c --- /dev/null +++ b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the models classes for LogAnalyticsDataClient. + * Log Analytics Data Plane Client. + */ +package com.microsoft.azure.loganalytics.models; diff --git a/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/package-info.java b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/package-info.java new file mode 100644 index 000000000000..374e44497e9c --- /dev/null +++ b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/package-info.java @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator. + +/** + * This package contains the classes for LogAnalyticsDataClient. + * Log Analytics Data Plane Client. + */ +package com.microsoft.azure.loganalytics; From 90d9d593a54e0679b4db8dd4c1a30fdf880dd95a Mon Sep 17 00:00:00 2001 From: Ace Eldeib Date: Wed, 8 Aug 2018 14:31:09 -0700 Subject: [PATCH 2/6] update pom.xml --- loganalytics/data-plane/pom.xml | 40 +++++++++++++++++++++++++++++++-- 1 file changed, 38 insertions(+), 2 deletions(-) diff --git a/loganalytics/data-plane/pom.xml b/loganalytics/data-plane/pom.xml index 1ea55f720941..3b4c158d5f65 100644 --- a/loganalytics/data-plane/pom.xml +++ b/loganalytics/data-plane/pom.xml @@ -29,6 +29,8 @@ UTF-8 + 1.6.1 + record @@ -40,7 +42,7 @@ com.microsoft.azure azure-client-runtime - 1.5.0 + 1.6.1 junit @@ -51,9 +53,26 @@ com.microsoft.azure azure-client-authentication - 1.5.0 + ${runtime.version} test + + com.microsoft.azure + azure-arm-client-runtime + ${runtime.version} + test-jar + test + + + com.microsoft.azure + azure-arm-client-runtime + ${runtime.version} + + + com.microsoft.azure + azure-client-runtime + ${runtime.version} + @@ -110,6 +129,23 @@ + + org.apache.maven.plugins + maven-surefire-plugin + 2.20 + + false + + **/Test*.java + **/*Test.java + **/*Tests.java + **/*TestCase.java + + + ${testMode} + + + From e2dc5e17cefd05e869adab08f3078b9a28bfbaf2 Mon Sep 17 00:00:00 2001 From: Ace Eldeib Date: Wed, 8 Aug 2018 15:27:37 -0700 Subject: [PATCH 3/6] update row type, version correctly, rebase off master, update tests --- api-specs.json | 8 ++-- loganalytics/data-plane/pom.xml | 2 +- .../loganalytics/LogAnalyticsDataClient.java | 12 +++--- .../LogAnalyticsDataClientImpl.java | 18 ++++----- .../azure/loganalytics/models/Table.java | 6 +-- .../LogAnalyticsDataClientTests.java | 37 +++++++++++++++++++ 6 files changed, 60 insertions(+), 23 deletions(-) create mode 100644 loganalytics/data-plane/src/test/java/com/microsoft/azure/loganalytics/LogAnalyticsDataClientTests.java diff --git a/api-specs.json b/api-specs.json index 1959721b41e7..e2f7de958adf 100644 --- a/api-specs.json +++ b/api-specs.json @@ -72,6 +72,10 @@ "source": "specification/keyvault/resource-manager/readme.md", "args": "--multiapi --fluent" }, + "loganalytics/data-plane": { + "source": "specification/operationalinsights/data-plane/readme.md", + "args": "--payload-flattening-threshold=1 --override-client-name=LogAnalyticsDataClient" + }, "logic/resource-manager": { "source": "specification/logic/resource-manager/readme.md", "args": "--multiapi --fluent" @@ -80,10 +84,6 @@ "source": "specification/notificationhubs/resource-manager/readme.md", "args": "--multiapi --fluent" }, - "loganalytics/data-plane": { - "source": "specification/operationalinsights/data-plane/readme.md", - "args": "--payload-flattening-threshold=1 --override-client-name=LogAnalyticsDataClient" - }, "mediaservices/resource-manager": { "source": "specification/mediaservices/resource-manager/readme.md", "args": "--multiapi --fluent" diff --git a/loganalytics/data-plane/pom.xml b/loganalytics/data-plane/pom.xml index 3b4c158d5f65..ee3869964c3d 100644 --- a/loganalytics/data-plane/pom.xml +++ b/loganalytics/data-plane/pom.xml @@ -9,7 +9,7 @@ 4.0.0 com.microsoft.azure azure-loganalytics - 0.0.1-beta + 1.0.0-Preview-1 jar Microsoft Azure SDK for Log Analytics This package contains Microsoft Log Analytics SDK. diff --git a/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/LogAnalyticsDataClient.java b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/LogAnalyticsDataClient.java index 8f2a9a889658..d3408c258d51 100644 --- a/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/LogAnalyticsDataClient.java +++ b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/LogAnalyticsDataClient.java @@ -44,14 +44,14 @@ public interface LogAnalyticsDataClient { String userAgent(); /** - * Gets Gets or sets the preferred language for the response.. + * Gets The preferred language for the response.. * * @return the acceptLanguage value. */ String acceptLanguage(); /** - * Sets Gets or sets the preferred language for the response.. + * Sets The preferred language for the response.. * * @param acceptLanguage the acceptLanguage value. * @return the service client itself @@ -59,14 +59,14 @@ public interface LogAnalyticsDataClient { LogAnalyticsDataClient withAcceptLanguage(String acceptLanguage); /** - * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.. + * Gets The retry timeout in seconds for Long Running Operations. Default value is 30.. * * @return the longRunningOperationRetryTimeout value. */ int longRunningOperationRetryTimeout(); /** - * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30.. + * Sets The retry timeout in seconds for Long Running Operations. Default value is 30.. * * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. * @return the service client itself @@ -74,14 +74,14 @@ public interface LogAnalyticsDataClient { LogAnalyticsDataClient withLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout); /** - * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.. + * Gets Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.. * * @return the generateClientRequestId value. */ boolean generateClientRequestId(); /** - * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.. + * Sets Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true.. * * @param generateClientRequestId the generateClientRequestId value. * @return the service client itself diff --git a/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/implementation/LogAnalyticsDataClientImpl.java b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/implementation/LogAnalyticsDataClientImpl.java index b820dce30f5e..e27ac9b6f98d 100644 --- a/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/implementation/LogAnalyticsDataClientImpl.java +++ b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/implementation/LogAnalyticsDataClientImpl.java @@ -49,11 +49,11 @@ public AzureClient getAzureClient() { return this.azureClient; } - /** Gets or sets the preferred language for the response. */ + /** The preferred language for the response. */ private String acceptLanguage; /** - * Gets Gets or sets the preferred language for the response. + * Gets The preferred language for the response. * * @return the acceptLanguage value. */ @@ -62,7 +62,7 @@ public String acceptLanguage() { } /** - * Sets Gets or sets the preferred language for the response. + * Sets The preferred language for the response. * * @param acceptLanguage the acceptLanguage value. * @return the service client itself @@ -72,11 +72,11 @@ public LogAnalyticsDataClientImpl withAcceptLanguage(String acceptLanguage) { return this; } - /** Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. */ + /** The retry timeout in seconds for Long Running Operations. Default value is 30. */ private int longRunningOperationRetryTimeout; /** - * Gets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * Gets The retry timeout in seconds for Long Running Operations. Default value is 30. * * @return the longRunningOperationRetryTimeout value. */ @@ -85,7 +85,7 @@ public int longRunningOperationRetryTimeout() { } /** - * Sets Gets or sets the retry timeout in seconds for Long Running Operations. Default value is 30. + * Sets The retry timeout in seconds for Long Running Operations. Default value is 30. * * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. * @return the service client itself @@ -95,11 +95,11 @@ public LogAnalyticsDataClientImpl withLongRunningOperationRetryTimeout(int longR return this; } - /** When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ + /** Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. */ private boolean generateClientRequestId; /** - * Gets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * Gets Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. * * @return the generateClientRequestId value. */ @@ -108,7 +108,7 @@ public boolean generateClientRequestId() { } /** - * Sets When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. + * Sets Whether a unique x-ms-client-request-id should be generated. When set to true a unique x-ms-client-request-id value is generated and included in each request. Default is true. * * @param generateClientRequestId the generateClientRequestId value. * @return the service client itself diff --git a/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/Table.java b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/Table.java index 3ad5f0999188..506d6a9f24b9 100644 --- a/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/Table.java +++ b/loganalytics/data-plane/src/main/java/com/microsoft/azure/loganalytics/models/Table.java @@ -32,7 +32,7 @@ public class Table { * The resulting rows from this query. */ @JsonProperty(value = "rows", required = true) - private List> rows; + private List> rows; /** * Get the name of the table. @@ -79,7 +79,7 @@ public Table withColumns(List columns) { * * @return the rows value */ - public List> rows() { + public List> rows() { return this.rows; } @@ -89,7 +89,7 @@ public List> rows() { * @param rows the rows value to set * @return the Table object itself. */ - public Table withRows(List> rows) { + public Table withRows(List> rows) { this.rows = rows; return this; } diff --git a/loganalytics/data-plane/src/test/java/com/microsoft/azure/loganalytics/LogAnalyticsDataClientTests.java b/loganalytics/data-plane/src/test/java/com/microsoft/azure/loganalytics/LogAnalyticsDataClientTests.java new file mode 100644 index 000000000000..cd831b82c298 --- /dev/null +++ b/loganalytics/data-plane/src/test/java/com/microsoft/azure/loganalytics/LogAnalyticsDataClientTests.java @@ -0,0 +1,37 @@ +package com.microsoft.azure.loganalytics; + +import com.microsoft.azure.AzureEnvironment; +import com.microsoft.azure.loganalytics.implementation.LogAnalyticsDataClientImpl; +import com.microsoft.azure.loganalytics.models.QueryBody; +import com.microsoft.azure.loganalytics.models.QueryResults; +import com.microsoft.azure.credentials.ApplicationTokenCredentials; +import com.microsoft.azure.arm.core.TestBase; +import com.microsoft.rest.RestClient; +import org.junit.Assert; +import org.junit.Test; + +public class LogAnalyticsDataClientTests { + protected static LogAnalyticsDataClientImpl logAnalyticsClient; + + public void initialize() { + ApplicationTokenCredentials credentials = new ApplicationTokenCredentials("997631f8-3a55-4bb2-81b2-c0972b222260", "microsoft.onmicrosoft.com", "Fmvuhf5imWGlA5zQ5jZNmelm5cpcVP85k8ja7BMPgzA=", null); + logAnalyticsClient = new LogAnalyticsDataClientImpl(credentials); + } + + @Test + public void firstTest() { + this.initialize(); + String query = "Heartbeat | take 1"; + String workspaceId = "cab864ad-d0c1-496b-bc5e-4418315621bf"; + QueryResults queryResults = logAnalyticsClient.query(workspaceId, new QueryBody().withQuery(query)); + Assert.assertNotNull(queryResults); + + // Query should return a single table with one row + Assert.assertEquals(queryResults.tables().size(), 1); + + // Check type behavior on results + Assert.assertTrue(queryResults.tables().get(0).rows().get(0).get(16) instanceof Double); + Assert.assertNull(queryResults.tables().get(0).rows().get(0).get(15)); + + } +} \ No newline at end of file From 4bc9cfe8aad9c24af83e79a81f7e6a2cd0afd695 Mon Sep 17 00:00:00 2001 From: Ace Eldeib Date: Wed, 8 Aug 2018 15:32:47 -0700 Subject: [PATCH 4/6] Remove exposed credentials; delete associated app --- .../azure/loganalytics/LogAnalyticsDataClientTests.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/loganalytics/data-plane/src/test/java/com/microsoft/azure/loganalytics/LogAnalyticsDataClientTests.java b/loganalytics/data-plane/src/test/java/com/microsoft/azure/loganalytics/LogAnalyticsDataClientTests.java index cd831b82c298..5f5d41fd0dde 100644 --- a/loganalytics/data-plane/src/test/java/com/microsoft/azure/loganalytics/LogAnalyticsDataClientTests.java +++ b/loganalytics/data-plane/src/test/java/com/microsoft/azure/loganalytics/LogAnalyticsDataClientTests.java @@ -14,7 +14,7 @@ public class LogAnalyticsDataClientTests { protected static LogAnalyticsDataClientImpl logAnalyticsClient; public void initialize() { - ApplicationTokenCredentials credentials = new ApplicationTokenCredentials("997631f8-3a55-4bb2-81b2-c0972b222260", "microsoft.onmicrosoft.com", "Fmvuhf5imWGlA5zQ5jZNmelm5cpcVP85k8ja7BMPgzA=", null); + ApplicationTokenCredentials credentials = new ApplicationTokenCredentials("", "", "", null); logAnalyticsClient = new LogAnalyticsDataClientImpl(credentials); } @@ -32,6 +32,6 @@ public void firstTest() { // Check type behavior on results Assert.assertTrue(queryResults.tables().get(0).rows().get(0).get(16) instanceof Double); Assert.assertNull(queryResults.tables().get(0).rows().get(0).get(15)); - + } } \ No newline at end of file From cefd635e87b6855002c5e7ea82fa14e58256c85b Mon Sep 17 00:00:00 2001 From: Ace Eldeib Date: Thu, 9 Aug 2018 12:37:32 -0700 Subject: [PATCH 5/6] update tests --- .../LogAnalyticsDataClientTests.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/loganalytics/data-plane/src/test/java/com/microsoft/azure/loganalytics/LogAnalyticsDataClientTests.java b/loganalytics/data-plane/src/test/java/com/microsoft/azure/loganalytics/LogAnalyticsDataClientTests.java index 5f5d41fd0dde..6a4a5604efb8 100644 --- a/loganalytics/data-plane/src/test/java/com/microsoft/azure/loganalytics/LogAnalyticsDataClientTests.java +++ b/loganalytics/data-plane/src/test/java/com/microsoft/azure/loganalytics/LogAnalyticsDataClientTests.java @@ -4,23 +4,32 @@ import com.microsoft.azure.loganalytics.implementation.LogAnalyticsDataClientImpl; import com.microsoft.azure.loganalytics.models.QueryBody; import com.microsoft.azure.loganalytics.models.QueryResults; -import com.microsoft.azure.credentials.ApplicationTokenCredentials; +import com.microsoft.azure.credentials.AzureTokenCredentials; import com.microsoft.azure.arm.core.TestBase; import com.microsoft.rest.RestClient; import org.junit.Assert; import org.junit.Test; -public class LogAnalyticsDataClientTests { +public class LogAnalyticsDataClientTests extends TestBase { protected static LogAnalyticsDataClientImpl logAnalyticsClient; - public void initialize() { - ApplicationTokenCredentials credentials = new ApplicationTokenCredentials("", "", "", null); - logAnalyticsClient = new LogAnalyticsDataClientImpl(credentials); + @Override + protected String baseUri() { + return AzureEnvironment.AZURE.logAnalyticsEndpoint() + "v1/"; + } + + @Override + protected void initializeClients(RestClient restClient, String defaultSubscription, String domain) { + logAnalyticsClient = new LogAnalyticsDataClientImpl(restClient); + } + + @Override + protected void cleanUpResources() { + return; } @Test public void firstTest() { - this.initialize(); String query = "Heartbeat | take 1"; String workspaceId = "cab864ad-d0c1-496b-bc5e-4418315621bf"; QueryResults queryResults = logAnalyticsClient.query(workspaceId, new QueryBody().withQuery(query)); @@ -28,10 +37,11 @@ public void firstTest() { // Query should return a single table with one row Assert.assertEquals(queryResults.tables().size(), 1); + Assert.assertEquals(queryResults.tables().get(0).rows().size(), 1); // Check type behavior on results + Assert.assertTrue(queryResults.tables().get(0).rows().get(0).get(1) instanceof String); Assert.assertTrue(queryResults.tables().get(0).rows().get(0).get(16) instanceof Double); Assert.assertNull(queryResults.tables().get(0).rows().get(0).get(15)); - } } \ No newline at end of file From 3a8e6322ac457ca1d92ec78a10b61a29f75a343c Mon Sep 17 00:00:00 2001 From: Ace Eldeib Date: Thu, 9 Aug 2018 12:42:08 -0700 Subject: [PATCH 6/6] add test recording --- .../session-records/firstTest.json | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 loganalytics/data-plane/target/test-classes/session-records/firstTest.json diff --git a/loganalytics/data-plane/target/test-classes/session-records/firstTest.json b/loganalytics/data-plane/target/test-classes/session-records/firstTest.json new file mode 100644 index 000000000000..416dfc85cc00 --- /dev/null +++ b/loganalytics/data-plane/target/test-classes/session-records/firstTest.json @@ -0,0 +1,28 @@ +{ + "networkCallRecords" : [ { + "Method" : "POST", + "Uri" : "http://localhost:1234/workspaces/cab864ad-d0c1-496b-bc5e-4418315621bf/query", + "Headers" : { + "User-Agent" : "Azure-SDK-For-Java/null OS:Windows 10/10.0 MacAddressHash:a868cd1346b534e1d19791216fab6df609d09c66b0f97bd640af4913ad89527e Java:10.0.1 (LogAnalyticsDataClient, v1)", + "Content-Type" : "application/json; charset=utf-8" + }, + "Response" : { + "date" : "Thu, 09 Aug 2018 19:35:54 GMT", + "server" : "nginx", + "content-length" : "1906", + "vary" : "Accept-Encoding", + "retry-after" : "0", + "StatusCode" : "200", + "strict-transport-security" : "max-age=31536000000; includeSubDomains", + "access-control-expose-headers" : "Retry-After,Age,WWW-Authenticate,x-resource-identities,x-ms-status-location", + "via" : "1.1 draft-oms-green.efbb771c-9c05-11e8-9972-70b3d5800001", + "access-control-allow-origin" : "*", + "x-content-type-options" : "nosniff", + "content-location" : "https://eastus.api.loganalytics.io/v1/workspaces/cab864ad-d0c1-496b-bc5e-4418315621bf/query", + "content-type" : "application/json; charset=utf-8", + "Body" : "{\"tables\":[{\"name\":\"PrimaryResult\",\"columns\":[{\"name\":\"TenantId\",\"type\":\"string\"},{\"name\":\"SourceSystem\",\"type\":\"string\"},{\"name\":\"TimeGenerated\",\"type\":\"datetime\"},{\"name\":\"MG\",\"type\":\"string\"},{\"name\":\"ManagementGroupName\",\"type\":\"string\"},{\"name\":\"SourceComputerId\",\"type\":\"string\"},{\"name\":\"ComputerIP\",\"type\":\"string\"},{\"name\":\"Computer\",\"type\":\"string\"},{\"name\":\"Category\",\"type\":\"string\"},{\"name\":\"OSType\",\"type\":\"string\"},{\"name\":\"OSName\",\"type\":\"string\"},{\"name\":\"OSMajorVersion\",\"type\":\"string\"},{\"name\":\"OSMinorVersion\",\"type\":\"string\"},{\"name\":\"Version\",\"type\":\"string\"},{\"name\":\"SCAgentChannel\",\"type\":\"string\"},{\"name\":\"IsGatewayInstalled\",\"type\":\"bool\"},{\"name\":\"RemoteIPLongitude\",\"type\":\"real\"},{\"name\":\"RemoteIPLatitude\",\"type\":\"real\"},{\"name\":\"RemoteIPCountry\",\"type\":\"string\"},{\"name\":\"SubscriptionId\",\"type\":\"string\"},{\"name\":\"ResourceGroup\",\"type\":\"string\"},{\"name\":\"ResourceProvider\",\"type\":\"string\"},{\"name\":\"Resource\",\"type\":\"string\"},{\"name\":\"ResourceId\",\"type\":\"string\"},{\"name\":\"ResourceType\",\"type\":\"string\"},{\"name\":\"ComputerEnvironment\",\"type\":\"string\"},{\"name\":\"Solutions\",\"type\":\"string\"},{\"name\":\"VMUUID\",\"type\":\"string\"},{\"name\":\"Type\",\"type\":\"string\"}],\"rows\":[[\"cab864ad-d0c1-496b-bc5e-4418315621bf\",\"OpsManager\",\"2018-07-19T06:16:53.32Z\",\"00000000-0000-0000-0000-000000000002\",\"\",\"54a48994-9f16-444b-8433-d7ba1f44f1c8\",\"104.42.118.149\",\"dcos-master-draftacs-int-green-0\",\"Direct Agent\",\"Linux\",\"Ubuntu\",\"16\",\"04\",\"1.6.0-42\",\"Direct\",null,-121.83,37.32,\"United States\",\"00000000-0000-0000-0000-000000000000\",\"draftacs-int-green\",\"microsoft.compute\",\"dcos-master-draftacs-int-green-0\",\"/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/draftacs-int-green/providers/microsoft.compute/virtualmachines/dcos-master-draftacs-int-green-0\",\"virtualmachines\",\"Azure\",\"\\\"security\\\", \\\"securityCenterFree\\\"\",\"1bae5f16-d661-7347-9427-a26b391ae746\",\"Heartbeat\"]]}]}", + "age" : "36" + } + } ], + "variables" : [ ] +} \ No newline at end of file