diff --git a/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/EndpointSettings.java b/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/EndpointSettings.java new file mode 100644 index 000000000000..eded5960888d --- /dev/null +++ b/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/EndpointSettings.java @@ -0,0 +1,133 @@ +/** + * 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.cognitiveservices.knowledge.qnamaker; + +import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.EndpointSettingsDTO; +import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.EndpointSettingsDTOActiveLearning; +import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.ErrorResponseException; +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceFuture; +import com.microsoft.rest.ServiceResponse; +import java.io.IOException; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in EndpointSettings. + */ +public interface EndpointSettings { + /** + * Gets endpoint settings for an endpoint. + * + * @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 EndpointSettingsDTO object if successful. + */ + EndpointSettingsDTO getSettings(); + + /** + * Gets endpoint settings for an endpoint. + * + * @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 getSettingsAsync(final ServiceCallback serviceCallback); + + /** + * Gets endpoint settings for an endpoint. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the EndpointSettingsDTO object + */ + Observable getSettingsAsync(); + + /** + * Gets endpoint settings for an endpoint. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the EndpointSettingsDTO object + */ + Observable> getSettingsWithServiceResponseAsync(); + + /** + * Updates endpoint settings for an endpoint. + * + * @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 String object if successful. + */ + String updateSettings(); + + /** + * Updates endpoint settings for an endpoint. + * + * @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 updateSettingsAsync(final ServiceCallback serviceCallback); + + /** + * Updates endpoint settings for an endpoint. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the String object + */ + Observable updateSettingsAsync(); + + /** + * Updates endpoint settings for an endpoint. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the String object + */ + Observable> updateSettingsWithServiceResponseAsync(); + /** + * Updates endpoint settings for an endpoint. + * + * @param activeLearning Active Learning settings of the endpoint. + * @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 String object if successful. + */ + String updateSettings(EndpointSettingsDTOActiveLearning activeLearning); + + /** + * Updates endpoint settings for an endpoint. + * + * @param activeLearning Active Learning settings of the endpoint. + * @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 updateSettingsAsync(EndpointSettingsDTOActiveLearning activeLearning, final ServiceCallback serviceCallback); + + /** + * Updates endpoint settings for an endpoint. + * + * @param activeLearning Active Learning settings of the endpoint. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the String object + */ + Observable updateSettingsAsync(EndpointSettingsDTOActiveLearning activeLearning); + + /** + * Updates endpoint settings for an endpoint. + * + * @param activeLearning Active Learning settings of the endpoint. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the String object + */ + Observable> updateSettingsWithServiceResponseAsync(EndpointSettingsDTOActiveLearning activeLearning); + +} diff --git a/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/QnAMakerClient.java b/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/QnAMakerClient.java index 24bd31a62d99..6ef812c6a75e 100644 --- a/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/QnAMakerClient.java +++ b/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/QnAMakerClient.java @@ -95,6 +95,12 @@ public interface QnAMakerClient { */ QnAMakerClient withGenerateClientRequestId(boolean generateClientRequestId); + /** + * Gets the EndpointSettings object to access its operations. + * @return the EndpointSettings object. + */ + EndpointSettings endpointSettings(); + /** * Gets the EndpointKeys object to access its operations. * @return the EndpointKeys object. diff --git a/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/EndpointSettingsImpl.java b/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/EndpointSettingsImpl.java new file mode 100644 index 000000000000..d35ab8d72ca0 --- /dev/null +++ b/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/EndpointSettingsImpl.java @@ -0,0 +1,282 @@ +/** + * 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.cognitiveservices.knowledge.qnamaker.implementation; + +import retrofit2.Retrofit; +import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.EndpointSettings; +import com.google.common.base.Joiner; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.EndpointSettingsDTO; +import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.EndpointSettingsDTOActiveLearning; +import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.models.ErrorResponseException; +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.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.PATCH; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in EndpointSettings. + */ +public class EndpointSettingsImpl implements EndpointSettings { + /** The Retrofit service to perform REST calls. */ + private EndpointSettingsService service; + /** The service client containing this operation class. */ + private QnAMakerClientImpl client; + + /** + * Initializes an instance of EndpointSettingsImpl. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public EndpointSettingsImpl(Retrofit retrofit, QnAMakerClientImpl client) { + this.service = retrofit.create(EndpointSettingsService.class); + this.client = client; + } + + /** + * The interface defining all the services for EndpointSettings to be + * used by Retrofit to perform actually REST calls. + */ + interface EndpointSettingsService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.knowledge.qnamaker.EndpointSettings getSettings" }) + @GET("endpointSettings") + Observable> getSettings(@Header("accept-language") String acceptLanguage, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.knowledge.qnamaker.EndpointSettings updateSettings" }) + @PATCH("endpointSettings") + Observable> updateSettings(@Header("accept-language") String acceptLanguage, @Body EndpointSettingsDTO endpointSettingsPayload, @Header("x-ms-parameterized-host") String parameterizedHost, @Header("User-Agent") String userAgent); + + } + + /** + * Gets endpoint settings for an endpoint. + * + * @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 EndpointSettingsDTO object if successful. + */ + public EndpointSettingsDTO getSettings() { + return getSettingsWithServiceResponseAsync().toBlocking().single().body(); + } + + /** + * Gets endpoint settings for an endpoint. + * + * @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 getSettingsAsync(final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(getSettingsWithServiceResponseAsync(), serviceCallback); + } + + /** + * Gets endpoint settings for an endpoint. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the EndpointSettingsDTO object + */ + public Observable getSettingsAsync() { + return getSettingsWithServiceResponseAsync().map(new Func1, EndpointSettingsDTO>() { + @Override + public EndpointSettingsDTO call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Gets endpoint settings for an endpoint. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the EndpointSettingsDTO object + */ + public Observable> getSettingsWithServiceResponseAsync() { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.getSettings(this.client.acceptLanguage(), parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = getSettingsDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse getSettingsDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + + /** + * Updates endpoint settings for an endpoint. + * + * @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 String object if successful. + */ + public String updateSettings() { + return updateSettingsWithServiceResponseAsync().toBlocking().single().body(); + } + + /** + * Updates endpoint settings for an endpoint. + * + * @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 updateSettingsAsync(final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateSettingsWithServiceResponseAsync(), serviceCallback); + } + + /** + * Updates endpoint settings for an endpoint. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the String object + */ + public Observable updateSettingsAsync() { + return updateSettingsWithServiceResponseAsync().map(new Func1, String>() { + @Override + public String call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Updates endpoint settings for an endpoint. + * + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the String object + */ + public Observable> updateSettingsWithServiceResponseAsync() { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + final EndpointSettingsDTOActiveLearning activeLearning = null; + EndpointSettingsDTO endpointSettingsPayload = new EndpointSettingsDTO(); + endpointSettingsPayload.withActiveLearning(null); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.updateSettings(this.client.acceptLanguage(), endpointSettingsPayload, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateSettingsDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * Updates endpoint settings for an endpoint. + * + * @param activeLearning Active Learning settings of the endpoint. + * @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 String object if successful. + */ + public String updateSettings(EndpointSettingsDTOActiveLearning activeLearning) { + return updateSettingsWithServiceResponseAsync(activeLearning).toBlocking().single().body(); + } + + /** + * Updates endpoint settings for an endpoint. + * + * @param activeLearning Active Learning settings of the endpoint. + * @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 updateSettingsAsync(EndpointSettingsDTOActiveLearning activeLearning, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(updateSettingsWithServiceResponseAsync(activeLearning), serviceCallback); + } + + /** + * Updates endpoint settings for an endpoint. + * + * @param activeLearning Active Learning settings of the endpoint. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the String object + */ + public Observable updateSettingsAsync(EndpointSettingsDTOActiveLearning activeLearning) { + return updateSettingsWithServiceResponseAsync(activeLearning).map(new Func1, String>() { + @Override + public String call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * Updates endpoint settings for an endpoint. + * + * @param activeLearning Active Learning settings of the endpoint. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the String object + */ + public Observable> updateSettingsWithServiceResponseAsync(EndpointSettingsDTOActiveLearning activeLearning) { + if (this.client.endpoint() == null) { + throw new IllegalArgumentException("Parameter this.client.endpoint() is required and cannot be null."); + } + Validator.validate(activeLearning); + EndpointSettingsDTO endpointSettingsPayload = new EndpointSettingsDTO(); + endpointSettingsPayload.withActiveLearning(activeLearning); + String parameterizedHost = Joiner.on(", ").join("{Endpoint}", this.client.endpoint()); + return service.updateSettings(this.client.acceptLanguage(), endpointSettingsPayload, parameterizedHost, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = updateSettingsDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse updateSettingsDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/QnAMakerClientImpl.java b/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/QnAMakerClientImpl.java index 61acd0db8625..aa195f3c9dc3 100644 --- a/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/QnAMakerClientImpl.java +++ b/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/implementation/QnAMakerClientImpl.java @@ -12,6 +12,7 @@ import com.microsoft.azure.AzureServiceClient; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.Alterations; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.EndpointKeys; +import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.EndpointSettings; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.Knowledgebases; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.Operations; import com.microsoft.azure.cognitiveservices.knowledge.qnamaker.QnAMakerClient; @@ -125,6 +126,19 @@ public QnAMakerClientImpl withGenerateClientRequestId(boolean generateClientRequ return this; } + /** + * The EndpointSettings object to access its operations. + */ + private EndpointSettings endpointSettings; + + /** + * Gets the EndpointSettings object to access its operations. + * @return the EndpointSettings object. + */ + public EndpointSettings endpointSettings() { + return this.endpointSettings; + } + /** * The EndpointKeys object to access its operations. */ @@ -211,6 +225,7 @@ protected void initialize() { this.acceptLanguage = "en-US"; this.longRunningOperationRetryTimeout = 30; this.generateClientRequestId = true; + this.endpointSettings = new EndpointSettingsImpl(restClient().retrofit(), this); this.endpointKeys = new EndpointKeysImpl(restClient().retrofit(), this); this.alterations = new AlterationsImpl(restClient().retrofit(), this); this.knowledgebases = new KnowledgebasesImpl(restClient().retrofit(), this); diff --git a/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/ActiveLearningSettingsDTO.java b/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/ActiveLearningSettingsDTO.java new file mode 100644 index 000000000000..0ef00cab59c3 --- /dev/null +++ b/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/ActiveLearningSettingsDTO.java @@ -0,0 +1,43 @@ +/** + * 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.cognitiveservices.knowledge.qnamaker.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Active Learning settings of the endpoint. + */ +public class ActiveLearningSettingsDTO { + /** + * True/False string providing Active Learning. + */ + @JsonProperty(value = "enable") + private String enable; + + /** + * Get true/False string providing Active Learning. + * + * @return the enable value + */ + public String enable() { + return this.enable; + } + + /** + * Set true/False string providing Active Learning. + * + * @param enable the enable value to set + * @return the ActiveLearningSettingsDTO object itself. + */ + public ActiveLearningSettingsDTO withEnable(String enable) { + this.enable = enable; + return this; + } + +} diff --git a/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/EndpointSettingsDTO.java b/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/EndpointSettingsDTO.java new file mode 100644 index 000000000000..0b2636a0dba5 --- /dev/null +++ b/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/EndpointSettingsDTO.java @@ -0,0 +1,43 @@ +/** + * 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.cognitiveservices.knowledge.qnamaker.models; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Endpoint settings. + */ +public class EndpointSettingsDTO { + /** + * Active Learning settings of the endpoint. + */ + @JsonProperty(value = "activeLearning") + private EndpointSettingsDTOActiveLearning activeLearning; + + /** + * Get active Learning settings of the endpoint. + * + * @return the activeLearning value + */ + public EndpointSettingsDTOActiveLearning activeLearning() { + return this.activeLearning; + } + + /** + * Set active Learning settings of the endpoint. + * + * @param activeLearning the activeLearning value to set + * @return the EndpointSettingsDTO object itself. + */ + public EndpointSettingsDTO withActiveLearning(EndpointSettingsDTOActiveLearning activeLearning) { + this.activeLearning = activeLearning; + return this; + } + +} diff --git a/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/EndpointSettingsDTOActiveLearning.java b/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/EndpointSettingsDTOActiveLearning.java new file mode 100644 index 000000000000..6851fe0c0258 --- /dev/null +++ b/cognitiveservices/data-plane/knowledge/qnamaker/src/main/java/com/microsoft/azure/cognitiveservices/knowledge/qnamaker/models/EndpointSettingsDTOActiveLearning.java @@ -0,0 +1,16 @@ +/** + * 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.cognitiveservices.knowledge.qnamaker.models; + + +/** + * Active Learning settings of the endpoint. + */ +public class EndpointSettingsDTOActiveLearning extends ActiveLearningSettingsDTO { +}