diff --git a/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/ActionType.java b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/ActionType.java new file mode 100644 index 00000000000..2aac319216f --- /dev/null +++ b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/ActionType.java @@ -0,0 +1,41 @@ +/** + * 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.spellcheck; + +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; + +/** + * Defines values for ActionType. + */ +public final class ActionType extends ExpandableStringEnum { + /** Static value Edit for ActionType. */ + public static final ActionType EDIT = fromString("Edit"); + + /** Static value Load for ActionType. */ + public static final ActionType LOAD = fromString("Load"); + + /** + * Creates or finds a ActionType from its string representation. + * @param name a name to look for + * @return the corresponding ActionType + */ + @JsonCreator + public static ActionType fromString(String name) { + return fromString(name, ActionType.class); + } + + /** + * @return known ActionType values + */ + public static Collection values() { + return values(ActionType.class); + } +} diff --git a/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/Answer.java b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/Answer.java new file mode 100644 index 00000000000..24ca1b98c7d --- /dev/null +++ b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/Answer.java @@ -0,0 +1,24 @@ +/** + * 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.spellcheck; + +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonSubTypes; + +/** + * The Answer model. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "_type") +@JsonTypeName("Answer") +@JsonSubTypes({ + @JsonSubTypes.Type(name = "SpellCheck", value = SpellCheckInner.class) +}) +public class Answer extends Response { +} diff --git a/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/Error.java b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/Error.java new file mode 100644 index 00000000000..4f1e50ebae2 --- /dev/null +++ b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/Error.java @@ -0,0 +1,135 @@ +/** + * 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.spellcheck; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Defines the error that occurred. + */ +public class Error { + /** + * The error code that identifies the category of error. Possible values + * include: 'None', 'ServerError', 'InvalidRequest', 'RateLimitExceeded', + * 'InvalidAuthorization', 'InsufficientAuthorization'. + */ + @JsonProperty(value = "code", required = true) + private ErrorCode code; + + /** + * The error code that further helps to identify the error. Possible values + * include: 'UnexpectedError', 'ResourceError', 'NotImplemented', + * 'ParameterMissing', 'ParameterInvalidValue', 'HttpNotAllowed', + * 'Blocked', 'AuthorizationMissing', 'AuthorizationRedundancy', + * 'AuthorizationDisabled', 'AuthorizationExpired'. + */ + @JsonProperty(value = "subCode", access = JsonProperty.Access.WRITE_ONLY) + private ErrorSubCode subCode; + + /** + * A description of the error. + */ + @JsonProperty(value = "message", required = true) + private String message; + + /** + * A description that provides additional information about the error. + */ + @JsonProperty(value = "moreDetails", access = JsonProperty.Access.WRITE_ONLY) + private String moreDetails; + + /** + * The parameter in the request that caused the error. + */ + @JsonProperty(value = "parameter", access = JsonProperty.Access.WRITE_ONLY) + private String parameter; + + /** + * The parameter's value in the request that was not valid. + */ + @JsonProperty(value = "value", access = JsonProperty.Access.WRITE_ONLY) + private String value; + + /** + * Get the code value. + * + * @return the code value + */ + public ErrorCode code() { + return this.code; + } + + /** + * Set the code value. + * + * @param code the code value to set + * @return the Error object itself. + */ + public Error withCode(ErrorCode code) { + this.code = code; + return this; + } + + /** + * Get the subCode value. + * + * @return the subCode value + */ + public ErrorSubCode subCode() { + return this.subCode; + } + + /** + * Get the message value. + * + * @return the message value + */ + public String message() { + return this.message; + } + + /** + * Set the message value. + * + * @param message the message value to set + * @return the Error object itself. + */ + public Error withMessage(String message) { + this.message = message; + return this; + } + + /** + * Get the moreDetails value. + * + * @return the moreDetails value + */ + public String moreDetails() { + return this.moreDetails; + } + + /** + * Get the parameter value. + * + * @return the parameter value + */ + public String parameter() { + return this.parameter; + } + + /** + * Get the value value. + * + * @return the value value + */ + public String value() { + return this.value; + } + +} diff --git a/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/ErrorCode.java b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/ErrorCode.java new file mode 100644 index 00000000000..086c0991878 --- /dev/null +++ b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/ErrorCode.java @@ -0,0 +1,53 @@ +/** + * 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.spellcheck; + +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; + +/** + * Defines values for ErrorCode. + */ +public final class ErrorCode extends ExpandableStringEnum { + /** Static value None for ErrorCode. */ + public static final ErrorCode NONE = fromString("None"); + + /** Static value ServerError for ErrorCode. */ + public static final ErrorCode SERVER_ERROR = fromString("ServerError"); + + /** Static value InvalidRequest for ErrorCode. */ + public static final ErrorCode INVALID_REQUEST = fromString("InvalidRequest"); + + /** Static value RateLimitExceeded for ErrorCode. */ + public static final ErrorCode RATE_LIMIT_EXCEEDED = fromString("RateLimitExceeded"); + + /** Static value InvalidAuthorization for ErrorCode. */ + public static final ErrorCode INVALID_AUTHORIZATION = fromString("InvalidAuthorization"); + + /** Static value InsufficientAuthorization for ErrorCode. */ + public static final ErrorCode INSUFFICIENT_AUTHORIZATION = fromString("InsufficientAuthorization"); + + /** + * Creates or finds a ErrorCode from its string representation. + * @param name a name to look for + * @return the corresponding ErrorCode + */ + @JsonCreator + public static ErrorCode fromString(String name) { + return fromString(name, ErrorCode.class); + } + + /** + * @return known ErrorCode values + */ + public static Collection values() { + return values(ErrorCode.class); + } +} diff --git a/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/ErrorResponse.java b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/ErrorResponse.java new file mode 100644 index 00000000000..442b9a51458 --- /dev/null +++ b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/ErrorResponse.java @@ -0,0 +1,48 @@ +/** + * 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.spellcheck; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * The top-level response that represents a failed request. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "_type") +@JsonTypeName("ErrorResponse") +public class ErrorResponse extends Response { + /** + * A list of errors that describe the reasons why the request failed. + */ + @JsonProperty(value = "errors", required = true) + private List errors; + + /** + * Get the errors value. + * + * @return the errors value + */ + public List errors() { + return this.errors; + } + + /** + * Set the errors value. + * + * @param errors the errors value to set + * @return the ErrorResponse object itself. + */ + public ErrorResponse withErrors(List errors) { + this.errors = errors; + return this; + } + +} diff --git a/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/ErrorResponseException.java b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/ErrorResponseException.java new file mode 100644 index 00000000000..619d30c7a15 --- /dev/null +++ b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/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.cognitiveservices.spellcheck; + +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/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/ErrorSubCode.java b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/ErrorSubCode.java new file mode 100644 index 00000000000..e1ccb1d52da --- /dev/null +++ b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/ErrorSubCode.java @@ -0,0 +1,68 @@ +/** + * 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.spellcheck; + +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; + +/** + * Defines values for ErrorSubCode. + */ +public final class ErrorSubCode extends ExpandableStringEnum { + /** Static value UnexpectedError for ErrorSubCode. */ + public static final ErrorSubCode UNEXPECTED_ERROR = fromString("UnexpectedError"); + + /** Static value ResourceError for ErrorSubCode. */ + public static final ErrorSubCode RESOURCE_ERROR = fromString("ResourceError"); + + /** Static value NotImplemented for ErrorSubCode. */ + public static final ErrorSubCode NOT_IMPLEMENTED = fromString("NotImplemented"); + + /** Static value ParameterMissing for ErrorSubCode. */ + public static final ErrorSubCode PARAMETER_MISSING = fromString("ParameterMissing"); + + /** Static value ParameterInvalidValue for ErrorSubCode. */ + public static final ErrorSubCode PARAMETER_INVALID_VALUE = fromString("ParameterInvalidValue"); + + /** Static value HttpNotAllowed for ErrorSubCode. */ + public static final ErrorSubCode HTTP_NOT_ALLOWED = fromString("HttpNotAllowed"); + + /** Static value Blocked for ErrorSubCode. */ + public static final ErrorSubCode BLOCKED = fromString("Blocked"); + + /** Static value AuthorizationMissing for ErrorSubCode. */ + public static final ErrorSubCode AUTHORIZATION_MISSING = fromString("AuthorizationMissing"); + + /** Static value AuthorizationRedundancy for ErrorSubCode. */ + public static final ErrorSubCode AUTHORIZATION_REDUNDANCY = fromString("AuthorizationRedundancy"); + + /** Static value AuthorizationDisabled for ErrorSubCode. */ + public static final ErrorSubCode AUTHORIZATION_DISABLED = fromString("AuthorizationDisabled"); + + /** Static value AuthorizationExpired for ErrorSubCode. */ + public static final ErrorSubCode AUTHORIZATION_EXPIRED = fromString("AuthorizationExpired"); + + /** + * Creates or finds a ErrorSubCode from its string representation. + * @param name a name to look for + * @return the corresponding ErrorSubCode + */ + @JsonCreator + public static ErrorSubCode fromString(String name) { + return fromString(name, ErrorSubCode.class); + } + + /** + * @return known ErrorSubCode values + */ + public static Collection values() { + return values(ErrorSubCode.class); + } +} diff --git a/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/ErrorType.java b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/ErrorType.java new file mode 100644 index 00000000000..18f40d63cc6 --- /dev/null +++ b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/ErrorType.java @@ -0,0 +1,41 @@ +/** + * 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.spellcheck; + +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; + +/** + * Defines values for ErrorType. + */ +public final class ErrorType extends ExpandableStringEnum { + /** Static value UnknownToken for ErrorType. */ + public static final ErrorType UNKNOWN_TOKEN = fromString("UnknownToken"); + + /** Static value RepeatedToken for ErrorType. */ + public static final ErrorType REPEATED_TOKEN = fromString("RepeatedToken"); + + /** + * Creates or finds a ErrorType from its string representation. + * @param name a name to look for + * @return the corresponding ErrorType + */ + @JsonCreator + public static ErrorType fromString(String name) { + return fromString(name, ErrorType.class); + } + + /** + * @return known ErrorType values + */ + public static Collection values() { + return values(ErrorType.class); + } +} diff --git a/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/Identifiable.java b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/Identifiable.java new file mode 100644 index 00000000000..ff51e249206 --- /dev/null +++ b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/Identifiable.java @@ -0,0 +1,40 @@ +/** + * 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.spellcheck; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonSubTypes; + +/** + * Defines the identity of a resource. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "_type") +@JsonTypeName("Identifiable") +@JsonSubTypes({ + @JsonSubTypes.Type(name = "Response", value = Response.class) +}) +public class Identifiable extends ResponseBase { + /** + * A String identifier. + */ + @JsonProperty(value = "id", access = JsonProperty.Access.WRITE_ONLY) + private String id; + + /** + * Get the id value. + * + * @return the id value + */ + public String id() { + return this.id; + } + +} diff --git a/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/Response.java b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/Response.java new file mode 100644 index 00000000000..20754bf1287 --- /dev/null +++ b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/Response.java @@ -0,0 +1,26 @@ +/** + * 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.spellcheck; + +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonSubTypes; + +/** + * Defines a response. All schemas that could be returned at the root of a + * response should inherit from this. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "_type") +@JsonTypeName("Response") +@JsonSubTypes({ + @JsonSubTypes.Type(name = "Answer", value = Answer.class), + @JsonSubTypes.Type(name = "ErrorResponse", value = ErrorResponse.class) +}) +public class Response extends Identifiable { +} diff --git a/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/ResponseBase.java b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/ResponseBase.java new file mode 100644 index 00000000000..39934685d22 --- /dev/null +++ b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/ResponseBase.java @@ -0,0 +1,24 @@ +/** + * 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.spellcheck; + +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonSubTypes; + +/** + * The ResponseBase model. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "_type") +@JsonTypeName("ResponseBase") +@JsonSubTypes({ + @JsonSubTypes.Type(name = "Identifiable", value = Identifiable.class) +}) +public class ResponseBase { +} diff --git a/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/SpellingFlaggedToken.java b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/SpellingFlaggedToken.java new file mode 100644 index 00000000000..ee5a54dd76a --- /dev/null +++ b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/SpellingFlaggedToken.java @@ -0,0 +1,126 @@ +/** + * 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.spellcheck; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The SpellingFlaggedToken model. + */ +public class SpellingFlaggedToken { + /** + * The offset property. + */ + @JsonProperty(value = "offset", required = true) + private int offset; + + /** + * The token property. + */ + @JsonProperty(value = "token", required = true) + private String token; + + /** + * Possible values include: 'UnknownToken', 'RepeatedToken'. + */ + @JsonProperty(value = "type", required = true) + private ErrorType type; + + /** + * The suggestions property. + */ + @JsonProperty(value = "suggestions", access = JsonProperty.Access.WRITE_ONLY) + private List suggestions; + + /** + * The pingUrlSuffix property. + */ + @JsonProperty(value = "pingUrlSuffix", access = JsonProperty.Access.WRITE_ONLY) + private String pingUrlSuffix; + + /** + * Get the offset value. + * + * @return the offset value + */ + public int offset() { + return this.offset; + } + + /** + * Set the offset value. + * + * @param offset the offset value to set + * @return the SpellingFlaggedToken object itself. + */ + public SpellingFlaggedToken withOffset(int offset) { + this.offset = offset; + return this; + } + + /** + * Get the token value. + * + * @return the token value + */ + public String token() { + return this.token; + } + + /** + * Set the token value. + * + * @param token the token value to set + * @return the SpellingFlaggedToken object itself. + */ + public SpellingFlaggedToken withToken(String token) { + this.token = token; + return this; + } + + /** + * Get the type value. + * + * @return the type value + */ + public ErrorType type() { + return this.type; + } + + /** + * Set the type value. + * + * @param type the type value to set + * @return the SpellingFlaggedToken object itself. + */ + public SpellingFlaggedToken withType(ErrorType type) { + this.type = type; + return this; + } + + /** + * Get the suggestions value. + * + * @return the suggestions value + */ + public List suggestions() { + return this.suggestions; + } + + /** + * Get the pingUrlSuffix value. + * + * @return the pingUrlSuffix value + */ + public String pingUrlSuffix() { + return this.pingUrlSuffix; + } + +} diff --git a/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/SpellingTokenSuggestion.java b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/SpellingTokenSuggestion.java new file mode 100644 index 00000000000..68b3a200a32 --- /dev/null +++ b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/SpellingTokenSuggestion.java @@ -0,0 +1,73 @@ +/** + * 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.spellcheck; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * The SpellingTokenSuggestion model. + */ +public class SpellingTokenSuggestion { + /** + * The suggestion property. + */ + @JsonProperty(value = "suggestion", required = true) + private String suggestion; + + /** + * The score property. + */ + @JsonProperty(value = "score", access = JsonProperty.Access.WRITE_ONLY) + private Double score; + + /** + * The pingUrlSuffix property. + */ + @JsonProperty(value = "pingUrlSuffix", access = JsonProperty.Access.WRITE_ONLY) + private String pingUrlSuffix; + + /** + * Get the suggestion value. + * + * @return the suggestion value + */ + public String suggestion() { + return this.suggestion; + } + + /** + * Set the suggestion value. + * + * @param suggestion the suggestion value to set + * @return the SpellingTokenSuggestion object itself. + */ + public SpellingTokenSuggestion withSuggestion(String suggestion) { + this.suggestion = suggestion; + return this; + } + + /** + * Get the score value. + * + * @return the score value + */ + public Double score() { + return this.score; + } + + /** + * Get the pingUrlSuffix value. + * + * @return the pingUrlSuffix value + */ + public String pingUrlSuffix() { + return this.pingUrlSuffix; + } + +} diff --git a/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/implementation/SpellCheckAPIImpl.java b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/implementation/SpellCheckAPIImpl.java new file mode 100644 index 00000000000..23e90c1c4d9 --- /dev/null +++ b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/implementation/SpellCheckAPIImpl.java @@ -0,0 +1,407 @@ +/** + * 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.spellcheck.implementation; + +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.AzureClient; +import com.microsoft.azure.AzureServiceClient; +import com.microsoft.azure.cognitiveservices.spellcheck.ActionType; +import com.microsoft.azure.cognitiveservices.spellcheck.ErrorResponseException; +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 java.io.IOException; +import okhttp3.ResponseBody; +import retrofit2.http.Header; +import retrofit2.http.Multipart; +import retrofit2.http.Part; +import retrofit2.http.POST; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * Initializes a new instance of the SpellCheckAPIImpl class. + */ +public class SpellCheckAPIImpl extends AzureServiceClient { + /** The Retrofit service to perform REST calls. */ + private SpellCheckAPIService 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 SpellCheckAPIImpl 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 SpellCheckAPIImpl 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 SpellCheckAPIImpl withGenerateClientRequestId(boolean generateClientRequestId) { + this.generateClientRequestId = generateClientRequestId; + return this; + } + + /** + * Initializes an instance of SpellCheckAPI client. + * + * @param credentials the management credentials for Azure + */ + public SpellCheckAPIImpl(ServiceClientCredentials credentials) { + this("https://api.cognitive.microsoft.com/bing/v7.0", credentials); + } + + /** + * Initializes an instance of SpellCheckAPI client. + * + * @param baseUrl the base URL of the host + * @param credentials the management credentials for Azure + */ + public SpellCheckAPIImpl(String baseUrl, ServiceClientCredentials credentials) { + super(baseUrl, credentials); + initialize(); + } + + /** + * Initializes an instance of SpellCheckAPI client. + * + * @param restClient the REST client to connect to Azure. + */ + public SpellCheckAPIImpl(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(), "SpellCheckAPI", "1.0"); + } + + private void initializeService() { + service = restClient().retrofit().create(SpellCheckAPIService.class); + } + + /** + * The interface defining all the services for SpellCheckAPI to be + * used by Retrofit to perform actually REST calls. + */ + interface SpellCheckAPIService { + @Multipart + @POST("spellcheck") + Observable> spellChecker(@Header("X-BingApis-SDK") String xBingApisSDK, @Header("Accept-Language") String acceptLanguage, @Header("Pragma") String pragma, @Header("User-Agent") String userAgent, @Header("X-MSEdge-ClientID") String clientId, @Header("X-MSEdge-ClientIP") String clientIp, @Header("X-Search-Location") String location, @Query("ActionType") ActionType actionType, @Query("AppName") String appName, @Query("cc") String countryCode, @Query("ClientMachineName") String clientMachineName, @Query("DocId") String docId, @Query("mkt") String market, @Query("SessionId") String sessionId, @Query("SetLang") String setLang, @Query("UserId") String userId, @Part("Mode") String mode, @Part("PreContextText") String preContextText, @Part("PostContextText") String postContextText, @Part("Text") String text, @Header("User-Agent") String userAgent); + + } + + /** + * The Bing Spell Check API lets you perform contextual grammar and spell checking. Bing has developed a web-based spell-checker that leverages machine learning and statistical machine translation to dynamically train a constantly evolving and highly contextual algorithm. The spell-checker is based on a massive corpus of web searches and documents. + * + * @param text The text string to check for spelling and grammar errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. Because of the query string length limit, you'll typically use a POST request unless you're checking only short strings. + * @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 SpellCheckInner object if successful. + */ + public SpellCheckInner spellChecker(String text) { + return spellCheckerWithServiceResponseAsync(text).toBlocking().single().body(); + } + + /** + * The Bing Spell Check API lets you perform contextual grammar and spell checking. Bing has developed a web-based spell-checker that leverages machine learning and statistical machine translation to dynamically train a constantly evolving and highly contextual algorithm. The spell-checker is based on a massive corpus of web searches and documents. + * + * @param text The text string to check for spelling and grammar errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. Because of the query string length limit, you'll typically use a POST request unless you're checking only short strings. + * @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 spellCheckerAsync(String text, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(spellCheckerWithServiceResponseAsync(text), serviceCallback); + } + + /** + * The Bing Spell Check API lets you perform contextual grammar and spell checking. Bing has developed a web-based spell-checker that leverages machine learning and statistical machine translation to dynamically train a constantly evolving and highly contextual algorithm. The spell-checker is based on a massive corpus of web searches and documents. + * + * @param text The text string to check for spelling and grammar errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. Because of the query string length limit, you'll typically use a POST request unless you're checking only short strings. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the SpellCheckInner object + */ + public Observable spellCheckerAsync(String text) { + return spellCheckerWithServiceResponseAsync(text).map(new Func1, SpellCheckInner>() { + @Override + public SpellCheckInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * The Bing Spell Check API lets you perform contextual grammar and spell checking. Bing has developed a web-based spell-checker that leverages machine learning and statistical machine translation to dynamically train a constantly evolving and highly contextual algorithm. The spell-checker is based on a massive corpus of web searches and documents. + * + * @param text The text string to check for spelling and grammar errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. Because of the query string length limit, you'll typically use a POST request unless you're checking only short strings. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the SpellCheckInner object + */ + public Observable> spellCheckerWithServiceResponseAsync(String text) { + if (text == null) { + throw new IllegalArgumentException("Parameter text is required and cannot be null."); + } + final String xBingApisSDK = "true"; + final String acceptLanguage = null; + final String pragma = null; + final String clientId = null; + final String clientIp = null; + final String location = null; + final ActionType actionType = null; + final String appName = null; + final String countryCode = null; + final String clientMachineName = null; + final String docId = null; + final String market = null; + final String sessionId = null; + final String setLang = null; + final String userId = null; + final String mode = null; + final String preContextText = null; + final String postContextText = null; + return service.spellChecker(xBingApisSDK, acceptLanguage, pragma, this.userAgent(), clientId, clientIp, location, actionType, appName, countryCode, clientMachineName, docId, market, sessionId, setLang, userId, mode, preContextText, postContextText, text, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = spellCheckerDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * The Bing Spell Check API lets you perform contextual grammar and spell checking. Bing has developed a web-based spell-checker that leverages machine learning and statistical machine translation to dynamically train a constantly evolving and highly contextual algorithm. The spell-checker is based on a massive corpus of web searches and documents. + * + * @param text The text string to check for spelling and grammar errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. Because of the query string length limit, you'll typically use a POST request unless you're checking only short strings. + * @param acceptLanguage A comma-delimited list of one or more languages to use for user interface strings. The list is in decreasing order of preference. For additional information, including expected format, see [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This header and the setLang query parameter are mutually exclusive; do not specify both. If you set this header, you must also specify the cc query parameter. Bing will use the first supported language it finds from the list, and combine that language with the cc parameter value to determine the market to return results for. If the list does not include a supported language, Bing will find the closest language and market that supports the request, and may use an aggregated or default market for the results instead of a specified one. You should use this header and the cc query parameter only if you specify multiple languages; otherwise, you should use the mkt and setLang query parameters. A user interface string is a string that's used as a label in a user interface. There are very few user interface strings in the JSON response objects. Any links in the response objects to Bing.com properties will apply the specified language. + * @param pragma By default, Bing returns cached content, if available. To prevent Bing from returning cached content, set the Pragma header to no-cache (for example, Pragma: no-cache). + * @param clientId Bing uses this header to provide users with consistent behavior across Bing API calls. Bing often flights new features and improvements, and it uses the client ID as a key for assigning traffic on different flights. If you do not use the same client ID for a user across multiple requests, then Bing may assign the user to multiple conflicting flights. Being assigned to multiple conflicting flights can lead to an inconsistent user experience. For example, if the second request has a different flight assignment than the first, the experience may be unexpected. Also, Bing can use the client ID to tailor web results to that client ID’s search history, providing a richer experience for the user. Bing also uses this header to help improve result rankings by analyzing the activity generated by a client ID. The relevance improvements help with better quality of results delivered by Bing APIs and in turn enables higher click-through rates for the API consumer. IMPORTANT: Although optional, you should consider this header required. Persisting the client ID across multiple requests for the same end user and device combination enables 1) the API consumer to receive a consistent user experience, and 2) higher click-through rates via better quality of results from the Bing APIs. Each user that uses your application on the device must have a unique, Bing generated client ID. If you do not include this header in the request, Bing generates an ID and returns it in the X-MSEdge-ClientID response header. The only time that you should NOT include this header in a request is the first time the user uses your app on that device. Use the client ID for each Bing API request that your app makes for this user on the device. Persist the client ID. To persist the ID in a browser app, use a persistent HTTP cookie to ensure the ID is used across all sessions. Do not use a session cookie. For other apps such as mobile apps, use the device's persistent storage to persist the ID. The next time the user uses your app on that device, get the client ID that you persisted. Bing responses may or may not include this header. If the response includes this header, capture the client ID and use it for all subsequent Bing requests for the user on that device. If you include the X-MSEdge-ClientID, you must not include cookies in the request. + * @param clientIp The IPv4 or IPv6 address of the client device. The IP address is used to discover the user's location. Bing uses the location information to determine safe search behavior. Although optional, you are encouraged to always specify this header and the X-Search-Location header. Do not obfuscate the address (for example, by changing the last octet to 0). Obfuscating the address results in the location not being anywhere near the device's actual location, which may result in Bing serving erroneous results. + * @param location A semicolon-delimited list of key/value pairs that describe the client's geographical location. Bing uses the location information to determine safe search behavior and to return relevant local content. Specify the key/value pair as <key>:<value>. The following are the keys that you use to specify the user's location. lat (required): The latitude of the client's location, in degrees. The latitude must be greater than or equal to -90.0 and less than or equal to +90.0. Negative values indicate southern latitudes and positive values indicate northern latitudes. long (required): The longitude of the client's location, in degrees. The longitude must be greater than or equal to -180.0 and less than or equal to +180.0. Negative values indicate western longitudes and positive values indicate eastern longitudes. re (required): The radius, in meters, which specifies the horizontal accuracy of the coordinates. Pass the value returned by the device's location service. Typical values might be 22m for GPS/Wi-Fi, 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts (optional): The UTC UNIX timestamp of when the client was at the location. (The UNIX timestamp is the number of seconds since January 1, 1970.) head (optional): The client's relative heading or direction of travel. Specify the direction of travel as degrees from 0 through 360, counting clockwise relative to true north. Specify this key only if the sp key is nonzero. sp (optional): The horizontal velocity (speed), in meters per second, that the client device is traveling. alt (optional): The altitude of the client device, in meters. are (optional): The radius, in meters, that specifies the vertical accuracy of the coordinates. Specify this key only if you specify the alt key. Although many of the keys are optional, the more information that you provide, the more accurate the location results are. Although optional, you are encouraged to always specify the user's geographical location. Providing the location is especially important if the client's IP address does not accurately reflect the user's physical location (for example, if the client uses VPN). For optimal results, you should include this header and the X-Search-ClientIP header, but at a minimum, you should include this header. + * @param actionType A string that's used by logging to determine whether the request is coming from an interactive session or a page load. The following are the possible values. 1) Edit—The request is from an interactive session 2) Load—The request is from a page load. Possible values include: 'Edit', 'Load' + * @param appName The unique name of your app. The name must be known by Bing. Do not include this parameter unless you have previously contacted Bing to get a unique app name. To get a unique name, contact your Bing Business Development manager. + * @param countryCode A 2-character country code of the country where the results come from. This API supports only the United States market. If you specify this query parameter, it must be set to us. If you set this parameter, you must also specify the Accept-Language header. Bing uses the first supported language it finds from the languages list, and combine that language with the country code that you specify to determine the market to return results for. If the languages list does not include a supported language, Bing finds the closest language and market that supports the request, or it may use an aggregated or default market for the results instead of a specified one. You should use this query parameter and the Accept-Language query parameter only if you specify multiple languages; otherwise, you should use the mkt and setLang query parameters. This parameter and the mkt query parameter are mutually exclusive—do not specify both. + * @param clientMachineName A unique name of the device that the request is being made from. Generate a unique value for each device (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. + * @param docId A unique ID that identifies the document that the text belongs to. Generate a unique value for each document (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. + * @param market The market where the results come from. You are strongly encouraged to always specify the market, if known. Specifying the market helps Bing route the request and return an appropriate and optimal response. This parameter and the cc query parameter are mutually exclusive—do not specify both. + * @param sessionId A unique ID that identifies this user session. Generate a unique value for each user session (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections + * @param setLang The language to use for user interface strings. Specify the language using the ISO 639-1 2-letter language code. For example, the language code for English is EN. The default is EN (English). Although optional, you should always specify the language. Typically, you set setLang to the same language specified by mkt unless the user wants the user interface strings displayed in a different language. This parameter and the Accept-Language header are mutually exclusive—do not specify both. A user interface string is a string that's used as a label in a user interface. There are few user interface strings in the JSON response objects. Also, any links to Bing.com properties in the response objects apply the specified language. + * @param userId A unique ID that identifies the user. Generate a unique value for each user (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. + * @param mode The type of spelling and grammar checks to perform. The following are the possible values (the values are case insensitive). The default is Proof. 1) Proof—Finds most spelling and grammar mistakes. 2) Spell—Finds most spelling mistakes but does not find some of the grammar errors that Proof catches (for example, capitalization and repeated words). Possible values include: 'proof', 'spell' + * @param preContextText A string that gives context to the text string. For example, the text string petal is valid. However, if you set preContextText to bike, the context changes and the text string becomes not valid. In this case, the API suggests that you change petal to pedal (as in bike pedal). This text is not checked for grammar or spelling errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. + * @param postContextText A string that gives context to the text string. For example, the text string read is valid. However, if you set postContextText to carpet, the context changes and the text string becomes not valid. In this case, the API suggests that you change read to red (as in red carpet). This text is not checked for grammar or spelling errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. + * @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 SpellCheckInner object if successful. + */ + public SpellCheckInner spellChecker(String text, String acceptLanguage, String pragma, String clientId, String clientIp, String location, ActionType actionType, String appName, String countryCode, String clientMachineName, String docId, String market, String sessionId, String setLang, String userId, String mode, String preContextText, String postContextText) { + return spellCheckerWithServiceResponseAsync(text, acceptLanguage, pragma, clientId, clientIp, location, actionType, appName, countryCode, clientMachineName, docId, market, sessionId, setLang, userId, mode, preContextText, postContextText).toBlocking().single().body(); + } + + /** + * The Bing Spell Check API lets you perform contextual grammar and spell checking. Bing has developed a web-based spell-checker that leverages machine learning and statistical machine translation to dynamically train a constantly evolving and highly contextual algorithm. The spell-checker is based on a massive corpus of web searches and documents. + * + * @param text The text string to check for spelling and grammar errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. Because of the query string length limit, you'll typically use a POST request unless you're checking only short strings. + * @param acceptLanguage A comma-delimited list of one or more languages to use for user interface strings. The list is in decreasing order of preference. For additional information, including expected format, see [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This header and the setLang query parameter are mutually exclusive; do not specify both. If you set this header, you must also specify the cc query parameter. Bing will use the first supported language it finds from the list, and combine that language with the cc parameter value to determine the market to return results for. If the list does not include a supported language, Bing will find the closest language and market that supports the request, and may use an aggregated or default market for the results instead of a specified one. You should use this header and the cc query parameter only if you specify multiple languages; otherwise, you should use the mkt and setLang query parameters. A user interface string is a string that's used as a label in a user interface. There are very few user interface strings in the JSON response objects. Any links in the response objects to Bing.com properties will apply the specified language. + * @param pragma By default, Bing returns cached content, if available. To prevent Bing from returning cached content, set the Pragma header to no-cache (for example, Pragma: no-cache). + * @param clientId Bing uses this header to provide users with consistent behavior across Bing API calls. Bing often flights new features and improvements, and it uses the client ID as a key for assigning traffic on different flights. If you do not use the same client ID for a user across multiple requests, then Bing may assign the user to multiple conflicting flights. Being assigned to multiple conflicting flights can lead to an inconsistent user experience. For example, if the second request has a different flight assignment than the first, the experience may be unexpected. Also, Bing can use the client ID to tailor web results to that client ID’s search history, providing a richer experience for the user. Bing also uses this header to help improve result rankings by analyzing the activity generated by a client ID. The relevance improvements help with better quality of results delivered by Bing APIs and in turn enables higher click-through rates for the API consumer. IMPORTANT: Although optional, you should consider this header required. Persisting the client ID across multiple requests for the same end user and device combination enables 1) the API consumer to receive a consistent user experience, and 2) higher click-through rates via better quality of results from the Bing APIs. Each user that uses your application on the device must have a unique, Bing generated client ID. If you do not include this header in the request, Bing generates an ID and returns it in the X-MSEdge-ClientID response header. The only time that you should NOT include this header in a request is the first time the user uses your app on that device. Use the client ID for each Bing API request that your app makes for this user on the device. Persist the client ID. To persist the ID in a browser app, use a persistent HTTP cookie to ensure the ID is used across all sessions. Do not use a session cookie. For other apps such as mobile apps, use the device's persistent storage to persist the ID. The next time the user uses your app on that device, get the client ID that you persisted. Bing responses may or may not include this header. If the response includes this header, capture the client ID and use it for all subsequent Bing requests for the user on that device. If you include the X-MSEdge-ClientID, you must not include cookies in the request. + * @param clientIp The IPv4 or IPv6 address of the client device. The IP address is used to discover the user's location. Bing uses the location information to determine safe search behavior. Although optional, you are encouraged to always specify this header and the X-Search-Location header. Do not obfuscate the address (for example, by changing the last octet to 0). Obfuscating the address results in the location not being anywhere near the device's actual location, which may result in Bing serving erroneous results. + * @param location A semicolon-delimited list of key/value pairs that describe the client's geographical location. Bing uses the location information to determine safe search behavior and to return relevant local content. Specify the key/value pair as <key>:<value>. The following are the keys that you use to specify the user's location. lat (required): The latitude of the client's location, in degrees. The latitude must be greater than or equal to -90.0 and less than or equal to +90.0. Negative values indicate southern latitudes and positive values indicate northern latitudes. long (required): The longitude of the client's location, in degrees. The longitude must be greater than or equal to -180.0 and less than or equal to +180.0. Negative values indicate western longitudes and positive values indicate eastern longitudes. re (required): The radius, in meters, which specifies the horizontal accuracy of the coordinates. Pass the value returned by the device's location service. Typical values might be 22m for GPS/Wi-Fi, 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts (optional): The UTC UNIX timestamp of when the client was at the location. (The UNIX timestamp is the number of seconds since January 1, 1970.) head (optional): The client's relative heading or direction of travel. Specify the direction of travel as degrees from 0 through 360, counting clockwise relative to true north. Specify this key only if the sp key is nonzero. sp (optional): The horizontal velocity (speed), in meters per second, that the client device is traveling. alt (optional): The altitude of the client device, in meters. are (optional): The radius, in meters, that specifies the vertical accuracy of the coordinates. Specify this key only if you specify the alt key. Although many of the keys are optional, the more information that you provide, the more accurate the location results are. Although optional, you are encouraged to always specify the user's geographical location. Providing the location is especially important if the client's IP address does not accurately reflect the user's physical location (for example, if the client uses VPN). For optimal results, you should include this header and the X-Search-ClientIP header, but at a minimum, you should include this header. + * @param actionType A string that's used by logging to determine whether the request is coming from an interactive session or a page load. The following are the possible values. 1) Edit—The request is from an interactive session 2) Load—The request is from a page load. Possible values include: 'Edit', 'Load' + * @param appName The unique name of your app. The name must be known by Bing. Do not include this parameter unless you have previously contacted Bing to get a unique app name. To get a unique name, contact your Bing Business Development manager. + * @param countryCode A 2-character country code of the country where the results come from. This API supports only the United States market. If you specify this query parameter, it must be set to us. If you set this parameter, you must also specify the Accept-Language header. Bing uses the first supported language it finds from the languages list, and combine that language with the country code that you specify to determine the market to return results for. If the languages list does not include a supported language, Bing finds the closest language and market that supports the request, or it may use an aggregated or default market for the results instead of a specified one. You should use this query parameter and the Accept-Language query parameter only if you specify multiple languages; otherwise, you should use the mkt and setLang query parameters. This parameter and the mkt query parameter are mutually exclusive—do not specify both. + * @param clientMachineName A unique name of the device that the request is being made from. Generate a unique value for each device (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. + * @param docId A unique ID that identifies the document that the text belongs to. Generate a unique value for each document (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. + * @param market The market where the results come from. You are strongly encouraged to always specify the market, if known. Specifying the market helps Bing route the request and return an appropriate and optimal response. This parameter and the cc query parameter are mutually exclusive—do not specify both. + * @param sessionId A unique ID that identifies this user session. Generate a unique value for each user session (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections + * @param setLang The language to use for user interface strings. Specify the language using the ISO 639-1 2-letter language code. For example, the language code for English is EN. The default is EN (English). Although optional, you should always specify the language. Typically, you set setLang to the same language specified by mkt unless the user wants the user interface strings displayed in a different language. This parameter and the Accept-Language header are mutually exclusive—do not specify both. A user interface string is a string that's used as a label in a user interface. There are few user interface strings in the JSON response objects. Also, any links to Bing.com properties in the response objects apply the specified language. + * @param userId A unique ID that identifies the user. Generate a unique value for each user (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. + * @param mode The type of spelling and grammar checks to perform. The following are the possible values (the values are case insensitive). The default is Proof. 1) Proof—Finds most spelling and grammar mistakes. 2) Spell—Finds most spelling mistakes but does not find some of the grammar errors that Proof catches (for example, capitalization and repeated words). Possible values include: 'proof', 'spell' + * @param preContextText A string that gives context to the text string. For example, the text string petal is valid. However, if you set preContextText to bike, the context changes and the text string becomes not valid. In this case, the API suggests that you change petal to pedal (as in bike pedal). This text is not checked for grammar or spelling errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. + * @param postContextText A string that gives context to the text string. For example, the text string read is valid. However, if you set postContextText to carpet, the context changes and the text string becomes not valid. In this case, the API suggests that you change read to red (as in red carpet). This text is not checked for grammar or spelling errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. + * @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 spellCheckerAsync(String text, String acceptLanguage, String pragma, String clientId, String clientIp, String location, ActionType actionType, String appName, String countryCode, String clientMachineName, String docId, String market, String sessionId, String setLang, String userId, String mode, String preContextText, String postContextText, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(spellCheckerWithServiceResponseAsync(text, acceptLanguage, pragma, clientId, clientIp, location, actionType, appName, countryCode, clientMachineName, docId, market, sessionId, setLang, userId, mode, preContextText, postContextText), serviceCallback); + } + + /** + * The Bing Spell Check API lets you perform contextual grammar and spell checking. Bing has developed a web-based spell-checker that leverages machine learning and statistical machine translation to dynamically train a constantly evolving and highly contextual algorithm. The spell-checker is based on a massive corpus of web searches and documents. + * + * @param text The text string to check for spelling and grammar errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. Because of the query string length limit, you'll typically use a POST request unless you're checking only short strings. + * @param acceptLanguage A comma-delimited list of one or more languages to use for user interface strings. The list is in decreasing order of preference. For additional information, including expected format, see [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This header and the setLang query parameter are mutually exclusive; do not specify both. If you set this header, you must also specify the cc query parameter. Bing will use the first supported language it finds from the list, and combine that language with the cc parameter value to determine the market to return results for. If the list does not include a supported language, Bing will find the closest language and market that supports the request, and may use an aggregated or default market for the results instead of a specified one. You should use this header and the cc query parameter only if you specify multiple languages; otherwise, you should use the mkt and setLang query parameters. A user interface string is a string that's used as a label in a user interface. There are very few user interface strings in the JSON response objects. Any links in the response objects to Bing.com properties will apply the specified language. + * @param pragma By default, Bing returns cached content, if available. To prevent Bing from returning cached content, set the Pragma header to no-cache (for example, Pragma: no-cache). + * @param clientId Bing uses this header to provide users with consistent behavior across Bing API calls. Bing often flights new features and improvements, and it uses the client ID as a key for assigning traffic on different flights. If you do not use the same client ID for a user across multiple requests, then Bing may assign the user to multiple conflicting flights. Being assigned to multiple conflicting flights can lead to an inconsistent user experience. For example, if the second request has a different flight assignment than the first, the experience may be unexpected. Also, Bing can use the client ID to tailor web results to that client ID’s search history, providing a richer experience for the user. Bing also uses this header to help improve result rankings by analyzing the activity generated by a client ID. The relevance improvements help with better quality of results delivered by Bing APIs and in turn enables higher click-through rates for the API consumer. IMPORTANT: Although optional, you should consider this header required. Persisting the client ID across multiple requests for the same end user and device combination enables 1) the API consumer to receive a consistent user experience, and 2) higher click-through rates via better quality of results from the Bing APIs. Each user that uses your application on the device must have a unique, Bing generated client ID. If you do not include this header in the request, Bing generates an ID and returns it in the X-MSEdge-ClientID response header. The only time that you should NOT include this header in a request is the first time the user uses your app on that device. Use the client ID for each Bing API request that your app makes for this user on the device. Persist the client ID. To persist the ID in a browser app, use a persistent HTTP cookie to ensure the ID is used across all sessions. Do not use a session cookie. For other apps such as mobile apps, use the device's persistent storage to persist the ID. The next time the user uses your app on that device, get the client ID that you persisted. Bing responses may or may not include this header. If the response includes this header, capture the client ID and use it for all subsequent Bing requests for the user on that device. If you include the X-MSEdge-ClientID, you must not include cookies in the request. + * @param clientIp The IPv4 or IPv6 address of the client device. The IP address is used to discover the user's location. Bing uses the location information to determine safe search behavior. Although optional, you are encouraged to always specify this header and the X-Search-Location header. Do not obfuscate the address (for example, by changing the last octet to 0). Obfuscating the address results in the location not being anywhere near the device's actual location, which may result in Bing serving erroneous results. + * @param location A semicolon-delimited list of key/value pairs that describe the client's geographical location. Bing uses the location information to determine safe search behavior and to return relevant local content. Specify the key/value pair as <key>:<value>. The following are the keys that you use to specify the user's location. lat (required): The latitude of the client's location, in degrees. The latitude must be greater than or equal to -90.0 and less than or equal to +90.0. Negative values indicate southern latitudes and positive values indicate northern latitudes. long (required): The longitude of the client's location, in degrees. The longitude must be greater than or equal to -180.0 and less than or equal to +180.0. Negative values indicate western longitudes and positive values indicate eastern longitudes. re (required): The radius, in meters, which specifies the horizontal accuracy of the coordinates. Pass the value returned by the device's location service. Typical values might be 22m for GPS/Wi-Fi, 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts (optional): The UTC UNIX timestamp of when the client was at the location. (The UNIX timestamp is the number of seconds since January 1, 1970.) head (optional): The client's relative heading or direction of travel. Specify the direction of travel as degrees from 0 through 360, counting clockwise relative to true north. Specify this key only if the sp key is nonzero. sp (optional): The horizontal velocity (speed), in meters per second, that the client device is traveling. alt (optional): The altitude of the client device, in meters. are (optional): The radius, in meters, that specifies the vertical accuracy of the coordinates. Specify this key only if you specify the alt key. Although many of the keys are optional, the more information that you provide, the more accurate the location results are. Although optional, you are encouraged to always specify the user's geographical location. Providing the location is especially important if the client's IP address does not accurately reflect the user's physical location (for example, if the client uses VPN). For optimal results, you should include this header and the X-Search-ClientIP header, but at a minimum, you should include this header. + * @param actionType A string that's used by logging to determine whether the request is coming from an interactive session or a page load. The following are the possible values. 1) Edit—The request is from an interactive session 2) Load—The request is from a page load. Possible values include: 'Edit', 'Load' + * @param appName The unique name of your app. The name must be known by Bing. Do not include this parameter unless you have previously contacted Bing to get a unique app name. To get a unique name, contact your Bing Business Development manager. + * @param countryCode A 2-character country code of the country where the results come from. This API supports only the United States market. If you specify this query parameter, it must be set to us. If you set this parameter, you must also specify the Accept-Language header. Bing uses the first supported language it finds from the languages list, and combine that language with the country code that you specify to determine the market to return results for. If the languages list does not include a supported language, Bing finds the closest language and market that supports the request, or it may use an aggregated or default market for the results instead of a specified one. You should use this query parameter and the Accept-Language query parameter only if you specify multiple languages; otherwise, you should use the mkt and setLang query parameters. This parameter and the mkt query parameter are mutually exclusive—do not specify both. + * @param clientMachineName A unique name of the device that the request is being made from. Generate a unique value for each device (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. + * @param docId A unique ID that identifies the document that the text belongs to. Generate a unique value for each document (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. + * @param market The market where the results come from. You are strongly encouraged to always specify the market, if known. Specifying the market helps Bing route the request and return an appropriate and optimal response. This parameter and the cc query parameter are mutually exclusive—do not specify both. + * @param sessionId A unique ID that identifies this user session. Generate a unique value for each user session (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections + * @param setLang The language to use for user interface strings. Specify the language using the ISO 639-1 2-letter language code. For example, the language code for English is EN. The default is EN (English). Although optional, you should always specify the language. Typically, you set setLang to the same language specified by mkt unless the user wants the user interface strings displayed in a different language. This parameter and the Accept-Language header are mutually exclusive—do not specify both. A user interface string is a string that's used as a label in a user interface. There are few user interface strings in the JSON response objects. Also, any links to Bing.com properties in the response objects apply the specified language. + * @param userId A unique ID that identifies the user. Generate a unique value for each user (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. + * @param mode The type of spelling and grammar checks to perform. The following are the possible values (the values are case insensitive). The default is Proof. 1) Proof—Finds most spelling and grammar mistakes. 2) Spell—Finds most spelling mistakes but does not find some of the grammar errors that Proof catches (for example, capitalization and repeated words). Possible values include: 'proof', 'spell' + * @param preContextText A string that gives context to the text string. For example, the text string petal is valid. However, if you set preContextText to bike, the context changes and the text string becomes not valid. In this case, the API suggests that you change petal to pedal (as in bike pedal). This text is not checked for grammar or spelling errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. + * @param postContextText A string that gives context to the text string. For example, the text string read is valid. However, if you set postContextText to carpet, the context changes and the text string becomes not valid. In this case, the API suggests that you change read to red (as in red carpet). This text is not checked for grammar or spelling errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the SpellCheckInner object + */ + public Observable spellCheckerAsync(String text, String acceptLanguage, String pragma, String clientId, String clientIp, String location, ActionType actionType, String appName, String countryCode, String clientMachineName, String docId, String market, String sessionId, String setLang, String userId, String mode, String preContextText, String postContextText) { + return spellCheckerWithServiceResponseAsync(text, acceptLanguage, pragma, clientId, clientIp, location, actionType, appName, countryCode, clientMachineName, docId, market, sessionId, setLang, userId, mode, preContextText, postContextText).map(new Func1, SpellCheckInner>() { + @Override + public SpellCheckInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * The Bing Spell Check API lets you perform contextual grammar and spell checking. Bing has developed a web-based spell-checker that leverages machine learning and statistical machine translation to dynamically train a constantly evolving and highly contextual algorithm. The spell-checker is based on a massive corpus of web searches and documents. + * + * @param text The text string to check for spelling and grammar errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. Because of the query string length limit, you'll typically use a POST request unless you're checking only short strings. + * @param acceptLanguage A comma-delimited list of one or more languages to use for user interface strings. The list is in decreasing order of preference. For additional information, including expected format, see [RFC2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). This header and the setLang query parameter are mutually exclusive; do not specify both. If you set this header, you must also specify the cc query parameter. Bing will use the first supported language it finds from the list, and combine that language with the cc parameter value to determine the market to return results for. If the list does not include a supported language, Bing will find the closest language and market that supports the request, and may use an aggregated or default market for the results instead of a specified one. You should use this header and the cc query parameter only if you specify multiple languages; otherwise, you should use the mkt and setLang query parameters. A user interface string is a string that's used as a label in a user interface. There are very few user interface strings in the JSON response objects. Any links in the response objects to Bing.com properties will apply the specified language. + * @param pragma By default, Bing returns cached content, if available. To prevent Bing from returning cached content, set the Pragma header to no-cache (for example, Pragma: no-cache). + * @param clientId Bing uses this header to provide users with consistent behavior across Bing API calls. Bing often flights new features and improvements, and it uses the client ID as a key for assigning traffic on different flights. If you do not use the same client ID for a user across multiple requests, then Bing may assign the user to multiple conflicting flights. Being assigned to multiple conflicting flights can lead to an inconsistent user experience. For example, if the second request has a different flight assignment than the first, the experience may be unexpected. Also, Bing can use the client ID to tailor web results to that client ID’s search history, providing a richer experience for the user. Bing also uses this header to help improve result rankings by analyzing the activity generated by a client ID. The relevance improvements help with better quality of results delivered by Bing APIs and in turn enables higher click-through rates for the API consumer. IMPORTANT: Although optional, you should consider this header required. Persisting the client ID across multiple requests for the same end user and device combination enables 1) the API consumer to receive a consistent user experience, and 2) higher click-through rates via better quality of results from the Bing APIs. Each user that uses your application on the device must have a unique, Bing generated client ID. If you do not include this header in the request, Bing generates an ID and returns it in the X-MSEdge-ClientID response header. The only time that you should NOT include this header in a request is the first time the user uses your app on that device. Use the client ID for each Bing API request that your app makes for this user on the device. Persist the client ID. To persist the ID in a browser app, use a persistent HTTP cookie to ensure the ID is used across all sessions. Do not use a session cookie. For other apps such as mobile apps, use the device's persistent storage to persist the ID. The next time the user uses your app on that device, get the client ID that you persisted. Bing responses may or may not include this header. If the response includes this header, capture the client ID and use it for all subsequent Bing requests for the user on that device. If you include the X-MSEdge-ClientID, you must not include cookies in the request. + * @param clientIp The IPv4 or IPv6 address of the client device. The IP address is used to discover the user's location. Bing uses the location information to determine safe search behavior. Although optional, you are encouraged to always specify this header and the X-Search-Location header. Do not obfuscate the address (for example, by changing the last octet to 0). Obfuscating the address results in the location not being anywhere near the device's actual location, which may result in Bing serving erroneous results. + * @param location A semicolon-delimited list of key/value pairs that describe the client's geographical location. Bing uses the location information to determine safe search behavior and to return relevant local content. Specify the key/value pair as <key>:<value>. The following are the keys that you use to specify the user's location. lat (required): The latitude of the client's location, in degrees. The latitude must be greater than or equal to -90.0 and less than or equal to +90.0. Negative values indicate southern latitudes and positive values indicate northern latitudes. long (required): The longitude of the client's location, in degrees. The longitude must be greater than or equal to -180.0 and less than or equal to +180.0. Negative values indicate western longitudes and positive values indicate eastern longitudes. re (required): The radius, in meters, which specifies the horizontal accuracy of the coordinates. Pass the value returned by the device's location service. Typical values might be 22m for GPS/Wi-Fi, 380m for cell tower triangulation, and 18,000m for reverse IP lookup. ts (optional): The UTC UNIX timestamp of when the client was at the location. (The UNIX timestamp is the number of seconds since January 1, 1970.) head (optional): The client's relative heading or direction of travel. Specify the direction of travel as degrees from 0 through 360, counting clockwise relative to true north. Specify this key only if the sp key is nonzero. sp (optional): The horizontal velocity (speed), in meters per second, that the client device is traveling. alt (optional): The altitude of the client device, in meters. are (optional): The radius, in meters, that specifies the vertical accuracy of the coordinates. Specify this key only if you specify the alt key. Although many of the keys are optional, the more information that you provide, the more accurate the location results are. Although optional, you are encouraged to always specify the user's geographical location. Providing the location is especially important if the client's IP address does not accurately reflect the user's physical location (for example, if the client uses VPN). For optimal results, you should include this header and the X-Search-ClientIP header, but at a minimum, you should include this header. + * @param actionType A string that's used by logging to determine whether the request is coming from an interactive session or a page load. The following are the possible values. 1) Edit—The request is from an interactive session 2) Load—The request is from a page load. Possible values include: 'Edit', 'Load' + * @param appName The unique name of your app. The name must be known by Bing. Do not include this parameter unless you have previously contacted Bing to get a unique app name. To get a unique name, contact your Bing Business Development manager. + * @param countryCode A 2-character country code of the country where the results come from. This API supports only the United States market. If you specify this query parameter, it must be set to us. If you set this parameter, you must also specify the Accept-Language header. Bing uses the first supported language it finds from the languages list, and combine that language with the country code that you specify to determine the market to return results for. If the languages list does not include a supported language, Bing finds the closest language and market that supports the request, or it may use an aggregated or default market for the results instead of a specified one. You should use this query parameter and the Accept-Language query parameter only if you specify multiple languages; otherwise, you should use the mkt and setLang query parameters. This parameter and the mkt query parameter are mutually exclusive—do not specify both. + * @param clientMachineName A unique name of the device that the request is being made from. Generate a unique value for each device (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. + * @param docId A unique ID that identifies the document that the text belongs to. Generate a unique value for each document (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. + * @param market The market where the results come from. You are strongly encouraged to always specify the market, if known. Specifying the market helps Bing route the request and return an appropriate and optimal response. This parameter and the cc query parameter are mutually exclusive—do not specify both. + * @param sessionId A unique ID that identifies this user session. Generate a unique value for each user session (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections + * @param setLang The language to use for user interface strings. Specify the language using the ISO 639-1 2-letter language code. For example, the language code for English is EN. The default is EN (English). Although optional, you should always specify the language. Typically, you set setLang to the same language specified by mkt unless the user wants the user interface strings displayed in a different language. This parameter and the Accept-Language header are mutually exclusive—do not specify both. A user interface string is a string that's used as a label in a user interface. There are few user interface strings in the JSON response objects. Also, any links to Bing.com properties in the response objects apply the specified language. + * @param userId A unique ID that identifies the user. Generate a unique value for each user (the value is unimportant). The service uses the ID to help debug issues and improve the quality of corrections. + * @param mode The type of spelling and grammar checks to perform. The following are the possible values (the values are case insensitive). The default is Proof. 1) Proof—Finds most spelling and grammar mistakes. 2) Spell—Finds most spelling mistakes but does not find some of the grammar errors that Proof catches (for example, capitalization and repeated words). Possible values include: 'proof', 'spell' + * @param preContextText A string that gives context to the text string. For example, the text string petal is valid. However, if you set preContextText to bike, the context changes and the text string becomes not valid. In this case, the API suggests that you change petal to pedal (as in bike pedal). This text is not checked for grammar or spelling errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. + * @param postContextText A string that gives context to the text string. For example, the text string read is valid. However, if you set postContextText to carpet, the context changes and the text string becomes not valid. In this case, the API suggests that you change read to red (as in red carpet). This text is not checked for grammar or spelling errors. The combined length of the text string, preContextText string, and postContextText string may not exceed 10,000 characters. You may specify this parameter in the query string of a GET request or in the body of a POST request. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the SpellCheckInner object + */ + public Observable> spellCheckerWithServiceResponseAsync(String text, String acceptLanguage, String pragma, String clientId, String clientIp, String location, ActionType actionType, String appName, String countryCode, String clientMachineName, String docId, String market, String sessionId, String setLang, String userId, String mode, String preContextText, String postContextText) { + if (text == null) { + throw new IllegalArgumentException("Parameter text is required and cannot be null."); + } + final String xBingApisSDK = "true"; + return service.spellChecker(xBingApisSDK, acceptLanguage, pragma, this.userAgent(), clientId, clientIp, location, actionType, appName, countryCode, clientMachineName, docId, market, sessionId, setLang, userId, mode, preContextText, postContextText, text, this.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = spellCheckerDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse spellCheckerDelegate(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/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/implementation/SpellCheckInner.java b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/implementation/SpellCheckInner.java new file mode 100644 index 00000000000..89d4d7d0305 --- /dev/null +++ b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/implementation/SpellCheckInner.java @@ -0,0 +1,50 @@ +/** + * 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.spellcheck.implementation; + +import java.util.List; +import com.microsoft.azure.cognitiveservices.spellcheck.SpellingFlaggedToken; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.microsoft.azure.cognitiveservices.spellcheck.Answer; + +/** + * The SpellCheckInner model. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "_type") +@JsonTypeName("SpellCheck") +public class SpellCheckInner extends Answer { + /** + * The flaggedTokens property. + */ + @JsonProperty(value = "flaggedTokens", required = true) + private List flaggedTokens; + + /** + * Get the flaggedTokens value. + * + * @return the flaggedTokens value + */ + public List flaggedTokens() { + return this.flaggedTokens; + } + + /** + * Set the flaggedTokens value. + * + * @param flaggedTokens the flaggedTokens value to set + * @return the SpellCheckInner object itself. + */ + public SpellCheckInner withFlaggedTokens(List flaggedTokens) { + this.flaggedTokens = flaggedTokens; + return this; + } + +} diff --git a/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/implementation/package-info.java b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/implementation/package-info.java new file mode 100644 index 00000000000..bffda571906 --- /dev/null +++ b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/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 SpellCheckAPI. + * The Spell Check API - V7 lets you check a text string for spelling and grammar errors. + */ +package com.microsoft.azure.cognitiveservices.spellcheck.implementation; diff --git a/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/package-info.java b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/package-info.java new file mode 100644 index 00000000000..d11dae531f1 --- /dev/null +++ b/azure-cognitiveservices/spellcheck/src/main/java/com/microsoft/azure/cognitiveservices/spellcheck/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 SpellCheckAPI. + * The Spell Check API - V7 lets you check a text string for spelling and grammar errors. + */ +package com.microsoft.azure.cognitiveservices.spellcheck;