diff --git a/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/Answer.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/Answer.java new file mode 100644 index 00000000000..f4630394487 --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/Answer.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.search.customsearch; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; +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 = "SearchResultsAnswer", value = SearchResultsAnswer.class) +}) +public class Answer extends Response { + /** + * The followUpQueries property. + */ + @JsonProperty(value = "followUpQueries", access = JsonProperty.Access.WRITE_ONLY) + private List followUpQueries; + + /** + * Get the followUpQueries value. + * + * @return the followUpQueries value + */ + public List followUpQueries() { + return this.followUpQueries; + } + +} diff --git a/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/CreativeWork.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/CreativeWork.java new file mode 100644 index 00000000000..22fa49e16aa --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/CreativeWork.java @@ -0,0 +1,71 @@ +/** + * 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.search.customsearch; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonSubTypes; + +/** + * The CreativeWork model. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "_type") +@JsonTypeName("CreativeWork") +@JsonSubTypes({ + @JsonSubTypes.Type(name = "WebPage", value = WebPage.class) +}) +public class CreativeWork extends Thing { + /** + * The URL to a thumbnail of the item. + */ + @JsonProperty(value = "thumbnailUrl", access = JsonProperty.Access.WRITE_ONLY) + private String thumbnailUrl; + + /** + * The source of the creative work. + */ + @JsonProperty(value = "provider", access = JsonProperty.Access.WRITE_ONLY) + private List provider; + + /** + * The text property. + */ + @JsonProperty(value = "text", access = JsonProperty.Access.WRITE_ONLY) + private String text; + + /** + * Get the thumbnailUrl value. + * + * @return the thumbnailUrl value + */ + public String thumbnailUrl() { + return this.thumbnailUrl; + } + + /** + * Get the provider value. + * + * @return the provider value + */ + public List provider() { + return this.provider; + } + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + +} diff --git a/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/Error.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/Error.java new file mode 100644 index 00000000000..8c5844f6b90 --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/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.search.customsearch; + +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/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/ErrorCode.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/ErrorCode.java new file mode 100644 index 00000000000..6440e5d1a7e --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/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.search.customsearch; + +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/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/ErrorResponse.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/ErrorResponse.java new file mode 100644 index 00000000000..3c55e3988d2 --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/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.search.customsearch; + +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/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/ErrorResponseException.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/ErrorResponseException.java new file mode 100644 index 00000000000..d240f78d66f --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/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.search.customsearch; + +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/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/ErrorSubCode.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/ErrorSubCode.java new file mode 100644 index 00000000000..4820669e6d2 --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/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.search.customsearch; + +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/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/Identifiable.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/Identifiable.java new file mode 100644 index 00000000000..c5fedc748f9 --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/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.search.customsearch; + +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/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/Query.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/Query.java new file mode 100644 index 00000000000..0504d23d7e0 --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/Query.java @@ -0,0 +1,93 @@ +/** + * 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.search.customsearch; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Defines a search query. + */ +public class Query { + /** + * The query string. Use this string as the query term in a new search + * request. + */ + @JsonProperty(value = "text", required = true) + private String text; + + /** + * The display version of the query term. This version of the query term + * may contain special characters that highlight the search term found in + * the query string. The string contains the highlighting characters only + * if the query enabled hit highlighting. + */ + @JsonProperty(value = "displayText", access = JsonProperty.Access.WRITE_ONLY) + private String displayText; + + /** + * The URL that takes the user to the Bing search results page for the + * query.Only related search results include this field. + */ + @JsonProperty(value = "webSearchUrl", access = JsonProperty.Access.WRITE_ONLY) + private String webSearchUrl; + + /** + * The searchLink property. + */ + @JsonProperty(value = "searchLink", access = JsonProperty.Access.WRITE_ONLY) + private String searchLink; + + /** + * Get the text value. + * + * @return the text value + */ + public String text() { + return this.text; + } + + /** + * Set the text value. + * + * @param text the text value to set + * @return the Query object itself. + */ + public Query withText(String text) { + this.text = text; + return this; + } + + /** + * Get the displayText value. + * + * @return the displayText value + */ + public String displayText() { + return this.displayText; + } + + /** + * Get the webSearchUrl value. + * + * @return the webSearchUrl value + */ + public String webSearchUrl() { + return this.webSearchUrl; + } + + /** + * Get the searchLink value. + * + * @return the searchLink value + */ + public String searchLink() { + return this.searchLink; + } + +} diff --git a/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/QueryContext.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/QueryContext.java new file mode 100644 index 00000000000..e1a46836ef0 --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/QueryContext.java @@ -0,0 +1,98 @@ +/** + * 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.search.customsearch; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Defines the query context that Bing used for the request. + */ +public class QueryContext { + /** + * The query string as specified in the request. + */ + @JsonProperty(value = "originalQuery", required = true) + private String originalQuery; + + /** + * The query string used by Bing to perform the query. Bing uses the + * altered query string if the original query string contained spelling + * mistakes. For example, if the query string is "saling downwind", the + * altered query string will be "sailing downwind". This field is included + * only if the original query string contains a spelling mistake. + */ + @JsonProperty(value = "alteredQuery", access = JsonProperty.Access.WRITE_ONLY) + private String alteredQuery; + + /** + * The query string to use to force Bing to use the original string. For + * example, if the query string is "saling downwind", the override query + * string will be "+saling downwind". Remember to encode the query string + * which results in "%2Bsaling+downwind". This field is included only if + * the original query string contains a spelling mistake. + */ + @JsonProperty(value = "alterationOverrideQuery", access = JsonProperty.Access.WRITE_ONLY) + private String alterationOverrideQuery; + + /** + * A Boolean value that indicates whether the specified query has adult + * intent. The value is true if the query has adult intent; otherwise, + * false. + */ + @JsonProperty(value = "adultIntent", access = JsonProperty.Access.WRITE_ONLY) + private Boolean adultIntent; + + /** + * Get the originalQuery value. + * + * @return the originalQuery value + */ + public String originalQuery() { + return this.originalQuery; + } + + /** + * Set the originalQuery value. + * + * @param originalQuery the originalQuery value to set + * @return the QueryContext object itself. + */ + public QueryContext withOriginalQuery(String originalQuery) { + this.originalQuery = originalQuery; + return this; + } + + /** + * Get the alteredQuery value. + * + * @return the alteredQuery value + */ + public String alteredQuery() { + return this.alteredQuery; + } + + /** + * Get the alterationOverrideQuery value. + * + * @return the alterationOverrideQuery value + */ + public String alterationOverrideQuery() { + return this.alterationOverrideQuery; + } + + /** + * Get the adultIntent value. + * + * @return the adultIntent value + */ + public Boolean adultIntent() { + return this.adultIntent; + } + +} diff --git a/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/Response.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/Response.java new file mode 100644 index 00000000000..c7c92f899d2 --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/Response.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.search.customsearch; + +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 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 = "SearchResponse", value = SearchResponseInner.class), + @JsonSubTypes.Type(name = "ErrorResponse", value = ErrorResponse.class), + @JsonSubTypes.Type(name = "Answer", value = Answer.class), + @JsonSubTypes.Type(name = "Thing", value = Thing.class) +}) +public class Response extends Identifiable { + /** + * The URL To Bing's search result for this item. + */ + @JsonProperty(value = "webSearchUrl", access = JsonProperty.Access.WRITE_ONLY) + private String webSearchUrl; + + /** + * Get the webSearchUrl value. + * + * @return the webSearchUrl value + */ + public String webSearchUrl() { + return this.webSearchUrl; + } + +} diff --git a/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/ResponseBase.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/ResponseBase.java new file mode 100644 index 00000000000..f94d84afe45 --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/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.search.customsearch; + +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/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/SafeSearch.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/SafeSearch.java new file mode 100644 index 00000000000..a2f96a10aeb --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/SafeSearch.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.search.customsearch; + +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; + +/** + * Defines values for SafeSearch. + */ +public final class SafeSearch extends ExpandableStringEnum { + /** Static value Off for SafeSearch. */ + public static final SafeSearch OFF = fromString("Off"); + + /** Static value Moderate for SafeSearch. */ + public static final SafeSearch MODERATE = fromString("Moderate"); + + /** Static value Strict for SafeSearch. */ + public static final SafeSearch STRICT = fromString("Strict"); + + /** + * Creates or finds a SafeSearch from its string representation. + * @param name a name to look for + * @return the corresponding SafeSearch + */ + @JsonCreator + public static SafeSearch fromString(String name) { + return fromString(name, SafeSearch.class); + } + + /** + * @return known SafeSearch values + */ + public static Collection values() { + return values(SafeSearch.class); + } +} diff --git a/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/SearchResultsAnswer.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/SearchResultsAnswer.java new file mode 100644 index 00000000000..6ed8a485131 --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/SearchResultsAnswer.java @@ -0,0 +1,72 @@ +/** + * 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.search.customsearch; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonSubTypes; + +/** + * The SearchResultsAnswer model. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "_type") +@JsonTypeName("SearchResultsAnswer") +@JsonSubTypes({ + @JsonSubTypes.Type(name = "Web/WebAnswer", value = WebWebAnswer.class) +}) +public class SearchResultsAnswer extends Answer { + /** + * The queryContext property. + */ + @JsonProperty(value = "queryContext", access = JsonProperty.Access.WRITE_ONLY) + private QueryContext queryContext; + + /** + * The estimated number of webpages that are relevant to the query. Use + * this number along with the count and offset query parameters to page the + * results. + */ + @JsonProperty(value = "totalEstimatedMatches", access = JsonProperty.Access.WRITE_ONLY) + private Long totalEstimatedMatches; + + /** + * The isFamilyFriendly property. + */ + @JsonProperty(value = "isFamilyFriendly", access = JsonProperty.Access.WRITE_ONLY) + private Boolean isFamilyFriendly; + + /** + * Get the queryContext value. + * + * @return the queryContext value + */ + public QueryContext queryContext() { + return this.queryContext; + } + + /** + * Get the totalEstimatedMatches value. + * + * @return the totalEstimatedMatches value + */ + public Long totalEstimatedMatches() { + return this.totalEstimatedMatches; + } + + /** + * Get the isFamilyFriendly value. + * + * @return the isFamilyFriendly value + */ + public Boolean isFamilyFriendly() { + return this.isFamilyFriendly; + } + +} diff --git a/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/TextFormat.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/TextFormat.java new file mode 100644 index 00000000000..1600449f1f2 --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/TextFormat.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.search.customsearch; + +import java.util.Collection; +import com.fasterxml.jackson.annotation.JsonCreator; +import com.microsoft.rest.ExpandableStringEnum; + +/** + * Defines values for TextFormat. + */ +public final class TextFormat extends ExpandableStringEnum { + /** Static value Raw for TextFormat. */ + public static final TextFormat RAW = fromString("Raw"); + + /** Static value Html for TextFormat. */ + public static final TextFormat HTML = fromString("Html"); + + /** + * Creates or finds a TextFormat from its string representation. + * @param name a name to look for + * @return the corresponding TextFormat + */ + @JsonCreator + public static TextFormat fromString(String name) { + return fromString(name, TextFormat.class); + } + + /** + * @return known TextFormat values + */ + public static Collection values() { + return values(TextFormat.class); + } +} diff --git a/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/Thing.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/Thing.java new file mode 100644 index 00000000000..25166cd27ce --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/Thing.java @@ -0,0 +1,86 @@ +/** + * 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.search.customsearch; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.fasterxml.jackson.annotation.JsonSubTypes; + +/** + * The Thing model. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "_type") +@JsonTypeName("Thing") +@JsonSubTypes({ + @JsonSubTypes.Type(name = "CreativeWork", value = CreativeWork.class) +}) +public class Thing extends Response { + /** + * The name of the thing represented by this object. + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /** + * The URL to get more information about the thing represented by this + * object. + */ + @JsonProperty(value = "url", access = JsonProperty.Access.WRITE_ONLY) + private String url; + + /** + * A short description of the item. + */ + @JsonProperty(value = "description", access = JsonProperty.Access.WRITE_ONLY) + private String description; + + /** + * An ID that uniquely identifies this item. + */ + @JsonProperty(value = "bingId", access = JsonProperty.Access.WRITE_ONLY) + private String bingId; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Get the url value. + * + * @return the url value + */ + public String url() { + return this.url; + } + + /** + * Get the description value. + * + * @return the description value + */ + public String description() { + return this.description; + } + + /** + * Get the bingId value. + * + * @return the bingId value + */ + public String bingId() { + return this.bingId; + } + +} diff --git a/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/WebMetaTag.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/WebMetaTag.java new file mode 100644 index 00000000000..b1e6a157192 --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/WebMetaTag.java @@ -0,0 +1,47 @@ +/** + * 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.search.customsearch; + +import com.fasterxml.jackson.annotation.JsonProperty; + +/** + * Defines a webpage's metadata. + */ +public class WebMetaTag { + /** + * The metadata. + */ + @JsonProperty(value = "name", access = JsonProperty.Access.WRITE_ONLY) + private String name; + + /** + * The name of the metadata. + */ + @JsonProperty(value = "content", access = JsonProperty.Access.WRITE_ONLY) + private String content; + + /** + * Get the name value. + * + * @return the name value + */ + public String name() { + return this.name; + } + + /** + * Get the content value. + * + * @return the content value + */ + public String content() { + return this.content; + } + +} diff --git a/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/WebPage.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/WebPage.java new file mode 100644 index 00000000000..fe209273436 --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/WebPage.java @@ -0,0 +1,105 @@ +/** + * 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.search.customsearch; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * Defines a webpage that is relevant to the query. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "_type") +@JsonTypeName("WebPage") +public class WebPage extends CreativeWork { + /** + * The display URL of the webpage. The URL is meant for display purposes + * only and is not well formed. + */ + @JsonProperty(value = "displayUrl", access = JsonProperty.Access.WRITE_ONLY) + private String displayUrl; + + /** + * A snippet of text from the webpage that describes its contents. + */ + @JsonProperty(value = "snippet", access = JsonProperty.Access.WRITE_ONLY) + private String snippet; + + /** + * A list of links to related content that Bing found in the website that + * contains this webpage. The Webpage object in this context includes only + * the name, url, urlPingSuffix, and snippet fields. + */ + @JsonProperty(value = "deepLinks", access = JsonProperty.Access.WRITE_ONLY) + private List deepLinks; + + /** + * The last time that Bing crawled the webpage. The date is in the form, + * YYYY-MM-DDTHH:MM:SS. For example, 2015-04-13T05:23:39. + */ + @JsonProperty(value = "dateLastCrawled", access = JsonProperty.Access.WRITE_ONLY) + private String dateLastCrawled; + + /** + * A list of search tags that the webpage owner specified on the webpage. + * The API returns only indexed search tags. The name field of the MetaTag + * object contains the indexed search tag. Search tags begin with search.* + * (for example, search.assetId). The content field contains the tag's + * value. + */ + @JsonProperty(value = "searchTags", access = JsonProperty.Access.WRITE_ONLY) + private List searchTags; + + /** + * Get the displayUrl value. + * + * @return the displayUrl value + */ + public String displayUrl() { + return this.displayUrl; + } + + /** + * Get the snippet value. + * + * @return the snippet value + */ + public String snippet() { + return this.snippet; + } + + /** + * Get the deepLinks value. + * + * @return the deepLinks value + */ + public List deepLinks() { + return this.deepLinks; + } + + /** + * Get the dateLastCrawled value. + * + * @return the dateLastCrawled value + */ + public String dateLastCrawled() { + return this.dateLastCrawled; + } + + /** + * Get the searchTags value. + * + * @return the searchTags value + */ + public List searchTags() { + return this.searchTags; + } + +} diff --git a/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/WebWebAnswer.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/WebWebAnswer.java new file mode 100644 index 00000000000..87b6f860564 --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/WebWebAnswer.java @@ -0,0 +1,65 @@ +/** + * 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.search.customsearch; + +import java.util.List; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; + +/** + * Defines a list of relevant webpage links. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "_type") +@JsonTypeName("Web/WebAnswer") +public class WebWebAnswer extends SearchResultsAnswer { + /** + * A list of webpages that are relevant to the query. + */ + @JsonProperty(value = "value", required = true) + private List value; + + /** + * A Boolean value that indicates whether the response excluded some + * results from the answer. If Bing excluded some results, the value is + * true. + */ + @JsonProperty(value = "someResultsRemoved", access = JsonProperty.Access.WRITE_ONLY) + private Boolean someResultsRemoved; + + /** + * Get the value value. + * + * @return the value value + */ + public List value() { + return this.value; + } + + /** + * Set the value value. + * + * @param value the value value to set + * @return the WebWebAnswer object itself. + */ + public WebWebAnswer withValue(List value) { + this.value = value; + return this; + } + + /** + * Get the someResultsRemoved value. + * + * @return the someResultsRemoved value + */ + public Boolean someResultsRemoved() { + return this.someResultsRemoved; + } + +} diff --git a/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/implementation/CustomInstancesInner.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/implementation/CustomInstancesInner.java new file mode 100644 index 00000000000..b59bab6ecf8 --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/implementation/CustomInstancesInner.java @@ -0,0 +1,270 @@ +/** + * 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.search.customsearch.implementation; + +import retrofit2.Retrofit; +import com.google.common.reflect.TypeToken; +import com.microsoft.azure.cognitiveservices.search.customsearch.ErrorResponseException; +import com.microsoft.azure.cognitiveservices.search.customsearch.SafeSearch; +import com.microsoft.azure.cognitiveservices.search.customsearch.TextFormat; +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.GET; +import retrofit2.http.Header; +import retrofit2.http.Headers; +import retrofit2.http.Query; +import retrofit2.Response; +import rx.functions.Func1; +import rx.Observable; + +/** + * An instance of this class provides access to all the operations defined + * in CustomInstances. + */ +public class CustomInstancesInner { + /** The Retrofit service to perform REST calls. */ + private CustomInstancesService service; + /** The service client containing this operation class. */ + private CustomSearchAPIImpl client; + + /** + * Initializes an instance of CustomInstancesInner. + * + * @param retrofit the Retrofit instance built from a Retrofit Builder. + * @param client the instance of the service client containing this operation class. + */ + public CustomInstancesInner(Retrofit retrofit, CustomSearchAPIImpl client) { + this.service = retrofit.create(CustomInstancesService.class); + this.client = client; + } + + /** + * The interface defining all the services for CustomInstances to be + * used by Retrofit to perform actually REST calls. + */ + interface CustomInstancesService { + @Headers({ "Content-Type: application/json; charset=utf-8", "x-ms-logging-context: com.microsoft.azure.cognitiveservices.search.customsearch.CustomInstances search" }) + @GET("search") + Observable> search(@Header("X-BingApis-SDK") String xBingApisSDK, @Header("Accept-Language") String acceptLanguage, @Header("User-Agent") String userAgent, @Header("X-MSEdge-ClientID") String clientId, @Header("X-MSEdge-ClientIP") String clientIp, @Header("X-Search-Location") String location, @Query("customConfig") long customConfig, @Query("cc") String countryCode, @Query("count") Integer count, @Query("mkt") String market, @Query("offset") Integer offset, @Query("q") String query, @Query("safeSearch") SafeSearch safeSearch, @Query("setLang") String setLang, @Query("textDecorations") Boolean textDecorations, @Query("textFormat") TextFormat textFormat, @Header("User-Agent") String userAgent); + + } + + /** + * The Custom Search API lets you send a search query to Bing and get back web pages found in your custom view of the web. + * + * @param customConfig The identifier for the custom search configuration + * @param query The user's search query term. The term may not be empty. The term may contain Bing Advanced Operators. For example, to limit results to a specific domain, use the site: operator. + * @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 SearchResponseInner object if successful. + */ + public SearchResponseInner search(long customConfig, String query) { + return searchWithServiceResponseAsync(customConfig, query).toBlocking().single().body(); + } + + /** + * The Custom Search API lets you send a search query to Bing and get back web pages found in your custom view of the web. + * + * @param customConfig The identifier for the custom search configuration + * @param query The user's search query term. The term may not be empty. The term may contain Bing Advanced Operators. For example, to limit results to a specific domain, use the site: operator. + * @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 searchAsync(long customConfig, String query, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(searchWithServiceResponseAsync(customConfig, query), serviceCallback); + } + + /** + * The Custom Search API lets you send a search query to Bing and get back web pages found in your custom view of the web. + * + * @param customConfig The identifier for the custom search configuration + * @param query The user's search query term. The term may not be empty. The term may contain Bing Advanced Operators. For example, to limit results to a specific domain, use the site: operator. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the SearchResponseInner object + */ + public Observable searchAsync(long customConfig, String query) { + return searchWithServiceResponseAsync(customConfig, query).map(new Func1, SearchResponseInner>() { + @Override + public SearchResponseInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * The Custom Search API lets you send a search query to Bing and get back web pages found in your custom view of the web. + * + * @param customConfig The identifier for the custom search configuration + * @param query The user's search query term. The term may not be empty. The term may contain Bing Advanced Operators. For example, to limit results to a specific domain, use the site: operator. + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the SearchResponseInner object + */ + public Observable> searchWithServiceResponseAsync(long customConfig, String query) { + if (query == null) { + throw new IllegalArgumentException("Parameter query is required and cannot be null."); + } + final String xBingApisSDK = "true"; + final String acceptLanguage = null; + final String clientId = null; + final String clientIp = null; + final String location = null; + final String countryCode = null; + final Integer count = null; + final String market = null; + final Integer offset = null; + final SafeSearch safeSearch = null; + final String setLang = null; + final Boolean textDecorations = null; + final TextFormat textFormat = null; + return service.search(xBingApisSDK, acceptLanguage, this.client.userAgent(), clientId, clientIp, location, customConfig, countryCode, count, market, offset, query, safeSearch, setLang, textDecorations, textFormat, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = searchDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + /** + * The Custom Search API lets you send a search query to Bing and get back web pages found in your custom view of the web. + * + * @param customConfig The identifier for the custom search configuration + * @param query The user's search query term. The term may not be empty. The term may contain Bing Advanced Operators. For example, to limit results to a specific domain, use the site: operator. + * @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 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-MSEdge-ClientIP header, but at a minimum, you should include this header. + * @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 count The number of search results to return in the response. The default is 10 and the maximum value is 50. The actual number delivered may be less than requested.Use this parameter along with the offset parameter to page results.For example, if your user interface displays 10 search results per page, set count to 10 and offset to 0 to get the first page of results. For each subsequent page, increment offset by 10 (for example, 0, 10, 20). It is possible for multiple pages to include some overlap in results. + * @param market The market where the results come from. Typically, mkt is the country where the user is making the request from. However, it could be a different country if the user is not located in a country where Bing delivers results. The market must be in the form <language code>-<country code>. For example, en-US. The string is case insensitive. If known, you are encouraged to always specify the market. Specifying the market helps Bing route the request and return an appropriate and optimal response. If you specify a market that is not listed in Market Codes, Bing uses a best fit market code based on an internal mapping that is subject to change. This parameter and the cc query parameter are mutually exclusive—do not specify both. + * @param offset The zero-based offset that indicates the number of search results to skip before returning results. The default is 0. The offset should be less than (totalEstimatedMatches - count). Use this parameter along with the count parameter to page results. For example, if your user interface displays 10 search results per page, set count to 10 and offset to 0 to get the first page of results. For each subsequent page, increment offset by 10 (for example, 0, 10, 20). it is possible for multiple pages to include some overlap in results. + * @param safeSearch A filter used to filter adult content. Off: Return webpages with adult text, images, or videos. Moderate: Return webpages with adult text, but not adult images or videos. Strict: Do not return webpages with adult text, images, or videos. The default is Moderate. If the request comes from a market that Bing's adult policy requires that safeSearch is set to Strict, Bing ignores the safeSearch value and uses Strict. If you use the site: query operator, there is the chance that the response may contain adult content regardless of what the safeSearch query parameter is set to. Use site: only if you are aware of the content on the site and your scenario supports the possibility of adult content. Possible values include: 'Off', 'Moderate', 'Strict' + * @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 textDecorations A Boolean value that determines whether display strings should contain decoration markers such as hit highlighting characters. If true, the strings may include markers. The default is false. To specify whether to use Unicode characters or HTML tags as the markers, see the textFormat query parameter. + * @param textFormat The type of markers to use for text decorations (see the textDecorations query parameter). Possible values are Raw—Use Unicode characters to mark content that needs special formatting. The Unicode characters are in the range E000 through E019. For example, Bing uses E000 and E001 to mark the beginning and end of query terms for hit highlighting. HTML—Use HTML tags to mark content that needs special formatting. For example, use <b> tags to highlight query terms in display strings. The default is Raw. For display strings that contain escapable HTML characters such as <, >, and &, if textFormat is set to HTML, Bing escapes the characters as appropriate (for example, < is escaped to &lt;). Possible values include: 'Raw', 'Html' + * @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 SearchResponseInner object if successful. + */ + public SearchResponseInner search(long customConfig, String query, String acceptLanguage, String clientId, String clientIp, String location, String countryCode, Integer count, String market, Integer offset, SafeSearch safeSearch, String setLang, Boolean textDecorations, TextFormat textFormat) { + return searchWithServiceResponseAsync(customConfig, query, acceptLanguage, clientId, clientIp, location, countryCode, count, market, offset, safeSearch, setLang, textDecorations, textFormat).toBlocking().single().body(); + } + + /** + * The Custom Search API lets you send a search query to Bing and get back web pages found in your custom view of the web. + * + * @param customConfig The identifier for the custom search configuration + * @param query The user's search query term. The term may not be empty. The term may contain Bing Advanced Operators. For example, to limit results to a specific domain, use the site: operator. + * @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 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-MSEdge-ClientIP header, but at a minimum, you should include this header. + * @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 count The number of search results to return in the response. The default is 10 and the maximum value is 50. The actual number delivered may be less than requested.Use this parameter along with the offset parameter to page results.For example, if your user interface displays 10 search results per page, set count to 10 and offset to 0 to get the first page of results. For each subsequent page, increment offset by 10 (for example, 0, 10, 20). It is possible for multiple pages to include some overlap in results. + * @param market The market where the results come from. Typically, mkt is the country where the user is making the request from. However, it could be a different country if the user is not located in a country where Bing delivers results. The market must be in the form <language code>-<country code>. For example, en-US. The string is case insensitive. If known, you are encouraged to always specify the market. Specifying the market helps Bing route the request and return an appropriate and optimal response. If you specify a market that is not listed in Market Codes, Bing uses a best fit market code based on an internal mapping that is subject to change. This parameter and the cc query parameter are mutually exclusive—do not specify both. + * @param offset The zero-based offset that indicates the number of search results to skip before returning results. The default is 0. The offset should be less than (totalEstimatedMatches - count). Use this parameter along with the count parameter to page results. For example, if your user interface displays 10 search results per page, set count to 10 and offset to 0 to get the first page of results. For each subsequent page, increment offset by 10 (for example, 0, 10, 20). it is possible for multiple pages to include some overlap in results. + * @param safeSearch A filter used to filter adult content. Off: Return webpages with adult text, images, or videos. Moderate: Return webpages with adult text, but not adult images or videos. Strict: Do not return webpages with adult text, images, or videos. The default is Moderate. If the request comes from a market that Bing's adult policy requires that safeSearch is set to Strict, Bing ignores the safeSearch value and uses Strict. If you use the site: query operator, there is the chance that the response may contain adult content regardless of what the safeSearch query parameter is set to. Use site: only if you are aware of the content on the site and your scenario supports the possibility of adult content. Possible values include: 'Off', 'Moderate', 'Strict' + * @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 textDecorations A Boolean value that determines whether display strings should contain decoration markers such as hit highlighting characters. If true, the strings may include markers. The default is false. To specify whether to use Unicode characters or HTML tags as the markers, see the textFormat query parameter. + * @param textFormat The type of markers to use for text decorations (see the textDecorations query parameter). Possible values are Raw—Use Unicode characters to mark content that needs special formatting. The Unicode characters are in the range E000 through E019. For example, Bing uses E000 and E001 to mark the beginning and end of query terms for hit highlighting. HTML—Use HTML tags to mark content that needs special formatting. For example, use <b> tags to highlight query terms in display strings. The default is Raw. For display strings that contain escapable HTML characters such as <, >, and &, if textFormat is set to HTML, Bing escapes the characters as appropriate (for example, < is escaped to &lt;). Possible values include: 'Raw', 'Html' + * @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 searchAsync(long customConfig, String query, String acceptLanguage, String clientId, String clientIp, String location, String countryCode, Integer count, String market, Integer offset, SafeSearch safeSearch, String setLang, Boolean textDecorations, TextFormat textFormat, final ServiceCallback serviceCallback) { + return ServiceFuture.fromResponse(searchWithServiceResponseAsync(customConfig, query, acceptLanguage, clientId, clientIp, location, countryCode, count, market, offset, safeSearch, setLang, textDecorations, textFormat), serviceCallback); + } + + /** + * The Custom Search API lets you send a search query to Bing and get back web pages found in your custom view of the web. + * + * @param customConfig The identifier for the custom search configuration + * @param query The user's search query term. The term may not be empty. The term may contain Bing Advanced Operators. For example, to limit results to a specific domain, use the site: operator. + * @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 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-MSEdge-ClientIP header, but at a minimum, you should include this header. + * @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 count The number of search results to return in the response. The default is 10 and the maximum value is 50. The actual number delivered may be less than requested.Use this parameter along with the offset parameter to page results.For example, if your user interface displays 10 search results per page, set count to 10 and offset to 0 to get the first page of results. For each subsequent page, increment offset by 10 (for example, 0, 10, 20). It is possible for multiple pages to include some overlap in results. + * @param market The market where the results come from. Typically, mkt is the country where the user is making the request from. However, it could be a different country if the user is not located in a country where Bing delivers results. The market must be in the form <language code>-<country code>. For example, en-US. The string is case insensitive. If known, you are encouraged to always specify the market. Specifying the market helps Bing route the request and return an appropriate and optimal response. If you specify a market that is not listed in Market Codes, Bing uses a best fit market code based on an internal mapping that is subject to change. This parameter and the cc query parameter are mutually exclusive—do not specify both. + * @param offset The zero-based offset that indicates the number of search results to skip before returning results. The default is 0. The offset should be less than (totalEstimatedMatches - count). Use this parameter along with the count parameter to page results. For example, if your user interface displays 10 search results per page, set count to 10 and offset to 0 to get the first page of results. For each subsequent page, increment offset by 10 (for example, 0, 10, 20). it is possible for multiple pages to include some overlap in results. + * @param safeSearch A filter used to filter adult content. Off: Return webpages with adult text, images, or videos. Moderate: Return webpages with adult text, but not adult images or videos. Strict: Do not return webpages with adult text, images, or videos. The default is Moderate. If the request comes from a market that Bing's adult policy requires that safeSearch is set to Strict, Bing ignores the safeSearch value and uses Strict. If you use the site: query operator, there is the chance that the response may contain adult content regardless of what the safeSearch query parameter is set to. Use site: only if you are aware of the content on the site and your scenario supports the possibility of adult content. Possible values include: 'Off', 'Moderate', 'Strict' + * @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 textDecorations A Boolean value that determines whether display strings should contain decoration markers such as hit highlighting characters. If true, the strings may include markers. The default is false. To specify whether to use Unicode characters or HTML tags as the markers, see the textFormat query parameter. + * @param textFormat The type of markers to use for text decorations (see the textDecorations query parameter). Possible values are Raw—Use Unicode characters to mark content that needs special formatting. The Unicode characters are in the range E000 through E019. For example, Bing uses E000 and E001 to mark the beginning and end of query terms for hit highlighting. HTML—Use HTML tags to mark content that needs special formatting. For example, use <b> tags to highlight query terms in display strings. The default is Raw. For display strings that contain escapable HTML characters such as <, >, and &, if textFormat is set to HTML, Bing escapes the characters as appropriate (for example, < is escaped to &lt;). Possible values include: 'Raw', 'Html' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the SearchResponseInner object + */ + public Observable searchAsync(long customConfig, String query, String acceptLanguage, String clientId, String clientIp, String location, String countryCode, Integer count, String market, Integer offset, SafeSearch safeSearch, String setLang, Boolean textDecorations, TextFormat textFormat) { + return searchWithServiceResponseAsync(customConfig, query, acceptLanguage, clientId, clientIp, location, countryCode, count, market, offset, safeSearch, setLang, textDecorations, textFormat).map(new Func1, SearchResponseInner>() { + @Override + public SearchResponseInner call(ServiceResponse response) { + return response.body(); + } + }); + } + + /** + * The Custom Search API lets you send a search query to Bing and get back web pages found in your custom view of the web. + * + * @param customConfig The identifier for the custom search configuration + * @param query The user's search query term. The term may not be empty. The term may contain Bing Advanced Operators. For example, to limit results to a specific domain, use the site: operator. + * @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 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-MSEdge-ClientIP header, but at a minimum, you should include this header. + * @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 count The number of search results to return in the response. The default is 10 and the maximum value is 50. The actual number delivered may be less than requested.Use this parameter along with the offset parameter to page results.For example, if your user interface displays 10 search results per page, set count to 10 and offset to 0 to get the first page of results. For each subsequent page, increment offset by 10 (for example, 0, 10, 20). It is possible for multiple pages to include some overlap in results. + * @param market The market where the results come from. Typically, mkt is the country where the user is making the request from. However, it could be a different country if the user is not located in a country where Bing delivers results. The market must be in the form <language code>-<country code>. For example, en-US. The string is case insensitive. If known, you are encouraged to always specify the market. Specifying the market helps Bing route the request and return an appropriate and optimal response. If you specify a market that is not listed in Market Codes, Bing uses a best fit market code based on an internal mapping that is subject to change. This parameter and the cc query parameter are mutually exclusive—do not specify both. + * @param offset The zero-based offset that indicates the number of search results to skip before returning results. The default is 0. The offset should be less than (totalEstimatedMatches - count). Use this parameter along with the count parameter to page results. For example, if your user interface displays 10 search results per page, set count to 10 and offset to 0 to get the first page of results. For each subsequent page, increment offset by 10 (for example, 0, 10, 20). it is possible for multiple pages to include some overlap in results. + * @param safeSearch A filter used to filter adult content. Off: Return webpages with adult text, images, or videos. Moderate: Return webpages with adult text, but not adult images or videos. Strict: Do not return webpages with adult text, images, or videos. The default is Moderate. If the request comes from a market that Bing's adult policy requires that safeSearch is set to Strict, Bing ignores the safeSearch value and uses Strict. If you use the site: query operator, there is the chance that the response may contain adult content regardless of what the safeSearch query parameter is set to. Use site: only if you are aware of the content on the site and your scenario supports the possibility of adult content. Possible values include: 'Off', 'Moderate', 'Strict' + * @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 textDecorations A Boolean value that determines whether display strings should contain decoration markers such as hit highlighting characters. If true, the strings may include markers. The default is false. To specify whether to use Unicode characters or HTML tags as the markers, see the textFormat query parameter. + * @param textFormat The type of markers to use for text decorations (see the textDecorations query parameter). Possible values are Raw—Use Unicode characters to mark content that needs special formatting. The Unicode characters are in the range E000 through E019. For example, Bing uses E000 and E001 to mark the beginning and end of query terms for hit highlighting. HTML—Use HTML tags to mark content that needs special formatting. For example, use <b> tags to highlight query terms in display strings. The default is Raw. For display strings that contain escapable HTML characters such as <, >, and &, if textFormat is set to HTML, Bing escapes the characters as appropriate (for example, < is escaped to &lt;). Possible values include: 'Raw', 'Html' + * @throws IllegalArgumentException thrown if parameters fail the validation + * @return the observable to the SearchResponseInner object + */ + public Observable> searchWithServiceResponseAsync(long customConfig, String query, String acceptLanguage, String clientId, String clientIp, String location, String countryCode, Integer count, String market, Integer offset, SafeSearch safeSearch, String setLang, Boolean textDecorations, TextFormat textFormat) { + if (query == null) { + throw new IllegalArgumentException("Parameter query is required and cannot be null."); + } + final String xBingApisSDK = "true"; + return service.search(xBingApisSDK, acceptLanguage, this.client.userAgent(), clientId, clientIp, location, customConfig, countryCode, count, market, offset, query, safeSearch, setLang, textDecorations, textFormat, this.client.userAgent()) + .flatMap(new Func1, Observable>>() { + @Override + public Observable> call(Response response) { + try { + ServiceResponse clientResponse = searchDelegate(response); + return Observable.just(clientResponse); + } catch (Throwable t) { + return Observable.error(t); + } + } + }); + } + + private ServiceResponse searchDelegate(Response response) throws ErrorResponseException, IOException, IllegalArgumentException { + return this.client.restClient().responseBuilderFactory().newInstance(this.client.serializerAdapter()) + .register(200, new TypeToken() { }.getType()) + .registerError(ErrorResponseException.class) + .build(response); + } + +} diff --git a/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/implementation/CustomSearchAPIImpl.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/implementation/CustomSearchAPIImpl.java new file mode 100644 index 00000000000..38e925d3b86 --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/implementation/CustomSearchAPIImpl.java @@ -0,0 +1,160 @@ +/** + * 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.search.customsearch.implementation; + +import com.microsoft.azure.AzureClient; +import com.microsoft.azure.AzureServiceClient; +import com.microsoft.rest.credentials.ServiceClientCredentials; +import com.microsoft.rest.RestClient; + +/** + * Initializes a new instance of the CustomSearchAPIImpl class. + */ +public class CustomSearchAPIImpl extends AzureServiceClient { + /** 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 CustomSearchAPIImpl 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 CustomSearchAPIImpl 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 CustomSearchAPIImpl withGenerateClientRequestId(boolean generateClientRequestId) { + this.generateClientRequestId = generateClientRequestId; + return this; + } + + /** + * The CustomInstancesInner object to access its operations. + */ + private CustomInstancesInner customInstances; + + /** + * Gets the CustomInstancesInner object to access its operations. + * @return the CustomInstancesInner object. + */ + public CustomInstancesInner customInstances() { + return this.customInstances; + } + + /** + * Initializes an instance of CustomSearchAPI client. + * + * @param credentials the management credentials for Azure + */ + public CustomSearchAPIImpl(ServiceClientCredentials credentials) { + this("https://api.cognitive.microsoft.com/bingcustomsearch/v7.0", credentials); + } + + /** + * Initializes an instance of CustomSearchAPI client. + * + * @param baseUrl the base URL of the host + * @param credentials the management credentials for Azure + */ + public CustomSearchAPIImpl(String baseUrl, ServiceClientCredentials credentials) { + super(baseUrl, credentials); + initialize(); + } + + /** + * Initializes an instance of CustomSearchAPI client. + * + * @param restClient the REST client to connect to Azure. + */ + public CustomSearchAPIImpl(RestClient restClient) { + super(restClient); + initialize(); + } + + protected void initialize() { + this.acceptLanguage = "en-US"; + this.longRunningOperationRetryTimeout = 30; + this.generateClientRequestId = true; + this.customInstances = new CustomInstancesInner(restClient().retrofit(), this); + this.azureClient = new AzureClient(this); + } + + /** + * 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(), "CustomSearchAPI", "1.0"); + } +} diff --git a/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/implementation/SearchResponseInner.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/implementation/SearchResponseInner.java new file mode 100644 index 00000000000..5c0440cd75f --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/implementation/SearchResponseInner.java @@ -0,0 +1,58 @@ +/** + * 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.search.customsearch.implementation; + +import com.microsoft.azure.cognitiveservices.search.customsearch.QueryContext; +import com.microsoft.azure.cognitiveservices.search.customsearch.WebWebAnswer; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import com.fasterxml.jackson.annotation.JsonTypeName; +import com.microsoft.azure.cognitiveservices.search.customsearch.Response; + +/** + * Defines the top-level object that the response includes when the request + * succeeds. + */ +@JsonTypeInfo(use = JsonTypeInfo.Id.NAME, include = JsonTypeInfo.As.PROPERTY, property = "_type") +@JsonTypeName("SearchResponse") +public class SearchResponseInner extends Response { + /** + * An object that contains the query string that Bing used for the request. + * This object contains the query string as entered by the user. It may + * also contain an altered query string that Bing used for the query if the + * query string contained a spelling mistake. + */ + @JsonProperty(value = "queryContext", access = JsonProperty.Access.WRITE_ONLY) + private QueryContext queryContext; + + /** + * A list of webpages that are relevant to the search query. + */ + @JsonProperty(value = "webPages", access = JsonProperty.Access.WRITE_ONLY) + private WebWebAnswer webPages; + + /** + * Get the queryContext value. + * + * @return the queryContext value + */ + public QueryContext queryContext() { + return this.queryContext; + } + + /** + * Get the webPages value. + * + * @return the webPages value + */ + public WebWebAnswer webPages() { + return this.webPages; + } + +} diff --git a/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/implementation/package-info.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/implementation/package-info.java new file mode 100644 index 00000000000..f720ea911e7 --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/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 CustomSearchAPI. + * The Bing Custom Search API lets you send a search query to Bing and get back search results customized to meet your custom search definition. + */ +package com.microsoft.azure.cognitiveservices.search.customsearch.implementation; diff --git a/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/package-info.java b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/package-info.java new file mode 100644 index 00000000000..5979d52f25e --- /dev/null +++ b/azure-cognitiveservices/search/bingcustomsearch/src/main/java/com/microsoft/azure/cognitiveservices/search/customsearch/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 CustomSearchAPI. + * The Bing Custom Search API lets you send a search query to Bing and get back search results customized to meet your custom search definition. + */ +package com.microsoft.azure.cognitiveservices.search.customsearch;