diff --git a/lib/services/autosuggest/LICENSE.txt b/lib/services/autosuggest/LICENSE.txt new file mode 100644 index 0000000000..5431ba98b9 --- /dev/null +++ b/lib/services/autosuggest/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2018 Microsoft + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/lib/services/autosuggest/lib/autoSuggestAPIClient.d.ts b/lib/services/autosuggest/lib/autoSuggestAPIClient.d.ts new file mode 100644 index 0000000000..a24a8e6596 --- /dev/null +++ b/lib/services/autosuggest/lib/autoSuggestAPIClient.d.ts @@ -0,0 +1,436 @@ +/* + * 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. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import { ServiceClient, ServiceClientOptions, ServiceCallback, HttpOperationResponse, ServiceClientCredentials } from 'ms-rest'; +import * as models from "./models"; + +export default class AutoSuggestAPIClient extends ServiceClient { + /** + * @class + * Initializes a new instance of the AutoSuggestAPIClient class. + * @constructor + * + * @param {credentials} credentials - Subscription credentials which uniquely identify client subscription. + * + * @param {string} [baseUri] - The base URI of the service. + * + * @param {object} [options] - The parameter options + * + * @param {Array} [options.filters] - Filters to be added to the request pipeline + * + * @param {object} [options.requestOptions] - Options for the underlying request object + * {@link https://github.com/request/request#requestoptions-callback Options doc} + * + * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy + * + */ + constructor(credentials: ServiceClientCredentials, baseUri?: string, options?: ServiceClientOptions); + + credentials: ServiceClientCredentials; + + + /** + * @summary The AutoSuggest API lets you send a search query to Bing and get + * back a list of suggestions. This section provides technical details about + * the query parameters and headers that you use to request suggestions and the + * JSON response objects that contain them. + * + * @param {string} query The user's search term. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.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](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#cc) + * query parameter. To determine the market to return results for, Bing uses + * the first supported language it finds from the list and combines it with the + * cc parameter value. If the list does not include a supported language, Bing + * finds the closest language and market that supports the request or it uses + * an aggregated or default market for the results. To determine the market + * that Bing used, see the BingAPIs-Market header. Use this header and the cc + * query parameter only if you specify multiple languages. Otherwise, use the + * [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#mkt) + * and + * [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#setlang) + * query parameters. 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. Any links to Bing.com properties in the response objects + * apply the specified language. + * + * @param {string} [options.pragma] By default, Bing returns cached content, if + * available. To prevent Bing from returning cached content, set the Pragma + * header to no-cache (for example, Pragma: no-cache). + * + * @param {string} [options.userAgent] The user agent originating the request. + * Bing uses the user agent to provide mobile users with an optimized + * experience. Although optional, you are encouraged to always specify this + * header. The user-agent should be the same string that any commonly used + * browser sends. For information about user agents, see [RFC + * 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following + * are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible; + * MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; + * Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH - + * I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version / + * 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1 + * like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142 + * iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3; + * WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad; + * CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version + * / 7.0 Mobile / 11A465 Safari / 9537.53 + * + * @param {string} [options.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 {string} [options.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 {string} [options.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 :. 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 {string} [options.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 {string} [options.market] The market where the results come from. You + * are strongly encouraged to always specify the market, if known. Specifying + * the market helps Bing route the request and return an appropriate and + * optimal response. This parameter and the cc query parameter are mutually + * exclusive—do not specify both. + * + * @param {string} [options.safeSearch] Filter suggestions for adult content. + * The following are the possible filter values. Off: Return suggestions with + * adult text, images, or videos. Moderate: Return suggestion with adult text + * but not adult images or videos. Strict: Do not return news articles with + * adult text, images, or videos. 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 {string} [options.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 {array} [options.responseFormat] The media type to use for the + * response. The following are the possible case-insensitive values: JSON, + * JSONLD. The default is JSON. If you specify JSONLD, the response body + * includes JSON-LD objects that contain the search results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + */ + autoSuggestWithHttpOperationResponse(query: string, options?: { acceptLanguage? : string, pragma? : string, userAgent? : string, clientId? : string, clientIp? : string, location? : string, countryCode? : string, market? : string, safeSearch? : string, setLang? : string, responseFormat? : string[], customHeaders? : { [headerName: string]: string; } }): Promise>; + + /** + * @summary The AutoSuggest API lets you send a search query to Bing and get + * back a list of suggestions. This section provides technical details about + * the query parameters and headers that you use to request suggestions and the + * JSON response objects that contain them. + * + * @param {string} query The user's search term. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.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](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#cc) + * query parameter. To determine the market to return results for, Bing uses + * the first supported language it finds from the list and combines it with the + * cc parameter value. If the list does not include a supported language, Bing + * finds the closest language and market that supports the request or it uses + * an aggregated or default market for the results. To determine the market + * that Bing used, see the BingAPIs-Market header. Use this header and the cc + * query parameter only if you specify multiple languages. Otherwise, use the + * [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#mkt) + * and + * [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#setlang) + * query parameters. 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. Any links to Bing.com properties in the response objects + * apply the specified language. + * + * @param {string} [options.pragma] By default, Bing returns cached content, if + * available. To prevent Bing from returning cached content, set the Pragma + * header to no-cache (for example, Pragma: no-cache). + * + * @param {string} [options.userAgent] The user agent originating the request. + * Bing uses the user agent to provide mobile users with an optimized + * experience. Although optional, you are encouraged to always specify this + * header. The user-agent should be the same string that any commonly used + * browser sends. For information about user agents, see [RFC + * 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following + * are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible; + * MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; + * Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH - + * I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version / + * 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1 + * like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142 + * iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3; + * WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad; + * CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version + * / 7.0 Mobile / 11A465 Safari / 9537.53 + * + * @param {string} [options.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 {string} [options.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 {string} [options.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 :. 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 {string} [options.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 {string} [options.market] The market where the results come from. You + * are strongly encouraged to always specify the market, if known. Specifying + * the market helps Bing route the request and return an appropriate and + * optimal response. This parameter and the cc query parameter are mutually + * exclusive—do not specify both. + * + * @param {string} [options.safeSearch] Filter suggestions for adult content. + * The following are the possible filter values. Off: Return suggestions with + * adult text, images, or videos. Moderate: Return suggestion with adult text + * but not adult images or videos. Strict: Do not return news articles with + * adult text, images, or videos. 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 {string} [options.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 {array} [options.responseFormat] The media type to use for the + * response. The following are the possible case-insensitive values: JSON, + * JSONLD. The default is JSON. If you specify JSONLD, the response body + * includes JSON-LD objects that contain the search results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {ServiceCallback} [optionalCallback] - The optional callback. + * + * @returns {ServiceCallback|Promise} If a callback was passed as the last + * parameter then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned. + * + * @resolve {Suggestions} - The deserialized result object. + * + * @reject {Error|ServiceError} - The error object. + * + * {ServiceCallback} optionalCallback(err, result, request, response) + * + * {Error|ServiceError} err - The Error object if an error occurred, null otherwise. + * + * {Suggestions} [result] - The deserialized result object if an error did not occur. + * See {@link Suggestions} for more information. + * + * {WebResource} [request] - The HTTP Request object if an error did not occur. + * + * {http.IncomingMessage} [response] - The HTTP Response stream if an error did not occur. + */ + autoSuggest(query: string, options?: { acceptLanguage? : string, pragma? : string, userAgent? : string, clientId? : string, clientIp? : string, location? : string, countryCode? : string, market? : string, safeSearch? : string, setLang? : string, responseFormat? : string[], customHeaders? : { [headerName: string]: string; } }): Promise; + autoSuggest(query: string, callback: ServiceCallback): void; + autoSuggest(query: string, options: { acceptLanguage? : string, pragma? : string, userAgent? : string, clientId? : string, clientIp? : string, location? : string, countryCode? : string, market? : string, safeSearch? : string, setLang? : string, responseFormat? : string[], customHeaders? : { [headerName: string]: string; } }, callback: ServiceCallback): void; +} + +export { AutoSuggestAPIClient, models as AutoSuggestAPIModels }; diff --git a/lib/services/autosuggest/lib/autoSuggestAPIClient.js b/lib/services/autosuggest/lib/autoSuggestAPIClient.js new file mode 100644 index 0000000000..b3ce58de52 --- /dev/null +++ b/lib/services/autosuggest/lib/autoSuggestAPIClient.js @@ -0,0 +1,866 @@ +/* + * 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. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +const msRest = require('ms-rest'); +const ServiceClient = msRest.ServiceClient; +const WebResource = msRest.WebResource; + +const models = require('./models'); + + +/** + * @summary The AutoSuggest API lets you send a search query to Bing and get + * back a list of suggestions. This section provides technical details about + * the query parameters and headers that you use to request suggestions and the + * JSON response objects that contain them. + * + * @param {string} query The user's search term. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.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](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#cc) + * query parameter. To determine the market to return results for, Bing uses + * the first supported language it finds from the list and combines it with the + * cc parameter value. If the list does not include a supported language, Bing + * finds the closest language and market that supports the request or it uses + * an aggregated or default market for the results. To determine the market + * that Bing used, see the BingAPIs-Market header. Use this header and the cc + * query parameter only if you specify multiple languages. Otherwise, use the + * [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#mkt) + * and + * [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#setlang) + * query parameters. 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. Any links to Bing.com properties in the response objects + * apply the specified language. + * + * @param {string} [options.pragma] By default, Bing returns cached content, if + * available. To prevent Bing from returning cached content, set the Pragma + * header to no-cache (for example, Pragma: no-cache). + * + * @param {string} [options.userAgent] The user agent originating the request. + * Bing uses the user agent to provide mobile users with an optimized + * experience. Although optional, you are encouraged to always specify this + * header. The user-agent should be the same string that any commonly used + * browser sends. For information about user agents, see [RFC + * 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following + * are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible; + * MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; + * Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH - + * I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version / + * 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1 + * like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142 + * iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3; + * WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad; + * CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version + * / 7.0 Mobile / 11A465 Safari / 9537.53 + * + * @param {string} [options.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 {string} [options.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 {string} [options.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 :. 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 {string} [options.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 {string} [options.market] The market where the results come from. You + * are strongly encouraged to always specify the market, if known. Specifying + * the market helps Bing route the request and return an appropriate and + * optimal response. This parameter and the cc query parameter are mutually + * exclusive—do not specify both. + * + * @param {string} [options.safeSearch] Filter suggestions for adult content. + * The following are the possible filter values. Off: Return suggestions with + * adult text, images, or videos. Moderate: Return suggestion with adult text + * but not adult images or videos. Strict: Do not return news articles with + * adult text, images, or videos. 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 {string} [options.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 {array} [options.responseFormat] The media type to use for the + * response. The following are the possible case-insensitive values: JSON, + * JSONLD. The default is JSON. If you specify JSONLD, the response body + * includes JSON-LD objects that contain the search results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} callback - The callback. + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Suggestions} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +function _autoSuggest(query, options, callback) { + /* jshint validthis: true */ + let client = this; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + let acceptLanguage = (options && options.acceptLanguage !== undefined) ? options.acceptLanguage : undefined; + let pragma = (options && options.pragma !== undefined) ? options.pragma : undefined; + let userAgent = (options && options.userAgent !== undefined) ? options.userAgent : undefined; + let clientId = (options && options.clientId !== undefined) ? options.clientId : undefined; + let clientIp = (options && options.clientIp !== undefined) ? options.clientIp : undefined; + let location = (options && options.location !== undefined) ? options.location : undefined; + let countryCode = (options && options.countryCode !== undefined) ? options.countryCode : undefined; + let market = (options && options.market !== undefined) ? options.market : 'en-us'; + let safeSearch = (options && options.safeSearch !== undefined) ? options.safeSearch : undefined; + let setLang = (options && options.setLang !== undefined) ? options.setLang : undefined; + let responseFormat = (options && options.responseFormat !== undefined) ? options.responseFormat : undefined; + let xBingApisSDK = 'true'; + // Validate + try { + if (acceptLanguage !== null && acceptLanguage !== undefined && typeof acceptLanguage.valueOf() !== 'string') { + throw new Error('acceptLanguage must be of type string.'); + } + if (pragma !== null && pragma !== undefined && typeof pragma.valueOf() !== 'string') { + throw new Error('pragma must be of type string.'); + } + if (userAgent !== null && userAgent !== undefined && typeof userAgent.valueOf() !== 'string') { + throw new Error('userAgent must be of type string.'); + } + if (clientId !== null && clientId !== undefined && typeof clientId.valueOf() !== 'string') { + throw new Error('clientId must be of type string.'); + } + if (clientIp !== null && clientIp !== undefined && typeof clientIp.valueOf() !== 'string') { + throw new Error('clientIp must be of type string.'); + } + if (location !== null && location !== undefined && typeof location.valueOf() !== 'string') { + throw new Error('location must be of type string.'); + } + if (countryCode !== null && countryCode !== undefined && typeof countryCode.valueOf() !== 'string') { + throw new Error('countryCode must be of type string.'); + } + if (market !== null && market !== undefined && typeof market.valueOf() !== 'string') { + throw new Error('market must be of type string.'); + } + if (query === null || query === undefined || typeof query.valueOf() !== 'string') { + throw new Error('query cannot be null or undefined and it must be of type string.'); + } + if (safeSearch !== null && safeSearch !== undefined && typeof safeSearch.valueOf() !== 'string') { + throw new Error('safeSearch must be of type string.'); + } + if (setLang !== null && setLang !== undefined && typeof setLang.valueOf() !== 'string') { + throw new Error('setLang must be of type string.'); + } + if (Array.isArray(responseFormat)) { + for (let i = 0; i < responseFormat.length; i++) { + if (responseFormat[i] !== null && responseFormat[i] !== undefined && typeof responseFormat[i].valueOf() !== 'string') { + throw new Error('responseFormat[i] must be of type string.'); + } + } + } + } catch (error) { + return callback(error); + } + + // Construct URL + let baseUrl = this.baseUri; + let requestUrl = baseUrl + (baseUrl.endsWith('/') ? '' : '/') + 'Suggestions'; + let queryParameters = []; + if (countryCode !== null && countryCode !== undefined) { + queryParameters.push('cc=' + encodeURIComponent(countryCode)); + } + if (market !== null && market !== undefined) { + queryParameters.push('mkt=' + encodeURIComponent(market)); + } + queryParameters.push('q=' + encodeURIComponent(query)); + if (safeSearch !== null && safeSearch !== undefined) { + queryParameters.push('safeSearch=' + encodeURIComponent(safeSearch)); + } + if (setLang !== null && setLang !== undefined) { + queryParameters.push('setLang=' + encodeURIComponent(setLang)); + } + if (responseFormat !== null && responseFormat !== undefined) { + queryParameters.push('ResponseFormat=' + encodeURIComponent(responseFormat.join(','))); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + + // Create HTTP transport objects + let httpRequest = new WebResource(); + httpRequest.method = 'GET'; + httpRequest.url = requestUrl; + httpRequest.headers = {}; + // Set Headers + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + if (xBingApisSDK !== undefined && xBingApisSDK !== null) { + httpRequest.headers['X-BingApis-SDK'] = xBingApisSDK; + } + if (acceptLanguage !== undefined && acceptLanguage !== null) { + httpRequest.headers['Accept-Language'] = acceptLanguage; + } + if (pragma !== undefined && pragma !== null) { + httpRequest.headers['Pragma'] = pragma; + } + if (userAgent !== undefined && userAgent !== null) { + httpRequest.headers['User-Agent'] = userAgent; + } + if (clientId !== undefined && clientId !== null) { + httpRequest.headers['X-MSEdge-ClientID'] = clientId; + } + if (clientIp !== undefined && clientIp !== null) { + httpRequest.headers['X-MSEdge-ClientIP'] = clientIp; + } + if (location !== undefined && location !== null) { + httpRequest.headers['X-Search-Location'] = location; + } + if(options) { + for(let headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.body = null; + // Send Request + return client.pipeline(httpRequest, (err, response, responseBody) => { + if (err) { + return callback(err); + } + let statusCode = response.statusCode; + if (statusCode !== 200) { + let error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = msRest.stripRequest(httpRequest); + error.response = msRest.stripResponse(response); + if (responseBody === '') responseBody = null; + let parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + if (parsedErrorResponse) { + let internalError = null; + if (parsedErrorResponse.error) internalError = parsedErrorResponse.error; + error.code = internalError ? internalError.code : parsedErrorResponse.code; + error.message = internalError ? internalError.message : parsedErrorResponse.message; + } + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + let resultMapper = new client.models['ErrorResponse']().mapper(); + error.body = client.deserialize(resultMapper, parsedErrorResponse, 'error.body'); + } + } catch (defaultError) { + error.message = `Error "${defaultError.message}" occurred in deserializing the responseBody ` + + `- "${responseBody}" for the default response.`; + return callback(error); + } + return callback(error); + } + // Create Result + let result = null; + if (responseBody === '') responseBody = null; + // Deserialize Response + if (statusCode === 200) { + let parsedResponse = null; + try { + parsedResponse = JSON.parse(responseBody); + result = JSON.parse(responseBody); + if (parsedResponse !== null && parsedResponse !== undefined) { + let resultMapper = new client.models['Suggestions']().mapper(); + result = client.deserialize(resultMapper, parsedResponse, 'result'); + } + } catch (error) { + let deserializationError = new Error(`Error ${error} occurred in deserializing the responseBody - ${responseBody}`); + deserializationError.request = msRest.stripRequest(httpRequest); + deserializationError.response = msRest.stripResponse(response); + return callback(deserializationError); + } + } + + return callback(null, result, httpRequest, response); + }); +} + +/** Class representing a AutoSuggestAPIClient. */ +class AutoSuggestAPIClient extends ServiceClient { + /** + * Create a AutoSuggestAPIClient. + * @param {credentials} credentials - Subscription credentials which uniquely identify client subscription. + * @param {string} [baseUri] - The base URI of the service. + * @param {object} [options] - The parameter options + * @param {Array} [options.filters] - Filters to be added to the request pipeline + * @param {object} [options.requestOptions] - Options for the underlying request object + * {@link https://github.com/request/request#requestoptions-callback Options doc} + * @param {boolean} [options.noRetryPolicy] - If set to true, turn off default retry policy + */ + constructor(credentials, baseUri, options) { + if (credentials === null || credentials === undefined) { + throw new Error('\'credentials\' cannot be null.'); + } + + if (!options) options = {}; + + super(credentials, options); + + this.baseUri = baseUri; + if (!this.baseUri) { + this.baseUri = 'https://api.cognitive.microsoft.com/bing/v7.0'; + } + this.credentials = credentials; + + let packageInfo = this.getPackageJsonInfo(__dirname); + this.addUserAgentInfo(`${packageInfo.name}/${packageInfo.version}`); + this.models = models; + this._autoSuggest = _autoSuggest; + msRest.addSerializationMixin(this); + } + + /** + * @summary The AutoSuggest API lets you send a search query to Bing and get + * back a list of suggestions. This section provides technical details about + * the query parameters and headers that you use to request suggestions and the + * JSON response objects that contain them. + * + * @param {string} query The user's search term. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.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](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#cc) + * query parameter. To determine the market to return results for, Bing uses + * the first supported language it finds from the list and combines it with the + * cc parameter value. If the list does not include a supported language, Bing + * finds the closest language and market that supports the request or it uses + * an aggregated or default market for the results. To determine the market + * that Bing used, see the BingAPIs-Market header. Use this header and the cc + * query parameter only if you specify multiple languages. Otherwise, use the + * [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#mkt) + * and + * [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#setlang) + * query parameters. 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. Any links to Bing.com properties in the response objects + * apply the specified language. + * + * @param {string} [options.pragma] By default, Bing returns cached content, if + * available. To prevent Bing from returning cached content, set the Pragma + * header to no-cache (for example, Pragma: no-cache). + * + * @param {string} [options.userAgent] The user agent originating the request. + * Bing uses the user agent to provide mobile users with an optimized + * experience. Although optional, you are encouraged to always specify this + * header. The user-agent should be the same string that any commonly used + * browser sends. For information about user agents, see [RFC + * 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following + * are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible; + * MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; + * Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH - + * I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version / + * 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1 + * like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142 + * iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3; + * WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad; + * CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version + * / 7.0 Mobile / 11A465 Safari / 9537.53 + * + * @param {string} [options.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 {string} [options.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 {string} [options.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 :. 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 {string} [options.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 {string} [options.market] The market where the results come from. You + * are strongly encouraged to always specify the market, if known. Specifying + * the market helps Bing route the request and return an appropriate and + * optimal response. This parameter and the cc query parameter are mutually + * exclusive—do not specify both. + * + * @param {string} [options.safeSearch] Filter suggestions for adult content. + * The following are the possible filter values. Off: Return suggestions with + * adult text, images, or videos. Moderate: Return suggestion with adult text + * but not adult images or videos. Strict: Do not return news articles with + * adult text, images, or videos. 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 {string} [options.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 {array} [options.responseFormat] The media type to use for the + * response. The following are the possible case-insensitive values: JSON, + * JSONLD. The default is JSON. If you specify JSONLD, the response body + * includes JSON-LD objects that contain the search results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @returns {Promise} A promise is returned + * + * @resolve {HttpOperationResponse} - The deserialized result object. + * + * @reject {Error} - The error object. + */ + autoSuggestWithHttpOperationResponse(query, options) { + let client = this; + let self = this; + return new Promise((resolve, reject) => { + self._autoSuggest(query, options, (err, result, request, response) => { + let httpOperationResponse = new msRest.HttpOperationResponse(request, response); + httpOperationResponse.body = result; + if (err) { reject(err); } + else { resolve(httpOperationResponse); } + return; + }); + }); + } + + /** + * @summary The AutoSuggest API lets you send a search query to Bing and get + * back a list of suggestions. This section provides technical details about + * the query parameters and headers that you use to request suggestions and the + * JSON response objects that contain them. + * + * @param {string} query The user's search term. + * + * @param {object} [options] Optional Parameters. + * + * @param {string} [options.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](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#cc) + * query parameter. To determine the market to return results for, Bing uses + * the first supported language it finds from the list and combines it with the + * cc parameter value. If the list does not include a supported language, Bing + * finds the closest language and market that supports the request or it uses + * an aggregated or default market for the results. To determine the market + * that Bing used, see the BingAPIs-Market header. Use this header and the cc + * query parameter only if you specify multiple languages. Otherwise, use the + * [mkt](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#mkt) + * and + * [setLang](https://docs.microsoft.com/en-us/rest/api/cognitiveservices/bing-autosuggest-api-v7-reference#setlang) + * query parameters. 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. Any links to Bing.com properties in the response objects + * apply the specified language. + * + * @param {string} [options.pragma] By default, Bing returns cached content, if + * available. To prevent Bing from returning cached content, set the Pragma + * header to no-cache (for example, Pragma: no-cache). + * + * @param {string} [options.userAgent] The user agent originating the request. + * Bing uses the user agent to provide mobile users with an optimized + * experience. Although optional, you are encouraged to always specify this + * header. The user-agent should be the same string that any commonly used + * browser sends. For information about user agents, see [RFC + * 2616](http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html). The following + * are examples of user-agent strings. Windows Phone: Mozilla/5.0 (compatible; + * MSIE 10.0; Windows Phone 8.0; Trident/6.0; IEMobile/10.0; ARM; Touch; NOKIA; + * Lumia 822). Android: Mozilla / 5.0 (Linux; U; Android 2.3.5; en - us; SCH - + * I500 Build / GINGERBREAD) AppleWebKit / 533.1 (KHTML; like Gecko) Version / + * 4.0 Mobile Safari / 533.1. iPhone: Mozilla / 5.0 (iPhone; CPU iPhone OS 6_1 + * like Mac OS X) AppleWebKit / 536.26 (KHTML; like Gecko) Mobile / 10B142 + * iPhone4; 1 BingWeb / 3.03.1428.20120423. PC: Mozilla / 5.0 (Windows NT 6.3; + * WOW64; Trident / 7.0; Touch; rv:11.0) like Gecko. iPad: Mozilla / 5.0 (iPad; + * CPU OS 7_0 like Mac OS X) AppleWebKit / 537.51.1 (KHTML, like Gecko) Version + * / 7.0 Mobile / 11A465 Safari / 9537.53 + * + * @param {string} [options.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 {string} [options.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 {string} [options.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 :. 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 {string} [options.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 {string} [options.market] The market where the results come from. You + * are strongly encouraged to always specify the market, if known. Specifying + * the market helps Bing route the request and return an appropriate and + * optimal response. This parameter and the cc query parameter are mutually + * exclusive—do not specify both. + * + * @param {string} [options.safeSearch] Filter suggestions for adult content. + * The following are the possible filter values. Off: Return suggestions with + * adult text, images, or videos. Moderate: Return suggestion with adult text + * but not adult images or videos. Strict: Do not return news articles with + * adult text, images, or videos. 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 {string} [options.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 {array} [options.responseFormat] The media type to use for the + * response. The following are the possible case-insensitive values: JSON, + * JSONLD. The default is JSON. If you specify JSONLD, the response body + * includes JSON-LD objects that contain the search results. + * + * @param {object} [options.customHeaders] Headers that will be added to the + * request + * + * @param {function} [optionalCallback] - The optional callback. + * + * @returns {function|Promise} If a callback was passed as the last parameter + * then it returns the callback else returns a Promise. + * + * {Promise} A promise is returned + * + * @resolve {Suggestions} - The deserialized result object. + * + * @reject {Error} - The error object. + * + * {function} optionalCallback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {object} [result] - The deserialized result object if an error did not occur. + * See {@link Suggestions} for more information. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ + autoSuggest(query, options, optionalCallback) { + let client = this; + let self = this; + if (!optionalCallback && typeof options === 'function') { + optionalCallback = options; + options = null; + } + if (!optionalCallback) { + return new Promise((resolve, reject) => { + self._autoSuggest(query, options, (err, result, request, response) => { + if (err) { reject(err); } + else { resolve(result); } + return; + }); + }); + } else { + return self._autoSuggest(query, options, optionalCallback); + } + } + +} + +module.exports = AutoSuggestAPIClient; +module.exports['default'] = AutoSuggestAPIClient; +module.exports.AutoSuggestAPIClient = AutoSuggestAPIClient; +module.exports.AutoSuggestAPIModels = models; diff --git a/lib/services/autosuggest/lib/models/action.js b/lib/services/autosuggest/lib/models/action.js new file mode 100644 index 0000000000..496d2171e4 --- /dev/null +++ b/lib/services/autosuggest/lib/models/action.js @@ -0,0 +1,391 @@ +/* + * 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. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Class representing a Action. + * @extends models['CreativeWork'] + */ +class Action extends models['CreativeWork'] { + /** + * Create a Action. + * @member {array} [result] + * @member {string} [displayName] + * @member {boolean} [isTopAction] + * @member {string} [serviceUrl] + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Action + * + * @returns {object} metadata of Action + * + */ + mapper() { + return { + required: false, + serializedName: 'Action', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + }, + url: { + required: false, + readOnly: true, + serializedName: 'url', + type: { + name: 'String' + } + }, + thumbnailUrl: { + required: false, + readOnly: true, + serializedName: 'thumbnailUrl', + type: { + name: 'String' + } + }, + about: { + required: false, + readOnly: true, + serializedName: 'about', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + mentions: { + required: false, + readOnly: true, + serializedName: 'mentions', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + provider: { + required: false, + readOnly: true, + serializedName: 'provider', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + creator: { + required: false, + readOnly: true, + serializedName: 'creator', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + }, + text: { + required: false, + readOnly: true, + serializedName: 'text', + type: { + name: 'String' + } + }, + discussionUrl: { + required: false, + readOnly: true, + serializedName: 'discussionUrl', + type: { + name: 'String' + } + }, + commentCount: { + required: false, + readOnly: true, + serializedName: 'commentCount', + type: { + name: 'Number' + } + }, + mainEntity: { + required: false, + readOnly: true, + serializedName: 'mainEntity', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + }, + headLine: { + required: false, + readOnly: true, + serializedName: 'headLine', + type: { + name: 'String' + } + }, + copyrightHolder: { + required: false, + readOnly: true, + serializedName: 'copyrightHolder', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + }, + copyrightYear: { + required: false, + readOnly: true, + serializedName: 'copyrightYear', + type: { + name: 'Number' + } + }, + disclaimer: { + required: false, + readOnly: true, + serializedName: 'disclaimer', + type: { + name: 'String' + } + }, + isAccessibleForFree: { + required: false, + readOnly: true, + serializedName: 'isAccessibleForFree', + type: { + name: 'Boolean' + } + }, + genre: { + required: false, + readOnly: true, + serializedName: 'genre', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + isFamilyFriendly: { + required: false, + readOnly: true, + serializedName: 'isFamilyFriendly', + type: { + name: 'Boolean' + } + }, + result: { + required: false, + readOnly: true, + serializedName: 'result', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + displayName: { + required: false, + readOnly: true, + serializedName: 'displayName', + type: { + name: 'String' + } + }, + isTopAction: { + required: false, + readOnly: true, + serializedName: 'isTopAction', + type: { + name: 'Boolean' + } + }, + serviceUrl: { + required: false, + readOnly: true, + serializedName: 'serviceUrl', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Action; diff --git a/lib/services/autosuggest/lib/models/answer.js b/lib/services/autosuggest/lib/models/answer.js new file mode 100644 index 0000000000..4a784445c9 --- /dev/null +++ b/lib/services/autosuggest/lib/models/answer.js @@ -0,0 +1,143 @@ +/* + * 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. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Defines an answer. + * + * @extends models['Response'] + */ +class Answer extends models['Response'] { + /** + * Create a Answer. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Answer + * + * @returns {object} metadata of Answer + * + */ + mapper() { + return { + required: false, + serializedName: 'Answer', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Answer', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Answer; diff --git a/lib/services/autosuggest/lib/models/autoSuggest.js b/lib/services/autosuggest/lib/models/autoSuggest.js new file mode 100644 index 0000000000..50b117b0de --- /dev/null +++ b/lib/services/autosuggest/lib/models/autoSuggest.js @@ -0,0 +1,144 @@ +/* + * 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. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Defines an AutoSuggest answer + * + * @extends models['SearchResultsAnswer'] + */ +class AutoSuggest extends models['SearchResultsAnswer'] { + /** + * Create a AutoSuggest. + * @member {array} suggestionGroups + */ + constructor() { + super(); + } + + /** + * Defines the metadata of AutoSuggest + * + * @returns {object} metadata of AutoSuggest + * + */ + mapper() { + return { + required: false, + serializedName: 'AutoSuggest', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'AutoSuggest', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + }, + queryContext: { + required: false, + readOnly: true, + serializedName: 'queryContext', + type: { + name: 'Composite', + className: 'QueryContext' + } + }, + suggestionGroups: { + required: true, + serializedName: 'suggestionGroups', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'SuggestionsSuggestionGroupElementType', + type: { + name: 'Composite', + className: 'SuggestionsSuggestionGroup' + } + } + } + } + } + } + }; + } +} + +module.exports = AutoSuggest; diff --git a/lib/services/autosuggest/lib/models/creativeWork.js b/lib/services/autosuggest/lib/models/creativeWork.js new file mode 100644 index 0000000000..7e9c564dc9 --- /dev/null +++ b/lib/services/autosuggest/lib/models/creativeWork.js @@ -0,0 +1,366 @@ +/* + * 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. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The most generic kind of creative work, including books, movies, + * photographs, software programs, etc. + * + * @extends models['Thing'] + */ +class CreativeWork extends models['Thing'] { + /** + * Create a CreativeWork. + * @member {string} [thumbnailUrl] The URL to a thumbnail of the item. + * @member {array} [about] For internal use only. + * @member {array} [mentions] For internal use only. + * @member {array} [provider] The source of the creative work. + * @member {object} [creator] + * @member {string} [creator.url] The URL to get more information about the + * thing represented by this object. + * @member {string} [text] Text content of this creative work + * @member {string} [discussionUrl] + * @member {number} [commentCount] + * @member {object} [mainEntity] + * @member {string} [mainEntity.url] The URL to get more information about + * the thing represented by this object. + * @member {string} [headLine] + * @member {object} [copyrightHolder] + * @member {string} [copyrightHolder.url] The URL to get more information + * about the thing represented by this object. + * @member {number} [copyrightYear] + * @member {string} [disclaimer] + * @member {boolean} [isAccessibleForFree] + * @member {array} [genre] + * @member {boolean} [isFamilyFriendly] + */ + constructor() { + super(); + } + + /** + * Defines the metadata of CreativeWork + * + * @returns {object} metadata of CreativeWork + * + */ + mapper() { + return { + required: false, + serializedName: 'CreativeWork', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'CreativeWork', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + }, + url: { + required: false, + readOnly: true, + serializedName: 'url', + type: { + name: 'String' + } + }, + thumbnailUrl: { + required: false, + readOnly: true, + serializedName: 'thumbnailUrl', + type: { + name: 'String' + } + }, + about: { + required: false, + readOnly: true, + serializedName: 'about', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + mentions: { + required: false, + readOnly: true, + serializedName: 'mentions', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + provider: { + required: false, + readOnly: true, + serializedName: 'provider', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + creator: { + required: false, + readOnly: true, + serializedName: 'creator', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + }, + text: { + required: false, + readOnly: true, + serializedName: 'text', + type: { + name: 'String' + } + }, + discussionUrl: { + required: false, + readOnly: true, + serializedName: 'discussionUrl', + type: { + name: 'String' + } + }, + commentCount: { + required: false, + readOnly: true, + serializedName: 'commentCount', + type: { + name: 'Number' + } + }, + mainEntity: { + required: false, + readOnly: true, + serializedName: 'mainEntity', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + }, + headLine: { + required: false, + readOnly: true, + serializedName: 'headLine', + type: { + name: 'String' + } + }, + copyrightHolder: { + required: false, + readOnly: true, + serializedName: 'copyrightHolder', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + }, + copyrightYear: { + required: false, + readOnly: true, + serializedName: 'copyrightYear', + type: { + name: 'Number' + } + }, + disclaimer: { + required: false, + readOnly: true, + serializedName: 'disclaimer', + type: { + name: 'String' + } + }, + isAccessibleForFree: { + required: false, + readOnly: true, + serializedName: 'isAccessibleForFree', + type: { + name: 'Boolean' + } + }, + genre: { + required: false, + readOnly: true, + serializedName: 'genre', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + isFamilyFriendly: { + required: false, + readOnly: true, + serializedName: 'isFamilyFriendly', + type: { + name: 'Boolean' + } + } + } + } + }; + } +} + +module.exports = CreativeWork; diff --git a/lib/services/autosuggest/lib/models/errorModel.js b/lib/services/autosuggest/lib/models/errorModel.js new file mode 100644 index 0000000000..3c95c71a32 --- /dev/null +++ b/lib/services/autosuggest/lib/models/errorModel.js @@ -0,0 +1,108 @@ +/* + * 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. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Defines the error that occurred. + * + */ +class ErrorModel { + /** + * Create a ErrorModel. + * @member {string} code The error code that identifies the category of + * error. Possible values include: 'None', 'ServerError', 'InvalidRequest', + * 'RateLimitExceeded', 'InvalidAuthorization', 'InsufficientAuthorization'. + * Default value: 'None' . + * @member {string} message A description of the error. + * @member {string} [moreDetails] A description that provides additional + * information about the error. + * @member {string} [parameter] The parameter in the request that caused the + * error. + * @member {string} [value] The parameter's value in the request that was not + * valid. + * @member {string} _type Polymorphic Discriminator + */ + constructor() { + } + + /** + * Defines the metadata of ErrorModel + * + * @returns {object} metadata of ErrorModel + * + */ + mapper() { + return { + required: false, + serializedName: 'Error', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ErrorModel', + className: 'ErrorModel', + modelProperties: { + code: { + required: true, + serializedName: 'code', + defaultValue: 'None', + type: { + name: 'String' + } + }, + message: { + required: true, + serializedName: 'message', + type: { + name: 'String' + } + }, + moreDetails: { + required: false, + readOnly: true, + serializedName: 'moreDetails', + type: { + name: 'String' + } + }, + parameter: { + required: false, + readOnly: true, + serializedName: 'parameter', + type: { + name: 'String' + } + }, + value: { + required: false, + readOnly: true, + serializedName: 'value', + type: { + name: 'String' + } + }, + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ErrorModel; diff --git a/lib/services/autosuggest/lib/models/errorResponse.js b/lib/services/autosuggest/lib/models/errorResponse.js new file mode 100644 index 0000000000..56a80f0a89 --- /dev/null +++ b/lib/services/autosuggest/lib/models/errorResponse.js @@ -0,0 +1,165 @@ +/* + * 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. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * The top-level response that represents a failed request. + * + * @extends models['Response'] + */ +class ErrorResponse extends models['Response'] { + /** + * Create a ErrorResponse. + * @member {array} errors A list of errors that describe the reasons why the + * request failed. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of ErrorResponse + * + * @returns {object} metadata of ErrorResponse + * + */ + mapper() { + return { + required: false, + serializedName: 'ErrorResponse', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'ErrorResponse', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + }, + errors: { + required: true, + serializedName: 'errors', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ErrorModelElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ErrorModel', + className: 'ErrorModel' + } + } + } + } + } + } + }; + } +} + +module.exports = ErrorResponse; diff --git a/lib/services/autosuggest/lib/models/identifiable.js b/lib/services/autosuggest/lib/models/identifiable.js new file mode 100644 index 0000000000..6cc9e3d679 --- /dev/null +++ b/lib/services/autosuggest/lib/models/identifiable.js @@ -0,0 +1,70 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Defines the identity of a resource. + * + * @extends models['ResponseBase'] + */ +class Identifiable extends models['ResponseBase'] { + /** + * Create a Identifiable. + * @member {string} [id] A String identifier. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Identifiable + * + * @returns {object} metadata of Identifiable + * + */ + mapper() { + return { + required: false, + serializedName: 'Identifiable', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Identifiable', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Identifiable; diff --git a/lib/services/autosuggest/lib/models/index.d.ts b/lib/services/autosuggest/lib/models/index.d.ts new file mode 100644 index 0000000000..aabc4bb493 --- /dev/null +++ b/lib/services/autosuggest/lib/models/index.d.ts @@ -0,0 +1,313 @@ +/* + * 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. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +import * as moment from "moment"; + + +/** + * @class + * Initializes a new instance of the ResponseBase class. + * @constructor + * Response base + * + * @member {string} _type Polymorphic Discriminator + */ +export interface ResponseBase { + _type: string; +} + +/** + * @class + * Initializes a new instance of the Identifiable class. + * @constructor + * Defines the identity of a resource. + * + * @member {string} [id] A String identifier. + */ +export interface Identifiable extends ResponseBase { + readonly id?: string; +} + +/** + * @class + * Initializes a new instance of the Response class. + * @constructor + * Defines a response. All schemas that could be returned at the root of a + * response should inherit from this + * + * @member {string} [readLink] The URL that returns this resource. + * @member {string} [webSearchUrl] The URL To Bing's search result for this + * item. + * @member {array} [potentialAction] + * @member {array} [immediateAction] + * @member {string} [preferredClickthroughUrl] + * @member {string} [adaptiveCard] + */ +export interface Response extends Identifiable { + readonly readLink?: string; + readonly webSearchUrl?: string; + readonly potentialAction?: Action[]; + readonly immediateAction?: Action[]; + readonly preferredClickthroughUrl?: string; + readonly adaptiveCard?: string; +} + +/** + * @class + * Initializes a new instance of the Thing class. + * @constructor + * Defines a thing. + * + * @member {string} [url] The URL to get more information about the thing + * represented by this object. + */ +export interface Thing extends Response { + readonly url?: string; +} + +/** + * @class + * Initializes a new instance of the CreativeWork class. + * @constructor + * The most generic kind of creative work, including books, movies, + * photographs, software programs, etc. + * + * @member {string} [thumbnailUrl] The URL to a thumbnail of the item. + * @member {array} [about] For internal use only. + * @member {array} [mentions] For internal use only. + * @member {array} [provider] The source of the creative work. + * @member {object} [creator] + * @member {string} [creator.url] The URL to get more information about the + * thing represented by this object. + * @member {string} [text] Text content of this creative work + * @member {string} [discussionUrl] + * @member {number} [commentCount] + * @member {object} [mainEntity] + * @member {string} [mainEntity.url] The URL to get more information about the + * thing represented by this object. + * @member {string} [headLine] + * @member {object} [copyrightHolder] + * @member {string} [copyrightHolder.url] The URL to get more information about + * the thing represented by this object. + * @member {number} [copyrightYear] + * @member {string} [disclaimer] + * @member {boolean} [isAccessibleForFree] + * @member {array} [genre] + * @member {boolean} [isFamilyFriendly] + */ +export interface CreativeWork extends Thing { + readonly thumbnailUrl?: string; + readonly about?: Thing[]; + readonly mentions?: Thing[]; + readonly provider?: Thing[]; + readonly creator?: Thing; + readonly text?: string; + readonly discussionUrl?: string; + readonly commentCount?: number; + readonly mainEntity?: Thing; + readonly headLine?: string; + readonly copyrightHolder?: Thing; + readonly copyrightYear?: number; + readonly disclaimer?: string; + readonly isAccessibleForFree?: boolean; + readonly genre?: string[]; + readonly isFamilyFriendly?: boolean; +} + +/** + * @class + * Initializes a new instance of the Action class. + * @constructor + * @member {array} [result] + * @member {string} [displayName] + * @member {boolean} [isTopAction] + * @member {string} [serviceUrl] + */ +export interface Action extends CreativeWork { + readonly result?: Thing[]; + readonly displayName?: string; + readonly isTopAction?: boolean; + readonly serviceUrl?: string; +} + +/** + * @class + * Initializes a new instance of the SearchAction class. + * @constructor + * @member {string} [displayText] + * @member {string} [query] + * @member {string} [searchKind] Possible values include: 'WebSearch', + * 'HistorySearch', 'DocumentSearch', 'TagSearch', 'LocationSearch', + * 'CustomSearch'. Default value: 'WebSearch' . + */ +export interface SearchAction extends Action { + readonly displayText?: string; + readonly query?: string; + readonly searchKind?: string; +} + +/** + * @class + * Initializes a new instance of the SuggestionsSuggestionGroup class. + * @constructor + * @member {string} name Possible values include: 'Unknown', 'Web', + * 'StoreApps', 'SearchHistory', 'PersonalSearchDocuments', + * 'PersonalSearchTags', 'Custom'. Default value: 'Unknown' . + * @member {array} searchSuggestions + * @member {string} _type Polymorphic Discriminator + */ +export interface SuggestionsSuggestionGroup { + name: string; + searchSuggestions: SearchAction[]; + _type: string; +} + +/** + * @class + * Initializes a new instance of the Answer class. + * @constructor + * Defines an answer. + * + */ +export interface Answer extends Response { +} + +/** + * @class + * Initializes a new instance of the SearchResultsAnswer class. + * @constructor + * Defines a search result answer. + * + * @member {object} [queryContext] + * @member {string} [queryContext.originalQuery] The query string as specified + * in the request. + * @member {string} [queryContext.alteredQuery] 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. + * @member {string} [queryContext.alterationOverrideQuery] 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. + * @member {boolean} [queryContext.adultIntent] A Boolean value that indicates + * whether the specified query has adult intent. The value is true if the query + * has adult intent; otherwise, false. + * @member {boolean} [queryContext.askUserForLocation] A Boolean value that + * indicates whether Bing requires the user's location to provide accurate + * results. If you specified the user's location by using the X-MSEdge-ClientIP + * and X-Search-Location headers, you can ignore this field. For location aware + * queries, such as "today's weather" or "restaurants near me" that need the + * user's location to provide accurate results, this field is set to true. For + * location aware queries that include the location (for example, "Seattle + * weather"), this field is set to false. This field is also set to false for + * queries that are not location aware, such as "best sellers". + * @member {boolean} [queryContext.isTransactional] + * @member {string} [queryContext._type] Polymorphic Discriminator + */ +export interface SearchResultsAnswer extends Answer { + readonly queryContext?: QueryContext; +} + +/** + * @class + * Initializes a new instance of the Suggestions class. + * @constructor + * @member {array} suggestionGroups + */ +export interface Suggestions extends SearchResultsAnswer { + suggestionGroups: SuggestionsSuggestionGroup[]; +} + +/** + * @class + * Initializes a new instance of the QueryContext class. + * @constructor + * Defines the query context that Bing used for the request. + * + * @member {string} originalQuery The query string as specified in the request. + * @member {string} [alteredQuery] 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. + * @member {string} [alterationOverrideQuery] 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. + * @member {boolean} [adultIntent] A Boolean value that indicates whether the + * specified query has adult intent. The value is true if the query has adult + * intent; otherwise, false. + * @member {boolean} [askUserForLocation] A Boolean value that indicates + * whether Bing requires the user's location to provide accurate results. If + * you specified the user's location by using the X-MSEdge-ClientIP and + * X-Search-Location headers, you can ignore this field. For location aware + * queries, such as "today's weather" or "restaurants near me" that need the + * user's location to provide accurate results, this field is set to true. For + * location aware queries that include the location (for example, "Seattle + * weather"), this field is set to false. This field is also set to false for + * queries that are not location aware, such as "best sellers". + * @member {boolean} [isTransactional] + * @member {string} _type Polymorphic Discriminator + */ +export interface QueryContext { + originalQuery: string; + readonly alteredQuery?: string; + readonly alterationOverrideQuery?: string; + readonly adultIntent?: boolean; + readonly askUserForLocation?: boolean; + readonly isTransactional?: boolean; + _type: string; +} + +/** + * @class + * Initializes a new instance of the ErrorModel class. + * @constructor + * Defines the error that occurred. + * + * @member {string} code The error code that identifies the category of error. + * Possible values include: 'None', 'ServerError', 'InvalidRequest', + * 'RateLimitExceeded', 'InvalidAuthorization', 'InsufficientAuthorization'. + * Default value: 'None' . + * @member {string} message A description of the error. + * @member {string} [moreDetails] A description that provides additional + * information about the error. + * @member {string} [parameter] The parameter in the request that caused the + * error. + * @member {string} [value] The parameter's value in the request that was not + * valid. + * @member {string} _type Polymorphic Discriminator + */ +export interface ErrorModel { + code: string; + message: string; + readonly moreDetails?: string; + readonly parameter?: string; + readonly value?: string; + _type: string; +} + +/** + * @class + * Initializes a new instance of the ErrorResponse class. + * @constructor + * The top-level response that represents a failed request. + * + * @member {array} errors A list of errors that describe the reasons why the + * request failed. + */ +export interface ErrorResponse extends Response { + errors: ErrorModel[]; +} diff --git a/lib/services/autosuggest/lib/models/index.js b/lib/services/autosuggest/lib/models/index.js new file mode 100644 index 0000000000..0f605e5b37 --- /dev/null +++ b/lib/services/autosuggest/lib/models/index.js @@ -0,0 +1,46 @@ +/* + * 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. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +exports.ResponseBase = require('./responseBase'); +exports.Identifiable = require('./identifiable'); +exports.Response = require('./response'); +exports.Thing = require('./thing'); +exports.CreativeWork = require('./creativeWork'); +exports.Action = require('./action'); +exports.SearchAction = require('./searchAction'); +exports.SuggestionsSuggestionGroup = require('./suggestionsSuggestionGroup'); +exports.Answer = require('./answer'); +exports.SearchResultsAnswer = require('./searchResultsAnswer'); +exports.Suggestions = require('./suggestions'); +exports.QueryContext = require('./queryContext'); +exports.ErrorModel = require('./errorModel'); +exports.ErrorResponse = require('./errorResponse'); +exports.discriminators = { + 'ResponseBase.SearchAction' : exports.SearchAction, + 'Suggestions/SuggestionGroup' : exports.SuggestionsSuggestionGroup, + 'ResponseBase.Suggestions' : exports.Suggestions, + 'QueryContext' : exports.QueryContext, + 'ResponseBase.SearchResultsAnswer' : exports.SearchResultsAnswer, + 'ResponseBase.Answer' : exports.Answer, + 'ResponseBase.Thing' : exports.Thing, + 'ResponseBase.Action' : exports.Action, + 'ResponseBase.Response' : exports.Response, + 'ResponseBase.Identifiable' : exports.Identifiable, + 'Error' : exports.ErrorModel, + 'ResponseBase.ErrorResponse' : exports.ErrorResponse, + 'ResponseBase.CreativeWork' : exports.CreativeWork, + 'ResponseBase' : exports.ResponseBase +}; diff --git a/lib/services/autosuggest/lib/models/queryContext.js b/lib/services/autosuggest/lib/models/queryContext.js new file mode 100644 index 0000000000..cbdd045c40 --- /dev/null +++ b/lib/services/autosuggest/lib/models/queryContext.js @@ -0,0 +1,131 @@ +/* + * 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. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Defines the query context that Bing used for the request. + * + */ +class QueryContext { + /** + * Create a QueryContext. + * @member {string} originalQuery The query string as specified in the + * request. + * @member {string} [alteredQuery] 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. + * @member {string} [alterationOverrideQuery] 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. + * @member {boolean} [adultIntent] A Boolean value that indicates whether the + * specified query has adult intent. The value is true if the query has adult + * intent; otherwise, false. + * @member {boolean} [askUserForLocation] A Boolean value that indicates + * whether Bing requires the user's location to provide accurate results. If + * you specified the user's location by using the X-MSEdge-ClientIP and + * X-Search-Location headers, you can ignore this field. For location aware + * queries, such as "today's weather" or "restaurants near me" that need the + * user's location to provide accurate results, this field is set to true. + * For location aware queries that include the location (for example, + * "Seattle weather"), this field is set to false. This field is also set to + * false for queries that are not location aware, such as "best sellers". + * @member {boolean} [isTransactional] + * @member {string} _type Polymorphic Discriminator + */ + constructor() { + } + + /** + * Defines the metadata of QueryContext + * + * @returns {object} metadata of QueryContext + * + */ + mapper() { + return { + required: false, + serializedName: 'QueryContext', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'QueryContext', + className: 'QueryContext', + modelProperties: { + originalQuery: { + required: true, + serializedName: 'originalQuery', + type: { + name: 'String' + } + }, + alteredQuery: { + required: false, + readOnly: true, + serializedName: 'alteredQuery', + type: { + name: 'String' + } + }, + alterationOverrideQuery: { + required: false, + readOnly: true, + serializedName: 'alterationOverrideQuery', + type: { + name: 'String' + } + }, + adultIntent: { + required: false, + readOnly: true, + serializedName: 'adultIntent', + type: { + name: 'Boolean' + } + }, + askUserForLocation: { + required: false, + readOnly: true, + serializedName: 'askUserForLocation', + type: { + name: 'Boolean' + } + }, + isTransactional: { + required: false, + readOnly: true, + serializedName: 'isTransactional', + type: { + name: 'Boolean' + } + }, + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = QueryContext; diff --git a/lib/services/autosuggest/lib/models/response.js b/lib/services/autosuggest/lib/models/response.js new file mode 100644 index 0000000000..8842125193 --- /dev/null +++ b/lib/services/autosuggest/lib/models/response.js @@ -0,0 +1,151 @@ +/* + * 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. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Defines a response. All schemas that could be returned at the root of a + * response should inherit from this + * + * @extends models['Identifiable'] + */ +class Response extends models['Identifiable'] { + /** + * Create a Response. + * @member {string} [readLink] The URL that returns this resource. + * @member {string} [webSearchUrl] The URL To Bing's search result for this + * item. + * @member {array} [potentialAction] + * @member {array} [immediateAction] + * @member {string} [preferredClickthroughUrl] + * @member {string} [adaptiveCard] + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Response + * + * @returns {object} metadata of Response + * + */ + mapper() { + return { + required: false, + serializedName: 'Response', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Response', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Response; diff --git a/lib/services/autosuggest/lib/models/responseBase.js b/lib/services/autosuggest/lib/models/responseBase.js new file mode 100644 index 0000000000..28a5d0d020 --- /dev/null +++ b/lib/services/autosuggest/lib/models/responseBase.js @@ -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. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * Response base + * + */ +class ResponseBase { + /** + * Create a ResponseBase. + * @member {string} _type Polymorphic Discriminator + */ + constructor() { + } + + /** + * Defines the metadata of ResponseBase + * + * @returns {object} metadata of ResponseBase + * + */ + mapper() { + return { + required: false, + serializedName: 'ResponseBase', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'ResponseBase', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = ResponseBase; diff --git a/lib/services/autosuggest/lib/models/searchAction.js b/lib/services/autosuggest/lib/models/searchAction.js new file mode 100644 index 0000000000..a54564f3e9 --- /dev/null +++ b/lib/services/autosuggest/lib/models/searchAction.js @@ -0,0 +1,417 @@ +/* + * 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. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Class representing a SearchAction. + * @extends models['Action'] + */ +class SearchAction extends models['Action'] { + /** + * Create a SearchAction. + * @member {string} [displayText] + * @member {string} [query] + * @member {string} [searchKind] Possible values include: 'WebSearch', + * 'HistorySearch', 'DocumentSearch', 'TagSearch', 'LocationSearch', + * 'CustomSearch'. Default value: 'WebSearch' . + */ + constructor() { + super(); + } + + /** + * Defines the metadata of SearchAction + * + * @returns {object} metadata of SearchAction + * + */ + mapper() { + return { + required: false, + serializedName: 'SearchAction', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'SearchAction', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + }, + url: { + required: false, + readOnly: true, + serializedName: 'url', + type: { + name: 'String' + } + }, + thumbnailUrl: { + required: false, + readOnly: true, + serializedName: 'thumbnailUrl', + type: { + name: 'String' + } + }, + about: { + required: false, + readOnly: true, + serializedName: 'about', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + mentions: { + required: false, + readOnly: true, + serializedName: 'mentions', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + provider: { + required: false, + readOnly: true, + serializedName: 'provider', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + creator: { + required: false, + readOnly: true, + serializedName: 'creator', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + }, + text: { + required: false, + readOnly: true, + serializedName: 'text', + type: { + name: 'String' + } + }, + discussionUrl: { + required: false, + readOnly: true, + serializedName: 'discussionUrl', + type: { + name: 'String' + } + }, + commentCount: { + required: false, + readOnly: true, + serializedName: 'commentCount', + type: { + name: 'Number' + } + }, + mainEntity: { + required: false, + readOnly: true, + serializedName: 'mainEntity', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + }, + headLine: { + required: false, + readOnly: true, + serializedName: 'headLine', + type: { + name: 'String' + } + }, + copyrightHolder: { + required: false, + readOnly: true, + serializedName: 'copyrightHolder', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + }, + copyrightYear: { + required: false, + readOnly: true, + serializedName: 'copyrightYear', + type: { + name: 'Number' + } + }, + disclaimer: { + required: false, + readOnly: true, + serializedName: 'disclaimer', + type: { + name: 'String' + } + }, + isAccessibleForFree: { + required: false, + readOnly: true, + serializedName: 'isAccessibleForFree', + type: { + name: 'Boolean' + } + }, + genre: { + required: false, + readOnly: true, + serializedName: 'genre', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'StringElementType', + type: { + name: 'String' + } + } + } + }, + isFamilyFriendly: { + required: false, + readOnly: true, + serializedName: 'isFamilyFriendly', + type: { + name: 'Boolean' + } + }, + result: { + required: false, + readOnly: true, + serializedName: 'result', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ThingElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing' + } + } + } + }, + displayName: { + required: false, + readOnly: true, + serializedName: 'displayName', + type: { + name: 'String' + } + }, + isTopAction: { + required: false, + readOnly: true, + serializedName: 'isTopAction', + type: { + name: 'Boolean' + } + }, + serviceUrl: { + required: false, + readOnly: true, + serializedName: 'serviceUrl', + type: { + name: 'String' + } + }, + displayText: { + required: false, + readOnly: true, + serializedName: 'displayText', + type: { + name: 'String' + } + }, + query: { + required: false, + readOnly: true, + serializedName: 'query', + type: { + name: 'String' + } + }, + searchKind: { + required: false, + readOnly: true, + serializedName: 'searchKind', + defaultValue: 'WebSearch', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = SearchAction; diff --git a/lib/services/autosuggest/lib/models/searchResultsAnswer.js b/lib/services/autosuggest/lib/models/searchResultsAnswer.js new file mode 100644 index 0000000000..9422b5d447 --- /dev/null +++ b/lib/services/autosuggest/lib/models/searchResultsAnswer.js @@ -0,0 +1,187 @@ +/* + * 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. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Defines a search result answer. + * + * @extends models['Answer'] + */ +class SearchResultsAnswer extends models['Answer'] { + /** + * Create a SearchResultsAnswer. + * @member {object} [queryContext] + * @member {string} [queryContext.originalQuery] The query string as + * specified in the request. + * @member {string} [queryContext.alteredQuery] 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. + * @member {string} [queryContext.alterationOverrideQuery] 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. + * @member {boolean} [queryContext.adultIntent] A Boolean value that + * indicates whether the specified query has adult intent. The value is true + * if the query has adult intent; otherwise, false. + * @member {boolean} [queryContext.askUserForLocation] A Boolean value that + * indicates whether Bing requires the user's location to provide accurate + * results. If you specified the user's location by using the + * X-MSEdge-ClientIP and X-Search-Location headers, you can ignore this + * field. For location aware queries, such as "today's weather" or + * "restaurants near me" that need the user's location to provide accurate + * results, this field is set to true. For location aware queries that + * include the location (for example, "Seattle weather"), this field is set + * to false. This field is also set to false for queries that are not + * location aware, such as "best sellers". + * @member {boolean} [queryContext.isTransactional] + * @member {string} [queryContext._type] Polymorphic Discriminator + */ + constructor() { + super(); + } + + /** + * Defines the metadata of SearchResultsAnswer + * + * @returns {object} metadata of SearchResultsAnswer + * + */ + mapper() { + return { + required: false, + serializedName: 'SearchResultsAnswer', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'SearchResultsAnswer', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + }, + queryContext: { + required: false, + readOnly: true, + serializedName: 'queryContext', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'QueryContext', + className: 'QueryContext' + } + } + } + } + }; + } +} + +module.exports = SearchResultsAnswer; diff --git a/lib/services/autosuggest/lib/models/suggestions.js b/lib/services/autosuggest/lib/models/suggestions.js new file mode 100644 index 0000000000..297ff06801 --- /dev/null +++ b/lib/services/autosuggest/lib/models/suggestions.js @@ -0,0 +1,177 @@ +/* + * 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. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Class representing a Suggestions. + * @extends models['SearchResultsAnswer'] + */ +class Suggestions extends models['SearchResultsAnswer'] { + /** + * Create a Suggestions. + * @member {array} suggestionGroups + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Suggestions + * + * @returns {object} metadata of Suggestions + * + */ + mapper() { + return { + required: false, + serializedName: 'Suggestions', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Suggestions', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + }, + queryContext: { + required: false, + readOnly: true, + serializedName: 'queryContext', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'QueryContext', + className: 'QueryContext' + } + }, + suggestionGroups: { + required: true, + serializedName: 'suggestionGroups', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'SuggestionsSuggestionGroupElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'SuggestionsSuggestionGroup', + className: 'SuggestionsSuggestionGroup' + } + } + } + } + } + } + }; + } +} + +module.exports = Suggestions; diff --git a/lib/services/autosuggest/lib/models/suggestionsSuggestionGroup.js b/lib/services/autosuggest/lib/models/suggestionsSuggestionGroup.js new file mode 100644 index 0000000000..8cc1a9e646 --- /dev/null +++ b/lib/services/autosuggest/lib/models/suggestionsSuggestionGroup.js @@ -0,0 +1,91 @@ +/* + * 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. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Class representing a SuggestionsSuggestionGroup. + */ +class SuggestionsSuggestionGroup { + /** + * Create a SuggestionsSuggestionGroup. + * @member {string} name Possible values include: 'Unknown', 'Web', + * 'StoreApps', 'SearchHistory', 'PersonalSearchDocuments', + * 'PersonalSearchTags', 'Custom'. Default value: 'Unknown' . + * @member {array} searchSuggestions + * @member {string} _type Polymorphic Discriminator + */ + constructor() { + } + + /** + * Defines the metadata of SuggestionsSuggestionGroup + * + * @returns {object} metadata of SuggestionsSuggestionGroup + * + */ + mapper() { + return { + required: false, + serializedName: 'Suggestions/SuggestionGroup', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'SuggestionsSuggestionGroup', + className: 'SuggestionsSuggestionGroup', + modelProperties: { + name: { + required: true, + serializedName: 'name', + defaultValue: 'Unknown', + type: { + name: 'String' + } + }, + searchSuggestions: { + required: true, + serializedName: 'searchSuggestions', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'SearchActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'SearchAction' + } + } + } + }, + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = SuggestionsSuggestionGroup; diff --git a/lib/services/autosuggest/lib/models/thing.js b/lib/services/autosuggest/lib/models/thing.js new file mode 100644 index 0000000000..5cb36eb6b6 --- /dev/null +++ b/lib/services/autosuggest/lib/models/thing.js @@ -0,0 +1,153 @@ +/* + * 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. + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +const models = require('./index'); + +/** + * Defines a thing. + * + * @extends models['Response'] + */ +class Thing extends models['Response'] { + /** + * Create a Thing. + * @member {string} [url] The URL to get more information about the thing + * represented by this object. + */ + constructor() { + super(); + } + + /** + * Defines the metadata of Thing + * + * @returns {object} metadata of Thing + * + */ + mapper() { + return { + required: false, + serializedName: 'Thing', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Thing', + modelProperties: { + _type: { + required: true, + serializedName: '_type', + isPolymorphicDiscriminator: true, + type: { + name: 'String' + } + }, + id: { + required: false, + readOnly: true, + serializedName: 'id', + type: { + name: 'String' + } + }, + readLink: { + required: false, + readOnly: true, + serializedName: 'readLink', + type: { + name: 'String' + } + }, + webSearchUrl: { + required: false, + readOnly: true, + serializedName: 'webSearchUrl', + type: { + name: 'String' + } + }, + potentialAction: { + required: false, + readOnly: true, + serializedName: 'potentialAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + immediateAction: { + required: false, + readOnly: true, + serializedName: 'immediateAction', + type: { + name: 'Sequence', + element: { + required: false, + serializedName: 'ActionElementType', + type: { + name: 'Composite', + polymorphicDiscriminator: { + serializedName: '_type', + clientName: '_type' + }, + uberParent: 'ResponseBase', + className: 'Action' + } + } + } + }, + preferredClickthroughUrl: { + required: false, + readOnly: true, + serializedName: 'preferredClickthroughUrl', + type: { + name: 'String' + } + }, + adaptiveCard: { + required: false, + readOnly: true, + serializedName: 'adaptiveCard', + type: { + name: 'String' + } + }, + url: { + required: false, + readOnly: true, + serializedName: 'url', + type: { + name: 'String' + } + } + } + } + }; + } +} + +module.exports = Thing; diff --git a/lib/services/autosuggest/package.json b/lib/services/autosuggest/package.json new file mode 100644 index 0000000000..279f5a7700 --- /dev/null +++ b/lib/services/autosuggest/package.json @@ -0,0 +1,24 @@ +{ + "name": "azure-cognitiveservices-autosuggest", + "author": "Microsoft Corporation", + "description": "AutoSuggestAPIClient Library with typescript type definitions for node", + "version": "1.1.0", + "dependencies": { + "ms-rest": "^2.3.3" + }, + "keywords": [ + "node", + "azure" + ], + "license": "MIT", + "main": "./lib/autoSuggestAPIClient.js", + "types": "./lib/autoSuggestAPIClient.d.ts", + "homepage": "http://github.com/azure/azure-sdk-for-node", + "repository": { + "type": "git", + "url": "https://github.com/azure/azure-sdk-for-node.git" + }, + "bugs": { + "url": "http://github.com/Azure/azure-sdk-for-node/issues" + } +}